From 1fb6ce7f165e85cb9458d6e8d1b6bf7debc1e665 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 03 十二月 2025 14:26:37 +0800
Subject: [PATCH] 功能开发

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java |  227 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 186 insertions(+), 41 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 3f6f205..4f627d6 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
@@ -31,14 +31,17 @@
 import com.doumee.service.business.third.model.PageWrap;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import com.sun.corba.se.impl.orbutil.concurrent.Sync;
 import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -142,9 +145,9 @@
             //鏇存柊閽ュ寵鏌滀俊鎭�
             jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda()
                     .set(JkCabinetGrid::getKeyId,jkCabinetGrid.getKeyId())
+                    .set(JkCabinetGrid::getActualLable,keysModel.getRfidLable())
                     .set(JkCabinetGrid::getEditor,loginUserInfo.getId())
                     .set(JkCabinetGrid::getEditDate,DateUtil.getCurrDateTime())
-                    .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime())
                     .eq(JkCabinetGrid::getId,jkCabinetGrid.getId()));
             //鏍囪閽ュ寵淇℃伅
             jkKeysMapper.update(new UpdateWrapper<JkKeys>().lambda()
@@ -201,8 +204,11 @@
                 .selectAll(JkCabinetGrid.class)
                 .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName)
                 .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
+                .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus)
+                .select("k.code",JkCabinetGrid::getActualCode)
                 .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId)
                 .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
+                .leftJoin(" jk_keys k on k.RFID_LABLE = t.ACTUAL_LABLE ")
                 .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
                 .eq(Objects.nonNull(model.getCabinetId()),JkCabinetGrid::getCabinetId,model.getCabinetId())
                 .eq(Objects.nonNull(model.getStatus()),JkCabinetGrid::getStatus,model.getStatus())
@@ -215,6 +221,19 @@
         IPage<JkCabinetGrid> iPage = jkCabinetGridMapper.selectJoinPage(page,JkCabinetGrid.class,wrapper);
         for (JkCabinetGrid jkCabinetGrid:iPage.getRecords()) {
             jkCabinetGrid.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE);
+            jkCabinetGrid.setKeyStatus(Objects.isNull(jkCabinetGrid.getKeyStatus())?Constants.ZERO:jkCabinetGrid.getKeyStatus());
+            if(!Constants.equalsInteger(jkCabinetGrid.getKeyStatus(),Constants.ZERO)){
+                if(StringUtils.isBlank(jkCabinetGrid.getKeyCode())||StringUtils.isBlank(jkCabinetGrid.getActualLable())
+                        || !StringUtils.equals(jkCabinetGrid.getKeyCode(),jkCabinetGrid.getActualLable())){
+
+                    jkCabinetGrid.setKeyStatus(Constants.FOUR);
+                    if(StringUtils.isBlank(jkCabinetGrid.getActualCode())){
+                        jkCabinetGrid.setErrInfo("鏈煡閽ュ寵 寮傚父");
+                    }else{
+                        jkCabinetGrid.setErrInfo(jkCabinetGrid.getActualCode()+" 寮傚父");
+                    }
+                }
+            }
         }
         return PageData.from(iPage);
     }
@@ -256,6 +275,7 @@
                 //鏇存柊閽ュ寵鏌滀俊鎭�
                 jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda()
                         .set(JkCabinetGrid::getKeyId,null)
+                        .set(JkCabinetGrid::getActualLable,null)
                         .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime())
                         .eq(JkCabinetGrid::getId,model.getId()));
                 JkKeys keysModel = jkKeysMapper.selectById(model.getKeyId());
@@ -274,6 +294,7 @@
             if(CollectionUtils.isNotEmpty(jkCabinetGridList)){
                 jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda()
                         .set(JkCabinetGrid::getKeyId,null)
+                        .set(JkCabinetGrid::getActualLable,null)
                         .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime())
                         .in(JkCabinetGrid::getId,jkCabinetGridList.stream().map(i->i.getId()).collect(Collectors.toList())));
                 List<Integer> keyIdList = jkCabinetGridList.stream().filter(i->Objects.nonNull(i.getKeyId())).map(i->i.getKeyId()).collect(Collectors.toList());
