Commit a3738991 by 杨林龙

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

1 parent 17466304
......@@ -68,7 +68,7 @@ public class RiskAssessmentController extends AbstractController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = AlarmInformationVO.class)})
@GetMapping(value = "/getAlarmInformation")
public R<AlarmInformationVO> getAlarmInformation(@RequestParam Long vehicleId) {
Set<AlarmInformationVO> alarmInformationVOSet = riskAssessmentService.getAlarmInformation(vehicleId);
List<AlarmInformationVO> alarmInformationVOSet = riskAssessmentService.getAlarmInformation(vehicleId);
return R.ok().data(alarmInformationVOSet);
}
......
......@@ -280,7 +280,7 @@ public class RiskAssessmentService {
* @param vehicleId 车辆ID
* @return 风控登记数据
*/
public Set<AlarmInformationVO> getAlarmInformation(Long vehicleId) {
public List<AlarmInformationVO> getAlarmInformation(Long vehicleId) {
// 校验车架号
if (Objects.isNull(vehicleId)) {
log.warn("该车辆ID不存在");
......@@ -330,13 +330,13 @@ public class RiskAssessmentService {
calculateTrueOffline(vehicleId, snList, basicAlarmDTOSet);
Map<Integer, List<AlarmInformationVO>> alarmInformationVOMap = basicAlarmDTOSet.stream().sorted(Comparator.comparingInt(AlarmInformationVO::getAlarmLevel)).collect(Collectors.groupingBy(AlarmInformationVO::getAlarmLevel));
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 -> {
List<AlarmInformationVO> valueList = entry.getValue();
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 {
@Test
public void getAlarmInformation() {
Set<AlarmInformationVO> alarmInformation = riskAssessmentService.getAlarmInformation(67771L);
List<AlarmInformationVO> alarmInformation = riskAssessmentService.getAlarmInformation(67771L);
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!