فهرست منبع

设备参数修改

wangyangyang 4 سال پیش
والد
کامیت
91ac468957

+ 3 - 2
sms_water/src/main/java/com/huaxu/service/SecSupplyService.java

@@ -111,9 +111,8 @@ public class SecSupplyService {
         //本日供水量
         deviceParmEntity.setParmType(3);//查询供水量
         List<DeviceParmEntity> deviceParms = deviceParmService.selectDeviceBySceneIdAndType(deviceParmEntity);
-        //瞬时流量
         double dayAmount = 0d;
-        for (DeviceParmEntity item : deviceParmEntities) {
+        for (DeviceParmEntity item : deviceParms) {
             //取缓存里的数据
             byte[] bytes = redisUtil.get(("sms_water_" + item.getDeviceCode()).getBytes());
             if (bytes != null && bytes.length > 0) {
@@ -125,6 +124,7 @@ public class SecSupplyService {
                     map.put(dateValue.getAttributeId(), dateValue);
                 }
                 if (map.containsKey(item.getAttributeId().longValue())) {
+
                     DayReportEntity dayReportEntity = new DayReportEntity();
                     dayReportEntity.setYear(begin.get(Calendar.YEAR));
                     dayReportEntity.setMonth(begin.get(Calendar.MONTH) + 1);
@@ -134,6 +134,7 @@ public class SecSupplyService {
                     List<DayReportEntity> dayReportEntities = dayReportService.findDeviceLastDayValue(dayReportEntity);
                     if (dayReportEntities.size() > 0) {
                         dayAmount += map.get(item.getAttributeId().longValue()).getDataValue();
+                        System.out.println("item.getAttributeId()"+item.getAttributeId()+"--"+map.get(item.getAttributeId().longValue()));
                         dayAmount = dayAmount - dayReportEntities.get(0).getLatestValue();
                     }
                 }

+ 1 - 1
sms_water/src/main/resources/mapper/DeviceParmMapper.xml

@@ -243,7 +243,7 @@
         select  a.DEVICE_ID as "deviceId",b.DEVICE_CODE as "deviceCode",a.ATTRIBUTE_ID  as "attributeId"
         from sms_device_parm a
         inner join sms_device b on a.DEVICE_ID=b.id
-        where a.PARM_TYPE=#{info.parmType} and b.`STATUS`=1
+        where a.PARM_TYPE=#{info.parmType} and b.`STATUS`=1 and a.`STATUS`=1
         and a.PARENT_SCENE_ID in
         <foreach collection="info.sceneEntities" item="dramaId" open="(" close=")" separator=",">
             #{dramaId.id}

+ 12 - 0
sms_water/src/main/resources/mapper/MonthReportMapper.xml

@@ -270,6 +270,18 @@
         select sum(a.LATEST_VALUE) as "latestValue"
         from sms_month_report a
         inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
+        inner join (
+        select max(a.`DAY`) as day,a.DEVICE_ID
+        from sms_month_report a
+        inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
+        where  b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
+        <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
+            #{dramaId.id}
+        </foreach>
+        <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
+        <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
+        GROUP BY a.DEVICE_ID
+        )as tab on tab.DEVICE_ID=a.DEVICE_ID and a.`DAY`=tab.`day`
         where  b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
         <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
             #{dramaId.id}

+ 11 - 0
sms_water/src/main/resources/mapper/YearReportMapper.xml

@@ -254,6 +254,17 @@
         select sum(a.LATEST_VALUE) as "latestValue"
         from sms_year_report a
         inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
+        inner join (
+        select max(a.`month`) as month,a.DEVICE_ID
+        from sms_year_report a
+        inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
+        where  b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
+        <foreach collection="yearReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
+            #{dramaId.id}
+        </foreach>
+        <if test="yearReport.year != null ">and a.year = #{yearReport.year}</if>
+        group by  a.DEVICE_ID
+        ) as tab on tab.DEVICE_ID=a.DEVICE_ID and a.`month`=tab.`month`
         where  b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
         <foreach collection="yearReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
             #{dramaId.id}