@@ -442,7 +463,7 @@
      */
     @Override
     @Transactional(rollbackFor = {BusinessException.class,Exception.class})
-    public void closeGrid(CloseGridDTO dto){
+    public JDYKeyUseByBookDTO closeGrid(CloseGridDTO dto){
         if(Objects.isNull(dto)
             || Objects.isNull(dto.getGridId())
             || Objects.isNull(dto.getCabinetId())
@@ -456,6 +477,7 @@
                 .eq(JkCabinetGrid::getId,dto.getGridId())
                 .last(" limit 1 ")
         );
+        JDYKeyUseByBookDTO jdyKeyUseByBookDTO = new JDYKeyUseByBookDTO();
         if(Objects.nonNull(jkCabinetGrid)){
             JkCabinetLog jkCabinetLog = new JkCabinetLog();
             jkCabinetLog.setCreateDate(new Date());
@@ -476,37 +498,48 @@
                         jkCabinetLog.setKeyInfo(jkKeys.getCarCode() + "_" + jkKeys.getCode() );
                     }
                     jkCabinetLog.setRoleType(jkKeys.getRoleType());
-                    jkCabinetLog.setKeyStatus(dto.getKeyStatus());
                     //閽ュ寵鐘舵�佷笌褰撳墠鎿嶄綔鐘舵�佷笉涓�鑷达紝鍒欒繘琛屾洿鏂伴挜鍖欑姸鎬�
                     if(!Constants.equalsInteger(jkKeys.getStatus(),dto.getKeyStatus())
                      && (Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)||Constants.equalsInteger(dto.getKeyStatus(),Constants.TWO))){
+                        jkCabinetLog.setKeyStatus(dto.getKeyStatus());
                         jkKeysMapper.update(null,new UpdateWrapper<JkKeys>().lambda()
                                 .set(JkKeys::getEditDate,DateUtil.getCurrDateTime())
                                 .set(JkKeys::getStatus,dto.getKeyStatus())
                                 .eq(JkKeys::getId,jkKeys.getId())
                         );
+                        if(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)&&
+                                (StringUtils.isBlank(jkCabinetGrid.getActualLable())||!StringUtils.equals(jkCabinetGrid.getActualLable(),jkKeys.getRfidLable()))){
+                            //鏇存柊閽ュ寵瀹為檯缂栫爜
+                            jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>().lambda()
+                                    .set(JkCabinetGrid::getActualLable,jkKeys.getRfidLable())
+                                    .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
+                            );
+                        }
                         //褰掕繕閽ュ寵/鍊熷嚭閽ュ寵 閮借鍘绘煡璇㈡渶鍚庝竴娆″紑闂ㄨ褰� 鑾峰彇鍏蜂綋鐨勫紑闂ㄧ殑鏂瑰紡 鏄殢杞�/娲捐溅/淇濇磥 璧嬩簣褰撳墠鍏抽棬璁板綍鍐� 濡傛灉鏄淳杞﹀崟鏁版嵁 闇�瑕佽皟璧风畝閬撲簯鎺ㄩ��
                         JkCabinetLog lastOutLog = jkCabinetLogMapper.selectOne(new QueryWrapper<JkCabinetLog>().lambda()
                                 .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId())
                                 .eq(JkCabinetLog::getType,Constants.ZERO)
