Procházet zdrojové kódy

检查要点配置数据来源 功能代码提交

jingyuanchao před 1 rokem
rodič
revize
dca880af91
14 změnil soubory, kde provedl 211 přidání a 27 odebrání
  1. 20 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteIotService.java
  2. 25 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteIotFallbackFactory.java
  3. 1 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/ServiceNameConstants.java
  4. 6 7
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/video/MediatorVideoDiagnosisRecord.java
  5. 25 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/resumption/RulePointDataSource.java
  6. 0 13
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/panel/controller/PanelController.java
  7. 35 4
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java
  8. 7 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/vo/ResumptionPlanVo.java
  9. 5 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRuleItemServiceImpl.java
  10. 3 1
      soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml
  11. 2 1
      soc-modules/soc-modules-core/src/main/resources/mapper/resumption/ResumptionMapper.xml
  12. 30 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotController.java
  13. 7 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotService.java
  14. 45 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotServiceImpl.java

+ 20 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteIotService.java

@@ -0,0 +1,20 @@
+package com.xunmei.system.api;
+
+import com.xunmei.common.core.constant.ServiceNameConstants;
+import com.xunmei.system.api.factory.RemoteIotFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+
+@FeignClient(contextId = "remoteIotService", value = ServiceNameConstants.IOT, fallbackFactory = RemoteIotFallbackFactory.class)
+public interface RemoteIotService {
+
+
+    @GetMapping("/days/{orgId}/{date}")
+    int selectVideoDayExceptionChannelNums(@PathVariable(value = "orgId") Long orgId, @PathVariable(value = "date") String date);
+
+
+    @GetMapping("/diagnosis/{orgId}/{date}")
+    int selectVideoDiagnosisExceptionChannelNums(@PathVariable(value = "orgId") Long orgId, @PathVariable(value = "date") String date);
+}

+ 25 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteIotFallbackFactory.java

@@ -0,0 +1,25 @@
+package com.xunmei.system.api.factory;
+
+import com.xunmei.system.api.RemoteIotService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * iot服务降级处理
+ *
+ * @author xunmei
+ */
+@Component
+public class RemoteIotFallbackFactory implements FallbackFactory<RemoteIotService> {
+    private static final Logger log = LoggerFactory.getLogger(RemoteIotFallbackFactory.class);
+
+
+    @Override
+    public RemoteIotService create(Throwable cause) {
+
+
+        return null;
+    }
+}

+ 1 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/ServiceNameConstants.java

@@ -27,4 +27,5 @@ public class ServiceNameConstants
     public static final String JOB_SERVICE="soc-job";
     public static final String MEDIATOR_SERVICE="soc-mediator";
     public static final String SMS="soc-sms";
+    public static final String IOT="soc-iot";
 }

+ 6 - 7
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/video/MediatorVideoDiagnosisRecord.java

@@ -1,17 +1,16 @@
 package com.xunmei.common.core.domain.video;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.xunmei.common.core.web.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.io.Serializable;
+
 /**
  * <p>
  * 
@@ -102,11 +101,11 @@ public class MediatorVideoDiagnosisRecord extends BaseEntity implements Serializ
     @TableField("alarm_time")
     private String alarmTime;
 
-    @ApiModelProperty(value = "报警状态标识")
+    @ApiModelProperty(value = "报警状态标识",notes = " 0:正常 | 1:异常")
     @TableField("is_alarm")
     private Integer isAlarm;
 
-    @ApiModelProperty(value = "质量当前状态详情")
+    @ApiModelProperty(value = "质量当前状态详情",notes = " 0: 正常 | 1:异常")
     @TableField("detail_info")
     private String detailInfo;
 

+ 25 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/resumption/RulePointDataSource.java

@@ -0,0 +1,25 @@
+package com.xunmei.common.core.enums.resumption;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public enum RulePointDataSource {
+
+    PROTECTION(1,"防区"),
+    VIDEO_DAYS(2,"录像缺失诊断"),
+    VIDEO_DIAGNOSIS(3,"录像质量诊断"),
+
+
+    ;
+
+    private Integer code;
+
+
+    private String desc;
+
+}

+ 0 - 13
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/panel/controller/PanelController.java

@@ -1,13 +1,7 @@
 package com.xunmei.core.panel.controller;
 
 
-import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanPageDto;
-import com.xunmei.common.core.domain.panel.vo.PanelListVo;
-import com.xunmei.common.core.domain.panel.vo.PanelResultVo;
 import com.xunmei.common.core.web.domain.AjaxResult;
-import com.xunmei.common.core.web.page.TableDataInfo;
-import com.xunmei.common.security.annotation.RequiresPermissions;
-import com.xunmei.core.edu.service.ICoreEduTrainingPlanService;
 import com.xunmei.core.panel.dto.UserUnDoTaskRequestDto;
 import com.xunmei.core.panel.service.PanelService;
 import io.swagger.annotations.Api;
@@ -48,9 +42,6 @@ public class PanelController {
         return AjaxResult.success(panelService.selectUserUnDoList(requestDtoList));
     }
 
-    /**
-     * App面板接口
-     */
     @ApiOperation(value = "Web面板接口")
     //@RequiresPermissions("core:panel:list")
     @GetMapping("/data")
