Explorar el Código

设备列表删除功能修改

zhengjie hace 1 año
padre
commit
92b1d55d03

+ 4 - 4
ruoyi-admin/src/main/resources/application-test.yml

@@ -9,9 +9,9 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://42.193.106.113:3306/yyky?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://192.168.56.10/yyky?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
-                password: zhonghui0123
+                password: root
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭
@@ -66,13 +66,13 @@ spring:
     # redis 配置
     redis:
         # 地址
-        host: localhost
+        host: 192.168.56.10
         # 端口,默认为6379
         port: 6379
         # 数据库索引
         database: 0
         # 密码
-        password:
+        password: redis
         # 连接超时时间
         timeout: 10s
         lettuce:

+ 2 - 2
ruoyi-admin/src/main/resources/application.yml

@@ -54,11 +54,11 @@ spring:
     basename: i18n/messages
   profiles:
     # 测试环境
-        active: test
+#        active: test
     # 开发环境
 #    active: dev
     # 生产环境
-#    active: druid
+    active: druid
 
   # 文件上传
   servlet:

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TDeviceListMapper.java

@@ -29,6 +29,13 @@ public interface TDeviceListMapper
      */
     public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList);
 
+    /**
+     * 查询设备列列表
+     *
+     * @return 设备列集合
+     */
+    public List<TDeviceList> selectTDeviceList();
+
     /**
      * 查询设备列列表
      *

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java

@@ -22,6 +22,14 @@ public interface TFacilityMapper
      */
     public TFacility selectTFacilityById(Long id);
 
+    /**
+     * 查询手环设备
+     *
+     * @param code 手环设备
+     * @return 手环设备
+     */
+    public TFacility selectTFacilityByCode(String code);
+
     /**
      * 查询手环设备列表
      * 

+ 21 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -137,6 +137,22 @@ public class TDeviceListServiceImpl implements ITDeviceListService
     @Override
     public int deleteTDeviceListByIds(Integer[] ids)
     {
+        List<TDeviceList> tDeviceLists = tDeviceListMapper.selectTDeviceList();
+        if (StringUtils.isNotEmpty(ids))
+        {
+            for (Integer id : ids)
+            {
+                for (TDeviceList tDevice : tDeviceLists)
+                {
+                    if (tDevice.getId().equals(id)){
+                        TFacility tFacility = tFacilityMapper.selectTFacilityByCode(tDevice.getDeviceId());
+                        if (StringUtils.isNotNull(tFacility)){
+                            tFacilityMapper.deleteTFacilityById(tFacility.getId());
+                        }
+                    }
+                }
+            }
+        }
         return tDeviceListMapper.deleteTDeviceListByIds(ids);
     }
 
@@ -149,6 +165,11 @@ public class TDeviceListServiceImpl implements ITDeviceListService
     @Override
     public int deleteTDeviceListById(Integer id)
     {
+        TDeviceList tDevice= this.selectTDeviceListById(id);
+        TFacility tFacility = tFacilityMapper.selectTFacilityByCode(tDevice.getDeviceId());
+        if (StringUtils.isNotNull(tFacility)){
+            tFacilityMapper.deleteTFacilityById(tFacility.getId());
+        }
         return tDeviceListMapper.deleteTDeviceListById(id);
     }
 

+ 3 - 0
ruoyi-system/src/main/resources/mapper/system/TDeviceListMapper.xml

@@ -123,6 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join t_shouhuan_info d on a.device_id=d.device_id_code
         where a.device_id = #{deviceId}
     </select>
+    <select id="selectTDeviceList" parameterType="TDeviceList" resultMap="TDeviceListResult">
+        <include refid="selectTDeviceListVo"/>
+    </select>
 
 
     <insert id="insertTDeviceList" parameterType="TDeviceList" useGeneratedKeys="true" keyProperty="id">

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/TFacilityMapper.xml

@@ -38,7 +38,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTFacilityVo"/>
         where id = #{id}
     </select>
-        
+    <select id="selectTFacilityByCode" resultMap="TFacilityResult">
+        <include refid="selectTFacilityVo"/>
+        where code = #{code}
+    </select>
+
     <insert id="insertTFacility" parameterType="TFacility" useGeneratedKeys="true" keyProperty="id">
         insert into t_facility
         <trim prefix="(" suffix=")" suffixOverrides=",">