Prechádzať zdrojové kódy

数据隔离+新增字段

lengfaqiang 2 rokov pred
rodič
commit
18696cb836

+ 7 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsAlarmMapper.java

@@ -41,17 +41,20 @@ public interface KwsAlarmMapper extends BaseMapper<KwsAlarm> {
      * @return
      */
     List<Map<String, Object>> getDataAlarmToDay(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
-                                                @Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("type") Integer type);
+                                                @Param("projectId") String projectId, @Param("mountainId") String mountainId,@Param("companyId")  String companyId,
+                                                @Param("type") Integer type);
 
     List<Map<String, Object>> getDataAlarmToWeek(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
-                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("dateTimeFormat") String dateTimeFormat, @Param("type") Integer type);
+                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId,
+                                                 @Param("companyId") String companyId,
+                                                 @Param("dateTimeFormat") String dateTimeFormat, @Param("type") Integer type);
 
     List<Map<String, Object>> getDataAlarmToYear(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("level") String level,
-                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("type") Integer type);
+                                                 @Param("projectId") String projectId, @Param("mountainId") String mountainId,@Param("companyId") String companyId, @Param("type") Integer type);
 
     List<Map<String, Object>> getProjectAlarmList(@Param("startTime") String startTime, @Param("endTime") String endTime,
                                                   @Param("level") String level, @Param("projectId") String projectId,
-                                                  @Param("mountainId") String mountainId, @Param("type") Integer type);
+                                                  @Param("companyId") String companyId, @Param("type") Integer type);
 
     List<AlarmLogThresholdVO> selectDetailList(@Param("page") Integer page, @Param("pageSize") Integer pageSize);
 

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/BindDevice.java

@@ -34,6 +34,7 @@ public class BindDevice implements Serializable {
 
     private String alias;
 
+    private String id;
     /**
      * 安装设备时间
      */

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/UpdateDeviceBindSelectVO.java

@@ -39,4 +39,9 @@ public class UpdateDeviceBindSelectVO implements Serializable {
      * 按照时间
      */
     private String installTime;
+
+    /**
+     * 主建 id
+     */
+    public Long id;
 }

+ 22 - 22
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -603,38 +603,38 @@ public class KwsAlarmService {
             String dateTimeFormat = startTime;
             endTime = weekMondayAndSunday.get(1);
             //按照天纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), headerData.getCompanyId(), dateTimeFormat, type);
         } else if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
             String dateTimeFormat = startTime;
             startTime = startTime + " 00:00:00";
             endTime = endTime + " 23:59:59";
             //统计小时的纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getCompanyId(), headerData.getCompanyId(), dateTimeFormat, type);
         } else {
             if (latitude != null) {
 
                 if ("1".equals(latitude)) {
                     startTime = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 00:00:00";
                     endTime = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 23:59:59";
-                    returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(), type);
+                    returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(), headerData.getCompanyId(), type);
                 } else if ("2".equals(latitude)) {
                     List<String> weekMondayAndSunday = com.sckw.excel.utils.DateUtil.getWeekMondayAndSunday();
                     startTime = weekMondayAndSunday.get(0);
                     String dateTimeFormat = startTime;
                     endTime = weekMondayAndSunday.get(1);
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getCompanyId(), headerData.getCompanyId(), dateTimeFormat, type);
                 } else if ("3".equals(latitude)) {
                     LocalDate firstDayOfMonth = com.sckw.excel.utils.DateUtil.getFirstDayOfMonth();
                     startTime = com.sckw.excel.utils.DateUtil.dateToStr(firstDayOfMonth, "yyyy-MM-dd") /*+ " 00:00:00"*/;
                     String dateTimeFormat = startTime;
                     LocalDate lastDayOfMonth = com.sckw.excel.utils.DateUtil.getLastDayOfMonth();
                     endTime = com.sckw.excel.utils.DateUtil.dateToStr(lastDayOfMonth, "yyyy-MM-dd")/* + " 23:59:59"*/;
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), headerData.getCompanyId(), dateTimeFormat, type);
                 } else if ("4".equals(latitude)) {
                     //查询全年每个月份
                     startTime = com.sckw.excel.utils.DateUtil.getYearFirstMonth() + "-01";
                     endTime = com.sckw.excel.utils.DateUtil.getYearLastMonth() + "-31";
-                    returnList = getDataAlarmToYear(startTime, endTime, level, projectId, headerData.getMountainId(), type);
+                    returnList = getDataAlarmToYear(startTime, endTime, level, projectId, headerData.getMountainId(), headerData.getCompanyId(), type);
                 }
             }
         }
@@ -679,7 +679,7 @@ public class KwsAlarmService {
                 }
             }
         }
