| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.OptGridDTO; |
| | | import com.doumee.dao.business.dto.CloseGridDTO; |
| | | import com.doumee.dao.business.dto.GetDriverGridDTO; |
| | | import com.doumee.dao.business.dto.OpenGridDriverDTO; |
| | | import com.doumee.dao.business.model.*; |
| | | 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.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 钥匙柜柜格基本信息表Service实现 |
| | |
| | | |
| | | @Autowired |
| | | private JkCabinetGridMapper jkCabinetGridMapper; |
| | | |
| | | @Autowired |
| | | private JkKeysMapper jkKeysMapper; |
| | | |
| | | @Autowired |
| | | private JkCabinetMapper jkCabinetMapper; |
| | | @Autowired |
| | | private JkCabinetLogMapper jkCabinetLogMapper; |
| | | |
| | | |
| | | |
| | | @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())){ |
| | | 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())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public PageData<JkCabinetGrid> findPage(PageWrap<JkCabinetGrid> pageWrap) { |
| | | IPage<JkCabinetGrid> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<JkCabinetGrid> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getId, pageWrap.getModel().getId()); |
| | | JkCabinetGrid model = pageWrap.getModel(); |
| | | MPJLambdaWrapper<JkCabinetGrid> wrapper = new MPJLambdaWrapper<JkCabinetGrid>() |
| | | .selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkCabinet::getName,JkCabinetGrid::getCabinetName) |
| | | .selectAs(JkKeys::getCode,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.getCabinetId()),JkCabinetGrid::getCabinetId,model.getCabinetId()) |
| | | .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()); |
| | | IPage<JkCabinetGrid> iPage = jkCabinetGridMapper.selectJoinPage(page,JkCabinetGrid.class,wrapper); |
| | | for (JkCabinetGrid jkCabinetGrid:iPage.getRecords()) { |
| | | jkCabinetGrid.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(JkCabinetGrid::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(JkCabinetGrid::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(JkCabinetGrid::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(JkCabinetGrid::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getInfo() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getInfo, pageWrap.getModel().getInfo()); |
| | | } |
| | | if (pageWrap.getModel().getCabinetId() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getCabinetId, pageWrap.getModel().getCabinetId()); |
| | | } |
| | | if (pageWrap.getModel().getCode() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getCode, pageWrap.getModel().getCode()); |
| | | } |
| | | if (pageWrap.getModel().getKeyId() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getKeyId, pageWrap.getModel().getKeyId()); |
| | | } |
| | | if (pageWrap.getModel().getSerialNo() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getSerialNo, pageWrap.getModel().getSerialNo()); |
| | | } |
| | | if (pageWrap.getModel().getStatus() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getStatus, pageWrap.getModel().getStatus()); |
| | | } |
| | | if (pageWrap.getModel().getWorkingStatus() != null) { |
| | | queryWrapper.lambda().eq(JkCabinetGrid::getWorkingStatus, pageWrap.getModel().getWorkingStatus()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(jkCabinetGridMapper.selectPage(page, queryWrapper)); |
| | | return PageData.from(iPage); |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<JkCabinetGrid> wrapper = new QueryWrapper<>(jkCabinetGrid); |
| | | return jkCabinetGridMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateStatusById(JkCabinetGrid jkCabinetGrid) { |
| | | if(Objects.isNull(jkCabinetGrid) |
| | | || Objects.isNull(jkCabinetGrid.getId()) |
| | | || Objects.isNull(jkCabinetGrid.getStatus())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>() |
| | | .lambda().set(JkCabinetGrid::getStatus,jkCabinetGrid.getStatus()) |
| | | .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime()) |
| | | .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void unBindKeys(List<Integer> idList){ |
| | | if(CollectionUtils.isEmpty(idList)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(idList.size()==Constants.ONE){ |
| | | JkCabinetGrid model = jkCabinetGridMapper.selectById(idList.get(Constants.ZERO)); |
| | | if(Objects.isNull(model)|| Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Objects.isNull(model.getKeyId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前规格未绑定钥匙,请刷新查看"); |
| | | }else{ |
| | | //更新钥匙柜信息 |
| | | jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda() |
| | | .set(JkCabinetGrid::getKeyId,null) |
| | | .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime()) |
| | | .eq(JkCabinetGrid::getId,model.getId())); |
| | | JkKeys keysModel = jkKeysMapper.selectById(model.getKeyId()); |
| | | if(Objects.nonNull(keysModel) && !Constants.equalsInteger(keysModel.getStatus(),Constants.ZERO)){ |
| | | jkKeysMapper.update(new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getStatus,Constants.ZERO) |
| | | .eq(JkKeys::getId,keysModel.getId()) |
| | | ); |
| | | } |
| | | } |
| | | }else{ |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectList(new QueryWrapper<JkCabinetGrid>().lambda() |
| | | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) |
| | | .isNotNull(JkCabinetGrid::getKeyId) |
| | | .in(JkCabinetGrid::getId,idList)); |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | 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()))); |
| | | 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() |
| | | .set(JkKeys::getStatus,Constants.ZERO) |
| | | .in(JkKeys::getId,keyIdList) |
| | | ); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 标记故障 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void markFault(OptGridDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | 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.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | } |
| | | 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::getCode,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.ONE) |
| | | .eq(JkCabinetGrid::getWorkingStatus,Constants.ZERO) |
| | | .eq(JkCabinetGrid::getCabinetId,dto.getCabinetId()) |
| | | .isNotNull(JkCabinetGrid::getKeyId) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | } |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkKeysMapper.update(null,new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getEditDate,DateUtil.getCurrDateTime()) |
| | | .set(JkKeys::getStatus,Constants.TWO) |
| | | .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())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | 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.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | } |
| | | 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())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | 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.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | } |
| | | 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()); |
| | | if(Objects.nonNull(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()) |
| | | || Objects.isNull(dto.getMemberId()) |
| | | ){ |
| | | 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.isNull(jkCabinetGrid)){ |
| | | return; |
| | | } |
| | | 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()); |
| | | if(Objects.nonNull(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()); |
| | | //钥匙状态与当前操作状态不一致,则进行更新钥匙状态 |
| | | if(!Constants.equalsInteger(jkKeys.getStatus(),dto.getKeyStatus())){ |
| | | jkKeysMapper.update(null,new UpdateWrapper<JkKeys>().lambda() |
| | | .set(JkKeys::getEditDate,DateUtil.getCurrDateTime()) |
| | | .set(JkKeys::getStatus,dto.getKeyStatus()) |
| | | .eq(JkKeys::getId,jkKeys.getId()) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | jkCabinetLog.setType(Constants.ONE); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 司机获取可操作的钥匙柜柜格 |
| | | */ |
| | | @Override |
| | | public List<JkCabinetGrid> getDriverGrid(GetDriverGridDTO dto){ |
| | | if(Objects.isNull(dto.getCabinetId()) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || Objects.isNull(dto.getMemberId()) |
| | | || Objects.isNull(dto.getType())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, |
| | | new MPJLambdaWrapper<JkCabinetGrid>().selectAll(JkCabinetGrid.class) |
| | | .selectAs(JkKeys::getCode,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(JkCabinetGrid::getWorkingStatus,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.CAR_ID from car_driver c left join cars c1 on c.car_id = c1.id where c.ISDELETED = 0 and c.TYPE != 0 and c.MEMBER_ID = "+dto.getMemberId()+" ) ") |
| | | ); |
| | | 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; |
| | | } |
| | | LoginUserInfo loginUserInfo = openGridDriverDTO.getLoginUserInfo(); |
| | | List<JkCabinetLog> jkCabinetLogs = new ArrayList<>(); |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | jkCabinetLog.setCreator(loginUserInfo.getId()); |
| | | jkCabinetLog.setIsdeleted(Constants.ZERO); |
| | | jkCabinetLog.setCabinetId(openGridDriverDTO.getCabinetId()); |
| | | jkCabinetLog.setGridId(jkCabinetGrid.getId()); |
| | | jkCabinetLog.setAuthType(openGridDriverDTO.getAuthType()); |
| | | jkCabinetLog.setMemberId(loginUserInfo.getMemberId()); |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | if(Objects.nonNull(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()); |
| | | } |
| | | } |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | } |
| | | |
| | | } |