|
|
|
|
@ -1,29 +1,13 @@
|
|
|
|
|
package com.biutag.supervision.flow.action; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
import com.biutag.supervision.constants.enums.DepartLevelEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.InspectCaseEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.IsRectifyEnum; |
|
|
|
|
import com.biutag.supervision.pojo.dto.ActionDto; |
|
|
|
|
import com.biutag.supervision.pojo.dto.flow.VerifyData; |
|
|
|
|
import com.biutag.supervision.pojo.entity.Negative; |
|
|
|
|
import com.biutag.supervision.pojo.entity.NegativeBlame; |
|
|
|
|
import com.biutag.supervision.pojo.entity.NegativeProblemRelation; |
|
|
|
|
import com.biutag.supervision.pojo.entity.SupDepart; |
|
|
|
|
import com.biutag.supervision.service.*; |
|
|
|
|
import com.biutag.supervision.util.JSON; |
|
|
|
|
import com.biutag.supervision.service.NegativeService; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 核查办理-保存 |
|
|
|
|
*/ |
|
|
|
|
@ -33,114 +17,13 @@ public class SaveAction implements Action {
|
|
|
|
|
|
|
|
|
|
private final NegativeService negativeService; |
|
|
|
|
|
|
|
|
|
private final NegativeBlameService negativeBlameService; |
|
|
|
|
|
|
|
|
|
private final NegativeProblemRelationService negativeProblemRelationService; |
|
|
|
|
|
|
|
|
|
private final NegativeFileService fileService; |
|
|
|
|
|
|
|
|
|
private final SupDepartService departService; |
|
|
|
|
private final ApplyCompletionAction applyCompletionAction; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void next(ActionDto actionDto) { |
|
|
|
|
VerifyData verifyData = BeanUtil.toBean(actionDto.getData(), VerifyData.class); |
|
|
|
|
updateNegative(actionDto.getNegativeId(), verifyData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateNegative(String negativeId, VerifyData verifyData) { |
|
|
|
|
if (StrUtil.isBlank(verifyData.getInvolveDepartId())) { |
|
|
|
|
throw new RuntimeException("涉及单位不能为空!"); |
|
|
|
|
} |
|
|
|
|
LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>() |
|
|
|
|
.eq(Negative::getId, negativeId) |
|
|
|
|
.set(Negative::getUpdTime, LocalDateTime.now()) |
|
|
|
|
.set(Negative::getCaseNumber, verifyData.getCaseNumber()) |
|
|
|
|
.set(Negative::getCheckStatus, verifyData.getCheckStatus()) |
|
|
|
|
.set(Negative::getCheckStatusDesc, verifyData.getCheckStatusDesc()) |
|
|
|
|
.set(Negative::getRectifyDesc, verifyData.getRectifyDesc()) |
|
|
|
|
.set(Negative::getUnrectifyReason, verifyData.getUnrectifyReason()) |
|
|
|
|
.set(Negative::getCheckStatusName, verifyData.getCheckStatusName()) |
|
|
|
|
.set(Negative::getResolveSituation, verifyData.getResolveSituation()) |
|
|
|
|
.set(Negative::getResolveStatus, verifyData.getResolveStatus()) |
|
|
|
|
.set(Negative::getVisitingLeaderName, verifyData.getVisitingLeaderName()) |
|
|
|
|
.set(Negative::getVisitingLeaderEmpNo, verifyData.getVisitingLeaderEmpNo()); |
|
|
|
|
// 经办人
|
|
|
|
|
if (CollectionUtil.isNotEmpty(verifyData.getHandlePolices().stream().filter(item -> StrUtil.isNotBlank(item.getName())).toList())) { |
|
|
|
|
updateWrapper.set(Negative::getHandlePolices, JSON.toJSONString(verifyData.getHandlePolices())); |
|
|
|
|
} |
|
|
|
|
// 涉及单位
|
|
|
|
|
SupDepart depart = departService.getById(verifyData.getInvolveDepartId()); |
|
|
|
|
updateWrapper.set(Negative::getInvolveDepartId, verifyData.getInvolveDepartId()) |
|
|
|
|
.set(Negative::getInvolveDepartName, depart.getShortName()); |
|
|
|
|
if (DepartLevelEnum.SECOND.getValue().equals(depart.getLevel())) { |
|
|
|
|
updateWrapper.set(Negative::getSecondInvolveDepartId, depart.getId()) |
|
|
|
|
.set(Negative::getThreeInvolveDepartId, null); |
|
|
|
|
} else if (DepartLevelEnum.THREE.getValue().equals(depart.getLevel())) { |
|
|
|
|
updateWrapper.set(Negative::getSecondInvolveDepartId, depart.getPid()) |
|
|
|
|
.set(Negative::getThreeInvolveDepartId, depart.getId()); |
|
|
|
|
} else { |
|
|
|
|
throw new RuntimeException("涉及单位请选择二级或三级单位"); |
|
|
|
|
} |
|
|
|
|
// 核查情况是否属实
|
|
|
|
|
if (InspectCaseEnum.isItTure(verifyData.getCheckStatus())) { |
|
|
|
|
updateWrapper.set(Negative::getIsRectifyCode, verifyData.getIsRectifyCode()) |
|
|
|
|
.set(Negative::getIsRectifyName, verifyData.getIsRectifyName()) |
|
|
|
|
.set(Negative::getAccountabilityTarget, verifyData.getAccountabilityTarget()); |
|
|
|
|
// 未整改
|
|
|
|
|
if (IsRectifyEnum.NOT.getValue().equals(verifyData.getIsRectifyCode())) { |
|
|
|
|
updateWrapper.set(Negative::getRectifyRestrictionDays, verifyData.getRectifyRestrictionDays()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
negativeService.update(updateWrapper); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 如果涉及不为空,则先删除原有数据,再新增 |
|
|
|
|
*/ |
|
|
|
|
negativeBlameService.remove(negativeId); |
|
|
|
|
negativeProblemRelationService.remove(negativeId); |
|
|
|
|
if (!verifyData.getBlames().isEmpty()) { |
|
|
|
|
List<NegativeProblemRelation> problemRelations = new ArrayList<>(); |
|
|
|
|
List<NegativeBlame> negativeBlames = verifyData.getBlames().stream().map(item -> { |
|
|
|
|
NegativeBlame negativeBlame = new NegativeBlame(); |
|
|
|
|
BeanUtil.copyProperties(item, negativeBlame); |
|
|
|
|
if (CollectionUtil.isNotEmpty(item.getHandleResultCode())) { |
|
|
|
|
negativeBlame.setHandleResultCode(String.join(",", item.getHandleResultCode())); |
|
|
|
|
} else { |
|
|
|
|
negativeBlame.setHandleResultCode(null); |
|
|
|
|
} |
|
|
|
|
VerifyData.BlameLeader blameLeader = verifyData.getBlameLeaders().stream() |
|
|
|
|
.filter(leader -> leader.getBlameIdCodes().contains(item.getBlameIdCode())).findFirst().orElse(null); |
|
|
|
|
if (Objects.nonNull(blameLeader)) { |
|
|
|
|
BeanUtil.copyProperties(blameLeader, negativeBlame); |
|
|
|
|
if (CollectionUtil.isNotEmpty(blameLeader.getLeadHandleResultCode())) { |
|
|
|
|
negativeBlame.setLeadHandleResultCode(String.join(",", blameLeader.getLeadHandleResultCode())); |
|
|
|
|
} else { |
|
|
|
|
negativeBlame.setLeadHandleResultCode(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
negativeBlame.setNegativeId(negativeId) |
|
|
|
|
.setBlameId(IdUtil.getSnowflakeNextIdStr()) |
|
|
|
|
.setCrtTime(LocalDateTime.now()) |
|
|
|
|
.setUpdTime(LocalDateTime.now()); |
|
|
|
|
problemRelations.addAll(item.getProblems().stream().map(problem -> { |
|
|
|
|
NegativeProblemRelation problemRelation = new NegativeProblemRelation(); |
|
|
|
|
BeanUtil.copyProperties(problem, problemRelation); |
|
|
|
|
problemRelation.setId(IdUtil.fastSimpleUUID()); |
|
|
|
|
problemRelation.setBlameId(negativeBlame.getBlameId()); |
|
|
|
|
problemRelation.setNegativeId(negativeId); |
|
|
|
|
return problemRelation; |
|
|
|
|
}).toList()); |
|
|
|
|
return negativeBlame; |
|
|
|
|
}).toList(); |
|
|
|
|
// 新增涉及人员
|
|
|
|
|
negativeBlameService.saveBatch(negativeBlames); |
|
|
|
|
// 新增涉及人员问题类型
|
|
|
|
|
if (!problemRelations.isEmpty()) { |
|
|
|
|
negativeProblemRelationService.saveBatch(problemRelations); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
fileService.remove(negativeId); |
|
|
|
|
fileService.saveBatch(verifyData.getFiles(), negativeId); |
|
|
|
|
Negative negative = negativeService.getById(actionDto.getNegativeId()); |
|
|
|
|
applyCompletionAction.updateNegative(negative, verifyData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|