From 4f6565cb9cca05981abdeb85dfc023a28c892e42 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 05 十一月 2025 16:42:45 +0800
Subject: [PATCH] 钥匙柜信息处理

---
 server/system_service/src/main/java/com/doumee/core/utils/Constants.java                                       |   17 ++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/WarningServiceImpl.java           |   71 ++++++++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/ext/HkSyncService.java                 |    4 
 server/visits/admin_timer/src/main/resources/bootstrap.yml                                                     |    2 
 server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java                     |    4 
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetLogServiceImpl.java      |  116 +++++++-------
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java |  209 +++++++++++++++++++++-----
 server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java                  |   33 +++
 server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java                    |   10 +
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java |    7 
 server/system_timer/src/main/resources/bootstrap.yml                                                           |    2 
 11 files changed, 363 insertions(+), 112 deletions(-)

diff --git a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
index f6daf8d..ce60ff7 100644
--- a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1526,6 +1526,13 @@
         ALARM_TEST(10002, "銆愰挜鍖欐煖銆戦厭绮炬祴璇曞紓甯�",0),
         GRID_TIME_OUT_INFO(10003, "銆愰挜鍖欐煖銆戝紑闂ㄨ秴鏃舵湭鍏抽棴",0),
         KEY_TIME_OUT_BACK(10004, "銆愰挜鍖欐煖銆戦挜鍖欒秴鏃舵湭褰掕繕",0),
+        AF_QYRQ(131588, "銆愬畨闃蹭簨浠躲�戝尯鍩熷叆渚�",1),
+        AF_QUPD(131592, "銆愬畨闃蹭簨浠躲�戝尯鍩熻窇鍔�",1),
+        AF_RYLG(131603, "銆愬畨闃蹭簨浠躲�戜汉鍛樼宀�",1),
+        AF_KYSCX(131585, "銆愬畨闃蹭簨浠躲�戣法瓒婄敓浜х嚎",1),
+        XF_SYBJ(253956, "銆愭秷闃蹭簨浠躲�戞按鍘嬫姤璀�",1),
+        XF_HZBJ(253999, "銆愭秷闃蹭簨浠躲�戠伀鐏炬姤璀�",1),
+        XF_YWBJ(254047, "銆愭秷闃蹭簨浠躲�戞恫浣嶆姤璀�",1),
         ;
         // 鎴愬憳鍙橀噺
         private int key;
@@ -1540,6 +1547,16 @@
         }
 
 
+        public static WarningConfig getConfig(int index) {
+            for (WarningConfig c : WarningConfig.values()) {
+                if (c.getKey() == index) {
+                    return c;
+                }
+            }
+            return null;
+        }
+
+
         public int getKey() {
             return key;
         }
diff --git a/server/system_timer/src/main/resources/bootstrap.yml b/server/system_timer/src/main/resources/bootstrap.yml
index 05a83ce..5eb6d62 100644
--- a/server/system_timer/src/main/resources/bootstrap.yml
+++ b/server/system_timer/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: pro
+    active: test
   application:
     name: systemTimer
     # 瀹夊叏閰嶇疆
diff --git a/server/visits/admin_timer/src/main/resources/bootstrap.yml b/server/visits/admin_timer/src/main/resources/bootstrap.yml
index b5b65b7..fb74d1e 100644
--- a/server/visits/admin_timer/src/main/resources/bootstrap.yml
+++ b/server/visits/admin_timer/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: pro
+    active: test
   application:
     name: visitsTimer
     # 瀹夊叏閰嶇疆
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
index 5d1cdd4..1d9c9fd 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
@@ -11,6 +11,7 @@
 import com.doumee.core.haikang.model.param.BaseResponse;
 import com.doumee.core.haikang.model.param.request.*;
 import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest;
+import com.doumee.core.haikang.model.param.request.event.base.EventBaseRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.EventParkRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.EventPlatformCarsRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.EventPlatformRequest;
@@ -19,6 +20,7 @@
 import com.doumee.core.haikang.model.param.respose.PageRegionInfoResponse;
 import com.doumee.core.haikang.service.HKService;
 import com.doumee.dao.web.response.platformReport.CarmeraListVO;
+import com.doumee.service.business.impl.JkCabinetGridServiceImpl;
 import com.doumee.service.business.third.BoardService;
 import com.doumee.service.business.third.model.ApiResponse;
 import com.doumee.service.business.third.model.LoginUserInfo;
@@ -78,6 +80,8 @@
     @Autowired
     private DeviceService deviceService;
 