+                                .orderByDesc(JkCabinetLog::getId)
                                 .last( "limit 1 "));
                         if(Objects.nonNull(lastOutLog)){
+                            jkCabinetLog.setOpenWay(lastOutLog.getOpenWay());
+                            jkCabinetLog.setCarUseBookId(lastOutLog.getCarUseBookId());
                             if(Objects.nonNull(lastOutLog.getCarUseBookId())) {
                                 CarUseBook carUseBook = carUseBookMapper.selectById(lastOutLog.getCarUseBookId());
-                                if (Objects.nonNull(carUseBook) && Constants.equalsInteger(carUseBook.getKeyStatus(), Constants.ZERO)) {
+                                if (Objects.nonNull(carUseBook)) {
                                     carUseBookMapper.update(new UpdateWrapper<CarUseBook>().lambda()
-                                            .set(CarUseBook::getKeyStatus, Constants.ONE)
+                                            .set(CarUseBook::getKeyStatus, Constants.equalsInteger(dto.getKeyStatus(),Constants.TWO)?Constants.ONE:Constants.TWO)
                                             .eq(CarUseBook::getId, carUseBook.getId())
                                     );
+                                    String carUseBookId = carUseBook.getJdyNo();
                                     //鎺ㄩ�佺畝閬撲簯 鏍囪涓氬姟鏁版嵁宸茶棰嗗彇閽ュ寵
                                     if (StringUtils.isNotBlank(carUseBook.getJdyId())) {
-                                        JDYKeyUseByBookDTO jdyKeyUseByBookDTO = new JDYKeyUseByBookDTO();
                                         jdyKeyUseByBookDTO.setCreate_date(System.currentTimeMillis());
-                                        jdyKeyUseByBookDTO.setStart_date(Constants.equalsInteger(dto.getKeyStatus(),Constants.TWO)?System.currentTimeMillis():null);
+                                        jdyKeyUseByBookDTO.setStart_date(System.currentTimeMillis());
                                         jdyKeyUseByBookDTO.setEnd_date(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)?System.currentTimeMillis():null);
                                         jdyKeyUseByBookDTO.setType(Constants.equalsInteger(dto.getKeyStatus(),Constants.TWO)?Constants.ZERO:Constants.ONE);
-                                        jdyKeyUseByBookDTO.setId(carUseBook.getJdyId());
-                                        this.pushJDYKeyInfo(jdyKeyUseByBookDTO);
+                                        jdyKeyUseByBookDTO.setId(carUseBook.getJdyNo());
+//                                        this.pushJDYKeyInfo(jdyKeyUseByBookDTO);
                                     }
                                 }
                             }
@@ -530,7 +563,10 @@
             }
 
         }
+        return jdyKeyUseByBookDTO;
     }
+
+
 
 
 
@@ -610,10 +646,23 @@
                                 .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId())
                                 .in(JkKeys::getStatus,Constants.TWO,Constants.THREE)
                                 .isNotNull(JkCabinetGrid::getKeyId)
-                                .apply("t1.car_id in ( select c.id from  cars c  where c.ISDELETED = 0 and  c.MEMBER_ID = "+dto.getMemberId()+" )")
-
+                                .apply(" ( t1.car_id in ( select c.id from  cars c  where c.ISDELETED = 0 and  c.MEMBER_ID = "+dto.getMemberId()+" ) " +
+                                        " or   t1.car_code in ( select c.car_code from car_use_book c   where c.isdeleted = 0  and c.KEY_STATUS = 1    and c.DRIVER_ID = "+dto.getMemberId()+" ) ) ")
                                 .orderByAsc(JkCabinetGrid::getCode)
                 );
+                for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) {
+                    JkCabinetLog log = jkCabinetLogMapper.selectOne(new QueryWrapper<JkCabinetLog>().lambda()
+                            .eq(JkCabinetLog::getGridId,jkCabinetGrid.getId())
+                            .eq(JkCabinetLog::getType,Constants.ZERO)
+                            .orderByDesc(JkCabinetLog::getId)
+                            .last("limit 1")
+                    );
+                    jkCabinetGrid.setGetKeyWay(Constants.ZERO);
+                    if(Objects.nonNull(log)){
+                        jkCabinetGrid.setGetKeyWay(log.getOpenWay());
+                        jkCabinetGrid.setCarUseBookId(log.getCarUseBookId());
+                    }
+                }
             }else{
                 //鍒ゆ柇褰撳墠鏃堕棿鏄惁澶勪簬淇濇磥鏃舵鍐�
                 String cleanConfig =  systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.CLEAN_TIME).getCode();
@@ -627,23 +676,37 @@
                                 .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode)
                                 .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId)
                                 .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus)
-                                .selectAs(CarUseBook::getId,JkCabinetGrid::getCarUseBookId)
                                 .select("1",JkCabinetGrid::getGetKeyWay)
                                 .innerJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
-                                .innerJoin(CarUseBook.class,CarUseBook::getCarCode,JkKeys::getCarCode)
-                                .innerJoin(Cars.class,Cars::getCode,CarUseBook::getCarCode)
+                                .innerJoin(Cars.class,Cars::getId,JkKeys::getCarId)
                                 .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
