| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | @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()) |
| | |
| | | .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | JDYKeyUseByBookDTO jdyKeyUseByBookDTO = new JDYKeyUseByBookDTO(); |
| | | if(Objects.nonNull(jkCabinetGrid)){ |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | |
| | | 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()) |
| | |
| | | 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)) { |
| | |
| | | .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); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | return jdyKeyUseByBookDTO; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | .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) { |
| | |
| | | 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) |
| | |
| | | .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) { |
| | |
| | | .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)) { |
| | |
| | | } |
| | | |
| | | |
| | | @Async |
| | | @Override |
| | | public void pushJDYKeyInfo(JDYKeyUseByBookDTO dto){ |
| | | String url = systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.PUSH_URL_KEYS).getCode(); |
| | | // JSONObject object = new JSONObject(); |
| | |
| | | log.error("【简道云】推送派车单数据领用与归还信息-请求入参:"+JSONObject.toJSONString(dto)); |
| | | String result = HttpsUtil.postJson(url,JSONObject.toJSONString(dto)); |
| | | log.error("【简道云】推送派车单数据领用与归还信息-请求结果:"+JSONObject.toJSONString(result)); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | |
| | | .eq(JkCabinetGrid::getId,jkCabinetGrid.getId()) |
| | | ); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |