Jelajahi Sumber

新增tos设备型号连接信息编辑处理逻辑

liuyaowen 1 tahun lalu
induk
melakukan
5d3db45f60

+ 5 - 0
src/main/java/com/yunfeiyun/agmp/iotm/mq/service/SendToIotsMsgService.java

@@ -7,6 +7,7 @@ import com.yunfeiyun.agmp.common.framework.manager.RedisCacheManager;
 import com.yunfeiyun.agmp.iot.common.constant.mq.IotActionEnums;
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
 import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconn;
+import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
 import com.yunfeiyun.agmp.iot.common.model.cmd.CmdGroupModel;
 import com.yunfeiyun.agmp.iot.common.model.mq.IotDeviceEditMqModel;
 import com.yunfeiyun.agmp.iotm.mq.provider.IotsMqProviderService;
@@ -110,4 +111,8 @@ public class SendToIotsMsgService {
         redisCacheManager.setCacheObject(RedisCacheKey.IOT_SYN_ALL_DEVICE_TIME_LIMIT,devTypeCode,devTypeCode,times,timeUnit);
 
     }
+
+    public void sendTosDeviceTypeUpdate(TosDevicetype tosDevicetype) {
+         mqService.sendBaseDataToIots(IotActionEnums.DEVICE_COMMON_CONN_UPDATE,tosDevicetype,"【Iotm】to【Iots】物联网设备型号更新,同步到Iots");
+    }
 }

+ 23 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/TosDevicetypeServiceImpl.java

@@ -1,11 +1,16 @@
 package com.yunfeiyun.agmp.iotm.web.service.impl;
 
 
+import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconn;
 import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
+import com.yunfeiyun.agmp.iot.common.enums.IotDeviceconnTypeEnum;
 import com.yunfeiyun.agmp.iot.common.service.TypeCacheService;
+import com.yunfeiyun.agmp.iotm.mq.service.SendToIotsMsgService;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDevicetypeListResVo;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.TosDevicetypeResVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceconnMapper;
 import com.yunfeiyun.agmp.iotm.web.mapper.TosDevicetypeMapper;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconnService;
 import com.yunfeiyun.agmp.iotm.web.service.ITosDevicetypeService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,7 +35,10 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     private TosDevicetypeMapper tosDevicetypeMapper;
     @Resource
     private TypeCacheService typeCacheService;
-
+    @Resource
+    private IotDeviceconnMapper iotDeviceconnMapper;
+    @Resource
+    private SendToIotsMsgService sendToIotsMsgService;
 
     @PostConstruct
     public void init(){
@@ -83,8 +91,22 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
      */
     @Override
     public int updateTosDevicetypeByTosMsg(TosDevicetype tosDevicetype){
+        TosDevicetype oldTosDeviceType = tosDevicetypeMapper.selectTosDevicetypeByDevtypeBid(tosDevicetype.getDevtypeBid());
         int result = tosDevicetypeMapper.updateTosDevicetype(tosDevicetype);
         typeCacheService.setCache(tosDevicetype);
+        if(oldTosDeviceType!= null&&!oldTosDeviceType.getDevTypeConfig().equals(tosDevicetype.getDevTypeConfig())) {
+            IotDeviceconn iotDeviceConnQuery = new IotDeviceconn();
+            iotDeviceConnQuery.setDevconnType(IotDeviceconnTypeEnum.COMMON.getCode());
+            iotDeviceConnQuery.setDevtypeBid(iotDeviceConnQuery.getDevconnBid());
+            List<IotDeviceconn> iotDeviceconnList = iotDeviceconnMapper.selectIotDeviceconnList(iotDeviceConnQuery);
+            for(IotDeviceconn iotDeviceconn : iotDeviceconnList){
+                iotDeviceconn.setDevconnConfig(tosDevicetype.getDevTypeConfig());
+            }
+            if(!iotDeviceconnList.isEmpty()){
+                iotDeviceconnMapper.updateBatchByBid(iotDeviceconnList);
+            }
+            sendToIotsMsgService.sendTosDeviceTypeUpdate(tosDevicetype);
+        }
         return result;
     }