| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | |
| | | import com.doumee.dao.business.dao.MemberMapper; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.vo.CabinetBoardDataVO; |
| | | import com.doumee.dao.business.vo.CabinetDetailVO; |
| | | import com.doumee.dao.business.vo.CabinetGridInfoVO; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | |
| | | 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; |
| | |
| | | //更新钥匙柜信息 |
| | | 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() |
| | |
| | | .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()) |
| | |
| | | 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); |
| | | } |
| | |
| | | //更新钥匙柜信息 |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | .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()) |
| | | ); |
| | | //推送简道云 标记业务数据已被领取钥匙 |
| | | 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()); |
| | | jdyKeyUseByBookDTO.setId(carUseBook.getJdyNo()); |
| | | this.pushJDYKeyInfo(jdyKeyUseByBookDTO); |
| | | } |
| | | } |
| | |
| | | .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()+" )") |
| | | |
| | | .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(); |
| | |
| | | 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) |
| | | .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 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()+" ) ") |
| | | ); |
| | | |
| | | 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(Cars::getMemberId,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()); |
| | | } |
| | |
| | | .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()+" ) ") |
| | | ) |
| | | ); |
| | |
| | | public void timeOutUnCloseAlarm(TimeOutCloseGridDTO dto){ |
| | | if(Objects.nonNull(dto) |
| | | && Objects.nonNull(dto.getGridId())){ |
| | | |
| | | SystemUser systemUser = null; |
| | | if(Objects.nonNull(dto.getMemberId())){ |
| | | systemUser = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(Objects.nonNull(dto.getMemberId()),SystemUser::getMemberId,dto.getMemberId()) |
| | | .eq(SystemUser::getDeleted,Constants.ZERO) |
| | | .last(" limit 1 ") |
| | | ); |
| | | } |
| | | |
| | | JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectJoinOne(JkCabinetGrid.class, |
| | | new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName) |
| | |
| | | .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | |
| | | if(Objects.nonNull(jkCabinetGrid)){ |
| | | log.error("柜格开门超时未关闭告警信息:{}"+JSONObject.toJSONString(jkCabinetGrid)); |
| | | //规则类型 |
| | |
| | | return; |
| | | } |
| | | |
| | | String content = "【钥匙柜-"+jkCabinetGrid.getCabinetName()+"】下【柜格-"+jkCabinetGrid.getCode()+"】超时未关闭"; |
| | | String content = "【钥匙柜-"+jkCabinetGrid.getCabinetName()+"】下【柜格-"+jkCabinetGrid.getCode()+"】柜格未关闭"; |
| | | |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | //存储报警异常记录 |
| | | WarningEvent warningEvent = new WarningEvent(); |
| | | 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); |
| | |
| | | //无任何规则 直接跳过 |
| | | 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); |
| | |
| | | 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; |
| | |
| | | |
| | | 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(); |
| | | warningEvent.setCreateDate(new Date()); |
| | | 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():"未知位置"); |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public CabinetBoardDataVO getCabinetGridData(){ |
| | | CabinetBoardDataVO cabinetBoardDataVO = new CabinetBoardDataVO(); |
| | | //所有柜格信息 |
| | | 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) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(JkCabinetGrid::getCode) |
| | | ); |
| | | List<CabinetGridInfoVO> cabinetGridInfoVOList = new ArrayList<>(); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | cabinetBoardDataVO.setGridNum(jkCabinetGridList.size()); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | CabinetGridInfoVO cabinetGridInfoVO = new CabinetGridInfoVO(); |
| | | BeanUtil.copyProperties(jkCabinetGrid,cabinetGridInfoVO); |
| | | cabinetGridInfoVO.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE); |
| | | cabinetGridInfoVO.setKeyStatus(Objects.isNull(cabinetGridInfoVO.getKeyStatus())?Constants.ZERO:cabinetGridInfoVO.getKeyStatus()); |
| | | cabinetGridInfoVOList.add(cabinetGridInfoVO); |
| | | } |
| | | cabinetBoardDataVO.setGridNum(jkCabinetGridList.size()); |
| | | cabinetBoardDataVO.setOnlineKeyNum( //在位数量 |
| | | cabinetGridInfoVOList.stream().filter(i->Constants.equalsInteger(i.getKeyStatus(),Constants.ONE)).collect(Collectors.toList()).size() |
| | | ); |
| | | cabinetBoardDataVO.setOutKeyNum( //借出数量 |
| | | cabinetGridInfoVOList.stream().filter(i->Constants.equalsInteger(i.getKeyStatus(),Constants.TWO)).collect(Collectors.toList()).size() |
| | | ); |
| | | cabinetBoardDataVO.setServiceKeyNum( //维护保养数量 |
| | | cabinetGridInfoVOList.stream().filter(i->Constants.equalsInteger(i.getKeyStatus(),Constants.THREE)).collect(Collectors.toList()).size() |
| | | ); |
| | | cabinetBoardDataVO.setUnBindGridNum(//空闲数量 |
| | | cabinetGridInfoVOList.stream().filter(i->Constants.equalsInteger(i.getBindStatus(),Constants.ZERO)).collect(Collectors.toList()).size() |
| | | ); |
| | | } |
| | | return cabinetBoardDataVO; |
| | | } |
| | | |
| | | |
| | | @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()) |
| | | ); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |