Procházet zdrojové kódy

布撤防跟踪功能调整

jiawuxian před 1 rokem
rodič
revize
0e0fbadaaa

+ 45 - 22
project_data/sql/0.0.6-iot/soc/soc.sql

@@ -72,35 +72,55 @@ CREATE PROCEDURE schema_change () BEGIN
 --         ALTER TABLE sys_device
 --             ADD COLUMN `channel_code`  varchar(225) NULL COMMENT '通道号' AFTER `host_code`;
 --     END IF;
-
+	IF EXISTS(SELECT *
+                  FROM information_schema.columns
+                  WHERE table_schema = DATABASE()
+                    AND table_name = 'core_protection_log') THEN
+        rename TABLE `core_protection_log` to `iot_alarm_subsystem_log`;
+    END IF;	
+	
+	IF EXISTS(SELECT *
+                  FROM information_schema.columns
+                  WHERE table_schema = DATABASE()
+                    AND table_name = 'core_protection') THEN
+        rename TABLE `core_protection` to `iot_alarm_subsystem`;
+    END IF;	
+	
     IF NOT EXISTS(SELECT *
                   FROM information_schema.columns
                   WHERE table_schema = DATABASE()
-                    AND table_name = 'core_protection'
+                    AND table_name = 'iot_alarm_subsystem'
                     AND column_name = 'status_change_time') THEN
-        ALTER TABLE `core_protection` 
+        ALTER TABLE `iot_alarm_subsystem` 
 					ADD COLUMN `status_change_time` datetime NULL COMMENT '布撤防时间' AFTER `all_Hour`,
 					ADD COLUMN `source` int NULL COMMENT '设备来源:0:设备登记;1:iot推送' AFTER `update_by`,
-					MODIFY COLUMN `status_update_time` datetime NULL DEFAULT NULL COMMENT '布撤防更新时间' AFTER `all_Hour`
-					COMMENT = '报警控制器(子系统)表';
-		
+					MODIFY COLUMN `status_update_time` datetime NULL DEFAULT NULL COMMENT '布撤防更新时间' AFTER `all_Hour`,
+					COMMENT = '报警控制器(子系统)表';		
     END IF;
 	IF NOT EXISTS(SELECT *
                   FROM information_schema.columns
                   WHERE table_schema = DATABASE()
-                    AND table_name = 'core_protection_log'
+                    AND table_name = 'iot_alarm_subsystem_log'
                     AND column_name = 'status_change_time') THEN
-        ALTER TABLE `core_protection_log` 
-					ADD COLUMN `status_change_time` datetime NULL COMMENT '布撤防时间' AFTER `all_Hour`,
-					MODIFY COLUMN `status_update_time` datetime NULL DEFAULT NULL COMMENT '布撤防更新时间' AFTER `all_Hour`
-					COMMENT = '报警控制器(子系统)布撤防历史表';
-		
+        ALTER TABLE `iot_alarm_subsystem_log` 
+					ADD COLUMN `status_change_time` datetime NULL COMMENT '布撤防时间' AFTER `status_update_time`,
+					MODIFY COLUMN `status_update_time` datetime NULL DEFAULT NULL COMMENT '布撤防更新时间',
+					COMMENT = '报警控制器(子系统)布撤防历史表';		
     END IF;	
+	
+	
 END ??
 DELIMITER ;
 CALL schema_change ();
 
 
