Commit a3738991 by 杨林龙

1.50.0 开发1.50.0需求版本 优化警情数据返回结果

1 parent 17466304
...@@ -68,7 +68,7 @@ public class RiskAssessmentController extends AbstractController { ...@@ -68,7 +68,7 @@ public class RiskAssessmentController extends AbstractController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = AlarmInformationVO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AlarmInformationVO.class)})
@GetMapping(value = "/getAlarmInformation") @GetMapping(value = "/getAlarmInformation")
public R<AlarmInformationVO> getAlarmInformation(@RequestParam Long vehicleId) { public R<AlarmInformationVO> getAlarmInformation(@RequestParam Long vehicleId) {
Set<AlarmInformationVO> alarmInformationVOSet = riskAssessmentService.getAlarmInformation(vehicleId); List<AlarmInformationVO> alarmInformationVOSet = riskAssessmentService.getAlarmInformation(vehicleId);
return R.ok().data(alarmInformationVOSet); return R.ok().data(alarmInformationVOSet);
} }
......
...@@ -280,7 +280,7 @@ public class RiskAssessmentService { ...@@ -280,7 +280,7 @@ public class RiskAssessmentService {
* @param vehicleId 车辆ID * @param vehicleId 车辆ID
* @return 风控登记数据 * @return 风控登记数据
*/ */
public Set<AlarmInformationVO> getAlarmInformation(Long vehicleId) { public List<AlarmInformationVO> getAlarmInformation(Long vehicleId) {
// 校验车架号 // 校验车架号
if (Objects.isNull(vehicleId)) { if (Objects.isNull(vehicleId)) {
log.warn("该车辆ID不存在"); log.warn("该车辆ID不存在");
...@@ -330,13 +330,13 @@ public class RiskAssessmentService { ...@@ -330,13 +330,13 @@ public class RiskAssessmentService {
calculateTrueOffline(vehicleId, snList, basicAlarmDTOSet); calculateTrueOffline(vehicleId, snList, basicAlarmDTOSet);
Map<Integer, List<AlarmInformationVO>> alarmInformationVOMap = basicAlarmDTOSet.stream().sorted(Comparator.comparingInt(AlarmInformationVO::getAlarmLevel)).collect(Collectors.groupingBy(AlarmInformationVO::getAlarmLevel)); Map<Integer, List<AlarmInformationVO>> alarmInformationVOMap = basicAlarmDTOSet.stream().sorted(Comparator.comparingInt(AlarmInformationVO::getAlarmLevel)).collect(Collectors.groupingBy(AlarmInformationVO::getAlarmLevel));
log.info("alarmInformationVOMap===" + JSONUtil.toJsonStr(alarmInformationVOMap)); log.info("alarmInformationVOMap===" + JSONUtil.toJsonStr(alarmInformationVOMap));
Set<AlarmInformationVO> alarmInformationVOResultSet = Sets.newHashSet(); List<AlarmInformationVO> alarmInformationVOResultList = Lists.newArrayList();
alarmInformationVOMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> { alarmInformationVOMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> {
List<AlarmInformationVO> valueList = entry.getValue(); List<AlarmInformationVO> valueList = entry.getValue();
log.info("valueList===" + JSONUtil.toJsonStr(valueList)); log.info("valueList===" + JSONUtil.toJsonStr(valueList));
alarmInformationVOResultSet.addAll(valueList.stream().sorted(Comparator.comparingInt(AlarmInformationVO::getAlarmRank)).collect(Collectors.toCollection(LinkedHashSet::new))); alarmInformationVOResultList.addAll(valueList.stream().sorted(Comparator.comparingInt(AlarmInformationVO::getAlarmRank)).collect(Collectors.toCollection(LinkedHashSet::new)));
}); });
return alarmInformationVOResultSet; return alarmInformationVOResultList;
} }
/** /**
......
...@@ -50,7 +50,7 @@ public class RiskAssessmentServiceTest { ...@@ -50,7 +50,7 @@ public class RiskAssessmentServiceTest {
@Test @Test
public void getAlarmInformation() { public void getAlarmInformation() {
Set<AlarmInformationVO> alarmInformation = riskAssessmentService.getAlarmInformation(67771L); List<AlarmInformationVO> alarmInformation = riskAssessmentService.getAlarmInformation(67771L);
System.out.println("alarmInformation = " + JSONUtil.toJsonStr(alarmInformation)); System.out.println("alarmInformation = " + JSONUtil.toJsonStr(alarmInformation));
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!