rk
14 小时以前 1fb6ce7f165e85cb9458d6e8d1b6bf7debc1e665
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;
    }
@@ -641,7 +646,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) {
@@ -664,29 +670,6 @@
                Boolean isCleanTime = Constants.betweenTimeConfig(cleanConfig);
                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 +686,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 +698,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 +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();
@@ -812,9 +797,6 @@
        log.error("【简道云】推送派车单数据领用与归还信息-请求入参:"+JSONObject.toJSONString(dto));
        String result = HttpsUtil.postJson(url,JSONObject.toJSONString(dto));
        log.error("【简道云】推送派车单数据领用与归还信息-请求结果:"+JSONObject.toJSONString(result));
    }
@@ -1058,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;
@@ -1223,11 +1233,7 @@
                        .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
                );
            }
        }
    }