-                                .eq(CarUseBook::getIsdeleted,Constants.ZERO)
                                 .eq(Cars::getIsdeleted,Constants.ZERO)
                                 .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO)
                                 .eq(JkCabinetGrid::getStatus,Constants.ZERO)
                                 .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId())
                                 .in(JkKeys::getStatus,Constants.ONE)
                                 .eq(JkKeys::getRoleType,Constants.ONE)
+//                                .eq(Cars::getMemberId,dto.getMemberId())
                                 .isNotNull(JkCabinetGrid::getKeyId)
-                                .apply("and NOW() > DATE_SUB(t2.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < t2.end_time and t3.MEMBER_ID = "+dto.getMemberId()+" )")
-
+                                .apply(" t2.code in ( select c.car_code from car_use_book c   where c.isdeleted = 0   and NOW() > DATE_SUB(c.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < c.end_time  and c.DRIVER_ID = "+dto.getMemberId()+" ) ")
                 );
+
+                for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) {
+                    List<CarUseBook> carUseBookList = carUseBookMapper.selectJoinList(CarUseBook.class,new MPJLambdaWrapper<CarUseBook>()
+                                    .selectAll(CarUseBook.class)
+                                    .leftJoin(Cars.class,Cars::getCode,CarUseBook::getCarCode)
+                            .eq(CarUseBook::getIsdeleted,Constants.ZERO)
+                            .eq(Cars::getIsdeleted,Constants.ZERO)
+                            .eq(CarUseBook::getCarCode,jkCabinetGrid.getCarCode())
+                            .eq(CarUseBook::getDriverId,dto.getMemberId())
+                            .apply("  NOW() > DATE_SUB(t.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < t.end_time  ")
+                    );
+                    if(CollectionUtils.isNotEmpty(carUseBookList)) {
+                        jkCabinetGrid.setCarUseBookId(carUseBookList.get(Constants.ZERO).getId());
+                    }
+                }
+
+
                 if(CollectionUtils.isNotEmpty(jkCabinetGridList)){
                     girdIdList = jkCabinetGridList.stream().map(i->i.getId()).collect(Collectors.toList());
                 }
@@ -662,7 +725,7 @@
                                     .eq(!isCleanTime,JkKeys::getRoleType,Constants.ZERO)
                                     .in(JkKeys::getStatus,Constants.ONE)
                                     .isNotNull(JkCabinetGrid::getKeyId)
-                                    .notIn(CollectionUtils.isNotEmpty(girdIdList),JkCabinetGrid::getId,jkCabinetGridList)
+                                    .notIn(CollectionUtils.isNotEmpty(girdIdList),JkCabinetGrid::getId,girdIdList)
                                     .apply("t1.car_id in ( select c.id from  cars c  where c.ISDELETED = 0 and  c.MEMBER_ID = "+dto.getMemberId()+" ) ")
                     )
                 );
@@ -721,6 +784,8 @@
     }
 
 
+    @Async
+    @Override
     public void pushJDYKeyInfo(JDYKeyUseByBookDTO dto){
         String url = systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.PUSH_URL_KEYS).getCode();
 //        JSONObject object = new JSONObject();
@@ -732,9 +797,6 @@
         log.error("銆愮畝閬撲簯銆戞帹閫佹淳杞﹀崟鏁版嵁棰嗙敤涓庡綊杩樹俊鎭�-璇锋眰鍏ュ弬锛�"+JSONObject.toJSONString(dto));
         String result = HttpsUtil.postJson(url,JSONObject.toJSONString(dto));
         log.error("銆愮畝閬撲簯銆戞帹閫佹淳杞﹀崟鏁版嵁棰嗙敤涓庡綊杩樹俊鎭�-璇锋眰缁撴灉锛�"+JSONObject.toJSONString(result));
-
-
-
     }
 
 
@@ -788,7 +850,7 @@
                         return;
                     }
 