-        returnList = getProjectAlarmList(startTime, endTime, level, projectId, headerData.getMountainId(), 2);
+        returnList = getProjectAlarmList(startTime, endTime, level, projectId, headerData.getCompanyId(), 2);
         if (!CollectionUtils.isEmpty(returnList)) {
             for (Map<String, Object> map : returnList) {
                 String id = map.get("projectId").toString();
@@ -690,23 +690,23 @@ public class KwsAlarmService {
         return HttpResult.ok(returnList);
     }
 
-    private List<Map<String, Object>> getProjectAlarmList(String startTime, String endTime, String level, String projectId, String mountainId, Integer type) {
-        List<Map<String, Object>> list = alarmMapper.getProjectAlarmList(startTime, endTime, level, projectId, mountainId, type);
+    private List<Map<String, Object>> getProjectAlarmList(String startTime, String endTime, String level, String projectId, String companyId, Integer type) {
+        List<Map<String, Object>> list = alarmMapper.getProjectAlarmList(startTime, endTime, level, projectId, companyId, type);
         return list;
     }
 
-    private List<Map<String, Object>> getDataAlarmToYear(String startTime, String endTime, String level, String projectId, String mountainId, Integer type) {
-        List<Map<String, Object>> list = alarmMapper.getDataAlarmToYear(startTime, endTime, level, projectId, mountainId, type);
+    private List<Map<String, Object>> getDataAlarmToYear(String startTime, String endTime, String level, String projectId, String mountainId, String companyId, Integer type) {
+        List<Map<String, Object>> list = alarmMapper.getDataAlarmToYear(startTime, endTime, level, projectId, mountainId,companyId, type);
         return list;
     }
 
-    private List<Map<String, Object>> getDataAlarmToWeek(String startTime, String endTime, String level, String projectId, String mountainId, String dateTimeFormat, Integer type) {
-        List<Map<String, Object>> list = alarmMapper.getDataAlarmToWeek(startTime, endTime, level, projectId, mountainId, dateTimeFormat, type);
+    private List<Map<String, Object>> getDataAlarmToWeek(String startTime, String endTime, String level, String projectId, String mountainId, String companyId, String dateTimeFormat, Integer type) {
+        List<Map<String, Object>> list = alarmMapper.getDataAlarmToWeek(startTime, endTime, level, projectId, mountainId, companyId, dateTimeFormat, type);
         return list;
     }
 
-    private List<Map<String, Object>> getDataAlarmToDay(String startTime, String endTime, String level, String projectId, String mountainId, Integer type) {
-        List<Map<String, Object>> list = alarmMapper.getDataAlarmToDay(startTime, endTime, level, projectId, mountainId, type);
+    private List<Map<String, Object>> getDataAlarmToDay(String startTime, String endTime, String level, String projectId, String mountainId, String companyId, Integer type) {
+        List<Map<String, Object>> list = alarmMapper.getDataAlarmToDay(startTime, endTime, level, projectId, mountainId, companyId, type);
         return list;
     }
 
@@ -726,36 +726,36 @@ public class KwsAlarmService {
             String dateTimeFormat = startTime;
             endTime = weekMondayAndSunday.get(1);
             //按照天纬度统计
-            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+            returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), dateTimeFormat, type);
         } else if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
             startTime = startTime + " 00:00:00";
             endTime = endTime + " 23:59:59";
             //统计小时的纬度统计
-            returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(), type);
+            returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), type);
         } else {
             if (latitude != null) {
                 if ("1".equals(latitude)) {
                     startTime = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 00:00:00";
                     endTime = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 23:59:59";
-                    returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(), type);
+                    returnList = getDataAlarmToDay(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), type);
                 } else if ("2".equals(latitude)) {
                     List<String> weekMondayAndSunday = com.sckw.excel.utils.DateUtil.getWeekMondayAndSunday();
                     startTime = weekMondayAndSunday.get(0);
                     String dateTimeFormat = startTime;
                     endTime = weekMondayAndSunday.get(1);
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), dateTimeFormat, type);
                 } else if ("3".equals(latitude)) {
                     LocalDate firstDayOfMonth = com.sckw.excel.utils.DateUtil.getFirstDayOfMonth();
                     startTime = com.sckw.excel.utils.DateUtil.dateToStr(firstDayOfMonth, "yyyy-MM-dd") /*+ " 00:00:00"*/;
                     LocalDate lastDayOfMonth = com.sckw.excel.utils.DateUtil.getLastDayOfMonth();
                     endTime = com.sckw.excel.utils.DateUtil.dateToStr(lastDayOfMonth, "yyyy-MM-dd")/* + " 23:59:59"*/;
                     String dateTimeFormat = startTime;
-                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(), dateTimeFormat, type);
+                    returnList = getDataAlarmToWeek(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), dateTimeFormat, type);
                 } else if ("4".equals(latitude)) {
                     //查询全年每个月份
                     startTime = com.sckw.excel.utils.DateUtil.getYearFirstMonth() + "-01";
                     endTime = com.sckw.excel.utils.DateUtil.getYearLastMonth() + "-31";
-                    returnList = getDataAlarmToYear(startTime, endTime, level, projectId, headerData.getMountainId(), type);
+                    returnList = getDataAlarmToYear(startTime, endTime, level, projectId, headerData.getMountainId(),headerData.getCompanyId(), type);
                 }
             }
         }
