From 88c60e6e4e03eb59bde5f83a944c818dfecb3975 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 05 十一月 2025 10:56:10 +0800
Subject: [PATCH] 最新版本541200007

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java |  358 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 308 insertions(+), 50 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java
index 72875bd..a14b88a 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java
@@ -1,6 +1,7 @@
 package com.doumee.service.business.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.dingTalk.DingTalk;
 import com.doumee.core.dingTalk.DingTalkStream;
@@ -25,6 +26,7 @@
 import com.doumee.service.business.third.model.PageWrap;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,13 +61,24 @@
     private JkCabinetLogMapper jkCabinetLogMapper;
 
     @Autowired
-    private WarningMapper warningMapper;
+    private WarningEventMapper warningEventMapper;
 
     @Autowired
     private MemberMapper memberMapper;
 
     @Autowired
+    private WarningMapper warningMapper;
+    @Autowired
     private WarningRuleMapper warningRuleMapper;
+
+    @Autowired
+    private WarningRuleDetailMapper warningRuleDetailMapper;
+
+    @Autowired
+    private WarningPushMapper warningPushMapper;
+    
+    @Autowired
+    private SystemDictDataBiz systemDictDataBiz;
 
     @Autowired
     private DingTalk dingTalk;
@@ -179,7 +192,7 @@
         MPJLambdaWrapper<JkCabinetGrid> wrapper = new MPJLambdaWrapper<JkCabinetGrid>()
                 .selectAll(JkCabinetGrid.class)
                 .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName)
-                .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode)
+                .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
                 .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId)
                 .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
                 .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
@@ -310,7 +323,7 @@
         }
         List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class,
                 new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class)
-                        .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode)
+                        .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
                         .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode)
                         .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId)
                 .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
@@ -392,6 +405,8 @@
                     jkCabinetLog.setAuthType(Constants.TWO);
                     jkCabinetLog.setMemberId(loginUserInfo.getMemberId());
                     jkCabinetLog.setStatus(Constants.ZERO);
+                    jkCabinetLog.setIsNotice(Constants.ZERO);
+                    jkCabinetLog.setInfo(Objects.isNull(dto.getOpenType())||Constants.equalsInteger(dto.getOpenType(),Constants.ZERO)?"绯荤粺寮�鍚�":"鎵嬪姩寮�鍚�");
                     if(Objects.nonNull(jkCabinetGrid.getKeyId())){
                         jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId());
                         JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId());
@@ -406,6 +421,7 @@
                     jkCabinetLog.setType(Constants.ZERO);
                     jkCabinetLogs.add(jkCabinetLog);
                 }
+
                 jkCabinetLogMapper.insert(jkCabinetLogs);
             }
         }
@@ -464,18 +480,50 @@
                     }
                 }
             }
+            jkCabinetLog.setIsNotice(Constants.ZERO);
             jkCabinetLog.setType(Constants.ONE);
             jkCabinetLogMapper.insert(jkCabinetLog);
             //鏌ヨ閽ュ寵鐨勫紑闂ㄨ褰� 杩涜娣诲姞鍏抽棬璁板綍涓婚敭
-            jkCabinetLogMapper.update(null,new UpdateWrapper<JkCabinetLog>().lambda()
-                    .set(JkCabinetLog::getCloseLogId,jkCabinetLog.getId())
-                    .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId())
-                    .eq(JkCabinetLog::getType,Constants.ZERO)
-                    .isNull(JkCabinetLog::getCloseLogId));
+            if(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)){
+                jkCabinetLogMapper.update(null,new UpdateWrapper<JkCabinetLog>().lambda()
+                        .set(JkCabinetLog::getCloseLogId,jkCabinetLog.getId())
+                        .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId())
+                        .eq(JkCabinetLog::getType,Constants.ONE)
+                        .eq(JkCabinetLog::getKeyStatus,Constants.TWO)
+                        .isNull(JkCabinetLog::getCloseLogId));
+            }
+
         }
     }
 
 