-                    String content = "銆愰挜鍖欐煖-"+jkCabinetGrid.getCabinetName()+"銆戜笅銆愭煖鏍�-"+jkCabinetGrid.getCode()+"銆戣秴鏃舵湭鍏抽棴";
+                    String content = "銆愰挜鍖欐煖-"+jkCabinetGrid.getCabinetName()+"銆戜笅銆愭煖鏍�-"+jkCabinetGrid.getCode()+"銆戞煖鏍兼湭鍏抽棴";
 
                     JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId());
                     //瀛樺偍鎶ヨ寮傚父璁板綍
@@ -796,12 +858,12 @@
                     warningEvent.setCreateDate(new Date());
                     warningEvent.setCreator(Objects.nonNull(systemUser)?systemUser.getId():null);
                     warningEvent.setWarningId(warning.getId());
+                    warningEvent.setIsdeleted(Constants.ZERO);
                     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();
@@ -834,9 +896,7 @@
                         warningEvent.setStatus(Constants.TWO);
                         warningEventMapper.updateById(warningEvent);
                     }
-
                 }
-
             }
         }
     }
@@ -878,8 +938,8 @@
                 //鏃犱换浣曡鍒� 鐩存帴璺宠繃
                 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());
+                }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);
@@ -887,25 +947,30 @@
                     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() ")
+                            .apply(Objects.nonNull(warningRule.getIntervalSec())," 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<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)){
+                    if(Objects.isNull(warningRule.getIntervalSec())){
                         resultList.add(ruleId);
+                    }else{
+                        //鑾峰彇鏃堕棿鍐呮墍鏈変簨浠朵俊鎭�
+                        List<WarningEvent> warningEventList = warningEventMapper.selectList(new QueryWrapper<WarningEvent>().lambda()
+                                .eq(WarningEvent::getIsdeleted,Constants.ZERO)
+                                .in(WarningEvent::getWarningId,setWarningIdList)
+                                .apply(Objects.nonNull(warningRule.getIntervalSec())," DATE_ADD(CREATE_DATE , INTERVAL "+warningRule.getIntervalSec()+" SECOND) > now() ")
+                        );
+                        if(this.processWarnFlag(wList,warningEventList)){
+                            resultList.add(ruleId);
+                        }
                     }
+
                 } 
             }
             return resultList;
@@ -975,6 +1040,34 @@
             if(Objects.isNull(warning)){
                 return;
             }
+            if(StringUtils.isNotBlank(dto.getAlcoholNum())){
+                try{
+                    //瀛樺偍閰掔簿妫�娴嬫棩蹇�
+                    Integer threshold = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.THRESHOLD).getCode());
+                    //妫�娴嬫爣鍑嗗��
+                    BigDecimal concentration = new BigDecimal( systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.CONCENTRATION).getCode());
+                    //妫�娴嬪��
+                    BigDecimal alcoholNum = new BigDecimal(dto.getAlcoholNum());
+                    JkCabinetLog jkCabinetLog = new JkCabinetLog();
+                    jkCabinetLog.setCreator(systemUser.getId());
+                    jkCabinetLog.setCreateDate(new Date());
+                    jkCabinetLog.setCabinetName(jkCabinet.getName());
+                    jkCabinetLog.setMemberId(dto.getMemberId());
+                    jkCabinetLog.setCabinetId(dto.getCabinetId());
+                    jkCabinetLog.setIsdeleted(Constants.ZERO);
+                    jkCabinetLog.setType(Constants.TWO);
+                    //1=mg/100ml;2=mg/L;3=%BAC  妫�娴嬪�硷細400mg/100ml锛屾爣鍑嗗��500mg/100ml
+                    jkCabinetLog.setStatus(alcoholNum.compareTo(concentration)<Constants.ZERO?Constants.ONE:Constants.ZERO);
+                    String thresholdStr = (Constants.equalsInteger(threshold,Constants.ONE)?"mg/100ml":Constants.equalsInteger(threshold,Constants.TWO)?"mg/L":"%BAC");
+                    jkCabinetLog.setKeyInfo("妫�娴嬪�硷細"+alcoholNum+thresholdStr+";鏍囧噯鍊硷細"+concentration+thresholdStr+";");
+                    jkCabinetLogMapper.insert(jkCabinetLog);
+                    if(alcoholNum.compareTo(concentration)<Constants.ZERO){
+                        return;
+                    }
+                }catch (Exception e){
+                    
+                }
+            }
             List<Integer> ruleIdList =  this.processWarnFront(warningConfig);
             if(CollectionUtils.isEmpty(ruleIdList)){
                 return;
@@ -991,15 +1084,15 @@
 
                 String content = "";
                 if(Objects.nonNull(systemUser.getRealname())){
-                    content = content + systemUser.getRealname();
+                    content = content +"銆�"+ systemUser.getRealname()+"銆�";
                 }
                 if(Objects.nonNull(jkCabinet)){
-                    content = content + "浜�"+jkCabinet.getName()+"閽ュ寵鏌�";
+                    content = content + "浜庛��"+jkCabinet.getName()+"銆戦挜鍖欐煖";
                 }
                 content = content + "閰掔簿妫�娴嬪紓甯�";
-                if(Objects.nonNull(dto.getAlcoholNum())){
-                    content = content + "锛岄厭绮惧害鏁般��"+dto.getAlcoholNum()+"掳銆�";
-                }
+//                if(Objects.nonNull(dto.getAlcoholNum())){
+//                    content = content + "锛岄厭绮惧害鏁般��"+dto.getAlcoholNum()+"掳銆�";
+//                }
 
                 //瀛樺偍鎶ヨ寮傚父璁板綍
                 WarningEvent warningEvent = new WarningEvent();
@@ -1007,6 +1100,7 @@
                 warningEvent.setCreator(Objects.nonNull(systemUser)?systemUser.getId():null);
                 warningEvent.setWarningId(warning.getId());
                 warningEvent.setTitle(warningConfig.getInfo());
+                warningEvent.setIsdeleted(Constants.ZERO);
                 warningEvent.setContent(content );
                 warningEvent.setStatus(Constants.ZERO);
                 warningEvent.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"鏈煡浣嶇疆");
