Kaynağa Gözat

Merge branch 'V0.0.2' of http://10.87.10.227:4000/jzyd_yyds/soc into V0.0.2

jiawuxian 2 yıl önce
ebeveyn
işleme
12f4619595

+ 6 - 0
project_data/sql/0.0.2/soc/soc.sql

@@ -133,6 +133,12 @@ BEGIN
         ALTER TABLE `sync_fjnx_org_business_relation`
             ADD COLUMN `tree_show_parent_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '机构树上显示的父级编码' AFTER `business_parent_code`;
     END IF;
+ IF  EXISTS( SELECT *
+      FROM INFORMATION_SCHEMA.COLUMNS
+      WHERE TABLE_NAME = 'core_protection'
+      AND COLUMN_NAME = 'device_id') THEN
+ALTER TABLE core_protection MODIFY device_id bigint
+END IF;
 
     IF NOT EXISTS(SELECT *
                   FROM information_schema.columns

+ 21 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteProtectionService.java

@@ -0,0 +1,21 @@
+package com.xunmei.system.api;
+
+import com.xunmei.common.core.constant.ServiceNameConstants;
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.system.api.dto.ProtectionDTO;
+import com.xunmei.system.api.factory.RemoteOrgFallbackFactory;
+import com.xunmei.system.api.factory.RemoteProtectionFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * @author :LuoWei
+ * @date : 2023/9/27
+ */
+
+@FeignClient(contextId = "remoteProtectionService", value = ServiceNameConstants.CORE_SERVICE, fallbackFactory = RemoteProtectionFallbackFactory.class)
+public interface RemoteProtectionService {
+    @PostMapping("/resumption/protection/addByDevice")
+    public AjaxResult addByDevice(@RequestBody ProtectionDTO editDto);
+}

+ 32 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/dto/ProtectionDTO.java

@@ -0,0 +1,32 @@
+package com.xunmei.system.api.dto;
+
+import lombok.Data;
+
+/**
+ * @author :LuoWei
+ * @date : 2023/9/27
+ */
+@Data
+public class ProtectionDTO {
+    Long id;
+
+    /**
+     * 所属机构
+     */
+    Long orgId;
+
+    String orgPath;
+
+    String orgName;
+
+    /**
+     * 防区名称
+     */
+    String name;
+
+    /**
+     * 是否24小时防区
+     */
+    Integer allHour;
+    private Long deviceId;
+}

+ 30 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteProtectionFallbackFactory.java

@@ -0,0 +1,30 @@
+package com.xunmei.system.api.factory;
+
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.RemoteProtectionService;
+import com.xunmei.system.api.dto.ProtectionDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author :LuoWei
+ * @date : 2023/9/27
+ */
+@Component
+public class RemoteProtectionFallbackFactory implements FallbackFactory<RemoteProtectionService> {
+    private static final Logger log = LoggerFactory.getLogger(RemoteProtectionFallbackFactory.class);
+    @Override
+    public RemoteProtectionService create(Throwable cause) {
+        log.error("机构服务调用失败:{}", cause.getMessage());
+        return new RemoteProtectionService(){
+
+            @Override
+            public AjaxResult addByDevice(ProtectionDTO editDto) {
+                return null;
+            }
+        };
+    }
+}

+ 9 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ProtectionController.java

@@ -1,20 +1,24 @@
 package com.xunmei.core.resumption.controller;
 
+import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.common.core.web.controller.BaseController;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.security.annotation.InnerAuth;
 import com.xunmei.common.security.annotation.RequiresPermissions;
 import com.xunmei.core.resumption.domain.Protection;
 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.service.IProtectionService;
+import com.xunmei.system.api.Eto.RoleConditionEto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  *
@@ -50,7 +54,11 @@ class ProtectionController extends BaseController {
     public AjaxResult edit(@RequestBody ProtectionEditDto editDto) {
         return success(protectionService.edit(editDto));
     }
-
+    @InnerAuth
+    @PostMapping("/addByDevice")
+    public AjaxResult addByDevice(@RequestBody ProtectionEditDto editDto) {
+        return success(protectionService.edit(editDto));
+    }
     @ApiOperation(value = "防区详情")
     @GetMapping("{id}")
     @RequiresPermissions({"device:protection:query"})

+ 23 - 3
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeviceServiceImpl.java

@@ -7,8 +7,10 @@ import com.alibaba.nacos.common.utils.CollectionUtils;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
+import com.xunmei.system.api.RemoteProtectionService;
 import com.xunmei.system.api.domain.SysDevice;
 import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.dto.ProtectionDTO;
 import com.xunmei.system.mapper.SysOrgMapper;
 import com.xunmei.system.vo.area.AccessType;
 import com.xunmei.system.vo.area.HostVO;
@@ -42,7 +44,8 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
     private ISysOrgService orgService;
     @Autowired
     private SysOrgMapper sysOrgMapper;
-
+    @Autowired
+  private RemoteProtectionService remoteProtectionService;
     @Override
     public TableDataInfo<SysDevice> selectPage(SysDevice sysDevice) {
         //未删除
@@ -131,7 +134,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
                 sysDevices.forEach(s -> {
                     VideoVO videoVO = new VideoVO();
                     videoVO.setVideoId(s.getId());
-                    videoVO.setVideoName("通道"+s.getChannel());
+                    videoVO.setVideoName(s.getDeviceName());
                     List<AccessType> accessByVideo = sysDeviceMapper.getAccessByVideo(s.getId(), taskId);
                     if (accessByVideo.size()>0) {
                         for (AccessType a:accessByVideo){
@@ -191,7 +194,17 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
         sysDevice.setCreateBy(SecurityUtils.getUsername());
         SysOrg sysOrg = orgService.selectSysOrgById(sysDevice.getOrgId());
         sysDevice.setOrgName(sysOrg.getShortName());
-        return sysDeviceMapper.insert(sysDevice);
+        int insert = sysDeviceMapper.insert(sysDevice);
+        //新增防区只有报警主机
+        if (sysDevice.getDeviceType().equals("1")){
+            ProtectionDTO protectionDTO=new ProtectionDTO();
+            protectionDTO.setName(sysDevice.getDeviceName());
+            protectionDTO.setOrgPath(sysOrg.getPath());
+            protectionDTO.setAllHour(0);
+            protectionDTO.setDeviceId(sysDevice.getId());
+            remoteProtectionService.addByDevice(protectionDTO);
+        }
+        return insert;
     }
 
     /**
@@ -206,6 +219,13 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
         sysDevice.setUpdateBy(SecurityUtils.getUsername());
         SysOrg sysOrg = orgService.selectSysOrgById(sysDevice.getOrgId());
         sysDevice.setOrgName(sysOrg.getShortName());
+        if (sysDevice.getDeviceType().equals("1")){
+            ProtectionDTO protectionDTO=new ProtectionDTO();
+            protectionDTO.setId(sysDevice.getId());
+            protectionDTO.setName(sysDevice.getDeviceName());
+            protectionDTO.setOrgPath(sysOrg.getPath());
+            remoteProtectionService.addByDevice(protectionDTO);
+        }
         return sysDeviceMapper.updateById(sysDevice);
     }