فهرست منبع

Merge branch 'dev' into sky_v2

15928045575 2 سال پیش
والد
کامیت
008f79a59f

+ 3 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ProjectController.java

@@ -154,9 +154,9 @@ public class ProjectController {
     @Log(description = "数据总览")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "数据总览", value = "/dataScreening", method = RequestMethod.GET)
-    public HttpResult dataScreening(/*@RequestParam("projectId") */String projectId ,HttpServletRequest request) {
-        log.info("数据总览 dataScreening param:{}", projectId);
-        return projectService.dataScreening(projectId);
+    public HttpResult dataScreening(/*@RequestParam("projectId") */String companyId,/*@RequestParam("projectId") */String projectId ,HttpServletRequest request) {
+        log.info("数据总览 dataScreening param:{}", projectId,companyId);
+        return projectService.dataScreening(projectId,companyId);
     }
 
     @Log(description = "项目查询(项目+设备)")

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

@@ -52,9 +52,9 @@ public interface KwsDeviceMapper extends BaseMapper<KwsDevice> {
 
     List<ThresholdSelectDTO> selectDeviceAllByProjectAndMountainId(@Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("status") List<Integer> status);
 
-    int selectCountByProject(@Param("projectId") String projectId);
+    int selectCountByProject(@Param("projectId") String projectId,@Param("companyId") String companyId);
 
-    int selectDeviceOnlineRateCountByProject(@Param("projectId") String projectId);
+    int selectDeviceOnlineRateCountByProject(@Param("projectId") String projectId,@Param("companyId") String companyId);
 
     List<Map<String, String>> selectListByModelType(@Param("modelType") String modelType,@Param("companyId") String companyId);
 

+ 38 - 12
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -336,9 +336,9 @@ public class ProjectService {
 
     @Transactional
     public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
-//        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
-//            return HttpResult.error("安装设备时间不能为空");
-//        }
+        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
+            return HttpResult.error("安装设备时间不能为空");
+        }
         HeaderData headerData = commonService.getHeaderData(request);
         Long projectId = Long.parseLong(bindDevice.getProjectId());
         KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
@@ -428,7 +428,7 @@ public class ProjectService {
                 deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
                         .eq(KwsDevice::getId, id)
                         .set(KwsDevice::getRelevanceLevel, level)
-                        .set(KwsDevice::getInstallTime,localDateTime)
+                        .set(KwsDevice::getInstallTime, localDateTime)
                         .set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
                         .set(KwsDevice::getOnline, 1)
                         .set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
@@ -1358,23 +1358,38 @@ public class ProjectService {
     @Autowired
     KwsAlarmDetailMapper alarmDetailMapper;
 
-    public HttpResult dataScreening(String projectId) {
+    public HttpResult dataScreening(String projectId, String companyId) {
         DataScreeningVO vo = new DataScreeningVO();
         LambdaQueryWrapper<KwsProject> wrapper = new LambdaQueryWrapper<>();
-        LambdaQueryWrapper<KwsProjectArea> wrapperProjectArea = new LambdaQueryWrapper<>();
         if (org.apache.commons.lang3.StringUtils.isNotBlank(projectId)) {
             wrapper.eq(KwsProject::getId, Long.parseLong(projectId));
         }
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(companyId)) {
+            wrapper.eq(KwsProject::getCompanyId, Long.parseLong(companyId));
+        }
         long count = projectMapper.selectList(wrapper.eq(KwsProject::getDelFlag, 0)).stream().count();
         vo.setProjectTotal(count);
-        int deviceCount = deviceMapper.selectCountByProject(projectId);
+        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))
+        );
+        List<Long> projectIdList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(projectList)) {
+            projectIdList = projectList.stream().map(KwsProject::getId).distinct().collect(Collectors.toList());
+        }
         //统计全部面积
-        BigDecimal area = projectAreaMapper.selectList(wrapperProjectArea.eq(KwsProjectArea::getDelFlag, 0)).stream().map(KwsProjectArea::getArea).reduce(BigDecimal.ZERO,
+        LambdaQueryWrapper<KwsProjectArea> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(KwsProjectArea::getDelFlag, 0);
+        if (!CollectionUtils.isEmpty(projectIdList) && projectIdList.size() > 0) {
+            queryWrapper.in(KwsProjectArea::getProjectId, projectIdList);
+        }
+        BigDecimal area = projectAreaMapper.selectList(queryWrapper).stream().map(KwsProjectArea::getArea).reduce(BigDecimal.ZERO,
                 BigDecimal::add);
         vo.setProjectTotalArea(area);
         /**仅统计设备在线的数据*/
-        int deviceOnline = deviceMapper.selectDeviceOnlineRateCountByProject(projectId);
+        int deviceOnline = deviceMapper.selectDeviceOnlineRateCountByProject(projectId, companyId);
         BigDecimal deviceOnlineRate = new BigDecimal("0.00");
         if (deviceOnline != 0) {
             deviceOnlineRate = new BigDecimal(deviceOnline).divide(new BigDecimal(deviceCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100.00"));
@@ -1393,6 +1408,7 @@ public class ProjectService {
         }
         List<KwsAlarm> kwsAlarmsCount = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
                 .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarm::getCompanyId, companyId)
                 .eq(KwsAlarm::getStatus, 0)
                 .eq(KwsAlarm::getDelFlag, 0)
         );
@@ -1404,12 +1420,14 @@ public class ProjectService {
         vo.setAlarmTotal(alarmTotal);
         List<KwsAlarmDetail> unreadKwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
                 .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarmDetail::getCompanyId, companyId)
                 .eq(KwsAlarmDetail::getStatus, 0)
                 .eq(KwsAlarmDetail::getDelFlag, 0)
         );
         vo.setUnreadAlarmTotal(CollectionUtils.isEmpty(unreadKwsAlarms) ? 0 : unreadKwsAlarms.size());
         List<KwsAlarm> oneThresholdAlarm = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
                 .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarm::getCompanyId, companyId)
                 .eq(KwsAlarm::getLevel, NumberConstant.ONE)
         );
         int oneAlarmTotal = 0;
