Browse Source

水质修改

wangyangyang 4 years ago
parent
commit
747a1baaad

+ 2 - 0
sms_water/src/main/java/com/huaxu/dao/DeviceParmMapper.java

@@ -81,4 +81,6 @@ public interface DeviceParmMapper  {
     List<DeviceParmEntity> selectDeviceBySceneIdAndType(@Param("info") DeviceParmEntity deviceParmEntity);
 
     List<ParmTypeCountDto> findAlarmCount(@Param("info") DeviceParmEntity deviceParmEntity);
+
+    List<ParmTypeCountDto> findAlarmTotalCount(@Param("info") DeviceParmEntity deviceParmEntity);
 }

+ 1 - 0
sms_water/src/main/java/com/huaxu/dto/ParmTypeCountDto.java

@@ -5,6 +5,7 @@ import lombok.Data;
 @Data
 public class ParmTypeCountDto {
     private Integer parmType;
+    private Long deviceId;
     private Integer totalCount;
     private Integer nbnormalCount;
 }

+ 2 - 0
sms_water/src/main/java/com/huaxu/service/DeviceParmService.java

@@ -89,4 +89,6 @@ public interface DeviceParmService {
     List<DeviceParmEntity> selectDeviceBySceneIdAndType(DeviceParmEntity deviceParmEntity);
 
     List<ParmTypeCountDto> findAlarmCount(DeviceParmEntity deviceParmEntity);
+
+    List<ParmTypeCountDto> findAlarmTotalCount(DeviceParmEntity deviceParmEntity);
 }

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

@@ -191,16 +191,12 @@ public class SecSupplyService {
         DeviceParmEntity deviceParmEntity = new DeviceParmEntity();
         deviceParmEntity.setSceneEntities(sceneEntities);
         List<ParmTypeCountDto> list = deviceParmService.findAlarmCount(deviceParmEntity);
-        //余氯11 浊度9  PH7  cod 15   15,7,9,11,18,19
-        Integer totalCount = 0;
-        Integer nbNormalCount = 0;
+        //余氯11 浊度9  PH8  cod 15   15,8,9,11,18,19
         for(ParmTypeCountDto item : list)
         {
-            totalCount +=item.getTotalCount();
-            nbNormalCount+=item.getNbnormalCount();
             switch(item.getParmType())
             {
-                case 7:
+                case 8:
                     WaterPieStateDto waterPieStateDto1 = new WaterPieStateDto();
                     waterPieStateDto1.setNormalCount(item.getTotalCount()- item.getNbnormalCount());
                     waterPieStateDto1.setNbnormalCount(item.getNbnormalCount());
@@ -225,10 +221,11 @@ public class SecSupplyService {
                     break;
             }
         }
+        List<ParmTypeCountDto> listTotal = deviceParmService.findAlarmTotalCount(deviceParmEntity);
         WaterPieStateDto waterPieStateDto4 = new WaterPieStateDto();
-        waterPieStateDto4.setNormalCount(totalCount- nbNormalCount);
-        waterPieStateDto4.setNbnormalCount(nbNormalCount);
-        waterPieStateDto4.setPercentage((double) (Math.round((Double.valueOf(totalCount- nbNormalCount)/Double.valueOf(totalCount))*100)));
+        waterPieStateDto4.setNormalCount(listTotal.get(0).getTotalCount()- listTotal.get(0).getNbnormalCount());
+        waterPieStateDto4.setNbnormalCount(listTotal.get(0).getNbnormalCount());
+        waterPieStateDto4.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount()- listTotal.get(0).getNbnormalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
         waterPieDto.setWaterQuality(waterPieStateDto4);
         return waterPieDto;
     }

+ 6 - 0
sms_water/src/main/java/com/huaxu/service/impl/DeviceParmServiceImpl.java

@@ -14,6 +14,7 @@ import com.huaxu.service.DeviceParmService;
 import com.huaxu.service.DeviceSceneService;
 import com.huaxu.service.SceneService;
 import com.huaxu.util.UserUtil;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -225,4 +226,9 @@ public class DeviceParmServiceImpl  implements DeviceParmService {
     public List<ParmTypeCountDto> findAlarmCount(DeviceParmEntity deviceParmEntity) {
         return deviceParmMapper.findAlarmCount(deviceParmEntity);
     }
+    public List<ParmTypeCountDto> findAlarmTotalCount(DeviceParmEntity deviceParmEntity)
+    {
+        return deviceParmMapper.findAlarmTotalCount(deviceParmEntity);
+    }
+
 }

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

@@ -253,7 +253,7 @@
         select b.PARM_TYPE as "parmType",count(a.DEVICE_ID) as "totalCount",count(c.id) as "nbnormalCount"
         from sms_device_scene a
         INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID
-               and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,7,9,11,18,19) and b.`STATUS`=1
+               and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,9,11,18,19) and b.`STATUS`=1
         LEFT JOIN  sms_alarm_details c on c.PARENT_SCENE_ID=b.PARENT_SCENE_ID
                and c.ATTRIBUTE_ID=b.ATTRIBUTE_ID and c.STATE=1
         where a.PARENT_SCENE_ID in
@@ -264,4 +264,21 @@
         a.`STATUS`=1
         group by b.PARM_TYPE
     </select>
+    <select id="findAlarmTotalCount" resultType="com.huaxu.dto.ParmTypeCountDto">
+        select count(1) as "totalCount" ,sum(tab.nbnormalCount) as "nbnormalCount" from(
+        select a.PARENT_SCENE_ID,a.DEVICE_ID as "deviceId",case when count(c.id)>0 then 1 else 0 end  as "nbnormalCount"
+        from sms_device_scene a
+        INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID
+        and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,9,11,18,19) and b.`STATUS`=1
+        LEFT JOIN  sms_alarm_details c on c.PARENT_SCENE_ID=b.PARENT_SCENE_ID
+        and c.ATTRIBUTE_ID=b.ATTRIBUTE_ID and c.STATE=1
+        where a.PARENT_SCENE_ID in
+        <foreach collection="info.sceneEntities" item="dramaId" open="(" close=")" separator=",">
+            #{dramaId.id}
+        </foreach>
+        and
+        a.`STATUS`=1
+        group by a.PARENT_SCENE_ID,a.DEVICE_ID
+        ) as tab
+    </select>
 </mapper>

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

@@ -1171,7 +1171,7 @@
 
             where s.`STATUS`=1 and st.SCENE_TYPE_NAME = '水厂' and s.TENANT_ID =#{tenantId}
             <if test="parmType != null and  parmType == -1">
-                and dp.PARM_TYPE in (15,7,9,11,18,19)
+                and dp.PARM_TYPE in (15,8,9,11,18,19)
             </if>
             <if test="parmType != null and  parmType != -1">
                 and dp.PARM_TYPE = #{parmType}