@@ -800,7 +800,7 @@ public class KwsAlarmService {
                 }
             }
         }
-        returnList = getProjectAlarmList(startTime, endTime, level, projectId, headerData.getMountainId(), 1);
+        returnList = getProjectAlarmList(startTime, endTime, level, projectId, headerData.getCompanyId(), 1);
         if (!CollectionUtils.isEmpty(returnList)) {
             for (Map<String, Object> map : returnList) {
                 String id = map.get("projectId").toString();

+ 4 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -1408,7 +1408,6 @@ public class ProjectService {
             deviceOnlineRate = new BigDecimal(deviceOnline).divide(new BigDecimal(deviceCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100.00"));
         }
         vo.setDeviceOnlineRate(deviceOnlineRate);
-        Date now = new Date();
         LocalDateTime localDateTimeEnd = LocalDateTime.now();
         LocalDateTime localDateTimeStart = LocalDateTime.now().plusHours(-24);
         KwsProject project = null;
@@ -1631,6 +1630,7 @@ public class ProjectService {
         if (deviceRelation != null) {
             Long deviceId1 = deviceRelation.getDeviceId();
             KwsDevice kwsDevice = deviceMapper.selectById(deviceId1);
+            bindSelectVO.setId(deviceRelation.getId());
             bindSelectVO.setDeviceId(deviceId1);
             bindSelectVO.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
             bindSelectVO.setDeviceNameAlias(kwsDevice == null ? null : kwsDevice.getAlias());
@@ -1657,8 +1657,9 @@ public class ProjectService {
         String bindDeviceId = bindDevice.getBindDeviceId();
         String deviceIds = bindDevice.getDeviceIds();
         String alias = bindDevice.getAlias();
+        String onlyId = bindDevice.getId();
         KwsDeviceRelation kwsDeviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
-                .eq(KwsDeviceRelation::getId, Long.parseLong(bindDeviceId))
+                .eq(KwsDeviceRelation::getId, Long.parseLong(onlyId))
                 .eq(KwsDeviceRelation::getDelFlag, NumberConstant.ZERO)
         );
         if (kwsDeviceRelation == null) {
@@ -1776,6 +1777,7 @@ public class ProjectService {
                     if (kwsDevice == null) {
                         throw new BusinessException("所属主设备id错误!");
                     }
+                    kwsDevice.setAlias(alias);
                     kwsDevice.setInstallTime(localDateTime);
                     kwsDevice.setRelevanceLevel(level);
                     kwsDevice.setUpdateTime(LocalDateTime.now());

+ 12 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmMapper.xml

@@ -257,6 +257,9 @@
             <if test="mountainId != null and mountainId != ''">
                 and b.mountain_id = #{mountainId}
             </if>
+            <if test="companyId != null and companyId != ''">
+                and b.company_id = #{companyId}
+            </if>
             <if test="level != null and level != ''">
                 and b.level = #{level}
             </if>
@@ -300,6 +303,9 @@
             <if test="mountainId != null and mountainId != ''">
                 and a.mountain_id = #{mountainId}
             </if>
+            <if test=" companyId != null and companyId != ''">
+                and a.company_id = #{companyId}
+            </if>
             <if test="projectId != null and projectId != ''">
                 and a.project_id = #{projectId}
             </if>
@@ -329,6 +335,9 @@
             <if test="mountainId != null and mountainId != ''">
                 and a.mountain_id = #{mountainId}
             </if>
+            <if test="companyId != null and companyId != ''">
+                and a.company_id = #{companyId}
+            </if>
             <if test="projectId != null and projectId != ''">
                 and a.project_id = #{projectId}
             </if>
@@ -357,6 +366,9 @@
             <if test="level != null and level != ''">
                 and a.level = #{level}
             </if>
+            <if test="companyId != null">
+                and a.company_id = #{companyId}
+            </if>
         </where>
         GROUP BY a.project_id
     </select>