lengfaqiang пре 2 година
родитељ
комит
9a9d7348bb

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java

@@ -41,9 +41,9 @@ public class DeviceController {
     @Log(description = "所属设备查询")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "所属设备查询", value = "/deviceAll", method = RequestMethod.GET)
-    public HttpResult deviceAll(@RequestParam("projectId") String projectId) {
+    public HttpResult deviceAll(@RequestParam("projectId") String projectId, HttpServletRequest request) {
         log.info("所属设备查询 deviceAll param :{}", projectId);
-        return deviceService.deviceAll(projectId);
+        return deviceService.deviceAll(projectId,request);
     }
 
     @Log(description = "设备查询-分页")

+ 3 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java

@@ -32,15 +32,16 @@ public interface KwsDeviceMapper extends BaseMapper<KwsDevice> {
      * 查询项目中未绑定设备关联关系的设备
      *
      * @param projectId
+     * @param companyId
      * @return
      */
-    List<DeviceDataDTO> selectDeviceAllNotDeviceRelation(@Param("projectId") String projectId);
+    List<DeviceDataDTO> selectDeviceAllNotDeviceRelation(@Param("projectId") String projectId, @Param("companyId") String companyId);
 
     List<DeviceDataDTO> selectAllDeviceByProject(@Param("projectId") String projectId);
 
     List<DeviceVo> selectByDeviceParam(@Param("deviceQuery") DeviceQuery deviceQuery);
 
-    List<DeviceVo> selectProjectByDeviceId(@Param("deviceId") String deviceId);
+    List<KwsDevice> selectProjectByDeviceId(@Param("deviceId") String deviceId);
 
     /**
      * 查询项目绑定的设备

+ 6 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectMapper.java

@@ -32,6 +32,12 @@ public interface KwsProjectMapper extends BaseMapper<KwsProject> {
 
     List<ProjectDeviceVO> selectDeviceNotBindList(@Param("deviceQuery") DeviceQuery deviceQuery);
 
+    /**
+     * 查询设备没有和项目关联的数据
+     * @param deviceQuery
+     * @param headerData
+     * @return
+     */
     List<ProjectDeviceVO> selectNotBindDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery, @Param("headerData") HeaderData headerData);
 
     List<KwsProject> selectListData(@Param("ids") List<String> ids, @Param("delFlag") Integer delFlag);

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeviceDeleteDTO.java

@@ -23,7 +23,9 @@ public class DeviceDeleteDTO {
 
 //    @NotBlank(message = "主设备id不能为空")
     private String parentId;
-
+    /**
+     * 设备父级id
+     */
     private String deviceParentId;
 
 }

+ 3 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -129,9 +129,10 @@ public class DeviceService {
         return HttpResult.ok("删除设备成功");
     }
 
-    public HttpResult deviceAll(String projectId) {
+    public HttpResult deviceAll(String projectId,HttpServletRequest request) {
         //设备至关联多只支持两层结构,因此子级设备不能在【所属设备名称】中被查询出来
-        List<DeviceDataDTO> list = deviceMapper.selectDeviceAllNotDeviceRelation(projectId);
+        HeaderData headerData = commonService.getHeaderData(request);
+        List<DeviceDataDTO> list = deviceMapper.selectDeviceAllNotDeviceRelation(projectId,headerData.getCompanyId());
         return HttpResult.ok(list);
     }
 

+ 5 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -1242,6 +1242,7 @@ public class ProjectService {
         List<Long> deleteList = new ArrayList<>();
         List<String> deleteDiviceList = new ArrayList<>();
         if (deviceId.equals(deviceParentId)) {
+            deleteList.add(Long.parseLong(bindDeviceId));
             deleteDiviceList.add(deviceId);
             List<KwsDeviceRelation> deviceRelationList = deviceRelationMapper.selectList(
                     new LambdaQueryWrapper<KwsDeviceRelation>()
@@ -1274,8 +1275,11 @@ public class ProjectService {
             }
         } else {
             deleteList.add(Long.parseLong(bindDeviceId));
+            deleteList.add(Long.parseLong(deviceId));
+            deleteList.add(Long.parseLong(deviceParentId));
             deleteDiviceList.add(deviceId);
             deleteDiviceList.add(bindDeviceId);
+            deleteDiviceList.add(deviceParentId);
             deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
                     .eq(KwsDeviceRelation::getDeviceId, deviceParentId)
                     .eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
@@ -1317,7 +1321,7 @@ public class ProjectService {
             );
         }
         if (!CollectionUtils.isEmpty(deleteDiviceList)) {
-            List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>().in(KwsDevice::getId, deviceId).eq(KwsDevice::getDelFlag, 0));
+            List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>().in(KwsDevice::getId, deleteDiviceList).eq(KwsDevice::getDelFlag, 0));
             if (!CollectionUtils.isEmpty(kwsDevices)) {
                 StringBuilder deviceName = new StringBuilder();
                 for (int i = 0; i < kwsDevices.size(); i++) {

+ 4 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

@@ -281,7 +281,7 @@
     </update>
 
     <select id="selectDeviceAllNotDeviceRelation" resultType="com.sckw.slope.detection.model.dto.DeviceDataDTO">
-        SELECT c.id     AS deviceId,
+        SELECT DISTINCT c.id     AS deviceId,
                c.alias  as deviceAlias,
                c.`name` AS deviceName
         FROM kws_project a
@@ -300,6 +300,9 @@
         <if test="projectId != null and projectId != ''">
             AND a.id = #{projectId}
         </if>
+        <if test="companyId != null and companyId != ''">
+            AND a.company_id = #{companyId}
+        </if>
     </select>
 
     <select id="selectDeviceAllAndProjectData"