删除合同时更新合同状态

合同审核时状态校验
提交erp接口调整
This commit is contained in:
guojunyun
2025-10-17 17:17:11 +08:00
parent 36ff79ac97
commit 37c3a10b00
5 changed files with 38 additions and 20 deletions

View File

@@ -25,4 +25,5 @@ public interface ErrorCodeConstants {
ErrorCode CONTRACT_STATUS_NOT_DELETE = new ErrorCode(1_027_000_010, "{}状态合同不允许删除");
ErrorCode CONTRACT_ERP_RCV_DLVY_NOT_EXISTS = new ErrorCode(1_027_000_011, "不存在的收支类型或收支类型为空");
ErrorCode CONTRACT_STATUS_NOT_ARCHIVE = new ErrorCode(1_027_000_012, "{}状态合同不允许归档");
ErrorCode CONTRACT_STATUS_NOT_SUBMIT_ERP = new ErrorCode(1_027_000_013, "{}状态合同不允许提交ERP");
}

View File

@@ -5,6 +5,11 @@ package com.zt.plat.module.contractorder.enums.contract;
*/
public enum DictEnum {
/** ERP请求状态 */
ERP_REQ_STS_RLBK("失败","RLBK",null),
ERP_REQ_STS_RCVG("执行中","RCVG",null),
ERP_REQ_STS_FIND("成功","FIND",null),
ERP_REQ_STS_WAIT("待上传","WAIT",null),
/** 业务关联类型 */
BSE_SYS_REL_TP_ORDER("订单","ORDER",null),
BSE_SYS_REL_TP_CONTRACT("合同","CONTRACT",null),

View File

@@ -145,7 +145,7 @@ public class ContractController implements BusinessControllerMarker {
@PostMapping("/submit/erp")
@Operation(summary = "提交ERP")
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
public CommonResult<List<String>> submitErp(@RequestBody List<Long> ids) {
public CommonResult<Boolean> submitErp(@RequestBody List<Long> ids) {
return success(contractService.submitErp(ids));
}

View File

@@ -104,7 +104,7 @@ public interface ContractService {
* @param ids 合同ID集合
* @return
*/
List<String> submitErp(List<Long> ids);
Boolean submitErp(List<Long> ids);
/**
* 删除合同

View File

@@ -54,9 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -1001,6 +999,9 @@ public class ContractServiceImpl implements ContractService {
// 删除品位不计价规则
contractNotMapper.delete(TableFieldConstants.BSE_CTRT_NT_CTRT_ID, id.toString());
// 更新合同状态
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DELETED.getCode());
contractMainMapper.updateById(contractMainDO);
// 删除合同数据
contractMainMapper.deleteById(id);
@@ -1113,8 +1114,7 @@ public class ContractServiceImpl implements ContractService {
}
// 合同状态校验
if (!(DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_WAIT_AUDIT.getCode().equals(contractMainDO.getStatus()))) {
if (!DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())) {
throw exception(CONTRACT_STATUS_NOT_APPROVAL,
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
@@ -1287,10 +1287,7 @@ public class ContractServiceImpl implements ContractService {
}
@Override
public List<String> submitErp(List<Long> ids) {
// 返回结果
List<String> result = new ArrayList<>();
public Boolean submitErp(List<Long> ids) {
// 遍历合同ID集合
ids.forEach(id -> {
@@ -1300,24 +1297,39 @@ public class ContractServiceImpl implements ContractService {
if (contractMainDO != null) {
// 合同状态校验
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
}
// 生成ERP合同映射表
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
// 调用ERP模块
String erpResult = null;
try {
erpResult = erpContractService.submitErp(erpContractVO);
} catch (Exception e) {
erpResult = e.getMessage();
}
Map<Boolean, String> erpResult = sendToErp(erpContractVO);
log.info("合同提交ERP结果{}", erpResult);
result.add(id.toString() + ":" + erpResult);
} else {
result.add(id.toString() + ":" + CONTRACT_NOT_EXISTS);
throw exception(CONTRACT_NOT_EXISTS);
}
});
return result;
return true;
}
private Map<Boolean, String> sendToErp(ErpContractSaveReqVO erpContractVO) {
Map<Boolean, String> erpResult = new HashMap<>();
try {
String result = erpContractService.submitErp(erpContractVO);
erpResult.put(true, result);
} catch (Exception e) {
erpResult.put(false, e.getMessage());
}
return erpResult;
}
@Override