| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.druid.sql.visitor.functions.Concat; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.dingTalk.DingTalk; |
| | | import com.doumee.core.dingTalk.DingTalkStream; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.JkKeysMapper; |
| | | import com.doumee.dao.business.model.Cars; |
| | | import com.doumee.dao.business.model.JkCabinet; |
| | | import com.doumee.dao.business.model.JkKeys; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dao.MemberMapper; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.model.*; |
| | | 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.PageData; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.JkCabinetGridMapper; |
| | | import com.doumee.dao.business.model.JkCabinetGrid; |
| | | import com.doumee.service.business.JkCabinetGridService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.github.yulichang.toolkit.MPJWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | 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.stereotype.Service; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @date 2025/09/28 09:01 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class JkCabinetGridServiceImpl implements JkCabinetGridService { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private JkKeysMapper jkKeysMapper; |
| | | |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | |
| | | @Autowired |
| | | private JkCabinetMapper jkCabinetMapper; |
| | | @Autowired |
| | | private JkCabinetLogMapper jkCabinetLogMapper; |
| | | |
| | | @Autowired |
| | | private WarningEventMapper warningEventMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private WarningMapper warningMapper; |
| | | @Autowired |
| | | private WarningRuleMapper warningRuleMapper; |
| | | |
| | | @Autowired |
| | | private WarningRuleDetailMapper warningRuleDetailMapper; |
| | | |
| | | @Autowired |
| | | private WarningPushMapper warningPushMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private DingTalk dingTalk; |
| | | |
| | | @Override |
| | | public Integer create(JkCabinetGrid jkCabinetGrid) { |
| | |
| | | |
| | | @Override |
| | | public void updateById(JkCabinetGrid jkCabinetGrid) { |
| | | jkCabinetGridMapper.updateById(jkCabinetGrid); |
| | | if(Objects.isNull(jkCabinetGrid) |
| | | || Objects.isNull(jkCabinetGrid.getId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = jkCabinetGrid.getLoginUserInfo(); |
| | | JkCabinetGrid model = jkCabinetGridMapper.selectById(jkCabinetGrid.getId()); |
| | | if(Objects.isNull(model)|| Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | if(Objects.nonNull(model.getKeyId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已绑定,请勿重复绑定"); |
| | | } |
| | | JkKeys keysModel = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | | if(Objects.isNull(keysModel)|| Constants.equalsInteger(keysModel.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(keysModel.getStatus(), (Constants.ZERO))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"钥匙已被绑定,请选择其他钥匙绑定"); |
| | | } |
| | | //更新钥匙柜信息 |
| | | jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda() |
| | | .set(JkCabinetGrid::getKeyId,jkCabinetGrid.getKeyId()) |
| | | .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() |
| | | .set(JkKeys::getStatus,Constants.ONE) |
| | | .eq(JkKeys::getId,jkCabinetGrid.getKeyId()) |
| | | ); |
| | | return; |
| | | }else if(Objects.nonNull(jkCabinetGrid.getChannelCode())||Objects.nonNull(jkCabinetGrid.getBoardCode())){ |
| | | try{ |
| | | jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda() |
| | | .set(Objects.nonNull(jkCabinetGrid.getChannelCode()),JkCabinetGrid::getChannelCode,jkCabinetGrid.getChannelCode()) |
| | | .set(Objects.nonNull(jkCabinetGrid.getBoardCode()),JkCabinetGrid::getBoardCode,jkCabinetGrid.getBoardCode()) |
| | | .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime()) |
| | | .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())); |
| | | }catch (Exception e){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请确保钥匙柜通道号/板号唯一"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | MPJLambdaWrapper<JkCabinetGrid> wrapper = new MPJLambdaWrapper<JkCabinetGrid>() |
| | | .selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName) |
| | | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) |
| | | .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode) |
| | | .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | |
| | | .eq(Objects.nonNull(model.getStatus()),JkCabinetGrid::getStatus,model.getStatus()) |
| | | .isNull(Objects.nonNull(model.getBindStatus())&&Constants.equalsInteger(model.getBindStatus(),Constants.ZERO),JkCabinetGrid::getKeyId) |
| | | .isNotNull(Objects.nonNull(model.getBindStatus())&&Constants.equalsInteger(model.getBindStatus(),Constants.ONE),JkCabinetGrid::getKeyId) |
| | | .like(StringUtils.isNotBlank(model.getKeyCode()),JkKeys::getCode,model.getKeyCode()); |
| | | .like(StringUtils.isNotBlank(model.getKeyCode()),JkKeys::getCode,model.getKeyCode()) |
| | | .orderByAsc(JkCabinetGrid::getId) |
| | | ; |
| | | |
| | | IPage<JkCabinetGrid> iPage = jkCabinetGridMapper.selectJoinPage(page,JkCabinetGrid.class,wrapper); |
| | | for (JkCabinetGrid jkCabinetGrid:iPage.getRecords()) { |
| | | jkCabinetGrid.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void bindingKeys(JkCabinetGrid jkCabinetGrid){ |
| | | public void updateStatusById(JkCabinetGrid jkCabinetGrid) { |
| | | if(Objects.isNull(jkCabinetGrid) |
| | | || Objects.isNull(jkCabinetGrid.getId()) |
| | | || Objects.isNull(jkCabinetGrid.getKeyId())){ |
| | | || Objects.isNull(jkCabinetGrid.getId()) |
| | | || Objects.isNull(jkCabinetGrid.getStatus())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | JkCabinetGrid model = jkCabinetGridMapper.selectById(jkCabinetGrid.getId()); |
| | | if(Objects.isNull(model)|| Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Objects.nonNull(model.getKeyId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已绑定,请勿重复绑定"); |
| | | } |
| | | JkKeys keysModel = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | | if(Objects.isNull(keysModel)|| Constants.equalsInteger(keysModel.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(keysModel.getStatus(), (Constants.ZERO))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"钥匙已被绑定,请选择其他钥匙绑定"); |
| | | } |
| | | //更新钥匙柜信息 |
| | | jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda() |
| | | .set(JkCabinetGrid::getKeyId,jkCabinetGrid.getKeyId()) |
| | | jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>() |
| | | .lambda().set(JkCabinetGrid::getStatus,jkCabinetGrid.getStatus()) |
| | | .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime()) |
| | | .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())); |
| | | //标记钥匙信息 |
| | | jkKeysMapper.update(new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getStatus,Constants.ONE) |
| | | .eq(JkKeys::getId,jkCabinetGrid.getKeyId()) |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda() |
| | | .set(JkCabinetGrid::getKeyId,null) |
| | | .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime()) |
| | | .eq(JkCabinetGrid::getId,jkCabinetGridList.stream().map(i->i.getId()).collect(Collectors.toList()))); |
| | | .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()); |
| | | if(CollectionUtils.isNotEmpty(keyIdList)){ |
| | | jkKeysMapper.update(new UpdateWrapper<JkKeys>().lambda() |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 标记故障 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void markFault(OptGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | return; |
| | | }else{ |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectList(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | LoginUserInfo loginUserInfo = dto.getLoginUserInfo(); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkCabinetGrid.setEditor(loginUserInfo.getId()); |
| | | jkCabinetGrid.setEditDate(new Date()); |
| | | jkCabinetGrid.setWorkingStatus(Constants.ONE); |
| | | jkCabinetGridMapper.updateById(jkCabinetGrid); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 标记维修保养 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void markRepair(OptGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | List<JkCabinetGrid> 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) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkKeys::getStatus,Constants.TWO) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .isNotNull(JkCabinetGrid::getKeyId) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkKeysMapper.update(null,new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getEditDate,DateUtil.getCurrDateTime()) |
| | | .set(JkKeys::getStatus,Constants.THREE) |
| | | .eq(JkKeys::getId,jkCabinetGrid.getKeyId()) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消故障 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void cancelFault(OptGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | return; |
| | | } |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectList(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ONE) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | LoginUserInfo loginUserInfo = dto.getLoginUserInfo(); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkCabinetGrid.setEditor(loginUserInfo.getId()); |
| | | jkCabinetGrid.setEditDate(new Date()); |
| | | jkCabinetGrid.setWorkingStatus(Constants.ZERO); |
| | | jkCabinetGridMapper.updateById(jkCabinetGrid); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设备管理员批量开锁 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void batchOpenGridAdmin(OptGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | return; |
| | | } |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectList(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | LoginUserInfo loginUserInfo = dto.getLoginUserInfo(); |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | List<JkCabinetLog> jkCabinetLogs = new ArrayList<>(); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | jkCabinetLog.setCreator(loginUserInfo.getId()); |
| | | jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | jkCabinetLog.setCabinetId(dto.getCabinetId()); |
| | | jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | jkCabinetLog.setAuthType(Constants.TWO); |
| | | jkCabinetLog.setMemberId(loginUserInfo.getMemberId()); |
| | | jkCabinetLog.setStatus(Constants.ZERO); |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLog.setInfo(Objects.isNull(dto.getOpenType())||Constants.equalsInteger(dto.getOpenType(),Constants.ZERO)?"系统开启":"手动开启"); |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId()); |
| | | JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | | if(Objects.nonNull(jkKeys)){ |
| | | if(!Constants.equalsInteger(jkKeys.getStatus(),Constants.ZERO)){ |
| | | jkCabinetLog.setCarId(jkKeys.getCarId()); |
| | | jkCabinetLog.setKeyInfo(jkKeys.getCarCode() + "_" + jkKeys.getCode() ); |
| | | } |
| | | jkCabinetLog.setRoleType(jkKeys.getRoleType()); |
| | | } |
| | | } |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLogs.add(jkCabinetLog); |
| | | } |
| | | |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 钥匙柜关门 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void closeGrid(CloseGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getGridId()) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || Objects.isNull(dto.getKeyStatus()) |
| | | || Objects.isNull(dto.getAuthType()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectOne(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.nonNull(jkCabinetGrid)){ |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | jkCabinetLog.setCabinetId(dto.getCabinetId()); |
| | | jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | jkCabinetLog.setAuthType(dto.getAuthType()); |
| | | jkCabinetLog.setMemberId(dto.getMemberId()); |
| | | jkCabinetLog.setKeyStatus(Constants.ZERO); |
| | | jkCabinetLog.setStatus(Constants.ZERO); |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | //只有钥匙柜绑定了钥匙信息 才会更新钥匙的信息 |
| | | JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | | jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId()); |
| | | if(Objects.nonNull(jkKeys)){ |
| | | if(!Constants.equalsInteger(jkKeys.getStatus(),Constants.ZERO)){ |
| | | jkCabinetLog.setCarId(jkKeys.getCarId()); |
| | | 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))){ |
| | | jkKeysMapper.update(null,new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getEditDate,DateUtil.getCurrDateTime()) |
| | | .set(JkKeys::getStatus,dto.getKeyStatus()) |
| | | .eq(JkKeys::getId,jkKeys.getId()) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLog.setType(Constants.ONE); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | //查询钥匙的开门记录 进行添加关门记录主键 |
| | | if(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)){ |
| | | jkCabinetLogMapper.update(null,new UpdateWrapper<JkCabinetLog>().lambda() |
| | | .set(JkCabinetLog::getCloseLogId,jkCabinetLog.getId()) |
| | | .eq(JkCabinetLog::getKeyId,jkCabinetLog.getKeyId()) |
| | | .eq(JkCabinetLog::getType,Constants.ONE) |
| | | .eq(JkCabinetLog::getKeyStatus,Constants.TWO) |
| | | .isNull(JkCabinetLog::getCloseLogId)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // public void saveAbnormalOpenGridLog(AbnormalOpenGridDTO dto){ |
| | | // if(Objects.isNull(dto) |
| | | // || StringUtils.isBlank(dto.getBoardCode()) |
| | | // || StringUtils.isBlank(dto.getBoardCode()) |
| | | // || Objects.isNull(dto.getCabinetId()) |
| | | // || Objects.isNull(dto.getKeyStatus()) |
| | | // || Objects.isNull(dto.getAuthType()) |
| | | // ){ |
| | | // throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | // } |
| | | // JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectOne(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | // .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | // .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | // jkCabinetLog.setCreateDate(new Date()); |
| | | // jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | // jkCabinetLog.setCabinetId(dto.getCabinetId()); |
| | | // jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | // jkCabinetLog.setAuthType(dto.getAuthType()); |
| | | // jkCabinetLog.setMemberId(dto.getMemberId()); |
| | | // jkCabinetLog.setKeyStatus(Constants.ZERO); |
| | | // jkCabinetLog.setStatus(Constants.ZERO); |
| | | // |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 司机获取可操作的钥匙柜柜格 |
| | | */ |
| | | @Override |
| | | public List<JkCabinetGrid> getDriverGrid(GetDriverGridDTO dto){ |
| | | List<JkCabinetGrid> jkCabinetGridList = new ArrayList<>(); |
| | | if(Objects.isNull(dto.getCabinetId()) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || Objects.isNull(dto.getMemberId()) |
| | | || Objects.isNull(dto.getType())){ |
| | | return jkCabinetGridList; |
| | | }else{ |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | if(Objects.isNull(jkCabinet)){ |
| | | return jkCabinetGridList; |
| | | } |
| | | if(Constants.equalsInteger(jkCabinet.getDoubleAuth(),Constants.ONE)){ |
| | | if(StringUtils.isBlank(jkCabinet.getAuthMemberId())){ |
| | | return jkCabinetGridList; |
| | | } |
| | | List<String> authMemberList = Arrays.asList(jkCabinet.getAuthMemberId().split(",")); |
| | | Boolean flag = true; |
| | | for (String id:authMemberList) { |
| | | if(Arrays.asList(jkCabinet.getAuthMemberId().split(",")).contains(id)){ |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag){ |
| | | return jkCabinetGridList; |
| | | } |
| | | } |
| | | 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) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .in(Constants.equalsInteger(dto.getType(),Constants.ONE),JkKeys::getStatus,Constants.TWO,Constants.THREE) |
| | | .in(Constants.equalsInteger(dto.getType(),Constants.ZERO),JkKeys::getStatus,Constants.ONE) |
| | | .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) { |
| | | jkCabinetGrid.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE); |
| | | jkCabinetGrid.setKeyStatus(Objects.isNull(jkCabinetGrid.getKeyStatus())?Constants.ZERO:jkCabinetGrid.getKeyStatus()); |
| | | } |
| | | |
| | | } |
| | | return jkCabinetGridList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 司机开启柜格 |
| | | * @param openGridDriverDTO |
| | | */ |
| | | @Override |
| | | public void openGridDriver(OpenGridDriverDTO openGridDriverDTO){ |
| | | JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectOne(new QueryWrapper<JkCabinetGrid>().lambda().eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,openGridDriverDTO.getCabinetId()) |
| | | .eq(JkCabinetGrid::getId,openGridDriverDTO.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.isNull(jkCabinetGrid)){ |
| | | return ; |
| | | } |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | jkCabinetLog.setCabinetId(openGridDriverDTO.getCabinetId()); |
| | | jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | jkCabinetLog.setAuthType(openGridDriverDTO.getAuthType()); |
| | | jkCabinetLog.setMemberId(openGridDriverDTO.getMemberId()); |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLog.setStatus(Constants.ZERO); |
| | | jkCabinetLog.setInfo(Objects.isNull(openGridDriverDTO.getOpenType())||Constants.equalsInteger(openGridDriverDTO.getOpenType(),Constants.ZERO)?"系统开启":"手动开启"); |
| | | if(Objects.nonNull(jkCabinetGrid.getKeyId())){ |
| | | jkCabinetLog.setKeyId(jkCabinetGrid.getKeyId()); |
| | | JkKeys jkKeys = jkKeysMapper.selectById(jkCabinetGrid.getKeyId()); |
| | | if(Objects.nonNull(jkKeys)){ |
| | | if(!Constants.equalsInteger(jkKeys.getStatus(),Constants.ZERO)){ |
| | | jkCabinetLog.setCarId(jkKeys.getCarId()); |
| | | jkCabinetLog.setKeyInfo(jkKeys.getCarCode() + "_" + jkKeys.getCode() ); |
| | | } |
| | | jkCabinetLog.setRoleType(jkKeys.getRoleType()); |
| | | } |
| | | } |
| | | jkCabinetLog.setIsNotice(Constants.ZERO); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void timeOutUnCloseAlarm(TimeOutCloseGridDTO dto){ |
| | | if(Objects.nonNull(dto) |
| | | && Objects.nonNull(dto.getGridId())){ |
| | | JkCabinetGrid jkCabinetGrid = jkCabinetGridMapper.selectJoinOne(JkCabinetGrid.class, |
| | | new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName) |
| | | .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId) |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getId,dto.getGridId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.nonNull(jkCabinetGrid)){ |
| | | log.error("柜格开门超时未关闭告警信息:{}"+JSONObject.toJSONString(jkCabinetGrid)); |
| | | //规则类型 |
| | | Constants.WarningConfig warningConfig = Constants.WarningConfig.GRID_TIME_OUT_INFO; |
| | | Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda() |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(warning)){ |
| | | return; |
| | | } |
| | | List<Integer> ruleIdList = this.processWarnFront(warningConfig); |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | for (Integer ruleId:ruleIdList) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | if(Objects.isNull(warningRule)){ |
| | | continue; |
| | | } |
| | | List<Member> memberList = this.getWarningRuleMemberList(warningRule); |
| | | if(CollectionUtils.isEmpty(memberList)){ |
| | | return; |
| | | } |
| | | |
| | | String content = "【钥匙柜-"+jkCabinetGrid.getCabinetName()+"】下【柜格-"+jkCabinetGrid.getCode()+"】超时未关闭"; |
| | | |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | //存储报警异常记录 |
| | | WarningEvent warningEvent = new WarningEvent(); |
| | | warningEvent.setCreateDate(new Date()); |
| | | warningEvent.setWarningId(warning.getId()); |
| | | 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(); |
| | | warningPush.setCreateDate(new Date()); |
| | | warningPush.setIsdeleted(Constants.ZERO); |
| | | warningPush.setWarningId(warning.getId()); |
| | | warningPush.setTitle(warningConfig.getInfo()); |
| | | warningPush.setContent(content); |
| | | warningPush.setStatus(Constants.ZERO); |
| | | warningPush.setPushType(Constants.ZERO); |
| | | warningPush.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i->i.getName()).collect(Collectors.toList()),",") |
| | | ); |
| | | //todo 暂时关闭 钉钉通知 |
| | | |
| | | // Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()), |
| | | // StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","), |
| | | // dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content)); |
| | | // warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO); |
| | | warningPushMapper.insert(warningPush); |
| | | warningEvent.setStatus(Constants.ONE); |
| | | warningEventMapper.updateById(warningEvent); |
| | | }catch (Exception e){ |
| | | warningEvent.setStatus(Constants.TWO); |
| | | warningEventMapper.updateById(warningEvent); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<Integer> processWarnFront(Constants.WarningConfig warningConfig){ |
| | | List<WarningRuleDetail> warningRuleDetailList = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>() |
| | | .selectAll(WarningRuleDetail.class) |
| | | .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId) |
| | | .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | ); |
| | | if(CollectionUtils.isEmpty(warningRuleDetailList)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | //所有报警规则配置信息 |
| | | List<Integer> ruleIdList = warningRuleDetailList.stream().map(i->i.getRuleId()).collect(Collectors.toList());; |
| | | Set<Integer> ruleIdSet = new HashSet<>(ruleIdList); |
| | | if(CollectionUtils.isNotEmpty(ruleIdSet)){ |
| | | List<Integer> resultList = new ArrayList<>(); |
| | | for (Integer ruleId:ruleIdSet) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | //查询其他规则信息 |
| | | List<WarningRuleDetail> warningRuleDetails = warningRuleDetailMapper.selectJoinList(WarningRuleDetail.class,new MPJLambdaWrapper<WarningRuleDetail>() |
| | | .selectAll(WarningRuleDetail.class) |
| | | .selectAs(Warning::getCode,WarningRuleDetail::getCode) |
| | | .leftJoin(Warning.class,Warning::getId,WarningRuleDetail::getWarningId) |
| | | .eq(WarningRuleDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(WarningRuleDetail::getRuleId,ruleId) |
| | | .in(Warning::getCode,Constants.WarningConfig.ALARM_TEST.getKey(), |
| | | Constants.WarningConfig.GRID_TIME_OUT_INFO.getKey(), |
| | | Constants.WarningConfig.KEY_TIME_OUT_BACK.getKey() |
| | | ) |
| | | ); |
| | | //无任何规则 直接跳过 |
| | | 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()); |
| | | //获取所有其他所有事件主键信息 |
| | | 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)){ |
| | | resultList.add(ruleId); |
| | | }; |
| | | }else{ |
| | | 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)){ |
| | | resultList.add(ruleId); |
| | | } |
| | | } |
| | | } |
| | | return resultList; |
| | | } |
| | | return new ArrayList<>(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断处理是否可以发送通知 当前告警配置的数据列表是否满足 |
| | | * @param warningRuleDetails |
| | | * @return |
| | | */ |
| | | public boolean processWarnFlag(List<WarningRuleDetail> warningRuleDetails,List<WarningEvent> warningEventList){ |
| | | if(CollectionUtils.isEmpty(warningEventList)){ |
| | | return false; |
| | | } |
| | | for (WarningRuleDetail warningRuleDetail:warningRuleDetails) { |
| | | if(Objects.nonNull(warningRuleDetail.getRegionId())){ |
| | | if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId()) |
| | | && StringUtils.isNotBlank(i.getRegionId()) && i.getRegionId().equals(warningRuleDetail.getRegionId()) |
| | | ).collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | return false; |
| | | } |
| | | }else{ |
| | | if(warningEventList.stream().filter(i->Constants.equalsInteger(i.getWarningId(),warningRuleDetail.getWarningId()) |
| | | ).collect(Collectors.toList()).size()<=Constants.ZERO){ |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public List<Member> getWarningRuleMemberList(WarningRule warningRule){ |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO) |
| | | .isNotNull(Member::getErpId) |
| | | .in(Member::getId,Arrays.asList(warningRule.getMemberIds().split(","))) |
| | | ); |
| | | return memberList; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void alcoholTestAlarm(AlcoholTestAlarmDTO dto){ |
| | | if(Objects.nonNull(dto) |
| | | && Objects.nonNull(dto.getMemberId())){ |
| | | SystemUser systemUser = |
| | | systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getMemberId,dto.getMemberId()) |
| | | .eq(SystemUser::getDeleted,Constants.ZERO) |
| | | .last(" limit 1 ") |
| | | ); |
| | | |
| | | JkCabinet jkCabinet = jkCabinetMapper.selectById(dto.getCabinetId()); |
| | | Constants.WarningConfig warningConfig = Constants.WarningConfig.ALARM_TEST; |
| | | Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda() |
| | | .eq(Warning::getIsdeleted,Constants.ZERO) |
| | | .eq(Warning::getStatus,Constants.ONE) |
| | | .eq(Warning::getCode,warningConfig.getKey()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(warning)){ |
| | | return; |
| | | } |
| | | List<Integer> ruleIdList = this.processWarnFront(warningConfig); |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | if(CollectionUtils.isEmpty(ruleIdList)){ |
| | | return; |
| | | } |
| | | for (Integer ruleId:ruleIdList) { |
| | | WarningRule warningRule = warningRuleMapper.selectById(ruleId); |
| | | if (Objects.isNull(warningRule)) { |
| | | continue; |
| | | } |
| | | List<Member> memberList = this.getWarningRuleMemberList(warningRule); |
| | | |
| | | String content = ""; |
| | | if(Objects.nonNull(systemUser.getRealname())){ |
| | | content = content + systemUser.getRealname(); |
| | | } |
| | | if(Objects.nonNull(jkCabinet)){ |
| | | content = content + "于"+jkCabinet.getName()+"钥匙柜"; |
| | | } |
| | | content = content + "酒精检测异常"; |
| | | if(Objects.nonNull(dto.getAlcoholNum())){ |
| | | content = content + ",酒精度数【"+dto.getAlcoholNum()+"°】"; |
| | | } |
| | | |
| | | //存储报警异常记录 |
| | | WarningEvent warningEvent = new WarningEvent(); |
| | | warningEvent.setCreateDate(new Date()); |
| | | warningEvent.setWarningId(warning.getId()); |
| | | 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(); |
| | | warningPush.setCreateDate(new Date()); |
| | | warningPush.setIsdeleted(Constants.ZERO); |
| | | warningPush.setWarningId(warning.getId()); |
| | | warningPush.setTitle(warningConfig.getInfo()); |
| | | warningPush.setContent(content); |
| | | warningPush.setStatus(Constants.ZERO); |
| | | warningPush.setPushType(Constants.ZERO); |
| | | warningPush.setRegion(Objects.nonNull(jkCabinet)&&StringUtils.isNotBlank(jkCabinet.getLocation())?jkCabinet.getLocation():"未知位置"); |
| | | warningPush.setMemberId(dto.getMemberId()); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i->i.getName()).collect(Collectors.toList()),",") |
| | | ); |
| | | //todo 暂时关闭 钉钉通知 |
| | | // Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()), |
| | | // StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","), |
| | | // dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),warningConfig.getInfo())); |
| | | // warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO); |
| | | warningPushMapper.insert(warningPush); |
| | | warningEvent.setStatus(Constants.ONE); |
| | | warningEventMapper.updateById(warningEvent); |
| | | }catch (Exception e){ |
| | | warningEvent.setStatus(Constants.TWO); |
| | | warningEventMapper.updateById(warningEvent); |
| | | } |
| | | |
| | | |
| | | //存储异常日志 |
| | | if(Objects.nonNull(systemUser)){ |
| | | log.error("司机酒精检测,超出酒精值告警信息:{}"+JSONObject.toJSONString(systemUser)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |