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.specialWork.entity.WorkInfo; import com.gkhy.safePlatform.specialWork.entity.WorkInfoDO; import com.gkhy.safePlatform.specialWork.enums.WorkingAbortStatusEnum; import com.gkhy.safePlatform.specialWork.enums.WorkingAnalysisStatusEnum; import com.gkhy.safePlatform.specialWork.enums.WorkingStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.db.*; import com.gkhy.safePlatform.specialWork.repository.WorkInfoRepository; import com.gkhy.safePlatform.specialWork.service.baseService.WorkInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service("workInfoService") public class WorkInfoServiceImpl extends ServiceImpl implements WorkInfoService { @Autowired private WorkInfoRepository workInfoRepository; @Override public void saveWorkInfo(WorkInfo workInfoEntity) { if (workInfoEntity == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workInfoRepository.insertWorkInfo(workInfoEntity); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_ADD_ERROR); } } @Override public void updateWorkInfoById(WorkInfo workInfoEntity) { if (workInfoEntity == null || workInfoEntity.getId() == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workInfoRepository.updateWorkInfoById(workInfoEntity); if (i > 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } if (i == 0) { throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE); } } @Override public List listWorkInfoByPage(Page page, WorkPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.listWorkInfoDOByPage(page,dbQuery); } @Override public List listWorkInfoMyRefByPage(Page page, WorkMyRefPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.listWorkInfoDOMyRefByPage(page, dbQuery); } @Override public long countWorkInfoMyRef(WorkMyRefPageDBQuery dbQuery) { if (dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.countWorkInfoMyRef(dbQuery); } @Override public long countWorkInfo(WorkPageDBQuery dbQuery) { if (dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.countWorkInfo(dbQuery); } @Override public void updateWorkInfoStatusByWorkId(Long workId, WorkingStatusEnum workingStatusEnum) { if (workId == null || workingStatusEnum == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workInfoRepository.updateWorkStatusByWorkId(workId, workingStatusEnum.code); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public void updateWorkAnalysisStatusByWorkId(Long workId, WorkingAnalysisStatusEnum statusEnum) { if (workId == null | statusEnum == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workInfoRepository.updateWorkAnalysisStatusByWorkId(workId, statusEnum.code); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public List listWorkInfoGuardianByPage(Page page, WorkGuardianPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.listWorkInfoGuardianByPage(page,dbQuery); } @Override public List listWorkInfoAcceptByPage(Page page, WorkAcceptPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.listWorkInfoAcceptByPage(page, dbQuery); } @Override public List listWorkInfoAnalysisByPage(Page page, WorkAnalysisPageDBQuery dbQuery) { if (page == null || dbQuery == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.listWorkInfoAnalysisByPage(page,dbQuery); } @Override public Integer countEvertWorkByOptions(WorkCountDbQuery workCountDbQuery) { if(workCountDbQuery == null) return 0; if(workCountDbQuery.getDepIdList() == null || workCountDbQuery.getDepIdList().isEmpty()) return 0; Integer count = workInfoRepository.countByOptions(workCountDbQuery); return count; } @Override public Integer countAllWorkByDep(Long depId, LocalDateTime startTime, LocalDateTime endTime) { if(depId == null || depId < 1) return 0; return workInfoRepository.countAllWorkByDep(depId,startTime,endTime); } @Override public void updateWorkStatusAndAbortStatusByWorkId(Long workId, WorkingStatusEnum workStatus, WorkingAbortStatusEnum abortStatus) { if (workId == null || workStatus == null || abortStatus == null) { throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } int i = workInfoRepository.updateWorkStatusAndAbortStatusByWorkId(workId, workStatus, abortStatus); if (i != 1) { throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR); } } @Override public WorkInfo getWorkByWorkApplyId(Long workApplyId) { if(workApplyId == null){ throw new BusinessException(ResultCodes.SERVER_PARAM_NULL); } return workInfoRepository.selectOne(new LambdaQueryWrapper() .eq(WorkInfo::getWorkApplyId,workApplyId)); } }