@@ -1097,4 +1191,55 @@
     }
 
 
+    @Override
+    public void syncGridData(SyncCabinetDTO dto){
+        if(Objects.isNull(dto)
+            ||StringUtils.isBlank(dto.getCode())
+            || CollectionUtils.isEmpty(dto.getGridDTOList())){
+            return;
+        }
+        List<JkCabinetGrid> jkCabinetGridList =
+                jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, new MPJLambdaWrapper<JkCabinetGrid>()
+                        .selectAll(JkCabinetGrid.class)
+                        .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode)
+                        .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
+                        .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus)
+                        .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
+                        .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId)
+                        .eq(JkCabinet::getCode,dto.getCode())
+                        .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
+                        .isNotNull(JkCabinetGrid::getBoardCode)
+                        .isNotNull(JkCabinetGrid::getChannelCode)
+                        .orderByAsc(JkCabinetGrid::getCode)
+                );
+        if(CollectionUtils.isEmpty(jkCabinetGridList)){
+            return;
+        }
+        List<SyncGridDTO> gridDTOList = dto.getGridDTOList();
+        for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) {
+            List<SyncGridDTO> gridSyncList = gridDTOList.stream().filter(i->StringUtils.isNotBlank(i.getBoardCode())&&
+                    StringUtils.isNotBlank(i.getChannelCode())&&StringUtils.isNotBlank(i.getActualLable())&&i.getBoardCode().equals(jkCabinetGrid.getBoardCode())
+            && i.getChannelCode().equals(jkCabinetGrid.getChannelCode())).collect(Collectors.toList());
+            if(CollectionUtils.isEmpty(gridDTOList)){
+                continue;
+            }
+            SyncGridDTO syncGridDTO = gridSyncList.get(Constants.ZERO);
+            if(StringUtils.isBlank(jkCabinetGrid.getKeyCode())
+            || (!jkCabinetGrid.getKeyCode().equals(syncGridDTO.getActualLable())
+                    && !jkCabinetGrid.getActualLable().equals(syncGridDTO.getActualLable()))){
+                //鏇存柊鏁版嵁 鏍囪瀵瑰簲code
+                jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>().lambda()
+                        .set(JkCabinetGrid::getActualLable,syncGridDTO.getActualLable())
+                        .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
+                );
+            }
+        }
+    }
+    
+    
+    
+    
+    
+    
+
 }

--
Gitblit v1.9.3