james 1 anno fa
parent
commit
c635efa974

+ 2 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/BaseAlarmMapper.java

@@ -19,6 +19,8 @@ import java.util.List;
 public interface BaseAlarmMapper extends CrudMapper<BaseAlarm> {
     BaseAlarmType getAlarmTypeOne(String alarmType);
 
+    List<BaseAlarmType> getAlarmTypeList();
+
     List<DmpDeviceInfo> getDeviceInfoList(@Param("devList") List<String> devList);
 
     List<BaseAlarm> getUnDeviceAlarmList(@Param("devList") List<String> devList);

+ 30 - 17
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAlarmServiceImpl.java

@@ -174,7 +174,7 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
         List<BaseAlarm> list = new ArrayList<>();
 
         LambdaQueryWrapper<BaseAlarm> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper
+        queryWrapper.eq(StringUtils.isNotBlank(baseAlarmListVO.getDeviceId()),BaseAlarm::getDeviceId,baseAlarmListVO.getDeviceId())
                 .eq(StringUtils.isNotBlank(baseAlarmListVO.getProductCode()),BaseAlarm::getProductCode,baseAlarmListVO.getProductCode())
                 .eq(StringUtils.isNotBlank(baseAlarmListVO.getAlarmType()),BaseAlarm::getAlarmType,baseAlarmListVO.getAlarmType())
                 .eq(null != baseAlarmListVO.getHandleStatus(),BaseAlarm::getHandleStatus,baseAlarmListVO.getHandleStatus())
@@ -199,7 +199,7 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                         for(int j=0;j<deviceInfo.size();j++){
                             if(records.get(i).getDeviceId().equals(deviceInfo.get(j).getDeviceId())){
                                 records.get(i).setDeviceName(deviceInfo.get(j).getDeviceName());
-                                continue;
+                                break;
                             }
                         }
 
@@ -207,13 +207,18 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                 }
             }
 
-            for(int i=0;i<records.size();i++){
-                BaseAlarmType baseAlarmType = baseMapper.getAlarmTypeOne(records.get(i).getAlarmType());
-                if(baseAlarmType != null){
-                    records.get(i).setTypeImg(baseAlarmType.getTypeImg());
+            List<BaseAlarmType> alarmTypeList = baseMapper.getAlarmTypeList();
+            if(CollectionUtils.isNotEmpty(alarmTypeList)){
+                for(int i=0;i<records.size();i++){
+                    for(int j=0;j<alarmTypeList.size();j++){
+                        if(records.get(i).getAlarmType().equals(alarmTypeList.get(j).getTypeCode())){
+                            records.get(i).setTypeImg(alarmTypeList.get(j).getTypeImg());
+                            break;
+                        }
+                    }
                 }
-
             }
+
         }
 
         if(StringUtils.isNotBlank(baseAlarmListVO.getDeviceName())){
@@ -382,12 +387,16 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                 }
             }
 
-            for(int i=0;i<records.size();i++){
-                BaseAlarmType baseAlarmType = baseMapper.getAlarmTypeOne(records.get(i).getAlarmType());
-                if(baseAlarmType != null){
-                    records.get(i).setTypeImg(baseAlarmType.getTypeImg());
+            List<BaseAlarmType> alarmTypeList = baseMapper.getAlarmTypeList();
+            if(CollectionUtils.isNotEmpty(alarmTypeList)){
+                for(int i=0;i<records.size();i++){
+                    for(int j=0;j<alarmTypeList.size();j++){
+                        if(records.get(i).getAlarmType().equals(alarmTypeList.get(j).getTypeCode())){
+                            records.get(i).setTypeImg(alarmTypeList.get(j).getTypeImg());
+                            break;
+                        }
+                    }
                 }
-
             }
         }
 
@@ -449,12 +458,16 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                 }
             }
 
-            for(int i=0;i<records.size();i++){
-                BaseAlarmType baseAlarmType = baseMapper.getAlarmTypeOne(records.get(i).getAlarmType());
-                if(baseAlarmType != null){
-                    records.get(i).setTypeImg(baseAlarmType.getTypeImg());
+            List<BaseAlarmType> alarmTypeList = baseMapper.getAlarmTypeList();
+            if(CollectionUtils.isNotEmpty(alarmTypeList)){
+                for(int i=0;i<records.size();i++){
+                    for(int j=0;j<alarmTypeList.size();j++){
+                        if(records.get(i).getAlarmType().equals(alarmTypeList.get(j).getTypeCode())){
+                            records.get(i).setTypeImg(alarmTypeList.get(j).getTypeImg());
+                            break;
+                        }
+                    }
                 }
-
             }
         }
         return records;

+ 5 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/vo/BaseAlarmListVO.java

@@ -23,6 +23,11 @@ public class BaseAlarmListVO {
      */
     private String companyName;
 
+    /**
+     * 设备Id
+     */
+    private String deviceId;
+
     /**
      * 设备名称
      */

+ 10 - 0
service-iot/service-iot-biz/src/main/resources/mapper/iot/BaseAlarmMapper.xml

@@ -37,6 +37,16 @@
             </if>
         </where>
     </select>
+    <select id="getAlarmTypeList" resultType="com.usky.iot.domain.BaseAlarmType">
+        select
+        *
+        from base_alarm_type
+        <where>
+            <if test="1 == 1">
+                and delete_flag = 0
+            </if>
+        </where>
+    </select>
     <select id="getDeviceInfoList" resultType="com.usky.iot.domain.DmpDeviceInfo">
         select ddi.*
         from dmp_device ddi