国贸2.0系统合同分页查询:查询逻辑修改

This commit is contained in:
guojunyun
2025-11-03 15:45:23 +08:00
parent 57022e04c0
commit 25053c316e

View File

@@ -44,10 +44,9 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays; import java.util.stream.Collectors;
import java.util.Iterator; import java.util.stream.Stream;
import java.util.List;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.framework.common.pojo.CommonResult.success; import static com.zt.plat.framework.common.pojo.CommonResult.success;
@@ -393,55 +392,49 @@ public class ContractApiImpl implements ContractApi {
// 合同ID // 合同ID
Long mainDOId = contractMainDO.getId(); Long mainDOId = contractMainDO.getId();
// 合同主信息 // 合同动态条款查询
List<ContractOtherFieldDO> mainFields = contractOtherFieldMapper.selectList( List<ContractOtherFormDO> otherFormDOs = contractOtherFormMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFieldDO>()
.eq(ContractOtherFieldDO::getContractMainId, mainDOId)
.isNull(ContractOtherFieldDO::getRelativityId)
);
JSONObject resultJson = new JSONObject();
mainFields.forEach(field
-> resultJson.putOnce(field.getFieldNumber(), field.getFieldValue()));
// 附件清单列表
List<ContractOtherFormDO> attachForms = contractOtherFormMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFormDO>() new LambdaQueryWrapperX<ContractOtherFormDO>()
.eq(ContractOtherFormDO::getContractMainId, mainDOId) .eq(ContractOtherFormDO::getContractMainId, mainDOId)
.eq(ContractOtherFormDO::getFormNumber, "attachList")
); );
if (attachForms != null && !attachForms.isEmpty()) { // 合同动态条款明细查询
JSONArray jsonArray = new JSONArray(); List<ContractOtherFieldDO> otherFieldDOs = contractOtherFieldMapper.selectList(
attachForms.forEach(form -> { new LambdaQueryWrapperX<ContractOtherFieldDO>()
ContractOtherFieldDO fieldDO = contractOtherFieldMapper.selectOne( .eq(ContractOtherFieldDO::getContractMainId, mainDOId)
new LambdaQueryWrapperX<ContractOtherFieldDO>() );
.eq(ContractOtherFieldDO::getContractMainId, mainDOId)
.eq(ContractOtherFieldDO::getRelativityId, form.getId())
);
if (fieldDO != null) {
jsonArray.add(fieldDO.getFieldValue());
}
});
if (!jsonArray.isEmpty()) {
resultJson.putOnce("attachList", jsonArray);
}
}
// 客商信息 JSONObject resultJson = new JSONObject();
resultJson.putOnce("partnerList", getQueryFieldJsonArray(mainDOId, "partnerList"));
// 收发港/站点 // 设置主信息
resultJson.putOnce("goodsSiteList", getQueryFieldJsonArray(mainDOId, "goodsSiteList")); otherFieldDOs.stream()
// 货物装卸要求 .filter(otherFieldDO -> otherFieldDO.getRelativityId() == null)
resultJson.putOnce("loadingRequirementsList", getQueryFieldJsonArray(mainDOId, "loadingRequirementsList")); .forEach(otherFieldDO
// 收付款账号 -> resultJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
resultJson.putOnce("accountList", getQueryFieldJsonArray(mainDOId, "accountList"));
// 费用明细 // 设置明细信息
resultJson.putOnce("freightList", getQueryFieldJsonArray(mainDOId, "freightList")); otherFormDOs.stream()
// 服务费用项目 .collect(Collectors.groupingBy(ContractOtherFormDO::getFormNumber))
resultJson.putOnce("serviceFeeList", getQueryFieldJsonArray(mainDOId, "serviceFeeList")); .forEach((key, value) -> {
// 仓库明细 JSONArray detailsJson = new JSONArray();
resultJson.putOnce("storgeList", getQueryFieldJsonArray(mainDOId, "storgeList")); value.forEach(detail -> {
// 接货地址 // 根据条款id筛选条款明细
resultJson.putOnce("receivingAddrList", getQueryFieldJsonArray(mainDOId, "receivingAddrList")); Stream<ContractOtherFieldDO> stream = otherFieldDOs.stream()
.filter(otherFieldDO
-> Objects.equals(otherFieldDO.getRelativityId(), detail.getId()));
if ("attachList".equals(key)) {
// 基础数据类型
stream.forEach(otherFieldDO
-> detailsJson.add(otherFieldDO.getFieldValue()));
} else {
// 对象数据类型
JSONObject detailJson = new JSONObject();
stream.forEach(otherFieldDO
-> detailJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
detailsJson.add(detailJson);
}
});
resultJson.putOnce(key, detailsJson);
});
// 添加到结果集 // 添加到结果集
resultList.add(resultJson.toBean(IntContract.class)); resultList.add(resultJson.toBean(IntContract.class));
@@ -451,33 +444,6 @@ public class ContractApiImpl implements ContractApi {
return success(result); return success(result);
} }
private JSONArray getQueryFieldJsonArray(Long mainDOId, String fieldName) {
JSONArray jsonArray = new JSONArray();
List<ContractOtherFormDO> forms = contractOtherFormMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFormDO>()
.eq(ContractOtherFormDO::getContractMainId, mainDOId)
.eq(ContractOtherFormDO::getFormNumber, fieldName)
);
if (forms != null && !forms.isEmpty()) {
forms.forEach(form -> {
List<ContractOtherFieldDO> fieldDOs = contractOtherFieldMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFieldDO>()
.eq(ContractOtherFieldDO::getContractMainId, mainDOId)
.eq(ContractOtherFieldDO::getRelativityId, form.getId())
);
if (fieldDOs != null && !fieldDOs.isEmpty()) {
JSONObject jsonObject = new JSONObject();
fieldDOs.forEach(field
-> jsonObject.putOnce(field.getFieldNumber(), field.getFieldValue()));
jsonArray.add(jsonObject);
}
});
}
return jsonArray.isEmpty() ? null : jsonArray;
}
@Override @Override
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> ids) { public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> ids) {
if (ids == null || ids.isEmpty()) { if (ids == null || ids.isEmpty()) {