|
|
@@ -2,18 +2,19 @@ package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
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.jzg.commons.constants.Constants;
|
|
|
import com.jzg.commons.constants.ReturnInformation;
|
|
|
+import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.core.base.StateResult;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
import com.jzg.commons.entity.dto.*;
|
|
|
-import com.jzg.commons.entity.po.PtlAgreementCost;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementCostExternal;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementCostExternalType;
|
|
|
+import com.jzg.commons.entity.vo.CostExternalListVo;
|
|
|
import com.jzg.commons.entity.vo.CostExternalVo;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.commons.util.DateTimeUtils;
|
|
|
@@ -26,7 +27,7 @@ import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -41,6 +42,8 @@ public class PtlAgreementCostExternalServiceImpl extends ServiceImpl<PtlAgreemen
|
|
|
@Resource
|
|
|
private CostStateListener costStateListener;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BaseController baseController;
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
@@ -213,56 +216,62 @@ public class PtlAgreementCostExternalServiceImpl extends ServiceImpl<PtlAgreemen
|
|
|
HttpResult.ok(ReturnInformation.UPDATE_SUCCESS) : HttpResult.error(ReturnInformation.UPDATE_FAILED);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public boolean auditSuccess(List<String> ids) {
|
|
|
- for (String id : ids) {
|
|
|
- PtlAgreementCostExternal ptlAgreementCostExternal = baseMapper.selectById(id);
|
|
|
- if (ObjectUtil.isNull(ptlAgreementCostExternal)) {
|
|
|
- throw new SystemException("该条补录费用不存在,请检查");
|
|
|
- }
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 1) {
|
|
|
- throw new SystemException("该条补录费用已审核通过,请勿重复操作");
|
|
|
- }
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 2) {
|
|
|
- throw new SystemException("该条补录费用已审核不通过,请勿重复操作");
|
|
|
- }
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 0) {
|
|
|
- StateResult stateResult = costStateListener.auditSuccess(ptlAgreementCostExternal);
|
|
|
- if (stateResult.isResult()) {
|
|
|
- ptlAgreementCostExternal.setAuditStatus(stateResult.getCurrentState());
|
|
|
- baseMapper.updateById(ptlAgreementCostExternal);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
+ public HttpResult auditSuccess(CostReviewParam costReviewParam) {
|
|
|
+ return audit(costReviewParam, true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public boolean auditFailed(List<String> ids, String reason) {
|
|
|
- for (String id : ids) {
|
|
|
- PtlAgreementCostExternal ptlAgreementCostExternal = baseMapper.selectById(id);
|
|
|
- if (ObjectUtil.isNull(ptlAgreementCostExternal)) {
|
|
|
- throw new SystemException("该条补录费用不存在,请检查");
|
|
|
- }
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 1) {
|
|
|
- throw new SystemException("该条补录费用已审核通过,请勿重复操作");
|
|
|
+ public HttpResult auditFailed(CostReviewParam costReviewParam) {
|
|
|
+ return audit(costReviewParam, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private HttpResult audit(CostReviewParam costReviewParam, boolean isSuccess) {
|
|
|
+ // 批量查询所有记录
|
|
|
+ List<PtlAgreementCostExternal> records = baseMapper.selectBatchIds(costReviewParam.getIds());
|
|
|
+ String userName = baseController.getUserName();
|
|
|
+ // 检查审核状态并执行相应操作
|
|
|
+ for (PtlAgreementCostExternal record : records) {
|
|
|
+ int auditStatus = record.getAuditStatus();
|
|
|
+ if (auditStatus == 1) {
|
|
|
+ throw new SystemException("补录费用 " + record.getId() + " 已审核通过,请勿重复操作");
|
|
|
}
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 2) {
|
|
|
- throw new SystemException("该条补录费用已审核不通过,请勿重复操作");
|
|
|
+ if (auditStatus == 2) {
|
|
|
+ throw new SystemException("补录费用 " + record.getId() + " 已审核不通过,请勿重复操作");
|
|
|
}
|
|
|
- if (ptlAgreementCostExternal.getAuditStatus() == 0) {
|
|
|
- StateResult stateResult = costStateListener.auditFailed(ptlAgreementCostExternal);
|
|
|
+ if (auditStatus == 0) {
|
|
|
+ StateResult stateResult = isSuccess
|
|
|
+ ? costStateListener.auditSuccess(record)
|
|
|
+ : costStateListener.auditFailed(record);
|
|
|
if (stateResult.isResult()) {
|
|
|
- ptlAgreementCostExternal.setAuditStatus(stateResult.getCurrentState());
|
|
|
- ptlAgreementCostExternal.setReviewDescription(reason);
|
|
|
- baseMapper.updateById(ptlAgreementCostExternal);
|
|
|
+ record.setAuditStatus(stateResult.getCurrentState());
|
|
|
+ if (!isSuccess) {
|
|
|
+ record.setReviewDescription(costReviewParam.getReason());
|
|
|
+ }
|
|
|
+ record.setAuditPerson(userName);
|
|
|
+ record.setAuditTime(LocalDateTime.now());
|
|
|
+ baseMapper.updateById(record);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return true;
|
|
|
+ return HttpResult.ok("审核成功",costReviewParam.isAutomatic() ? nextDataID() : null);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public String nextDataID() {
|
|
|
+ CostExternalPageParam costParam = new CostExternalPageParam();
|
|
|
+ costParam.getPage().setSize(1);
|
|
|
+ costParam.setAuditStatus("0");
|
|
|
+ Page<CostExternalListVo> costManagementVoPage = baseMapper.pageList(costParam.getPage(), costParam);
|
|
|
+ return costManagementVoPage.getRecords().size() > 0 ?
|
|
|
+ String.valueOf(costManagementVoPage.getRecords().get(0).getId()) : "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|