Преглед на файлове

修复tos设备类型编辑时,未正常更新通用连接的bug

liuyaowen преди 1 година
родител
ревизия
0e9e59db4f
променени са 1 файла, в които са добавени 21 реда и са изтрити 22 реда
  1. 21 22
      src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/TosDevicetypeServiceImpl.java

+ 21 - 22
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/TosDevicetypeServiceImpl.java

@@ -24,13 +24,12 @@ import java.util.List;
 
 /**
  * 设备类型Service业务层处理
- * 
+ *
  * @author 杨晓辉
  * @date 2024-11-06
  */
 @Service
-public class TosDevicetypeServiceImpl implements ITosDevicetypeService
-{
+public class TosDevicetypeServiceImpl implements ITosDevicetypeService {
     @Autowired
     private TosDevicetypeMapper tosDevicetypeMapper;
     @Resource
@@ -41,12 +40,13 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     private SendToIotsMsgService sendToIotsMsgService;
 
     @PostConstruct
-    public void init(){
+    public void init() {
         List<TosDevicetype> tosDevicetypeList = tosDevicetypeMapper.selectTosDevicetypeList(null);
-        for(TosDevicetype tosDevicetype : tosDevicetypeList){
+        for (TosDevicetype tosDevicetype : tosDevicetypeList) {
             typeCacheService.setCache(tosDevicetype);
         }
     }
+    
 
     /**
      * 查询设备类型
@@ -55,29 +55,29 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
      * @return 设备类型
      */
     @Override
-    public TosDevicetype selectTosDevicetypeByDevtypeBid(String devtypeBid){
+    public TosDevicetype selectTosDevicetypeByDevtypeBid(String devtypeBid) {
         return tosDevicetypeMapper.selectTosDevicetypeByDevtypeBid(devtypeBid);
     }
 
     /**
      * 查询设备类型列表
-     * 
+     *
      * @param tosDevicetype 设备类型
      * @return 设备类型
      */
     @Override
-    public List<TosDevicetype> selectTosDevicetypeList(TosDevicetype tosDevicetype){
+    public List<TosDevicetype> selectTosDevicetypeList(TosDevicetype tosDevicetype) {
         return tosDevicetypeMapper.selectTosDevicetypeList(tosDevicetype);
     }
 
     /**
      * 新增设备类型
-     * 
+     *
      * @param tosDevicetype 设备类型
      * @return 结果
      */
     @Override
-    public int insertTosDevicetypeByTosMsg(TosDevicetype tosDevicetype){
+    public int insertTosDevicetypeByTosMsg(TosDevicetype tosDevicetype) {
         int result = tosDevicetypeMapper.insertTosDevicetype(tosDevicetype);
         typeCacheService.setCache(tosDevicetype);
         return result;
@@ -85,24 +85,24 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
 
     /**
      * 修改设备类型
-     * 
+     *
      * @param tosDevicetype 设备类型
      * @return 结果
      */
     @Override
-    public int updateTosDevicetypeByTosMsg(TosDevicetype tosDevicetype){
+    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())) {
+        if (oldTosDeviceType != null && !oldTosDeviceType.getDevTypeConfig().equals(tosDevicetype.getDevTypeConfig())) {
             IotDeviceconn iotDeviceConnQuery = new IotDeviceconn();
             iotDeviceConnQuery.setDevconnType(IotDeviceconnTypeEnum.COMMON.getCode());
-            iotDeviceConnQuery.setDevtypeBid(iotDeviceConnQuery.getDevconnBid());
+            iotDeviceConnQuery.setDevtypeBid(tosDevicetype.getDevtypeBid());
             List<IotDeviceconn> iotDeviceconnList = iotDeviceconnMapper.selectIotDeviceconnList(iotDeviceConnQuery);
-            for(IotDeviceconn iotDeviceconn : iotDeviceconnList){
+            for (IotDeviceconn iotDeviceconn : iotDeviceconnList) {
                 iotDeviceconn.setDevconnConfig(tosDevicetype.getDevTypeConfig());
             }
-            if(!iotDeviceconnList.isEmpty()){
+            if (!iotDeviceconnList.isEmpty()) {
                 iotDeviceconnMapper.updateBatchByBid(iotDeviceconnList);
             }
             sendToIotsMsgService.sendTosDeviceTypeUpdate(tosDevicetype);
@@ -111,23 +111,22 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     }
 
 
-
     /**
      * 删除设备类型信息
-     * 
-     * @param id 设备类型主键
+     *
+     * @param devtypeBid 设备类型主键
      * @return 结果
      */
     @Override
-    public int deleteTosDevicetypeByDevtypeBid(String devtypeBid){
+    public int deleteTosDevicetypeByDevtypeBid(String devtypeBid) {
         return tosDevicetypeMapper.deleteTosDevicetypeByDevtypeBid(devtypeBid);
     }
 
     @Override
     public int deleteTosDevicetypeByTosMsg(TosDevicetype tosDevicetype) {
         int result = 0;
-        if(null == tosDevicetype){
-           return result;
+        if (null == tosDevicetype) {
+            return result;
         }
         result = tosDevicetypeMapper.deleteTosDevicetypeByDevtypeBid(tosDevicetype.getDevtypeBid());
         typeCacheService.deleteCache(tosDevicetype);