소스 검색

30天供水量修改

wangyangyang 4 년 전
부모
커밋
c7aee7de4e
2개의 변경된 파일9개의 추가작업 그리고 16개의 파일을 삭제
  1. 6 14
      sms_water/src/main/java/com/huaxu/service/SecSupplyService.java
  2. 3 2
      sms_water/src/main/resources/mapper/MonthReportMapper.xml

+ 6 - 14
sms_water/src/main/java/com/huaxu/service/SecSupplyService.java

@@ -41,35 +41,27 @@ public class SecSupplyService {
         List<MonthReportEntity> monthReportEntities = monthReportService.findAmountBySceneIds(monthReportEntity);
         Map<String, Double> maps = new LinkedHashMap<>();
         for (MonthReportEntity item : monthReportEntities) {
-            maps.put(item.getYear() + "-" + String.format("%02d", item.getMonth()) + "-" + String.format("%02d", item.getDay()), item.getLatestValue());
+            maps.put(item.getYear() + "-" + String.format("%02d", item.getMonth()) + "-" + String.format("%02d", item.getDay()), item.getSumValue());
         }
         Calendar begin = Calendar.getInstance();// 得到一个Calendar的实例
         begin.setTime(new Date()); // 设置时间为当前时间
         List<AmountDayThirtyDto> listC = new ArrayList<>();
-        for (int i = 1; i <= 31; i++) {
+        for (int i = 1; i <= 30; i++) {
             begin.add(Calendar.DATE, -1);// 日期加1
             Date d = new Date(begin.getTimeInMillis());
             DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
             AmountDayThirtyDto amountDayThirtyDto = new AmountDayThirtyDto();
             if (maps.containsKey(df.format(d).toString())) {
                 amountDayThirtyDto.setAmountTime(d);
-                amountDayThirtyDto.setAmount(maps.get(df.format(d)));
+                amountDayThirtyDto.setAmount((double)Math.round(maps.get(df.format(d))*1000)/1000);
             } else {
                 amountDayThirtyDto.setAmountTime(d);
+                amountDayThirtyDto.setAmount(0d);
             }
             listC.add(amountDayThirtyDto);
         }
-        List<AmountDayThirtyDto> listD = new ArrayList<>();
-        for (int m = 0; m < 30; m++) {
-            AmountDayThirtyDto amountDayThirtyDto = new AmountDayThirtyDto();
-            amountDayThirtyDto.setAmountTime(listC.get(m).getAmountTime());
-            if (listC.get(m + 1).getAmount() != null && listC.get(m).getAmount() != null)
-                amountDayThirtyDto.setAmount((double) Math.round((listC.get(m).getAmount() - listC.get(m + 1).getAmount()) * 1000) / 1000);
-            else
-                amountDayThirtyDto.setAmount(0d);
-            listD.add(amountDayThirtyDto);
-        }
-        return listD;
+
+        return listC;
     }
 
     /**

+ 3 - 2
sms_water/src/main/resources/mapper/MonthReportMapper.xml

@@ -255,10 +255,11 @@
         order by tab.DEVICE_ID,tab.year,tab.month,tab.day
     </select>
     <select id="findAmountBySceneIds" resultType="com.huaxu.entity.MonthReportEntity">
-        SELECT a.year as "year",a.`MONTH` as "month",a.`DAY` as "day",sum(a.LATEST_VALUE) as "latestValue"
+        SELECT a.year as "year",a.`MONTH` as "month",a.`DAY` as "day",sum(a.LATEST_VALUE) as "latestValue",
+        sum(a.SUM_VALUE) as "sumValue"
         FROM  sms_month_report a
         INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
-        where DATE_SUB(CURDATE(), INTERVAL 31 DAY) &lt;= date(a.COLLECT_DATE)
+        where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(a.COLLECT_DATE)
         and b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
         <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
             #{dramaId.id}