+    @Autowired
+    private JkCabinetGridServiceImpl impl;
     @Autowired
     private RedisTemplate<String,Object> redisTemplate;
 
@@ -172,14 +176,16 @@
         String result = hkSyncPushService.dealVisitEvent(param,response);
         return ApiResponse.success(result);
     }
+
     @ApiOperation("銆愭捣搴枫�戝叾浠栬闃呬簨浠惰闃呮帹閫佸鎺ュ鐞嗘帴鍙�")
     @PostMapping("/push/notice")
     @LoginNoRequired
-    public ApiResponse pushNotice(@RequestBody EventVisitRequest param, HttpServletResponse response){
-        String result = hkSyncPushService.dealVisitEvent(param,response);
+    public ApiResponse pushNotice(@RequestBody EventBaseRequest param, HttpServletResponse response){
+        String result = hkSyncPushService.dealSecurityEvent(param,response,impl);
 
         return ApiResponse.success(result);
     }
+
     @ApiOperation("銆愭捣搴枫�戣瀹CCM浜嬩欢璁㈤槄鎺ㄩ�佸鎺ュ鐞嗘帴鍙�")
     @PostMapping("/push/visitIccm")
     @LoginNoRequired
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
index 0a46fbe..748fa8d 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
@@ -1,5 +1,6 @@
 package com.doumee.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.haikang.model.HKConstants;
 import com.doumee.core.haikang.model.HKTools;
@@ -8,9 +9,12 @@
 import com.doumee.core.haikang.model.param.respose.OrgInfoResponse;
 import com.doumee.core.haikang.service.HKService;
 import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.WarningMapper;
+import com.doumee.dao.business.model.Warning;
 import com.doumee.dao.system.model.SystemDictData;
 import com.doumee.service.business.InterfaceLogService;
 import com.doumee.service.business.impl.hksync.HkSyncBaseServiceImpl;
+import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
 import com.hikvision.artemis.sdk.config.ArtemisConfig;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +22,8 @@
 
 import javax.annotation.PostConstruct;
 import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 娴峰悍浜嬩欢璁㈤槄琛⊿ervice瀹炵幇
@@ -31,6 +37,8 @@
     private SystemDictDataBiz systemDictDataBiz;
     @Autowired
     private InterfaceLogService interfaceLogService;
+    @Autowired
+    private WarningMapper warningMapper;
 
     @PostConstruct
     public  int  initHkConfig(){
@@ -111,11 +119,28 @@
         HKService.cancelEventSub(param);//鍏堝彇娑�
 //        HKService.eventSub(param);//鏈堝彴宸ヤ綔鐘舵�佷簨浠�
 
+        try{
+            List<Warning> warningList = warningMapper.selectList(new QueryWrapper<Warning>().lambda()
+                    .eq(Warning::getIsdeleted,Constants.ZERO)
+                    .eq(Warning::getStatus,Constants.ONE)
+                    .in(Warning::getType,Constants.ZERO,Constants.ONE)
+                    .isNotNull(Warning::getCode)
+            );
+            if(CollectionUtils.isNotEmpty(warningList)){
+                List<String> codeList = warningList.stream().map(i->i.getCode()).collect(Collectors.toList());
+                if(CollectionUtils.isNotEmpty(codeList)){
+                    param.setEventDest(path+"/notice");
+                    param.setEventTypes(codeList.stream().map(i->Integer.valueOf(i)).toArray(Integer[]::new));
+                    HKService.cancelEventSub(param);//鍏堝彇娑�
+                    HKService.eventSub(param);//瀹夐槻浜嬩欢
+                }
+            }
+        }catch (Exception e){
 
-        param.setEventDest(path+"/platform/carstatus");
-        param.setEventTypes(new Integer[]{HKConstants.EventTypes.PLATFORM_CAR_STATUS.getKey()});
-        HKService.cancelEventSub(param);//鍏堝彇娑�
-        HKService.eventSub(param);//鏈堝彴杞﹁締鐘舵�佷簨浠�
+        }
+
+
+
 
     }
     /**
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
index 8bc7655..78ab9c1 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
@@ -611,7 +611,9 @@
         DOOR_FACE_AUTH_FAIL(197163, "浜鸿劯璁よ瘉澶辫触"  ),
         DOOR_FACE_AUTH_SUCCESS(196893, "浜鸿劯璁よ瘉閫氳繃"  ),
         PLATFORM_WORKSTATUS(483329, "鏈堝彴宸ヤ綔鐘舵�佷簨浠�"  ),
-        PLATFORM_CAR_STATUS(487425, "鏈堝彴杞﹁締鐘舵�佷簨浠�"  )
+        PLATFORM_CAR_STATUS(487425, "鏈堝彴杞﹁締鐘舵�佷簨浠�"  ),
+        //todo 鏆傛湭鎻愪緵
+        SECURITY_STATUS(111111, "瀹夐槻浜嬩欢"  )
 
         ;
         // 鎴愬憳鍙橀噺
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/ext/HkSyncService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/ext/HkSyncService.java
index abed35f..c30d332 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/ext/HkSyncService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/ext/HkSyncService.java
@@ -2,9 +2,11 @@
 
 import com.doumee.core.haikang.model.param.request.*;
 import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest;
+import com.doumee.core.haikang.model.param.request.event.base.EventBaseRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.*;
 import com.doumee.core.haikang.model.param.request.event.visit.EventVisitIccmRequest;
 import com.doumee.core.haikang.model.param.request.event.visit.EventVisitRequest;
+import com.doumee.service.business.impl.JkCabinetGridServiceImpl;
 import com.doumee.service.business.third.model.LoginUserInfo;
 import com.doumee.dao.business.model.Device;
 import com.doumee.dao.business.model.ParkBook;
@@ -53,6 +55,8 @@
 
     String dealVisitEvent(EventVisitRequest param, HttpServletResponse response);
 
+    String dealSecurityEvent(EventBaseRequest param, HttpServletResponse response, JkCabinetGridServiceImpl impl);
+
     String dealParkEvent(EventParkRequest param, HttpServletResponse response);
     String downHKImgs(int type);
     void startDealPlatformEventImg();
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetLogServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetLogServiceImpl.java
index 56eae5b..2f683d5 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetLogServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetLogServiceImpl.java
@@ -216,70 +216,68 @@
                 .orderByDesc(JkCabinetLog::getCreateDate);
         List<JkCabinetLog> jkCabinetLogs = jkCabinetLogMapper.selectJoinList(JkCabinetLog.class,wrapper);
         if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(jkCabinetLogs)){
+
             List<Integer> ruleIdList =  impl.processWarnFront(warningConfig);
-            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ruleIdList)){
-                return;
-            }
-            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ruleIdList)){
-                return;
-            }
-            for (Integer ruleId:ruleIdList) {
-                WarningRule warningRule = warningRuleMapper.selectById(ruleId);
-                if (Objects.isNull(warningRule)) {
-                    continue;
-                }
-                List<Member> memberList = impl.getWarningRuleMemberList(warningRule);
-                if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(memberList)) {
-                    return;
-                }
-                for (JkCabinetLog jkCabinetLog:jkCabinetLogs) {
 
-                    String content = "銆愯溅杈�-"+jkCabinetLog.getCarCode()+"閽ュ寵銆戠敱+"+(StringUtils.isNotBlank(jkCabinetLog.getMemberName())?jkCabinetLog.getMemberName():"鏈煡浜哄憳")+"鍊熷嚭锛岃秴鏃舵湭褰掕繕";
+            for (JkCabinetLog jkCabinetLog:jkCabinetLogs) {
+                String content = "銆愯溅杈�-"+jkCabinetLog.getCarCode()+"閽ュ寵銆戠敱+"+(StringUtils.isNotBlank(jkCabinetLog.getMemberName())?jkCabinetLog.getMemberName():"鏈煡浜哄憳")+"鍊熷嚭锛岃秴鏃舵湭褰掕繕";
+                //瀛樺偍鎶ヨ寮傚父璁板綍
+                WarningEvent warningEvent = new WarningEvent();
+                warningEvent.setCreateDate(new Date());
+                warningEvent.setWarningId(warning.getId());
+                warningEvent.setTitle(warningConfig.getInfo());
+                warningEvent.setContent(content );
+                warningEvent.setStatus(Constants.ZERO);
+                warningEvent.setRegion( StringUtils.isNotBlank(jkCabinetLog.getLocation())?jkCabinetLog.getLocation():"鏈煡浣嶇疆");
+                warningEventMapper.insert(warningEvent);
+                Boolean falg = false;
+                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ruleIdList)){
+                    for (Integer ruleId:ruleIdList) {
+                        WarningRule warningRule = warningRuleMapper.selectById(ruleId);
+                        if (Objects.isNull(warningRule)) {
+                            continue;
+                        }
+                        List<Member> memberList = impl.getWarningRuleMemberList(warningRule);
+                        if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(memberList)) {
+                            continue;
+                        }
+                        try {
+                            WarningPush warningPush = new WarningPush();
+                            warningPush.setCreateDate(new Date());
+                            warningPush.setIsdeleted(Constants.ZERO);
+                            warningPush.setWarningId(warning.getId());
+                            warningPush.setTitle(warningConfig.getInfo());
 
-                    //瀛樺偍鎶ヨ寮傚父璁板綍
-                    WarningEvent warningEvent = new WarningEvent();
-                    warningEvent.setCreateDate(new Date());
-                    warningEvent.setWarningId(warning.getId());
-                    warningEvent.setTitle(warningConfig.getInfo());
-                    warningEvent.setContent(content );
-                    warningEvent.setStatus(Constants.ZERO);
-                    warningEvent.setRegion( StringUtils.isNotBlank(jkCabinetLog.getLocation())?jkCabinetLog.getLocation():"鏈煡浣嶇疆");
-                    warningEventMapper.insert(warningEvent);
-
-
-                    try {
-                        WarningPush warningPush = new WarningPush();
-                        warningPush.setCreateDate(new Date());
-                        warningPush.setIsdeleted(Constants.ZERO);
-                        warningPush.setWarningId(warning.getId());
-                        warningPush.setTitle(warningConfig.getInfo());
-
-                        warningPush.setContent(content);
-                        warningPush.setStatus(Constants.ZERO);
-                        warningPush.setPushType(Constants.ZERO);
-                        warningPush.setRegion(StringUtils.isNotBlank(jkCabinetLog.getLocation()) ? jkCabinetLog.getLocation() : "鏈煡浣嶇疆");
-                        warningPush.setMemberIds(
-                                StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
-                        );
-                        warningPush.setMemberIds(
-                                StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
-                        );
-                        warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i -> i.getName()).collect(Collectors.toList()), ",")
-                        );
-                        //todo 鏆傛椂鍏抽棴 閽夐拤閫氱煡
-
-                        //            Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()),
-                        //                    StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","),
-                        //                dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content));
-                        //            warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO);
-                        warningPushMapper.insert(warningPush);
-                        warningEvent.setStatus(Constants.ONE);
-                        warningEventMapper.updateById(warningEvent);
-                    }catch (Exception e){
-                        warningEvent.setStatus(Constants.TWO);
-                        warningEventMapper.updateById(warningEvent);
+                            warningPush.setContent(content);
+                            warningPush.setStatus(Constants.ZERO);
+                            warningPush.setPushType(Constants.ZERO);
+                            warningPush.setRegion(StringUtils.isNotBlank(jkCabinetLog.getLocation()) ? jkCabinetLog.getLocation() : "鏈煡浣嶇疆");
+                            warningPush.setMemberIds(
+                                    StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
+                            );
+                            warningPush.setMemberIds(
+                                    StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
+                            );
+                            warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i -> i.getName()).collect(Collectors.toList()), ",")
+                            );
+                            // todo 鏆傛椂鍏抽棴 閽夐拤閫氱煡
+                            //            Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()),
+                            //                    StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","),
+                            //                dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content));
+                            //            warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO);
+                            warningPushMapper.insert(warningPush);
+                            falg = true;
+                        }catch (Exception e){
+                            warningEvent.setStatus(Constants.TWO);
+                            warningEventMapper.updateById(warningEvent);
+                        }
                     }
                 }
+                if(falg){
+                    warningEvent.setStatus(Constants.ONE);
+                    warningEventMapper.updateById(warningEvent);
+                }
+
 
 
 
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/WarningServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/WarningServiceImpl.java
index 0b6d126..5758472 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/WarningServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/WarningServiceImpl.java
@@ -7,6 +7,8 @@
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.dingTalk.DingTalk;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.core.haikang.model.param.request.EventSubRequest;
+import com.doumee.core.haikang.service.HKService;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.WeatherUtil;
@@ -75,6 +77,23 @@
                 .eq(Warning::getName,warning.getName()) )>0){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝浜嬩欢绫诲瀷宸插瓨鍦紝璇疯繑鍥炲埛鏂伴〉闈㈡煡鐪嬶紒");
         }
+
+        if(StringUtils.isNotBlank(warning.getCode())&&Constants.equalsInteger(warning.getType(),Constants.ZERO)||Constants.equalsInteger(warning.getType(),Constants.ONE)){
+            EventSubRequest eventParam = new EventSubRequest();
+            String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
+            eventParam.setEventDest(path+"/notice");
+            try {
+                eventParam.setEventTypes(new Integer[]{Integer.valueOf(warning.getCode())});
+            }catch (Exception e){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浜嬩欢缂栫爜閿欒锛�");
+            }
+            HKService.cancelEventSub(eventParam);//鍏堝彇娑�
+            if(Constants.equalsInteger(warning.getStatus(),Constants.ONE)){
+                HKService.eventSub(eventParam);//瀹夐槻浜嬩欢
+            }
+        }
+
+
         warning.setStatus(Constants.formatIntegerNum(warning.getStatus()));
         warning.setIsdeleted(Constants.ZERO);
         warning.setCreator(warning.getLoginUserInfo().getId());
@@ -89,6 +108,23 @@
 
     @Override
     public void deleteById(Integer id, LoginUserInfo user) {
+        Warning warning = warningMapper.selectById(id);
+        if(Objects.isNull(warning)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+
+        if(StringUtils.isNotBlank(warning.getCode())&&Constants.equalsInteger(warning.getType(),Constants.ZERO)||Constants.equalsInteger(warning.getType(),Constants.ONE)){
+            EventSubRequest eventParam = new EventSubRequest();
+            String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
+            eventParam.setEventDest(path+"/notice");
+            try {
+                eventParam.setEventTypes(new Integer[]{Integer.valueOf(warning.getCode())});
+            }catch (Exception e){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浜嬩欢缂栫爜閿欒锛�");
+            }
+            HKService.cancelEventSub(eventParam);//鍏堝彇娑�
+        }
+
         warningMapper.update(null,new UpdateWrapper<Warning>().lambda()
                 .set(Warning::getIsdeleted,Constants.ONE)
                 .set(Warning::getEditor,user.getId())
@@ -124,6 +160,22 @@
                 .eq(Warning::getName,warning.getName()) )>0){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝浜嬩欢绫诲瀷宸插瓨鍦紝璇疯繑鍥炲埛鏂伴〉闈㈡煡鐪嬶紒");
         }
+
+        if(StringUtils.isNotBlank(warning.getCode())&&Constants.equalsInteger(warning.getType(),Constants.ZERO)||Constants.equalsInteger(warning.getType(),Constants.ONE)){
+            EventSubRequest eventParam = new EventSubRequest();
+            String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
+            eventParam.setEventDest(path+"/notice");
+            try {
+                eventParam.setEventTypes(new Integer[]{Integer.valueOf(warning.getCode())});
+            }catch (Exception e){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浜嬩欢缂栫爜閿欒锛�");
+            }
+            HKService.cancelEventSub(eventParam);//鍏堝彇娑�
+            if(Constants.equalsInteger(warning.getStatus(),Constants.ONE)){
+                HKService.eventSub(eventParam);//瀹夐槻浜嬩欢
+            }
+        }
+
         warning.setEditDate(warning.getCreateDate());
         warning.setEditor(warning.getCreator());
         warningMapper.updateById(warning);
@@ -242,6 +294,22 @@
         if(Constants.equalsInteger(model.getStatus(),param.getStatus())){
             return;
         }
+        if(StringUtils.isNotBlank(param.getCode())&&Constants.equalsInteger(model.getType(),Constants.ZERO)||Constants.equalsInteger(model.getType(),Constants.ONE)){
+            EventSubRequest eventParam = new EventSubRequest();
+            String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
+            eventParam.setEventDest(path+"/notice");
+            try {
+                eventParam.setEventTypes(new Integer[]{Integer.valueOf(model.getCode())});
+            }catch (Exception e){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浜嬩欢缂栫爜閿欒锛�");
+            }
+            HKService.cancelEventSub(eventParam);//鍏堝彇娑�
+            if(Constants.equalsInteger(param.getStatus(),Constants.ONE)){
+                HKService.eventSub(eventParam);//瀹夐槻浜嬩欢
+            }
+        }
+
+
         model.setStatus(param.getStatus());
         model.setEditDate(new Date());
         model.setEditor(param.getLoginUserInfo().getId());
@@ -346,9 +414,6 @@
         }catch (Exception e){
 
         }
-
-
-
 
     }
 
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java
index aaad2b1..54013e0 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java
@@ -6,11 +6,13 @@
 import com.doumee.core.haikang.model.param.BaseResponse;
 import com.doumee.core.haikang.model.param.request.*;
 import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest;
+import com.doumee.core.haikang.model.param.request.event.base.EventBaseRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.*;
 import com.doumee.core.haikang.model.param.request.event.visit.EventVisitIccmRequest;
 import com.doumee.core.haikang.model.param.request.event.visit.EventVisitRequest;
 import com.doumee.core.haikang.model.param.respose.TaskAdditionResponse;
 import com.doumee.core.haikang.service.HKService;
+import com.doumee.service.business.impl.JkCabinetGridServiceImpl;
 import com.doumee.service.business.third.model.LoginUserInfo;
 import com.doumee.dao.business.model.Device;
 import com.doumee.dao.business.model.ParkBook;
@@ -119,6 +121,11 @@
     }
 
     @Override
+    public String dealSecurityEvent(EventBaseRequest param, HttpServletResponse response, JkCabinetGridServiceImpl impl){
+        return null;
+    }
+
+    @Override
     public String   dealParkEvent(EventParkRequest param, HttpServletResponse response){
         return  null;
     }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java
index 525300d..4a8c6bb 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java
@@ -11,6 +11,8 @@
 import com.doumee.core.haikang.model.param.request.event.acs.EventAcsInfoRequest;
 import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest;
 import com.doumee.core.haikang.model.param.request.event.acs.EventDeviceDataRequest;
+import com.doumee.core.haikang.model.param.request.event.base.EventBaseInfoRequest;
+import com.doumee.core.haikang.model.param.request.event.base.EventBaseRequest;
 import com.doumee.core.haikang.model.param.request.event.parks.*;
 import com.doumee.core.haikang.model.param.request.event.visit.*;
 import com.doumee.core.haikang.service.HKService;
@@ -25,6 +27,7 @@
 import com.doumee.dao.business.model.Member;
 import com.doumee.dao.web.reqeust.SavePlatformWarnEventDTO;
 import com.doumee.service.business.VisitsService;
+import com.doumee.service.business.impl.JkCabinetGridServiceImpl;
 import com.doumee.service.business.impl.PlatformWarnEventServiceImpl;
 import com.doumee.service.business.third.TmsService;
 import com.doumee.service.business.third.model.request.TmsOrderInfoRequest;
@@ -101,6 +104,14 @@
     private PlatformLogMapper platformLogMapper;
     @Autowired
     private PlatformWarnEventServiceImpl platformWarnEventService;
+    @Autowired
+    private WarningMapper warningMapper;
+    @Autowired
+    private WarningEventMapper warningEventMapper;
+    @Autowired
+    private WarningRuleMapper warningRuleMapper;
+    @Autowired
+    private WarningPushMapper warningPushMapper;
 
 
 
@@ -339,7 +350,7 @@
         event.setExtEventAlarmOutID(request.getData().getExtEventAlarmOutID());
         event.setExtEventAlarmInID(request.getData().getExtEventAlarmInID());
         event.setExtAccessChannel(request.getData().getExtAccessChannel());
-        //閫氶亾浜嬩欢淇℃伅
+        //閫氶亾浜嬩欢淇℃伅`
         if(request.getData().getExtEventCustomerNumInfo() !=null){
             event.setTotalTimes(request.getData().getExtEventCustomerNumInfo().getTotalTimes());
             event.setEntryTimes(request.getData().getExtEventCustomerNumInfo().getEntryTimes());
@@ -447,6 +458,122 @@
             log.error("銆愭捣搴疯瀹簨浠舵帹閫併��========澶辫触=======锛歕n"+e.getMessage());
         }
         saveInterfaceLog(param,"/business/hksync/push/visit",result,true);
+        return  null;
+
+    }
+
+
+    /**
+     * 娴峰悍浜嬩欢鎺ㄩ��
+     * @param param
+     * @param response
+     * @return
+     */
+    @Override
+    public String dealSecurityEvent(EventBaseRequest param, HttpServletResponse response, JkCabinetGridServiceImpl impl){
+        log.info("銆愭捣搴烽�氱敤浜嬩欢鎺ㄩ�併��==========寮�濮�=======锛歕n"+JSONObject.toJSONString(param));
+        String result = null;
+        try {
+            if(param == null || param.getParams() == null || param.getParams().getEvents()==null){
+                return null;
+            }
+            //闂ㄧ浜嬩欢闆嗗悎
+            List<EventBaseInfoRequest> events  = param.getParams().getEvents();
+            for(EventBaseInfoRequest request : events){
+                Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda()
+                        .eq(Warning::getIsdeleted,Constants.ZERO)
+                        .eq(Warning::getCode, request.getSrcType()).last("limit 1"));
+
+                Constants.WarningConfig warningConfig = Constants.WarningConfig.getConfig(request.getEventType());
+                
+                if(Objects.nonNull(warning)){
+                    WarningEvent warningEvent = new WarningEvent();
+                    warningEvent.setCreateDate(new Date());
+                    warningEvent.setEditDate(warningEvent.getCreateDate());
+                    warningEvent.setIsdeleted(Constants.ZERO);
+                    warningEvent.setTitle(warning.getName());
+                    warningEvent.setContent(warning.getName() +"-"+ request.getSrcName());
+                    warningEvent.setStatus(Constants.ZERO);
+                    warningEvent.setEventId(request.getEventId());
+                    warningEvent.setEventType(request.getEventType().toString());
+                    warningEvent.setHappenTime(request.getHappenTime());
+                    warningEvent.setJsonContent(request.getData().toJSONString());
+                    warningEvent.setSrcIndex(request.getSrcIndex());
+                    warningEvent.setSrcType(request.getSrcType());
+                    warningEvent.setSrcName(request.getSrcName());
+                    warningEventMapper.insert(warningEvent);
+
+                    if(Objects.nonNull(warningConfig)){
+                        List<Integer> ruleIdList =  impl.processWarnFront(warningConfig);
+
+                        Boolean falg = false;
+                        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ruleIdList)){
+                            for (Integer ruleId:ruleIdList) {
+                                WarningRule warningRule = warningRuleMapper.selectById(ruleId);
+                                if (Objects.isNull(warningRule)) {
+                                    break;
+                                }
+                                List<Member> memberList = impl.getWarningRuleMemberList(warningRule);
+                                if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(memberList)) {
+                                    break;
+                                }
+                                try {
+                                    WarningPush warningPush = new WarningPush();
+                                    warningPush.setCreateDate(new Date());
+                                    warningPush.setIsdeleted(Constants.ZERO);
+                                    warningPush.setWarningId(warning.getId());
+                                    warningPush.setTitle(warningConfig.getInfo());
+                                    String content = warningEvent.getContent();
+                                    warningPush.setContent(content);
+                                    warningPush.setStatus(Constants.ZERO);
+                                    warningPush.setPushType(Constants.ZERO);
+                                    //TODO 鏍规嵁鍏蜂綋鏁版嵁瀵规瘮鑾峰彇
+                                    warningPush.setRegion( "鏈煡浣嶇疆");
+                                    warningPush.setMemberIds(
+                                            StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
+                                    );
+                                    warningPush.setMemberIds(
+                                            StringUtils.join(memberList.stream().map(i -> i.getId()).collect(Collectors.toList()), ",")
+                                    );
+                                    warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i -> i.getName()).collect(Collectors.toList()), ",")
+                                    );
+                                    // todo 鏆傛椂鍏抽棴 閽夐拤閫氱煡
+                                    //            Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()),
+                                    //                    StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","),
+                                    //                dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content));
+                                    //            warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO);
+                                    warningPushMapper.insert(warningPush);
+                                    falg = true;
+                                }catch (Exception e){
+                                    warningEvent.setStatus(Constants.TWO);
+                                    warningEventMapper.updateById(warningEvent);
+                                }
+                            }
+                        }
+                        if(falg){
+                            warningEvent.setStatus(Constants.ONE);
+                            warningEventMapper.updateById(warningEvent);
+                        }
+
+
+
+
+
+
+                    }
+
+
+
+
+                }
+
+            }
+            log.info("銆愭捣搴烽�氱敤浜嬩欢鎺ㄩ�併��========鎴愬姛=======");
+        }catch (Exception e){
+
+            log.error("銆愭捣搴烽�氱敤浜嬩欢鎺ㄩ�併��========澶辫触=======锛歕n"+e.getMessage());
+        }
+        saveInterfaceLog(param,"/business/hksync/push/notice",result,true);
         return  null;
 
     }
