Browse Source

Merge branch 'usky-zyj' of uskycloud/usky-modules into master

gez 1 month ago
parent
commit
445d821931

+ 18 - 20
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAlarmServiceImpl.java

@@ -626,15 +626,24 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
 
     @Override
     public void deviceOffLineAlarm(){
-        log.info("定时同步设备状态和设备告警数据 start");
-        ApiResult<List<StatusVO>> resultList = dataQueryClient.status();
-        List<StatusVO> list = resultList.getData();
-        if(CollectionUtils.isNotEmpty(list)){
-            List<String> devList = new ArrayList<>();
-            for(int i=0;i<list.size();i++){
-                devList.add(list.get(i).getDeviceId());
+        log.info("定时同步设备告警数据 start");
+        List<StatusVO> list = new ArrayList<>();
+        List<String> devList = new ArrayList<>();
+        LambdaQueryWrapper<DmpDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(DmpDeviceStatus::getProductCode,DmpDeviceStatus::getDeviceId,DmpDeviceStatus::getLastOnlineTime);
+        List<DmpDeviceStatus> dmpDeviceStatusList = dmpDeviceStatusService.list(queryWrapper);
+        if(CollectionUtils.isNotEmpty(dmpDeviceStatusList)){
+            for (int i = 0; i < dmpDeviceStatusList.size(); i++) {
+                StatusVO statusVO = new StatusVO();
+                statusVO.setProductCode(dmpDeviceStatusList.get(i).getProductCode());
+                statusVO.setDeviceId(dmpDeviceStatusList.get(i).getDeviceId());
+                statusVO.setTime(dmpDeviceStatusList.get(i).getLastOnlineTime());
+                list.add(statusVO);
+                devList.add(dmpDeviceStatusList.get(i).getDeviceId());
             }
+        }
 
+        if(CollectionUtils.isNotEmpty(list)){
             List<DmpDeviceInfo> devInfoList = new ArrayList<>();
             List<BaseAlarm> baseUnAlarmList = new ArrayList<>();
 //            List<BaseAlarm> baseAlarmList = new ArrayList<>();
@@ -646,14 +655,8 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
 
             if(CollectionUtils.isNotEmpty(devInfoList)){
                 for(int i=0;i<list.size();i++){
-                    String date =  list.get(i).getTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                     String currentDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-                    LambdaUpdateWrapper<DmpDeviceStatus> updateWrapper = Wrappers.lambdaUpdate();
-                    if(date.equals(currentDate)){
-                        updateWrapper.set(DmpDeviceStatus::getDeviceStatus,1)  //设备在线
-                                .set(DmpDeviceStatus::getLastOnlineTime,list.get(i).getTime())
-                                .eq(DmpDeviceStatus::getDeviceId,list.get(i).getDeviceId())
-                                .eq(DmpDeviceStatus::getProductCode,list.get(i).getProductCode());
+                    if(Objects.nonNull(list.get(i).getTime()) && currentDate.equals(list.get(i).getTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))){
                         //设备离线告警恢复在线自动默认处理
                         if(CollectionUtils.isNotEmpty(baseUnAlarmList)){
                             for(int j=0;j<baseUnAlarmList.size();j++){
@@ -672,10 +675,6 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                         }
 
                     }else{
-                        updateWrapper.set(DmpDeviceStatus::getDeviceStatus,2)  //设备离线
-                                .set(DmpDeviceStatus::getLastOfflineTime,list.get(i).getTime())
-                                .eq(DmpDeviceStatus::getDeviceId,list.get(i).getDeviceId())
-                                .eq(DmpDeviceStatus::getProductCode,list.get(i).getProductCode());
 
                         for(int j=0;j<devInfoList.size();j++){
                             if(list.get(i).getDeviceId().equals(devInfoList.get(j).getDeviceId()) && list.get(i).getProductCode().equals(devInfoList.get(j).getProductCode())){
@@ -705,12 +704,11 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
                         }
 
                     }
-                    dmpDeviceStatusService.update(updateWrapper);
                 }
             }
 
         }
-        log.info("定时同步设备状态和设备告警数据 end");
+        log.info("定时同步设备告警数据 end");
     }
 
     @Override

+ 5 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/DmpDeviceInfoServiceImpl.java

@@ -370,6 +370,8 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
             }
             this.save(dmpDeviceInfo);
 
+            remoteTransferService.deleteDeviceCache(dmpDeviceInfo.getProductCode());
+
             DmpDeviceStatus dmpDeviceStatus = new DmpDeviceStatus();
             dmpDeviceStatus.setDeviceId(dmpDeviceInfo.getDeviceId());
             dmpDeviceStatus.setProductId(dmpDeviceInfo.getProductId());
@@ -873,6 +875,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
         }
 
         dmpDeviceInfo.setDeleteFlag(1);
+
+        remoteTransferService.deleteDeviceCache(dmpDeviceInfo.getProductCode());
+
         return this.updateById(dmpDeviceInfo);
     }
 

+ 10 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/DmpProductInfoServiceImpl.java

@@ -21,6 +21,7 @@ import com.usky.iot.mapper.DmpProductInfoMapper;
 import com.usky.iot.service.*;
 import com.usky.iot.service.config.IntegerUtils;
 import com.usky.iot.service.vo.DmpProductInfoRequest;
+import com.usky.transfer.RemoteTransferService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -54,6 +55,9 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
     @Autowired
     private DmpProductAttributeService dmpProductAttributeService;
 
+    @Autowired
+    private RemoteTransferService remoteTransferService;
+
     @Override
     public void add(DmpProductInfo dmpProductInfo) {
         if (checkNameUnique(dmpProductInfo)){
@@ -81,6 +85,9 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
         dmpProductInfo.setDeleteFlag(0);
         dmpProductInfo.setTenantId(SecurityUtils.getTenantId());
         this.save(dmpProductInfo);
+
+        remoteTransferService.deleteProductCache();
+
         int productId = dmpProductInfo.getId();
         if(null != one){
             String dataField = one.getDataField();
@@ -253,6 +260,9 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
         }
 
         dmpProductInfo.setDeleteFlag(1);
+
+        remoteTransferService.deleteProductCache();
+
         return this.updateById(dmpProductInfo);
     }
 

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

@@ -52,7 +52,7 @@
         from dmp_device ddi
         <where>
             <if test="1 == 1">
-                and delete_flag = 0
+                and delete_flag = 0 and service_status = 2
             </if>
             <if test="1 == 1">
                 and device_id in

+ 8 - 3
service-job/src/main/java/com/ruoyi/job/task/RyTask.java

@@ -54,9 +54,14 @@ public class RyTask {
         remoteIotTaskService.dataOverviewJobData();
     }
 
-    public void baseAlarmStatus(){
-        System.out.println("baseAlarmStatus start......");
-        remoteIotTaskService.baseAlarmStatus();
+    public void deviceStatus(){
+        System.out.println("deviceStatus start......");
+        remoteIotTaskService.deviceStatus();
+    }
+
+    public void deviceOffLineAlarm(){
+        System.out.println("deviceOffLineAlarm start......");
+        remoteIotTaskService.deviceOffLineAlarm();
     }
 
     public void customInfoStatus(){