Browse Source

优化返回值

develop
wangsixiang 2 months ago
parent
commit
16032eda23
  1. 18
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java
  2. 8
      zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml

18
zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

@ -224,8 +224,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
int thisTimeValue = entry.getValue();
Map<String, Object> row = new HashMap<>();
row.put("stakeMark", stakeMark);
row.put("thisTimeList", thisTimeValue);
row.put("lastTimeList", lastTimeList.getOrDefault(stakeMark, 0));
row.put(thisTime, thisTimeValue);
row.put(lastTime, lastTimeList.getOrDefault(stakeMark, 0));
sortedResult.add(row);
}
// 添加那些只在lastTimeList中的键
@ -233,8 +233,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
if (!thisTimeList.containsKey(stakeMark)) {
Map<String, Object> row = new HashMap<>();
row.put("stakeMark", stakeMark);
row.put("thisTimeList", 0);
row.put("lastTimeList", lastTimeList.get(stakeMark));
row.put(thisTime, 0);
row.put(lastTime, lastTimeList.get(stakeMark));
sortedResult.add(row);
}
}
@ -315,8 +315,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
String thisTimeValue = entry.getValue();
Map<String, Object> row = new HashMap<>();
row.put("stakeMark", stakeMark);
row.put("thisTimeList", thisTimeValue);
row.put("lastTimeList", lastTimeList.getOrDefault(stakeMark, "0.00"));
row.put(thisTime, thisTimeValue);
row.put(lastTime, lastTimeList.getOrDefault(stakeMark, "0.00"));
sortedResult.add(row);
}
// 添加那些只在lastTimeList中的键
@ -324,8 +324,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
if (!thisTimeList.containsKey(stakeMark)) {
Map<String, Object> row = new HashMap<>();
row.put("stakeMark", stakeMark);
row.put("thisTimeList", "0.00");
row.put("lastTimeList", lastTimeList.get(stakeMark));
row.put(thisTime, "0.00");
row.put(lastTime, lastTimeList.get(stakeMark));
sortedResult.add(row);
}
}
@ -377,7 +377,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
Integer differenceInMinute = (int)differenceInMinutes;
if (averageMap.get(groupKey)==null){ //事件还为存入map
averageMap.putIfAbsent(groupKey, UniversalEnum.ONE.getNumber());//事件类型不存在存1
averageMap.putIfAbsent(groupKey, differenceInMinute);//
}else {
Integer currentSum = averageMap.get(groupKey);
averageMap.put(groupKey, currentSum +differenceInMinute );

8
zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml

@ -187,8 +187,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="accidentTypeAnalysis" resultType="java.util.HashMap">
SELECT e.event_type AS eventType,
IFNULL(t1.num, 0) AS thisTimeList,
IFNULL(t2.num, 0) AS lastTimeList
IFNULL(t1.num, 0) as #{thisTime},
IFNULL(t2.num, 0) as #{lastTime}
FROM `dc_sdhs_event` e
LEFT JOIN (SELECT event_type,
COUNT(*) AS num FROM
@ -241,8 +241,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="accidentCongestedLocation" resultType="java.util.HashMap">
SELECT
e.event_subclass AS eventSubclass,
IFNULL(t1.num, 0) AS thisTimeList,
IFNULL(t2.num, 0) AS lastTimeList
IFNULL(t1.num, 0) as #{thisTime},
IFNULL(t2.num, 0) as #{lastTime}
FROM `dc_sdhs_event` e
LEFT JOIN (SELECT event_subclass, COUNT(*) AS num
FROM `dc_sdhs_event`

Loading…
Cancel
Save