+
+//    public void saveAbnormalOpenGridLog(AbnormalOpenGridDTO dto){
+//        if(Objects.isNull(dto)
+//                || StringUtils.isBlank(dto.getBoardCode())
+//                || StringUtils.isBlank(dto.getBoardCode())
+//                || Objects.isNull(dto.getCabinetId())
+//                || Objects.isNull(dto.getKeyStatus())
+//                || Objects.isNull(dto.getAuthType())
+//        ){
+//            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+//        }
+//        JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectOne(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
+//                .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId())
+//                .eq(JkCabinetGrid::getId,dto.getGridId())
+//                .last(" limit 1 ")
+//        );
+//        JkCabinetLog jkCabinetLog = new JkCabinetLog();
+//        jkCabinetLog.setCreateDate(new Date());
+//        jkCabinetLog.setIsdeleted(Constants.ZERO);
+//        jkCabinetLog.setCabinetId(dto.getCabinetId());
+//        jkCabinetLog.setGridId(jkCabinetGrid.getId());
+//        jkCabinetLog.setAuthType(dto.getAuthType());
+//        jkCabinetLog.setMemberId(dto.getMemberId());
+//        jkCabinetLog.setKeyStatus(Constants.ZERO);
+//        jkCabinetLog.setStatus(Constants.ZERO);
+//
+//    }
 
 
     /**
@@ -512,7 +560,7 @@
             }
             jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class,
                     new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class)
-                            .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode)
+                            .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
                             .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode)
                             .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId)
                             .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus)
@@ -551,10 +599,8 @@
         if(Objects.isNull(jkCabinetGrid)){
             return ;
         }
-//        LoginUserInfo loginUserInfo = openGridDriverDTO.getLoginUserInfo();
         JkCabinetLog jkCabinetLog = new JkCabinetLog();
         jkCabinetLog.setCreateDate(new Date());
-//        jkCabinetLog.setCreator(loginUserInfo.getId());
         jkCabinetLog.setIsdeleted(Constants.ZERO);
         jkCabinetLog.setCabinetId(openGridDriverDTO.getCabinetId());
         jkCabinetLog.setGridId(jkCabinetGrid.getId());
@@ -562,6 +608,7 @@
         jkCabinetLog.setMemberId(openGridDriverDTO.getMemberId());
         jkCabinetLog.setType(Constants.ZERO);
         jkCabinetLog.setStatus(Constants.ZERO);
+        jkCabinetLog.setInfo(Objects.isNull(openGridDriverDTO.getOpenType())||Constants.equalsInteger(openGridDriverDTO.getOpenType(),Constants.ZERO)?"绯荤粺寮�鍚�":"鎵嬪姩寮�鍚�");
         if(Objects.nonNull(jkCabinetGrid.getKeyId())){
             jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId());
             JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId());
@@ -573,6 +620,7 @@
                 jkCabinetLog.setRoleType(jkKeys.getRoleType());
             }
         }
+        jkCabinetLog.setIsNotice(Constants.ZERO);
         jkCabinetLogMapper.insert(jkCabinetLog);
     }
 
@@ -590,59 +638,195 @@
                             .eq(JkCabinetGrid::getId,dto.getGridId())
                             .last(" limit 1 ")
             );
-
             if(Objects.nonNull(jkCabinetGrid)){
                 log.error("鏌滄牸寮�闂ㄨ秴鏃舵湭鍏抽棴鍛婅淇℃伅锛歿}"+JSONObject.toJSONString(jkCabinetGrid));
+                //瑙勫垯绫诲瀷
+                Constants.WarningConfig warningConfig = Constants.WarningConfig.GRID_TIME_OUT_INFO;
                 Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda()
-                        .eq(Warning::getType,Constants.THREE).eq(Warning::getCode,Constants.WarningConfig.GRID_TIME_OUT_INFO.getKey()).eq(Warning::getIsdeleted,Constants.ZERO).last("limt 1"));
+                        .eq(Warning::getIsdeleted,Constants.ZERO)
+                        .eq(Warning::getStatus,Constants.ONE)
+                        .eq(Warning::getCode,warningConfig.getKey())
+                        .last("limit 1")
+                );
                 if(Objects.isNull(warning)){
                     return;
                 }
-                List<Member> memberList = this.getWarningList(warning);
-                if(CollectionUtils.isEmpty(memberList)){
+                List<Integer> ruleIdList =  this.processWarnFront(warningConfig);
+                if(CollectionUtils.isEmpty(ruleIdList)){
                     return;
                 }
-                //todo 瀛樺偍寮傚父鏃ュ織
+                for (Integer ruleId:ruleIdList) {
+                    WarningRule warningRule = warningRuleMapper.selectById(ruleId);
+                    if(Objects.isNull(warningRule)){
+                        continue;
+                    }
+                    List<Member> memberList = this.getWarningRuleMemberList(warningRule);
+                    if(CollectionUtils.isEmpty(memberList)){
+                        return;
+                    }
 
+                    String content = "銆愰挜鍖欐煖-"+jkCabinetGrid.getCabinetName()+"銆戜笅銆愭煖鏍�-"+jkCabinetGrid.getCode()+"銆戣秴鏃舵湭鍏抽棴";
 
-            }else{
+                    JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId());
+                    //瀛樺偍鎶ヨ寮傚父璁板綍
+                    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(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.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(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.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);
+                    }
 
-    public List<Member> getWarningList(Warning warning){
-        if(Constants.equalsInteger(warning.getStatus(),Constants.ZERO)){
-            return null;
-        }
-        //鏌ヨ閫氱煡浜哄憳
-        List<WarningRule> warningRuleList = warningRuleMapper.selectList(new QueryWrapper<WarningRule>().lambda()
-                .eq(WarningRule::getIsdeleted,Constants.ZERO)
-                .apply(" id in ( select w.RULE_ID from warning_rule_detail w where w.WARNING_ID = '"+warning.getId()+"' and w.ISDELETED = 0  ) ")
-        );
-        List<Member> memberList = new ArrayList<>();
-        if(org.apache.commons.collections.CollectionUtils.isNotEmpty(warningRuleList)){
-            List<String> memberIdStr =  warningRuleList.stream().map(i->i.getMemberIds()).collect(Collectors.toList());
-            if(org.apache.commons.collections.CollectionUtils.isNotEmpty(memberIdStr)){
-                List<String> memberIdList = new ArrayList<>();
-                for (String s:memberIdStr) {
-                    memberIdList.addAll(
-                            Arrays.asList(s.split(","))
-                    );
                 }
-                memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO)
-                        .notIn(Member::getErpId)
-                        .in(Member::getId,memberIdList)
-                );
+
             }
         }
-        return memberList;
+    }
 
+
+    public List<Integer> processWarnFront(Constants.WarningConfig warningConfig){
+        List<WarningRuleDetail> warningRuleDetailList = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>()
+                .selectAll(WarningRuleDetail.class)
+                .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId)
+                .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO)
+                .eq(Warning::getIsdeleted,Constants.ZERO)
+                .eq(Warning::getStatus,Constants.ONE)
+                .eq(Warning::getCode,warningConfig.getKey())
+        );
+        if(CollectionUtils.isEmpty(warningRuleDetailList)){ 
+            return new ArrayList<>();
+        }
+        //鎵�鏈夋姤璀﹁鍒欓厤缃俊鎭�
+        List<Integer> ruleIdList = warningRuleDetailList.stream().map(i->i.getRuleId()).collect(Collectors.toList());;
+        Set<Integer> ruleIdSet = new HashSet<>(ruleIdList);
+        if(CollectionUtils.isNotEmpty(ruleIdSet)){
+            List<Integer> resultList = new ArrayList<>();
+            for (Integer ruleId:ruleIdSet) {
+                WarningRule warningRule = warningRuleMapper.selectById(ruleId);
+                //鏌ヨ鍏朵粬瑙勫垯淇℃伅
+                List<WarningRuleDetail> warningRuleDetails = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>()
+                        .selectAll(WarningRuleDetail.class)
+                        .selectAs(Warning::getCode,WarningRuleDetail::getCode)
+                        .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId)
+                        .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO)
+                        .eq(Warning::getIsdeleted,Constants.ZERO)
+                        .eq(Warning::getStatus,Constants.ONE)
+                        .eq(WarningRuleDetail::getRuleId,ruleId)
+                        .in(Warning::getCode,Constants.WarningConfig.ALARM_TEST.getKey(),
+                                Constants.WarningConfig.GRID_TIME_OUT_INFO.getKey(),
+                                Constants.WarningConfig.KEY_TIME_OUT_BACK.getKey()
+                        )
+                );
+                //鏃犱换浣曡鍒� 鐩存帴璺宠繃
+                if(CollectionUtils.isEmpty(warningRuleDetails)){
+                    return resultList;
+                }else if(!Constants.equalsInteger(warningRuleDetails.stream().filter(i->!i.getCode().equals(warningConfig.getKey())).collect(Collectors.toList()).size(),Constants.ZERO)){
+                    List<WarningRuleDetail> wList = warningRuleDetails.stream().filter(i->!i.getCode().equals(warningConfig.getKey())).collect(Collectors.toList());
+                    //鑾峰彇鎵�鏈夊叾浠栨墍鏈変簨浠朵富閿俊鎭�
+                    List<Integer> warningIdList = wList.stream().map(i->i.getWarningId()).collect(Collectors.toList());
+                    Set<Integer> setWarningIdList = new HashSet<>(warningIdList);
+                    //鑾峰彇鏃堕棿鍐呮墍鏈変簨浠朵俊鎭�
+                    List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda()
+                            .eq(WarningEvent::getIsdeleted,Constants.ZERO)
+                            .in(WarningEvent::getWarningId,setWarningIdList)
+                            .apply(" DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ")
+                    );
+                    if(this.processWarnFlag(wList,warningEventList)){
+                        resultList.add(ruleId);
+                    };
+                }else{
+                    List<WarningRuleDetail> wList = warningRuleDetails.stream().filter(i->i.getCode().equals(warningConfig.getKey())).collect(Collectors.toList());
+                    //鑾峰彇鏈浜嬩欢涓婚敭淇℃伅
+                    List<Integer> warningIdList = wList.stream().map(i->i.getWarningId()).collect(Collectors.toList());
+                    Set<Integer> setWarningIdList = new HashSet<>(warningIdList);
+                    //鑾峰彇鏃堕棿鍐呮墍鏈変簨浠朵俊鎭�
+                    List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda()
+                            .eq(WarningEvent::getIsdeleted,Constants.ZERO)
+                            .in(WarningEvent::getWarningId,setWarningIdList)
+                            .apply(" DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ")
+                    );
+                    if(this.processWarnFlag(wList,warningEventList)){
+                        resultList.add(ruleId);
+                    }
+                } 
+            }
+            return resultList;
+        }
+        return new ArrayList<>();
 
 
     }
 
+
+
+    /**
+     * 鍒ゆ柇澶勭悊鏄惁鍙互鍙戦�侀�氱煡 褰撳墠鍛婅閰嶇疆鐨勬暟鎹垪琛ㄦ槸鍚︽弧瓒� 
+     * @param warningRuleDetails
+     * @return
+     */
+    public boolean processWarnFlag(List<WarningRuleDetail> warningRuleDetails,List<WarningEvent> warningEventList){
+        if(CollectionUtils.isEmpty(warningEventList)){
+            return false;
+        }
+        for (WarningRuleDetail warningRuleDetail:warningRuleDetails) {
+            if(Objects.nonNull(warningRuleDetail.getRegionId())){
+                if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId())
+                        && StringUtils.isNotBlank(i.getRegionId()) && i.getRegionId().equals(warningRuleDetail.getRegionId())
+                ).collect(Collectors.toList()).size()<=Constants.ZERO){
+                    return false;
+                }
+            }else{
+                if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId())
+                ).collect(Collectors.toList()).size()<=Constants.ZERO){
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+
+    public List<Member> getWarningRuleMemberList(WarningRule warningRule){
+        List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO)
+                .isNotNull(Member::getErpId)
+                .in(Member::getId,Arrays.asList(warningRule.getMemberIds().split(",")))
+        );
+        return memberList;
+    }
 
 
     @Override