@@ -1717,46 +1844,46 @@
         return model;
     }
 
-    /**
-     * 璁板綍鏈堝彴浣滀笟鏃ュ織
-     * @param job
-     * @param status
-     */
-    @Transactional
-    private void dealPlatformJobLogBiz(PlatformJob job,EventPlatformCarsStatusInfoRequest status) {
-        platformJobMapper.updateById(job);//鏇存柊浣滀笟鐘舵��
-        PlatformLog log = new PlatformLog();
-        log.setIsdeleted(Constants.ZERO);
-        log.setCreateDate(new Date());
-        log.setEditDate(log.getCreateDate());
-        log.setJobId(job.getId());
-        log.setObjId(job.getId()+"");
-        if(Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.DONE.getKey())){
-            //濡傛灉鏄綔涓氬畬鎴�
-            log.setObjType(Constants.PlatformJobLogType.DONE.getKey());
-            log.setTitle(Constants.PlatformJobLogType.DONE.getName());
-            log.setContent(Constants.PlatformJobLogType.DONE.getInfo());
-            //鏌ヨ鏈�鍚庝竴娆″紑濮嬩綔涓氱殑鏃ュ織
-            PlatformLog lastBeginPlatform = platformLogMapper.selectOne(new QueryWrapper<PlatformLog>().lambda()
-                    .eq(PlatformLog::getIsdeleted,Constants.ZERO)
-                    .eq(PlatformLog::getObjType,Constants.PlatformJobLogType.WORKING.getKey())
-                    .eq(PlatformLog::getJobId,job.getId())
-                    .orderByDesc(PlatformLog::getCreateDate)
-                    .last(" limit 1"));
-            String v = Long.toString(job.getDoneDate().getTime() - lastBeginPlatform.getCreateDate().getTime() / 1000) ;
-            lastBeginPlatform.setRemark(job.getPlatformId().toString());
-            lastBeginPlatform.setParam3(v);
-            lastBeginPlatform.setParam2(DateUtil.getDate(lastBeginPlatform.getCreateDate(),"yyyy-MM-dd HH:mm:ss"));
-            platformLogMapper.updateById(lastBeginPlatform);//鏇存柊涓婁竴娆′綔涓氱殑瀹屾垚鏃堕棿鍜屼綔涓氭椂闀�
-        }else{
-            //濡傛灉鏄綔涓氫腑
-            log.setObjType(Constants.PlatformJobLogType.WORKING.getKey());
-            log.setTitle(Constants.PlatformJobLogType.WORKING.getName());
-            log.setContent(Constants.PlatformJobLogType.WORKING.getInfo());
-            log.setParam1(DateUtil.getDate(log.getCreateDate(),"yyyy-MM-dd HH:mm:ss"));
-        }
-        platformLogMapper.insert(log);
-    }
+//    /**
+//     * 璁板綍鏈堝彴浣滀笟鏃ュ織
+//     * @param job
+//     * @param status
+//     */
+//    @Transactional
+//    private void dealPlatformJobLogBiz(PlatformJob job,EventPlatformCarsStatusInfoRequest status) {
+//        platformJobMapper.updateById(job);//鏇存柊浣滀笟鐘舵��
+//        PlatformLog log = new PlatformLog();
+//        log.setIsdeleted(Constants.ZERO);
+//        log.setCreateDate(new Date());
+//        log.setEditDate(log.getCreateDate());
+//        log.setJobId(job.getId());
+//        log.setObjId(job.getId()+"");
+//        if(Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.DONE.getKey())){
+//            //濡傛灉鏄綔涓氬畬鎴�
+//            log.setObjType(Constants.PlatformJobLogType.DONE.getKey());
+//            log.setTitle(Constants.PlatformJobLogType.DONE.getName());
+//            log.setContent(Constants.PlatformJobLogType.DONE.getInfo());
+//            //鏌ヨ鏈�鍚庝竴娆″紑濮嬩綔涓氱殑鏃ュ織
+//            PlatformLog lastBeginPlatform = platformLogMapper.selectOne(new QueryWrapper<PlatformLog>().lambda()
+//                    .eq(PlatformLog::getIsdeleted,Constants.ZERO)
+//                    .eq(PlatformLog::getObjType,Constants.PlatformJobLogType.WORKING.getKey())
+//                    .eq(PlatformLog::getJobId,job.getId())
+//                    .orderByDesc(PlatformLog::getCreateDate)
+//                    .last(" limit 1"));
+//            String v = Long.toString(job.getDoneDate().getTime() - lastBeginPlatform.getCreateDate().getTime() / 1000) ;
+//            lastBeginPlatform.setRemark(job.getPlatformId().toString());
+//            lastBeginPlatform.setParam3(v);
+//            lastBeginPlatform.setParam2(DateUtil.getDate(lastBeginPlatform.getCreateDate(),"yyyy-MM-dd HH:mm:ss"));
+//            platformLogMapper.updateById(lastBeginPlatform);//鏇存柊涓婁竴娆′綔涓氱殑瀹屾垚鏃堕棿鍜屼綔涓氭椂闀�
+//        }else{
+//            //濡傛灉鏄綔涓氫腑
+//            log.setObjType(Constants.PlatformJobLogType.WORKING.getKey());
+//            log.setTitle(Constants.PlatformJobLogType.WORKING.getName());
+//            log.setContent(Constants.PlatformJobLogType.WORKING.getInfo());
+//            log.setParam1(DateUtil.getDate(log.getCreateDate(),"yyyy-MM-dd HH:mm:ss"));
+//        }
+//        platformLogMapper.insert(log);
+//    }
 
     /**
      * 澶勭悊杞﹁締杩涘叆閿欒鏈堝彴涓氬姟閫昏緫

--
Gitblit v1.9.3