From 3593c619ef18b1e0ef4d4ef3e8c7e9a667879df3 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期二, 09 十二月 2025 13:35:30 +0800
Subject: [PATCH] 钥匙柜酒精检测开关
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java | 93 +++++++++++++++++++++++++---------------------
1 files changed, 51 insertions(+), 42 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 9f68973..7d2f487 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
@@ -36,10 +36,12 @@
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;
@@ -461,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())
@@ -475,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());
@@ -495,10 +498,10 @@
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())
@@ -521,7 +524,6 @@
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)) {
@@ -529,15 +531,15 @@
.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(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.getJdyNo());
- this.pushJDYKeyInfo(jdyKeyUseByBookDTO);
+// this.pushJDYKeyInfo(jdyKeyUseByBookDTO);
}
}
}
@@ -561,7 +563,10 @@
}
}
+ return jdyKeyUseByBookDTO;
}
+
+
@@ -605,7 +610,10 @@
|| Objects.isNull(dto.getType())){
return jkCabinetGridList;
}else{
- JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId());
+ JkCabinet jkCabinet = jkCabinetMapper.selectJoinOne(JkCabinet.class,new MPJLambdaWrapper<JkCabinet>()
+ .selectAll(JkCabinet.class)
+ .select("now()",JkCabinet::getNow)
+ .eq(JkCabinet::getId,dto.getCabinetId()));
if(Objects.isNull(jkCabinet)){
return jkCabinetGridList;
}
@@ -641,7 +649,8 @@
.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) {
@@ -661,32 +670,9 @@
//鍒ゆ柇褰撳墠鏃堕棿鏄惁澶勪簬淇濇磥鏃舵鍐�
String cleanConfig = systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.CLEAN_TIME).getCode();
String earlyConfig = systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.EARLY_CONFIG).getCode();
- Boolean isCleanTime = Constants.betweenTimeConfig(cleanConfig);
+ Boolean isCleanTime = Constants.betweenTimeConfig(cleanConfig,jkCabinet.getNow());
List<Integer> girdIdList = new ArrayList<>();
//鏌ヨ鏍规嵁浠诲姟鍙互棰嗗彇鐨勬暟鎹�
-// jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class,
-// new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class)
-// .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
-// .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)
-// .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)
-// .isNotNull(JkCabinetGrid::getKeyId)
-// .apply(" NOW() > DATE_SUB(t2.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < t2.end_time and t3.MEMBER_ID = "+dto.getMemberId()+" ")
-// );
-
jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class,
new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class)
.selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
@@ -703,9 +689,9 @@
.eq(JkCabinetGrid::getCabinetId,dto.getCabinetId())
.in(JkKeys::getStatus,Constants.ONE)
.eq(JkKeys::getRoleType,Constants.ONE)
- .eq(Cars::getMemberId,dto.getMemberId())
+// .eq(Cars::getMemberId,dto.getMemberId())
.isNotNull(JkCabinetGrid::getKeyId)
- .apply(" t2.code in ( select c.car_code from car_use_book c left join cars c1 on c.car_code = c1.code where c.isdeleted = 0 and c1.isdeleted =0 and NOW() > DATE_SUB(c.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < c.end_time and c1.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) {
@@ -715,7 +701,7 @@
.eq(CarUseBook::getIsdeleted,Constants.ZERO)
.eq(Cars::getIsdeleted,Constants.ZERO)
.eq(CarUseBook::getCarCode,jkCabinetGrid.getCarCode())
- .eq(Cars::getMemberId,dto.getMemberId())
+ .eq(CarUseBook::getDriverId,dto.getMemberId())
.apply(" NOW() > DATE_SUB(t.START_TIME, INTERVAL "+earlyConfig+" MINUTE) and now() < t.end_time ")
);
if(CollectionUtils.isNotEmpty(carUseBookList)) {
@@ -801,6 +787,8 @@
}
+ @Async
+ @Override
public void pushJDYKeyInfo(JDYKeyUseByBookDTO dto){
String url = systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.PUSH_URL_KEYS).getCode();
// JSONObject object = new JSONObject();
@@ -812,9 +800,6 @@
log.error("銆愮畝閬撲簯銆戞帹閫佹淳杞﹀崟鏁版嵁棰嗙敤涓庡綊杩樹俊鎭�-璇锋眰鍏ュ弬锛�"+JSONObject.toJSONString(dto));
String result = HttpsUtil.postJson(url,JSONObject.toJSONString(dto));
log.error("銆愮畝閬撲簯銆戞帹閫佹淳杞﹀崟鏁版嵁棰嗙敤涓庡綊杩樹俊鎭�-璇锋眰缁撴灉锛�"+JSONObject.toJSONString(result));
-
-
-
}
@@ -1058,6 +1043,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;
@@ -1210,7 +1223,7 @@
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)){
+ if(CollectionUtils.isEmpty(gridSyncList)){
continue;
}
SyncGridDTO syncGridDTO = gridSyncList.get(Constants.ZERO);
@@ -1223,11 +1236,7 @@
.eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
);
}
-
}
-
-
-
}
--
Gitblit v1.9.3