@@ -656,23 +840,97 @@
                             .last(" limit 1 ")
                     );
 
+            JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId());
+            Constants.WarningConfig warningConfig = Constants.WarningConfig.ALARM_TEST;
             Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda()
-                    .eq(Warning::getType,Constants.THREE).eq(Warning::getCode,Constants.WarningConfig.KEY_TIME_OUT_BACK.getKey()).eq(Warning::getIsdeleted,Constants.ZERO).last("limt 1"));
+                    .eq(Warning::getIsdeleted,Constants.ZERO)
+                    .eq(Warning::getStatus,Constants.ONE)
+                    .eq(Warning::getCode,warningConfig.getKey())
+                    .last("limit 1")
+            );
             if(Objects.isNull(warning)){
                 return;
             }
-            List<Member> memberList = this.getWarningList(warning);
-            if(CollectionUtils.isEmpty(memberList)){
+            List<Integer> ruleIdList =  this.processWarnFront(warningConfig);
+            if(CollectionUtils.isEmpty(ruleIdList)){
                 return;
             }
-            //todo 瀛樺偍寮傚父鏃ュ織
+            if(CollectionUtils.isEmpty(ruleIdList)){
+                return;
+            }
+            for (Integer ruleId:ruleIdList) {
+                WarningRule warningRule = warningRuleMapper.selectById(ruleId);
+                if (Objects.isNull(warningRule)) {
+                    continue;
+                }
+                List<Member> memberList = this.getWarningRuleMemberList(warningRule);
 
-            //瀛樺偍寮傚父鏃ュ織
-            if(Objects.nonNull(systemUser)){
-                log.error("鍙告満閰掔簿妫�娴嬶紝瓒呭嚭閰掔簿鍊煎憡璀︿俊鎭細{}"+JSONObject.toJSONString(systemUser));
+                String content = "";
+                if(Objects.nonNull(systemUser.getRealname())){
+                    content = content + systemUser.getRealname();
+                }
+                if(Objects.nonNull(jkCabinet)){
+                    content = content + "浜�"+jkCabinet.getName()+"閽ュ寵鏌�";
+                }
+                content = content + "閰掔簿妫�娴嬪紓甯�";
+                if(Objects.nonNull(dto.getAlcoholNum())){
+                    content = content + "锛岄厭绮惧害鏁般��"+dto.getAlcoholNum()+"掳銆�";
+                }
+
+                //瀛樺偍鎶ヨ寮傚父璁板綍
+                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(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.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(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"鏈煡浣嶇疆");
+                    warningPush.setMemberId(dto.getMemberId());
+                    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(),warningConfig.getInfo()));
+        //            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);
+                }
+
+
+                //瀛樺偍寮傚父鏃ュ織
+                if(Objects.nonNull(systemUser)){
+                    log.error("鍙告満閰掔簿妫�娴嬶紝瓒呭嚭閰掔簿鍊煎憡璀︿俊鎭細{}"+JSONObject.toJSONString(systemUser));
+                }
+
             }
         }
     }
 
 
+
+
+
 }

--
Gitblit v1.9.3