package com.gkhy.safePlatform.specialWork.service.baseService.impl;
|
|
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.WorkApprovalItemStandInfo;
|
import com.gkhy.safePlatform.specialWork.entity.WorkApprovalStepInfo;
|
import com.gkhy.safePlatform.specialWork.enums.WorkApprovalStepResultEnum;
|
import com.gkhy.safePlatform.specialWork.model.bo.WorkApprovalStepInfoBO;
|
import com.gkhy.safePlatform.specialWork.repository.WorkApprovalStepInfoRepository;
|
import com.gkhy.safePlatform.specialWork.service.baseService.WorkApprovalStepInfoService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service("workApprovalStepInfoService")
|
public class WorkApprovalStepInfoServiceImpl extends ServiceImpl<WorkApprovalStepInfoRepository, WorkApprovalStepInfo> implements WorkApprovalStepInfoService {
|
|
@Autowired
|
private WorkApprovalStepInfoRepository workApprovalStepInfoRepository;
|
|
@Override
|
public void saveBatchRuleStep(List<WorkApprovalStepInfo> ruleStepEntities) {
|
if (ruleStepEntities == null || ruleStepEntities.size() == 0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
int i = workApprovalStepInfoRepository.insertBatch(ruleStepEntities);
|
if (i != ruleStepEntities.size()) {
|
throw new BusinessException(ResultCodes.SERVER_ADD_ERROR);
|
}
|
}
|
|
@Override
|
public List<WorkApprovalStepInfo> listApprovalRuleStepByWorkApplyId(Long workApplyId) {
|
if (workApplyId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return workApprovalStepInfoRepository.listApprovalRuleStepByWorkApplyId(workApplyId);
|
}
|
|
@Override
|
public void updateStatusById(Long stepId, WorkApprovalStepResultEnum result) {
|
if (stepId == null || result == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
int i = workApprovalStepInfoRepository.updateStatusById(stepId, result.getResult());
|
if (i == 0) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE);
|
}
|
if (i > 1) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
|
}
|
}
|
|
@Override
|
public void updateFinishApprovalTimeById(Long stepId, LocalDateTime now) {
|
if (stepId == null || now == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
int i = workApprovalStepInfoRepository.updateFinishApprovalTimeById(stepId, now);
|
if (i == 0) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE);
|
}
|
if (i > 1) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
|
}
|
}
|
|
@Override
|
public void updateStartApprovalTimeById(Long stepId, LocalDateTime now) {
|
if (stepId == null || now == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
int i = workApprovalStepInfoRepository.updateStartApprovalTimeById(stepId, now);
|
if (i == 0) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE);
|
}
|
if (i > 1) {
|
throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
|
}
|
}
|
|
}
|