@@ -1420,6 +1438,7 @@ public class ProjectService {
         vo.setOneAlarmTotal(oneAlarmTotal);
         List<KwsAlarmDetail> kwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
                 .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarmDetail::getCompanyId, companyId)
                 .eq(KwsAlarmDetail::getDelFlag, 0)
                 .gt(KwsAlarmDetail::getCreateTime, localDateTimeStart).lt(KwsAlarmDetail::getCreateTime, localDateTimeEnd)
         );
@@ -1581,9 +1600,9 @@ public class ProjectService {
 
     @Transactional
     public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
-//        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
-//            return HttpResult.error("安装设备时间不能为空");
-//        }
+        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
+            return HttpResult.error("安装设备时间不能为空");
+        }
         String deviceRelationId = bindDevice.getDeviceRelationId();
         if (StringUtils.isBlank(deviceRelationId)) {
             return HttpResult.error("关联主键id不能为空");
@@ -1591,6 +1610,13 @@ public class ProjectService {
         String bindDeviceId = bindDevice.getBindDeviceId();
         String deviceIds = bindDevice.getDeviceIds();
         String alias = bindDevice.getAlias();
+        KwsDeviceRelation kwsDeviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
+                .eq(KwsDeviceRelation::getId, Long.parseLong(bindDeviceId))
+                .eq(KwsDeviceRelation::getDelFlag, NumberConstant.ZERO)
+        );
+        if (kwsDeviceRelation == null) {
+            return HttpResult.error("修改id传递错误");
+        }
         HeaderData headerData = commonService.getHeaderData(request);
         /**验证主设备是否存在子设备*/
 //        List<KwsDeviceRelation> deviceRelations = deviceRelationMapper.selectList(

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

@@ -374,6 +374,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="selectDeviceOnlineRateCountByProject" resultType="int">
@@ -391,6 +394,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="selectListByModelType" resultType="java.util.Map">