@@ -58,10 +49,6 @@ public class PanelController {
         return AjaxResult.success(panelService.selectWebData());
     }
 
-
-    /**
-     * App面板接口
-     */
     @ApiOperation(value = "Web面板接口")
     //@RequiresPermissions("core:panel:list")
     @GetMapping("/other")

+ 35 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.enums.resumption.RulePointDataSource;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.utils.DateHelper;
 import com.xunmei.common.security.utils.SecurityUtils;
@@ -18,8 +19,12 @@ import com.xunmei.core.question.service.IQuestionService;
 import com.xunmei.core.resumption.domain.*;
 import com.xunmei.core.resumption.enums.ResumptionStatus;
 import com.xunmei.core.resumption.gx.vo.*;
-import com.xunmei.core.resumption.mapper.*;
+import com.xunmei.core.resumption.mapper.AppPlanMapper;
+import com.xunmei.core.resumption.mapper.AppResumptionDataNfcMapper;
+import com.xunmei.core.resumption.mapper.AppResumptionDataRemarkimgMapper;
+import com.xunmei.core.resumption.mapper.ResumptionMapper;
 import com.xunmei.core.resumption.service.AppPlanService;
+import com.xunmei.system.api.RemoteIotService;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.TransactionSynchronization;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -44,7 +50,7 @@ public class ResumptionServiceImpl implements ResumptionService {
     private AppResumptionDataRemarkimgMapper appResumptionDataRemarkimgMapper;
 
     @Autowired
-    private AppResumptionDataMapper appResumptionDataMapper;
+    private RemoteIotService remoteIotService;
 
     @Autowired
     private AppResumptionDataNfcMapper appResumptionDataNfcMapper;
@@ -405,7 +411,7 @@ public class ResumptionServiceImpl implements ResumptionService {
         //区域数据
         Map<Long, AreaResumptionVo> map = new HashMap<>();
 
-        dealData(resumptionPlanVos, imgMap, itemMap, itComMap, map, taskVo, isExist);
+        dealData(resumptionPlanVos, imgMap, itemMap, itComMap, map, taskVo, isExist,resumption.getOrgId());
 
 
         int yesNFC = 0;
@@ -496,7 +502,8 @@ public class ResumptionServiceImpl implements ResumptionService {
                           Map<Long, Map<String, Integer>> itComMap,
                           Map<Long, AreaResumptionVo> map,
                           ResumptionTaskDetailVo taskVo,
-                          boolean isExist) {
+                          boolean isExist,
+                          Long orgId) {
 
         Integer noPointNum = 0;
         Integer yesPointNum = 0;
@@ -551,6 +558,10 @@ public class ResumptionServiceImpl implements ResumptionService {
             }
             pointVo.setRectificationDeadline(vo.getRectificationDeadline());
             pointVo.setDataStatus(vo.getDataStatus());
+
+            //处理设置了数据来源的检查要点
+            dealPointDataSource(vo,orgId);
+
             resumptionItemVo.getPoints().add(pointVo);
 
 
@@ -594,4 +605,24 @@ public class ResumptionServiceImpl implements ResumptionService {
         imgMap = images.stream().collect(Collectors.groupingBy(AppResumptionDataRemarkimg::getResumptionDataId));
         return imgMap;
     }
+
+    private void dealPointDataSource(ResumptionPlanVo vo,Long orgId){
+        Integer pointDataSource = vo.getPointDataSource();
+        if (ObjectUtil.isNull(pointDataSource)){
+            return;
+        }
+
+        if (RulePointDataSource.VIDEO_DAYS.getCode().equals(pointDataSource)){
+            String yesterDay = LocalDate.now().plusDays(-1).toString();
+           int nums = remoteIotService.selectVideoDayExceptionChannelNums(orgId,yesterDay);
+            vo.setExceptionChannelNum(nums);
+        }
+
+        if (RulePointDataSource.VIDEO_DIAGNOSIS.getCode().equals(pointDataSource)){
+            String today = LocalDate.now().toString();
+            int nums = remoteIotService.selectVideoDiagnosisExceptionChannelNums(orgId,today);
+            vo.setExceptionChannelNum(nums);
+        }
+
+    }
 }

+ 7 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/vo/ResumptionPlanVo.java

@@ -4,6 +4,7 @@ package com.xunmei.core.resumption.gx.vo;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.xunmei.core.resumption.domain.AppResumptionDataRemarkimg;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -48,6 +49,12 @@ public class ResumptionPlanVo {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long pointId;
 
+    @ApiModelProperty(value = "数据来源",notes = "0:防区,1:录像天数,2:视频质量")
+    private Integer pointDataSource;
+
+    @ApiModelProperty(value = "异常通道数")
+    private Integer exceptionChannelNum;
+
     /**
      * 是否扫描NFC 1扫描,0不扫描
      */

+ 5 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRuleItemServiceImpl.java

@@ -120,12 +120,14 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
             if (point.getId() == null) {
                 //新增
                 point.setId(IDHelper.id());
-
+                point.setCreateTime(new Date());
+                point.setUpdateTime(new Date());
                 appRulePointService.save(point);
             } else {
                 //修改
                 Integer isUsed = appRulePointMapper.checkIsUsed(point.getId());
                 if (isUsed == null) {
+                    point.setUpdateTime(new Date());
                     appRulePointService.updateById(point);
                 } else {
                     //将之前的记录逻辑删除,然后新增一条记录关联到检查项
@@ -133,6 +135,8 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
                     Long newId = IDHelper.id();
                     appRulePointMapper.updatePlanItem(point.getId(), newId);
                     point.setId(newId);
+                    point.setCreateTime(new Date());
+                    point.setUpdateTime(new Date());
                     appRulePointMapper.insert(point);
 
                 }

+ 3 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml

@@ -416,11 +416,13 @@
                q.check_id,
                q.plan_id,
                q.point_scan,
-               q.required
+               q.required,
+               q.business_type as pointDataSource
         from (select c.id     as item_id,
                      c.`name` as item_name,
                      b.id     as point_id,
                      b.name   as point_name,
+                     b.business_type as business_type,
                      CASE
                          WHEN b.area_id IS NULL
                              THEN d.area_id

+ 2 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/ResumptionMapper.xml

@@ -193,7 +193,8 @@
                a.rectification_deadline,
                a.data_status,
                a.point_scan,
-               a.required
+               a.required,
+               b.business_type as pointDataSource
         from (select id as data_id,
                      area_id,
                      check_id,

+ 30 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotController.java

@@ -0,0 +1,30 @@
+package com.xunmei.iot.controller;
+
+
+import com.xunmei.iot.service.IotService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 接收远程调用
+ */
+@RestController
+@RequestMapping
+public class IotController {
+
+    @Autowired
+    private IotService iotService;
+
+    @GetMapping("/days/{orgId}/{date}")
+    public int selectVideoDayExceptionChannelNums(@PathVariable Long orgId, @PathVariable String date) {
+        return iotService.selectVideoDayExceptionChannelNums(orgId,date);
+    }
+
+    @GetMapping("/diagnosis/{orgId}/{date}")
+    public int selectVideoDiagnosisExceptionChannelNums(@PathVariable Long orgId, @PathVariable String date) {
+        return iotService.selectVideoDiagnosisExceptionChannelNums(orgId,date);
+    }
+}

+ 7 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotService.java

@@ -0,0 +1,7 @@
+package com.xunmei.iot.service;
+
+public interface IotService {
+    int selectVideoDayExceptionChannelNums(Long orgId,String date);
+
+    int selectVideoDiagnosisExceptionChannelNums(Long orgId, String date);
+}

+ 45 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotServiceImpl.java

@@ -0,0 +1,45 @@
+package com.xunmei.iot.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.xunmei.common.core.domain.video.MediatorVideoDaysCheck;
+import com.xunmei.common.core.domain.video.MediatorVideoDiagnosisRecord;
+import com.xunmei.iot.mapper.VideoDaysCheckMapper;
+import com.xunmei.iot.mapper.VideoDiagnosisRecordMapper;
+import com.xunmei.iot.service.IotService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+@Service
+public class IotServiceImpl implements IotService {
+
+    @Resource
+    VideoDaysCheckMapper videoDaysCheckMapper;
+    @Resource
+    VideoDiagnosisRecordMapper diagnosisRecordMapper;
+
+    @Override
+    public int selectVideoDayExceptionChannelNums(Long orgId, String date) {
+        Date time = DateUtil.parse(date, "yyyy-MM-dd");
+        LambdaQueryWrapper<MediatorVideoDaysCheck> wrapper = new LambdaQueryWrapper<MediatorVideoDaysCheck>();
+        wrapper.eq(MediatorVideoDaysCheck::getOrgId, orgId);
+        wrapper.eq(MediatorVideoDaysCheck::getStatus, 1);
+        wrapper.ge(MediatorVideoDaysCheck::getUpdateTime, DateUtil.beginOfDay(time));
+        wrapper.le(MediatorVideoDaysCheck::getUpdateTime, DateUtil.endOfDay(time));
+        return videoDaysCheckMapper.selectCount(wrapper).intValue();
+    }
+
+
+    @Override
+    public int selectVideoDiagnosisExceptionChannelNums(Long orgId, String date) {
+        Date time = DateUtil.parse(date, "yyyy-MM-dd");
+        LambdaQueryWrapper<MediatorVideoDiagnosisRecord> wrapper = new LambdaQueryWrapper<MediatorVideoDiagnosisRecord>();
+        wrapper.eq(MediatorVideoDiagnosisRecord::getOrgId, orgId);
+        wrapper.eq(MediatorVideoDiagnosisRecord::getIsAlarm, 1);
+        wrapper.ge(MediatorVideoDiagnosisRecord::getAlarmTime, DateUtil.beginOfDay(time));
+        wrapper.le(MediatorVideoDiagnosisRecord::getAlarmTime, DateUtil.endOfDay(time));
+        return diagnosisRecordMapper.selectCount(wrapper).intValue();
+    }
+}