Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
潘荣晟
2025-10-31 16:15:57 +08:00
6 changed files with 124 additions and 147 deletions

View File

@@ -42,7 +42,7 @@ public interface ContractApi {
@PostMapping(PREFIX + "/push")
@Operation(summary = "国贸2.0系统推送合同")
CommonResult<Boolean> push(@Valid @RequestBody IntContract reqVO) throws Exception;
CommonResult<Boolean> push(@Valid @RequestBody IntContract reqVO);
@GetMapping(PREFIX + "/logistics/list/page")
@Operation(summary = "国贸2.0系统合同分页查询")

View File

@@ -8,6 +8,9 @@ import lombok.Getter;
@Getter
public enum DictEnum {
/** 方式系统 */
BSE_SYS_REL_WY_EXTERNAL("系统外关联","EXTERNAL",null),
BSE_SYS_REL_WY_INTERNAL("内关联","INTERNAL",null),
/** 供应链业务大类 */
SPLY_BSN_TP_03BX("货物保险","03BX",null),
SPLY_BSN_TP_11CC("货物保管仓储","11CC",null),

View File

@@ -11,7 +11,9 @@ import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
import com.zt.plat.module.contractorder.api.dto.order.PrchOrdDtlDTO;
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
import com.zt.plat.module.contractorder.api.dto.order.SalesOrdDtlDTO;
import com.zt.plat.module.contractorder.api.vo.contract.international.*;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
import com.zt.plat.module.contractorder.api.vo.contract.international.Partner;
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.PurchaseOrderDetailsRespVO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFieldDO;
@@ -39,10 +41,12 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -151,10 +155,10 @@ public class ContractApiImpl implements ContractApi {
@Transactional
@Override
public CommonResult<Boolean> push(@RequestBody IntContract reqVO) throws Exception {
public CommonResult<Boolean> push(@RequestBody IntContract reqVO) {
// 合同主信息表映射
ContractMainDO contractMainDO = getcontractMainDO(reqVO);
ContractMainDO contractMainDO = internationalToMainDO(reqVO);
// 逻辑处理
// 操作标志 I 新增/更新D 删除
@@ -178,7 +182,7 @@ public class ContractApiImpl implements ContractApi {
SystemRelativityDO saveRelation = new SystemRelativityDO();
saveRelation.setUpId(Long.parseLong(externalId));
saveRelation.setDownId(contractId);
saveRelation.setWay("EXTERNAL");
saveRelation.setWay(DictEnum.BSE_SYS_REL_WY_EXTERNAL.getCode());
saveRelation.setStatus(DictEnum.BSE_SYS_REL_TP_CONTRACT.getCode());
systemRelativityMapper.insert(saveRelation);
}
@@ -242,107 +246,116 @@ public class ContractApiImpl implements ContractApi {
contractOtherFieldMapper.delete("CTRT_MAIN_ID", contractId.toString());
// 请求参数保存到动态条款
Field[] fields = reqVO.getClass().getDeclaredFields();
saveFields(fields, contractId, null, reqVO);
// 明细部分保存
// 附件清单列表
ContractOtherFormDO otherFormDO = saveContractOtherForm(contractId, "attachList",
"附件清单列表", "附件清单列表");
List<ContractOtherFieldDO> otherFieldDOS = new ArrayList<>();
if (reqVO.getAttachList() != null && !reqVO.getAttachList().isEmpty()) {
for (String attach : reqVO.getAttachList()) {
otherFieldDOS.add(getContractOtherField(contractId, otherFormDO.getId(), "attach", "附件",
attach, "附件", "java.lang.String"));
}
}
// 保存
contractOtherFieldMapper.insertBatch(otherFieldDOS);
//----- 嵌套列表
// 客商信息
if (reqVO.getPartnerList() != null && !reqVO.getPartnerList().isEmpty()) {
for (Partner partner : reqVO.getPartnerList()) {
otherFormDO = saveContractOtherForm(contractId, "partnerList",
"客商信息", "客商信息");
fields = partner.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), partner);
}
}
// 收发港/站点
if (reqVO.getGoodsSiteList() != null && !reqVO.getGoodsSiteList().isEmpty()) {
for (GoodsSite goodsSite : reqVO.getGoodsSiteList()) {
otherFormDO = saveContractOtherForm(contractId, "goodsSiteList",
"收发港/站点", "收发港/站点");
fields = goodsSite.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), goodsSite);
}
}
// 货物装卸要求
if (reqVO.getLoadingRequirementsList() != null && !reqVO.getLoadingRequirementsList().isEmpty()) {
for (LoadingRequirement loadingRequirement : reqVO.getLoadingRequirementsList()) {
otherFormDO = saveContractOtherForm(contractId, "loadingRequirementsList",
"货物装卸要求", "货物装卸要求");
fields = loadingRequirement.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), loadingRequirement);
}
}
// 收付款账号
if (reqVO.getAccountList() != null && !reqVO.getAccountList().isEmpty()) {
for (Account account : reqVO.getAccountList()) {
otherFormDO = saveContractOtherForm(contractId, "accountList",
"收付款账号", "收付款账号");
fields = account.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), account);
}
}
// 费用明细
if (reqVO.getFreightList() != null && !reqVO.getFreightList().isEmpty()) {
for (Freight freight : reqVO.getFreightList()) {
otherFormDO = saveContractOtherForm(contractId, "freightList",
"费用明细", "费用明细");
fields = freight.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), freight);
}
}
// 服务费用项目
if (reqVO.getServiceFeeList() != null && !reqVO.getServiceFeeList().isEmpty()) {
for (ServiceFee serviceFee : reqVO.getServiceFeeList()) {
otherFormDO = saveContractOtherForm(contractId, "serviceFeeList",
"服务费用项目", "服务费用项目");
fields = serviceFee.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), serviceFee);
}
}
// 仓库明细
if (reqVO.getStorgeList() != null && !reqVO.getStorgeList().isEmpty()) {
for (Storge storge : reqVO.getStorgeList()) {
otherFormDO = saveContractOtherForm(contractId, "storgeList",
"仓库明细", "仓库明细");
fields = storge.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), storge);
}
}
// 接货地址
if (reqVO.getReceivingAddrList() != null && !reqVO.getReceivingAddrList().isEmpty()) {
for (ReceivingAddr receivingAddr : reqVO.getReceivingAddrList()) {
otherFormDO = saveContractOtherForm(contractId, "receivingAddrList",
"接货地址", "接货地址");
fields = receivingAddr.getClass().getDeclaredFields();
saveFields(fields, contractId, otherFormDO.getId(), receivingAddr);
}
}
saveIntContractFields(reqVO, contractId);
return success(true);
}
private void saveIntContractFields(IntContract reqVO, Long contractId) {
try {
// 获取请求参数类结构
Class<? extends IntContract> reqClass = reqVO.getClass();
// 请求参数字段
Field[] reqClassFields = reqClass.getDeclaredFields();
// 条款明细表保存集合
List<ContractOtherFieldDO> saveFields = new ArrayList<>();
// 遍历字段
for (Field reqClassField : reqClassFields) {
reqClassField.setAccessible(true);
// 获取字段说明
Schema reqFieldSchema = reqClassField.getAnnotation(Schema.class);
String reqFieldDesc = reqFieldSchema.description();
// 获取字段对象
Object reqFieldObj = reqClassField.get(reqVO);
if (reqFieldObj != null) {
if (!"java.util.List".equals(reqClassField.getType().getName())) {
// 基础类型字段保存到条款明细表
ContractOtherFieldDO otherFieldDO = new ContractOtherFieldDO();
otherFieldDO.setContractMainId(contractId.toString());
otherFieldDO.setFieldNumber(reqClassField.getName());
otherFieldDO.setFieldName(reqFieldDesc);
otherFieldDO.setFieldValue(reqFieldObj.toString());
otherFieldDO.setFieldDescription(reqFieldDesc);
otherFieldDO.setType(reqClassField.getType().getName());
saveFields.add(otherFieldDO);
} else {
// list类型字段保存到条款表再将字段保存到条款明细表
// 获取list类结构
Class<?> listClass = reqClassField.get(reqVO).getClass();
// 获取list迭代方法
Method iteratorMethod = listClass.getMethod("iterator");
// 获取迭代器
Iterator<?> iterator = (Iterator<?>) iteratorMethod.invoke(reqClassField.get(reqVO));
// 遍历
while (iterator.hasNext()) {
// 条款表保存
ContractOtherFormDO otherFormDO = new ContractOtherFormDO();
otherFormDO.setContractMainId(contractId);
otherFormDO.setFormNumber(reqClassField.getName());
otherFormDO.setFormName(reqFieldDesc);
otherFormDO.setFormDescription(reqFieldDesc);
contractOtherFormMapper.insert(otherFormDO);
// 条款表ID
Long otherFormDOId = otherFormDO.getId();
// 获取明细对象
Object detailObj = iterator.next();
// 获取明细对象类结构
Class<?> detailClass = detailObj.getClass();
// 条款明细表
if ("java.lang.String".equals(detailClass.getTypeName())) {
// 基础类型对应生成一条明细
ContractOtherFieldDO otherFieldDO = new ContractOtherFieldDO();
otherFieldDO.setContractMainId(contractId.toString());
otherFieldDO.setRelativityId(otherFormDOId);
otherFieldDO.setFieldNumber(detailClass.getTypeName());
otherFieldDO.setFieldName(reqFieldDesc);
otherFieldDO.setFieldValue(detailObj.toString());
otherFieldDO.setFieldDescription(reqFieldDesc);
otherFieldDO.setType(detailClass.getTypeName());
saveFields.add(otherFieldDO);
} else {
// 对象类型遍历字段保存对应明细
Field[] detailClassFields = detailClass.getDeclaredFields();
for (Field detailClassField : detailClassFields) {
detailClassField.setAccessible(true);
if (detailClassField.get(detailObj) != null) {
ContractOtherFieldDO otherFieldDO = new ContractOtherFieldDO();
otherFieldDO.setContractMainId(contractId.toString());
otherFieldDO.setRelativityId(otherFormDOId);
otherFieldDO.setFieldNumber(detailClassField.getName());
otherFieldDO.setFieldName(detailClassField.getAnnotation(Schema.class).description());
otherFieldDO.setFieldValue(detailClassField.get(detailObj).toString());
otherFieldDO.setFieldDescription(detailClassField.getAnnotation(Schema.class).description());
otherFieldDO.setType(detailClassField.getType().getName());
saveFields.add(otherFieldDO);
}
}
}
}
}
}
}
// 条款明细表集合批量保存
if (!saveFields.isEmpty()) {
contractOtherFieldMapper.insertBatch(saveFields);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw exception(CONTRACT_PUSH_FAIL, e.getMessage());
}
}
@Override
public CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq) {
@@ -496,7 +509,7 @@ public class ContractApiImpl implements ContractApi {
return CommonResult.success(purchaseOrderDetails);
}
private ContractMainDO getcontractMainDO(IntContract reqVO) {
private ContractMainDO internationalToMainDO(IntContract reqVO) {
// 合同主信息表映射
ContractMainDO contractMainDO = new ContractMainDO();
@@ -575,43 +588,6 @@ public class ContractApiImpl implements ContractApi {
return contractMainDO;
}
private ContractOtherFormDO saveContractOtherForm(Long contractId, String formNumber, String formName, String formDescription) {
ContractOtherFormDO otherFormDO = new ContractOtherFormDO();
otherFormDO.setContractMainId(contractId);
otherFormDO.setFormNumber(formNumber);
otherFormDO.setFormName(formName);
otherFormDO.setFormDescription(formDescription);
contractOtherFormMapper.insert(otherFormDO);
return otherFormDO;
}
private ContractOtherFieldDO getContractOtherField(Long contractId, Long relativityId, String number, String name,
String value, String description, String type) {
ContractOtherFieldDO otherFieldDO = new ContractOtherFieldDO();
otherFieldDO.setContractMainId(contractId.toString());
otherFieldDO.setRelativityId(relativityId);
otherFieldDO.setFieldNumber(number);
otherFieldDO.setFieldName(name);
otherFieldDO.setFieldValue(value);
otherFieldDO.setFieldDescription(description);
otherFieldDO.setType(type);
return otherFieldDO;
}
private <T> void saveFields(Field[] fields, Long contractId, Long relativityId, T obj) throws Exception {
List<ContractOtherFieldDO> otherFieldDOS = new ArrayList<>();
for (Field field : fields) {
field.setAccessible(true);
if (!"java.util.List".equals(field.getType().getName()) && field.get(obj) != null) {
Schema annotation = field.getAnnotation(Schema.class);
otherFieldDOS.add(getContractOtherField(contractId, relativityId, field.getName(),
annotation.description(), field.get(obj).toString(),annotation.description(),
field.getType().getName()));
}
}
contractOtherFieldMapper.insertBatch(otherFieldDOS);
}
private List<PurchaseOrderWithDetailsDTO> getSalesOrdDetailsByIds(List<Long> ids) {
if (ids.isEmpty()) {
return new ArrayList<>();

View File

@@ -26,7 +26,6 @@ import java.util.List;
import static com.zt.plat.framework.common.pojo.CommonResult.error;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_PUSH_FAIL;
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_SUBMIT_ERP_FAIL;
@Slf4j
@@ -197,11 +196,7 @@ public class ContractController implements BusinessControllerMarker {
@Operation(summary = "国贸2.0系统推送合同")
@PreAuthorize("@ss.hasPermission('base:contract:create')")
CommonResult<Boolean> push(@Valid @RequestBody IntContract reqVO) {
try {
return contractApi.push(reqVO);
} catch (Exception e) {
return error(CONTRACT_PUSH_FAIL, e.getMessage());
}
}
@PostMapping("/logistics/list/page")

View File

@@ -61,6 +61,7 @@ public interface PurchaseOrderMapper extends BaseMapperX<PurchaseOrderDO> {
.eqIfPresent(PurchaseOrderDO::getSplyBsnTp, reqVO.getSplyBsnTp() != null ? reqVO.getSplyBsnTp() : "PUR")
.eqIfPresent(PurchaseOrderDO::getCause, reqVO.getCause())
.eqIfPresent(PurchaseOrderDO::getStatus, reqVO.getStatus())
.eqIfPresent(PurchaseOrderDO::getMtrlTp, reqVO.getMtrlTp())
.likeIfPresent(PurchaseOrderDO::getPurchaseGroupName, reqVO.getPurchaseGroupName())
.orderByDesc(PurchaseOrderDO::getId));
}

View File

@@ -921,8 +921,10 @@ public class ContractServiceImpl implements ContractService {
}
// 更新合同主信息
Long instanceId = newContractMainDO.getInstanceId();
newContractMainDO.setInstanceId(null);
contractMainMapper.update(newContractMainDO, new LambdaUpdateWrapper<>(ContractMainDO.class)
.set(ContractMainDO::getInstanceId, newContractMainDO.getInstanceId())
.set(ContractMainDO::getInstanceId, instanceId)
.eq(ContractMainDO::getId, newContractMainDO.getId()));
if (DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(newContractMainDO.getStatus())) {