yuejiaying hace 4 años
padre
commit
b16fa25738

+ 1 - 4
sms_water/src/main/java/com/huaxu/dto/MonitorDataDto.java

@@ -41,10 +41,7 @@ public class MonitorDataDto implements Serializable {
     @ApiModelProperty(value = "设备标识",hidden = true)
     @JsonIgnore
     private String deviceCode;
-    @ApiModelProperty(value = "离线日报表今日总量",hidden = true)
-    @JsonIgnore
-    private Double sumValue;
-    @ApiModelProperty(value = "离线日报表今日最新值",hidden = true)
+    @ApiModelProperty(value = "离线日报表昨日最新值",hidden = true)
     @JsonIgnore
     private Double latestValue;
 }

+ 6 - 8
sms_water/src/main/java/com/huaxu/service/impl/OnlineMonitorImpl.java

@@ -219,13 +219,12 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                                     -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
                             MonitorDataValueEntity  attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
                             if (attributeEntity != null) {
-                                Double attributeDiffValue =0d;
+                                Double attributeValue =0d;
                                 if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
-                                    attributeDiffValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
+                                    attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
                                 }else if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() == null) {
-                                    attributeDiffValue=attributeEntity.getDataValue();
+                                    attributeValue=attributeEntity.getDataValue();
                                 }
-                                Double attributeValue = monitorData.getSumValue() != null ? monitorData.getSumValue() + attributeDiffValue : attributeDiffValue;
                                 switch (monitorData.getAttributeType()) {
                                     case "3":
                                         monDataCol.setYieldWaterUsage(monDataCol.getYieldWaterUsage() != null ? monDataCol.getYieldWaterUsage() + attributeValue : attributeValue);
@@ -267,13 +266,12 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                                     -> m.getAttributeId().equals(monitorData.getAttributeId())).collect(Collectors.toList());
                             MonitorDataValueEntity  attributeEntity=attributeEntities.size()>0?attributeEntities.get(0):null;
                             if (attributeEntity != null) {
-                                Double attributeDiffValue =0d;
+                                Double attributeValue =0d;
                                 if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() != null){
-                                    attributeDiffValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
+                                    attributeValue=attributeEntity.getDataValue() - monitorData.getLatestValue();
                                 }else if(attributeEntity.getDataValue() != null && monitorData.getLatestValue() == null) {
-                                    attributeDiffValue=attributeEntity.getDataValue();
+                                    attributeValue=attributeEntity.getDataValue();
                                 }
-                                Double attributeValue = monitorData.getSumValue() != null ? monitorData.getSumValue() + attributeDiffValue : attributeDiffValue;
                                 //实时数据
                                 monitorData.setDataValue(attributeEntity.getDataValue());
                                 monitorData.setUnit(attributeEntity.getUnit());

+ 19 - 6
sms_water/src/main/resources/mapper/OnlineMonitorMapper.xml

@@ -58,7 +58,14 @@
             from sms_device a1
             inner join sms_alarm_details a2 on a1.id=a2.device_id and a2.`status` = 1 and  a2.state = 1
             inner join sms_scene a3 on a3.id=a1.scene_id and a3.`status` = 1
-            where a1.`status` = 1 and a1.enable_state=1 group by one_scene_id
+            where a1.`status` = 1 and a1.enable_state=1
+            <if test="sceneIds != null and sceneIds.size() > 0">
+                and a1.scene_id  in
+                <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            group by one_scene_id
         )t7 on t7.one_scene_id=t1.id
     </sql>
 
@@ -218,7 +225,6 @@
         if(t6.id is null , 0 , 1 ) is_alarm,
         t5.attribute_type,
         if (t5.device_id is null, null, t4.device_code) device_code,
-        t8.sum_value,
         t8.latest_value
         from sms_scene t1
         <include refid="sceneDeviceJoins"/>
@@ -233,10 +239,17 @@
         )t5 on t5.device_id=t4.id
         left join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1 and t6.attribute_id = t5.attribute_id and t6.state = 1
         left join (
-            select b1.device_id,b1.attribute_id,sum(sum_value) as sum_value,max(latest_value) latest_value from sms_day_report b1
-            where b1.collect_date>=date(now())
-            group by b1.device_id,b1.attribute_id
-        )t8 on t8.attribute_id =t5.attribute_id and t8.device_id=t5.device_id
+            select parent_scene_id,max(latest_value) latest_value
+            from sms_day_report b1
+            where b1.year = year(now() + interval-1 day) and b1.year = month(now() + interval-1 day) and b1.day = day(now() + interval-1 day)
+                <if test="sceneIds != null and sceneIds.size() > 0">
+                    and b1.parent_scene_id  in
+                    <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
+            group by  parent_scene_id
+        )t8 on t8.parent_scene_id = t1.id
         where t1.parent_scene_id = 0 and t1. status = 1
         <if test="sceneTypeName != null and sceneTypeName != '' ">
             and t3.scene_type_name = #{sceneTypeName}