| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | 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.*; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @date 2025/09/28 09:01 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class JkCabinetGridServiceImpl implements JkCabinetGridService { |
| | | |
| | | @Autowired |
| | |
| | | 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; |
| | | }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); |
| | | } |
| | | } |
| | | } |
| | | LoginUserInfo loginUserInfo = dto.getLoginUserInfo(); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkCabinetGrid.setEditor(loginUserInfo.getId()); |
| | | jkCabinetGrid.setEditDate(new Date()); |
| | | jkCabinetGrid.setWorkingStatus(Constants.ONE); |
| | | jkCabinetGridMapper.updateById(jkCabinetGrid); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | .isNotNull(JkCabinetGrid::getKeyId) |
| | | .in(JkCabinetGrid::getId,dto.getGridIdList()) |
| | | ); |
| | | if(CollectionUtils.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ |
| | | 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()) |
| | | ); |
| | | } |
| | | } |
| | | 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()) |
| | | ); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | 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.isEmpty(jkCabinetGridList)){ |
| | | return; |
| | | 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); |
| | | } |
| | | } |
| | | LoginUserInfo loginUserInfo = dto.getLoginUserInfo(); |
| | | for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) { |
| | | jkCabinetGrid.setEditor(loginUserInfo.getId()); |
| | | jkCabinetGrid.setEditDate(new Date()); |
| | | jkCabinetGrid.setWorkingStatus(Constants.ZERO); |
| | | jkCabinetGridMapper.updateById(jkCabinetGrid); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | if(Objects.isNull(dto) |
| | | || Objects.isNull(dto.getCabinetId()) |
| | | || CollectionUtils.isEmpty(dto.getGridIdList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | 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.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() ); |
| | | 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()); |
| | | 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.setRoleType(jkKeys.getRoleType()); |
| | | } |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLogs.add(jkCabinetLog); |
| | | } |
| | | jkCabinetLog.setType(Constants.ZERO); |
| | | jkCabinetLogs.add(jkCabinetLog); |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | } |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | .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()) |
| | | ); |
| | | 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); |
| | | Boolean isChange = false; |
| | | 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.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()) |
| | | ); |
| | | isChange = true; |
| | | } |
| | | } |
| | | } |
| | | jkCabinetLog.setType(Constants.ONE); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | //查询钥匙对应的借出了钥匙的开门记录 进行添加关门记录主键 |
| | | if(isChange && 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.ZERO) |
| | | .eq(JkCabinetLog::getKeyStatus,Constants.TWO) |
| | | .isNotNull(JkCabinetLog::getCloseLogId)); |
| | | } |
| | | } |
| | | jkCabinetLog.setType(Constants.ONE); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | 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(id.equals(jkCabinet.getAuthMemberId())){ |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag){ |
| | | return jkCabinetGridList; |
| | | } |
| | | } |
| | | 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()+" ) ") |
| | | ); |
| | | } |
| | | 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; |
| | | } |
| | | |
| | |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.isNull(jkCabinetGrid)){ |
| | | return; |
| | | return ; |
| | | } |
| | | LoginUserInfo loginUserInfo = openGridDriverDTO.getLoginUserInfo(); |
| | | List<JkCabinetLog> jkCabinetLogs = new ArrayList<>(); |
| | | JkCabinetLog jkCabinetLog = new JkCabinetLog(); |
| | | jkCabinetLog.setCreateDate(new Date()); |
| | | jkCabinetLog.setCreator(loginUserInfo.getId()); |
| | |
| | | jkCabinetLog.setRoleType(jkKeys.getRoleType()); |
| | | } |
| | | } |
| | | jkCabinetLogMapper.insert(jkCabinetLogs); |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |