Ver Fonte

Merge branch 'dev' into sky_v2

15928045575 há 2 anos atrás
pai
commit
7fde2e1a11

+ 2 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectMapper.java

@@ -3,6 +3,7 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsProject;
+import com.sckw.slope.detection.model.dto.HeaderData;
 import com.sckw.slope.detection.model.param.DeviceQuery;
 import com.sckw.slope.detection.model.vo.ProjectDeviceVO;
 import com.sckw.slope.detection.model.param.ProjectQuery;
@@ -31,7 +32,7 @@ public interface KwsProjectMapper extends BaseMapper<KwsProject> {
 
     List<ProjectDeviceVO> selectDeviceNotBindList(@Param("deviceQuery") DeviceQuery deviceQuery);
 
-    List<ProjectDeviceVO> selectNotBindDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery);
+    List<ProjectDeviceVO> selectNotBindDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery, @Param("headerData") HeaderData headerData);
 
     List<KwsProject> selectListData(@Param("ids") List<String> ids, @Param("delFlag") Integer delFlag);
 

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

@@ -373,6 +373,7 @@ public class ProjectService {
             deviceRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
             deviceRelation.setDeviceId(Long.parseLong(deviceId));
             deviceRelation.setMountainId(headerData.getMountainId());
+            deviceRelation.setCompanyId(headerData.getCompanyId());
             deviceRelation.setRelateDeviceId(id);
             deviceRelation.setStatus(NumberConstant.ZERO);
             deviceRelation.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
@@ -445,8 +446,9 @@ public class ProjectService {
     }
 
     public PageRes deviceBindSelect(DeviceQuery deviceQuery, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
         PageHelper.startPage(deviceQuery.getPage(), deviceQuery.getPageSize());
-        List<ProjectDeviceVO> list = projectMapper.selectNotBindDeviceList(deviceQuery);
+        List<ProjectDeviceVO> list = projectMapper.selectNotBindDeviceList(deviceQuery, headerData);
         PageInfo<ProjectDeviceVO> info = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(info, list);
@@ -1371,12 +1373,18 @@ public class ProjectService {
         vo.setProjectTotal(count);
         int deviceCount = deviceMapper.selectCountByProject(projectId, companyId);
         vo.setDeviceTotal(deviceCount);
-        List<KwsProject> projectList = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
-                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(projectId), KwsProject::getId, Long.parseLong(projectId))
-                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsProject::getCompanyId, Long.parseLong(companyId))
+        LambdaQueryWrapper<KwsProject> projectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        projectLambdaQueryWrapper.eq(KwsProject::getDelFlag, 0);
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(projectId)) {
+            projectLambdaQueryWrapper.eq(KwsProject::getId, Long.parseLong(projectId));
+        }
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(companyId)) {
+            projectLambdaQueryWrapper.eq(KwsProject::getCompanyId, Long.parseLong(companyId));
+        }
+        List<KwsProject> projectList = projectMapper.selectList(projectLambdaQueryWrapper
         );
         List<Long> projectIdList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(projectList)) {
+        if (!CollectionUtils.isEmpty(projectList) && projectList.size() > 0) {
             projectIdList = projectList.stream().map(KwsProject::getId).distinct().collect(Collectors.toList());
         }
         //统计全部面积

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

@@ -372,10 +372,10 @@
         and a.mountain_id = b.mountain_id
         and b.mountain_id = c.mountain_id
       <if test="projectId != null and projectId != ''">
-          and a.id=#{projectId}
+          and a.id = #{projectId}
       </if>
       <if test="companyId != null and companyId != ''">
-          and a.company_id=#{companyId}
+          and a.company_id = #{companyId}
       </if>
   </select>
 

+ 3 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml

@@ -217,6 +217,9 @@
                 , #{deviceQuery.name}
                 , '%')
         </if>
+        <if test="headerData.companyId != null and headerData.companyId != ''">
+            and a.mountain_id =#{headerData.companyId}
+        </if>
     </select>
 
     <select id="selectListData" resultMap="BaseResultMap">