+ALTER TABLE `iot_alarm_subsystem_log` 
+MODIFY COLUMN `status` int NULL DEFAULT NULL COMMENT '布防状态,0:撤防,1:布防,2:未知(未登记过或离线)' AFTER `name`;
+ALTER TABLE `iot_alarm_subsystem` 
+MODIFY COLUMN `status` int NULL DEFAULT NULL COMMENT '布防状态,0:撤防,1:布防,2:未知(未登记过或离线)' AFTER `name`;
+update iot_alarm_subsystem set `status`=2 WHERE status is null;
+update iot_alarm_subsystem_log set `status`=2 WHERE status is null;
+
 
 drop table if exists mediator_video_days_check;
 CREATE TABLE `mediator_video_days_check` (
@@ -765,13 +785,16 @@ CREATE TABLE `mediator_network_device_detection_log` (
 
 DELETE FROM `sys_dict_type` WHERE `dict_type` in('video_integrity_state','video_days_state','video_diagnosis_state');
 DELETE FROM `sys_dict_data` WHERE `dict_type` in('video_integrity_state','video_days_state','video_diagnosis_state');
-INSERT INTO `sys_dict_type` (`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231113187, '录像完整性状态', 'video_integrity_state', '0', '超级管理员', '2024-02-22 18:00:41', '', NULL, NULL);
-INSERT INTO `sys_dict_type` (`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231113189, '录像存储天数状态', 'video_days_state', '0', '超级管理员', '2024-02-22 18:02:56', '', NULL, NULL);
-INSERT INTO `sys_dict_type` (`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231113191, '视频诊断结果', 'video_diagnosis_state', '0', '超级管理员', '2024-02-22 18:04:19', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115055, 0, '完整', '0', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:01:50', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115057, 1, '部分丢失', '1', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:02:01', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115059, 2, '部分丢失', '2', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:02:08', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115061, 0, '未报警', '0', 'video_days_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:03:41', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115063, 1, '报警', '1', 'video_days_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:03:48', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115065, 0, '正常', '0', 'video_diagnosis_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:04:49', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115067, 1, '异常', '1', 'video_diagnosis_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:04:57', '', NULL, NULL);
+INSERT INTO `sys_dict_type` ( `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( '录像完整性状态', 'video_integrity_state', '0', '超级管理员', '2024-02-22 18:00:41', '', NULL, NULL);
+INSERT INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( '录像存储天数状态', 'video_days_state', '0', '超级管理员', '2024-02-22 18:02:56', '', NULL, NULL);
+INSERT INTO `sys_dict_type` ( `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('视频诊断结果', 'video_diagnosis_state', '0', '超级管理员', '2024-02-22 18:04:19', '', NULL, NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 0, '完整', '0', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:01:50', '', NULL, NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '部分丢失', '1', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:02:01', '', NULL, NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 2, '部分丢失', '2', 'video_integrity_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:02:08', '', NULL, NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 0, '未报警', '0', 'video_days_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:03:41', '', NULL, NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '报警', '1', 'video_days_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:03:48', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 0, '正常', '0', 'video_diagnosis_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:04:49', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '异常', '1', 'video_diagnosis_state', NULL, 'default', 'N', '0', '超级管理员', '2024-02-22 18:04:57', '', NULL, NULL);
+
+
+update sys_menu set component ='iot/subSystem/index',parent_id=1747911340288892930 WHERE menu_name='布撤防情况跟踪' and platform_type=1;

+ 1 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotAlarmSubsystemLog.java

@@ -48,7 +48,7 @@ public class IotAlarmSubsystemLog implements Serializable {
 
     @ApiModelProperty(value = "布防状态,0:撤防,1:布防")
     @TableField("status")
-    private String status;
+    private Integer status;
 
     @ApiModelProperty(value = "布撤防时间")
     @TableField("status_change_time")

+ 4 - 3
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ProtectionStatusController.java

@@ -7,6 +7,7 @@ import com.xunmei.common.security.annotation.RequiresPermissions;
 import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
 import com.xunmei.core.resumption.dto.protection.ProtectionLogPageDto;
 import com.xunmei.core.resumption.dto.protection.ProtectionPageDto;
+import com.xunmei.core.resumption.dto.protection.SubSystemStateUpdateDto;
 import com.xunmei.core.resumption.service.IProtectionService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -52,9 +53,9 @@ class ProtectionStatusController extends BaseController {
     }
 
     @ApiOperation(value = "布撤防")
-    @PostMapping("updatestatus/{protectionId}/{status}")
+    @PostMapping("updatestatus")
     @RequiresPermissions({"device:protectionstatus:maintain",})
-    public AjaxResult updateStatus(@PathVariable Long protectionId,@PathVariable String status) {
-        return success(protectionService.updateStatus(protectionId,status));
+    public AjaxResult updateStatus(@RequestBody SubSystemStateUpdateDto updateDto) {
+        return success(protectionService.updateStatus(updateDto));
     }
 }

+ 17 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/dto/protection/SubSystemStateUpdateDto.java

@@ -0,0 +1,17 @@
+package com.xunmei.core.resumption.dto.protection;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Data
+public class SubSystemStateUpdateDto {
+    private Long id;
+
+    private Integer state;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime changeTime;
+}

+ 2 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/IProtectionService.java

@@ -8,6 +8,7 @@ import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
 import com.xunmei.core.resumption.dto.protection.ProtectionEditDto;
 import com.xunmei.core.resumption.dto.protection.ProtectionLogPageDto;
 import com.xunmei.core.resumption.dto.protection.ProtectionPageDto;
+import com.xunmei.core.resumption.dto.protection.SubSystemStateUpdateDto;
 import com.xunmei.system.api.vo.ProtectionVO;
 
 import javax.servlet.http.HttpServletResponse;
@@ -41,7 +42,7 @@ public interface IProtectionService extends IService<IotAlarmSubsystem> {
 
     TableDataInfo history(ProtectionLogPageDto request);
 
-    LocalDateTime updateStatus(Long protectionId, String status);
+    LocalDateTime updateStatus(SubSystemStateUpdateDto updateDto);
 
     List<IotAlarmSubsystem> findNotAllHour(Long orgId);
 

+ 11 - 7
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/ProtectionServiceImpl.java

@@ -22,6 +22,7 @@ import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystemLog;
 import com.xunmei.core.resumption.dto.protection.ProtectionEditDto;
 import com.xunmei.core.resumption.dto.protection.ProtectionLogPageDto;
 import com.xunmei.core.resumption.dto.protection.ProtectionPageDto;
+import com.xunmei.core.resumption.dto.protection.SubSystemStateUpdateDto;
 import com.xunmei.core.resumption.mapper.ProtectionLogMapper;
 import com.xunmei.core.resumption.mapper.ProtectionMapper;
 import com.xunmei.core.resumption.service.IProtectionService;
@@ -29,6 +30,7 @@ import com.xunmei.core.resumption.vo.protection.ProtectionLogPageVo;
 import com.xunmei.core.resumption.vo.protection.ProtectionPageVo;
 import com.xunmei.system.api.RemoteDictDataService;
 import com.xunmei.system.api.domain.SysDictData;
+import com.xunmei.system.api.enums.ProtectionStatus;
 import com.xunmei.system.api.vo.ProtectionVO;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -112,7 +114,7 @@ public class ProtectionServiceImpl extends ServiceImpl<ProtectionMapper, IotAlar
             updateById(protection);
         } else {
             BeanUtil.copyProperties(dto, protection);
-            protection.setStatus(2);
+            protection.setStatus(ProtectionStatus.UNKNOWN.ordinal());
             save(protection);
         }
 
@@ -170,22 +172,24 @@ public class ProtectionServiceImpl extends ServiceImpl<ProtectionMapper, IotAlar
 
     @Override
     @Transactional
-    public LocalDateTime updateStatus(Long protectionId, String status) {
+    public LocalDateTime updateStatus(SubSystemStateUpdateDto updateDto) {
         LocalDateTime now = LocalDateTime.now();
         int count = baseMapper.update(null, new LambdaUpdateWrapper<IotAlarmSubsystem>()
-                .eq(IotAlarmSubsystem::getId, protectionId)
-                .set(IotAlarmSubsystem::getStatus, status)
+                .eq(IotAlarmSubsystem::getId, updateDto.getId())
+                .set(IotAlarmSubsystem::getStatus, updateDto.getState())
+                        .set(IotAlarmSubsystem::getStatusChangeTime,updateDto.getChangeTime())
                 .set(IotAlarmSubsystem::getStatusUpdateTime, now)
                 .set(IotAlarmSubsystem::getStatusUpdatorId, SecurityUtils.getUserId())
                 .set(IotAlarmSubsystem::getStatusUpdatorName, SecurityUtils.getLoginUser().getName()));
         if (count > 0) {
-            IotAlarmSubsystem p = getById(protectionId);
+            IotAlarmSubsystem p = getById(updateDto.getId());
             IotAlarmSubsystemLog log = new IotAlarmSubsystemLog();
             BeanUtil.copyProperties(p, log);
             log.setId(null);
-            log.setProtectionId(protectionId);
-            log.setStatus(status);
+            log.setProtectionId(updateDto.getId());
+            log.setStatus(updateDto.getState());
             log.setStatusUpdateTime(now);
+            log.setStatusChangeTime(updateDto.getChangeTime());
             log.setStatusUpdatorId(SecurityUtils.getLoginUser().getUserid());
             log.setStatusUpdatorName(SecurityUtils.getLoginUser().getName());
             protectionLogMapper.insert(log);

+ 17 - 9
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/protection/ProtectionPageVo.java

@@ -18,7 +18,7 @@ import java.util.Date;
 @AllArgsConstructor
 @NoArgsConstructor
 public class ProtectionPageVo {
-    @ExcelProperty(value = "序号",index = 0)
+    @ExcelProperty(value = "序号", index = 0)
     @ColumnWidth(10)
     @JsonIgnore
     private int index;
@@ -33,22 +33,22 @@ public class ProtectionPageVo {
     private String orgId;
 
     @ApiModelProperty("地区")
-    @ExcelProperty(value="地区",index = 1)
+    @ExcelProperty(value = "地区", index = 1)
     @ColumnWidth(20)
     private String affiliatedArea;
 
     @ApiModelProperty("行社名称")
-    @ExcelProperty(value="行社名称",index = 2)
+    @ExcelProperty(value = "行社名称", index = 2)
     @ColumnWidth(20)
     private String affiliatedBank;
 
     @ApiModelProperty("机构名称")
-    @ExcelProperty(value = "所属机构",index = 3)
+    @ExcelProperty(value = "所属机构", index = 3)
     @ColumnWidth(20)
     private String orgName;
 
     @ApiModelProperty("防区的名称")
-    @ExcelProperty(value = "报警控制器名称",index = 4)
+    @ExcelProperty(value = "报警控制器名称", index = 4)
     @ColumnWidth(20)
     private String name;
 
@@ -57,7 +57,7 @@ public class ProtectionPageVo {
     private String status;
 
     @ApiModelProperty("防区状态")
-    @ExcelProperty(value = "报警控制器状态",index = 5)
+    @ExcelProperty(value = "报警控制器状态", index = 5)
     @ColumnWidth(20)
     private String statusText;
 
@@ -72,7 +72,7 @@ public class ProtectionPageVo {
     /**
      * 登记人姓名
      */
-    @ExcelProperty(value = "登记人",index = 6)
+    @ExcelProperty(value = "登记人/数据来源", index = 6)
     @ColumnWidth(15)
     private String statusUpdatorName;
 
@@ -80,9 +80,17 @@ public class ProtectionPageVo {
      * 布撤防时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
-    @ExcelProperty(value = "最近登记时间",index = 7)
+    @ExcelProperty(value = "最近登记时间", index = 7)
     @ColumnWidth(20)
-    private  Date statusUpdateTime;
+    private Date statusUpdateTime;
+
+    /**
+     * 布撤防时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @ExcelProperty(value = "布撤防时间", index = 8)
+    @ColumnWidth(20)
+    private Date statusChangeTime;
 }
 
 

+ 1 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/device/ProtectionMapper.xml

@@ -22,6 +22,7 @@
         a.all_hour as allHour,
         a.status_update_time as statusUpdateTime,
         a.status_updator_name as statusUpdatorName,
+        a.status_change_time as statusChangeTime,
         c.affiliated_area ,
         c.affiliated_bank
         from iot_alarm_subsystem a

+ 1 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeviceServiceImpl.java

@@ -247,6 +247,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
             protectionDTO.setDeviceId(sysDevice.getId());
             protectionDTO.setOrgId(sysOrg.getId());
             protectionDTO.setOrgName(sysOrg.getShortName());
+
             remoteProtectionService.addByDevice(protectionDTO, SecurityConstants.INNER);
         }
         return insert;