package com.gkhy.safePlatform.specialWork.service.baseService.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.commons.utils.StringUtils; import com.gkhy.safePlatform.specialWork.entity.WorkApplyCountDO; import com.gkhy.safePlatform.specialWork.entity.WorkApplyInfo; import com.gkhy.safePlatform.specialWork.entity.WorkApplyReportableDO; import com.gkhy.safePlatform.specialWork.enums.WorkApplyStatusEnum; import com.gkhy.safePlatform.specialWork.model.bo.WorkApplyPendingInfoBO; import com.gkhy.safePlatform.specialWork.model.query.db.AllWorkApplyPageDBQuery; import com.gkhy.safePlatform.specialWork.model.query.db.WorkApplyApplyingPageDBQuery; import com.gkhy.safePlatform.specialWork.model.query.db.WorkApplyPendingPageDBQuery; import com.gkhy.safePlatform.specialWork.model.query.db.WorkProcessWorkApplyDBQuery; import com.gkhy.safePlatform.specialWork.repository.WorkApplyInfoRepository; import com.gkhy.safePlatform.specialWork.service.baseService.WorkApplyInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service("workApplyInfoService") public class WorkApplyInfoServiceImpl extends ServiceImpl implements WorkApplyInfoService { @Autowired private WorkApplyInfoRepository workApplyInfoRepository; @Override public void saveWorkApplyInfo(WorkApplyInfo applyEntity) { if (applyEntity == null || applyEntity.getId() == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workApplyInfoRepository.insertWorkApplyInfo(applyEntity); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_ADD_ERROR); } } @Override public void updateStatusById(Long workApplyId, WorkApplyStatusEnum statusEnum) { if (workApplyId == null || statusEnum == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workApplyInfoRepository.updateStatusById(workApplyId, statusEnum.getStatus()); if (i == 0) { throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE); } if (i > 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public List listWorkApplyInfoByPage(Page page, WorkApplyApplyingPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workApplyInfoRepository.listWorkApplyInfoByPage(page,dbQuery); } @Override public List listPendingWorkApplyInfo(Page page, WorkApplyPendingPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workApplyInfoRepository.listPendingWorkApplyInfo(page,dbQuery); } @Override public WorkApplyInfo getWorkApprovalByApprovalUid(Long workApplyId, Long approvalUid) { if (workApplyId == null || approvalUid == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workApplyInfoRepository.getWorkApprovalByApprovalUid(workApplyId,approvalUid); } @Override public int countWorkApplyInfo() { return workApplyInfoRepository.countWorkApplyInfo(); } @Override public void updateApprovalStepIdById(Long workApplyId, Long nextStepId) { if (workApplyId == null || nextStepId == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workApplyInfoRepository.updateApprovalStepIdById(workApplyId, nextStepId); if (i == 0) { throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE); } if (i > 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public WorkApplyInfo getApplyInfoByWorkPermitNo(String workPermitNo) { if (StringUtils.isBlank(workPermitNo)) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } List workApplyInfos = workApplyInfoRepository.selectList(new LambdaQueryWrapper() // 编号 .eq(WorkApplyInfo::getWorkPermitNo, workPermitNo)); if (workApplyInfos.size() == 0) { return null; } if (workApplyInfos.size() > 1) { throw new BusinessException(ResultCodes.SERVER_DATABASE_DATA_DUPLICATED); } return workApplyInfos.get(0); } @Override public List listReportableWorkApply(WorkProcessWorkApplyDBQuery dbQuery) { if (dbQuery == null || dbQuery.getNow() == null || dbQuery.getStatus() == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workApplyInfoRepository.listReportableWorkApply(dbQuery); } @Override public List listAllWorkApplyByPage(Page page, AllWorkApplyPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workApplyInfoRepository.listAllWorkApplyByPage(page,dbQuery); } @Override public List getWorkApplyCountByDep() { return workApplyInfoRepository.getWorkApplyCountByDep(); } @Override public void finishStepById(Long workApplyId) { if (workApplyId == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workApplyInfoRepository.updateApprovalStepIdToNull(workApplyId); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } }