From 94313a6f57c218b52f33c9f91f03fe9146ea885c Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Mon, 3 Nov 2025 17:12:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E-erp=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=BC=96=E7=A0=81=E4=BC=98=E5=8C=96=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8A=9B=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/base/enums/ErrorCodeConstants.java | 21 +++++------ .../base/dal/mysql/base/WarehouseMapper.java | 6 ++++ .../service/base/WarehouseServiceImpl.java | 35 ++++++++++++------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java index a15b0ee8..94fdeab9 100644 --- a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java +++ b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/enums/ErrorCodeConstants.java @@ -10,16 +10,17 @@ import com.zt.plat.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { // ========== 示例模块 1-001-000-000 ========== - ErrorCode MATERIAL_OTHER_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode ELEMENT_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode MATERIAL_DESTROY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode COMPANY_RELATIVITY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode FACTORY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); - ErrorCode TAX_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在"); + ErrorCode MATERIAL_OTHER_NOT_EXISTS = new ErrorCode(1_001_000_001, "物料不存在"); + ErrorCode ELEMENT_NOT_EXISTS = new ErrorCode(1_001_000_001, "金属元素不存在"); + ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_001_000_001, "联系人不存在"); + ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_001_000_001, "账户条款不存在"); + ErrorCode MATERIAL_DESTROY_NOT_EXISTS = new ErrorCode(1_001_000_001, "物料回收率不存在"); + ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_001_000_001, "物料信息不存在"); + ErrorCode COMPANY_RELATIVITY_NOT_EXISTS = new ErrorCode(1_001_000_001, "公司关系不存在"); + ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_001_000_001, "库位不存在"); + ErrorCode WAREHOUSE_CODE_EXISTS = new ErrorCode(1_001_000_002, "库位编码已存在"); + ErrorCode FACTORY_NOT_EXISTS = new ErrorCode(1_001_000_001, "工厂不存在"); + ErrorCode TAX_NOT_EXISTS = new ErrorCode(1_001_000_001, "公司关系不存在"); ErrorCode BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_027_100_001, "规则模型不存在"); diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/WarehouseMapper.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/WarehouseMapper.java index e6ae7530..c449a9c3 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/WarehouseMapper.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/base/WarehouseMapper.java @@ -33,4 +33,10 @@ public interface WarehouseMapper extends BaseMapperX { } String selectMaxCode(); + + default WarehouseDO selectByCode(String code){ + return selectOne(new LambdaQueryWrapperX() + .eq(WarehouseDO::getCoding, code) + .last("LIMIT 1")); + }; } \ No newline at end of file diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/WarehouseServiceImpl.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/WarehouseServiceImpl.java index ca7f5e62..a4cd1f59 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/WarehouseServiceImpl.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/base/WarehouseServiceImpl.java @@ -16,6 +16,7 @@ import org.springframework.validation.annotation.Validated; import java.util.List; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.zt.plat.module.base.enums.ErrorCodeConstants.WAREHOUSE_CODE_EXISTS; import static com.zt.plat.module.base.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; /** @@ -35,16 +36,17 @@ public class WarehouseServiceImpl implements WarehouseService { // 插入 WarehouseDO warehouse = BeanUtils.toBean(createReqVO, WarehouseDO.class); // 库位编码自动生成,格式 KW-0001,依次新增 - String maxCode = warehouseMapper.selectMaxCode(); - if (maxCode == null) { - warehouse.setCoding("KW-0001"); - } else { - String prefix = "KW-"; - String numberPart = maxCode.substring(prefix.length()); - int nextNumber = Integer.parseInt(numberPart) + 1; - String nextCode = prefix + String.format("%04d", nextNumber); - warehouse.setCoding(nextCode); - } +// String maxCode = warehouseMapper.selectMaxCode(); +// if (maxCode == null) { +// warehouse.setCoding("KW-0001"); +// } else { +// String prefix = "KW-"; +// String numberPart = maxCode.substring(prefix.length()); +// int nextNumber = Integer.parseInt(numberPart) + 1; +// String nextCode = prefix + String.format("%04d", nextNumber); +// warehouse.setCoding(nextCode); +// } + validateWarehouseCodeExists(warehouse.getCoding()); warehouseMapper.insert(warehouse); // 返回 return BeanUtils.toBean(warehouse, WarehouseRespVO.class); @@ -68,12 +70,12 @@ public class WarehouseServiceImpl implements WarehouseService { } @Override - public void deleteWarehouseListByIds(List ids) { + public void deleteWarehouseListByIds(List ids) { // 校验存在 validateWarehouseExists(ids); // 删除 warehouseMapper.deleteByIds(ids); - } + } private void validateWarehouseExists(List ids) { List list = warehouseMapper.selectByIds(ids); @@ -88,6 +90,13 @@ public class WarehouseServiceImpl implements WarehouseService { } } + private void validateWarehouseCodeExists(String code) { + WarehouseDO warehouse = warehouseMapper.selectByCode(code); + if (warehouse != null) { + throw exception(WAREHOUSE_CODE_EXISTS); + } + } + @Override public WarehouseDO getWarehouse(Long id) { return warehouseMapper.selectById(id); @@ -101,7 +110,7 @@ public class WarehouseServiceImpl implements WarehouseService { @Override public void enableWarehouseList(List saveReqVOS) { List updateObj = BeanUtils.toBean(saveReqVOS, WarehouseDO.class); - List count = warehouseMapper.updateById(updateObj); + List count = warehouseMapper.updateById(updateObj); if (CollUtil.isEmpty(count)) { throw exception(WAREHOUSE_NOT_EXISTS); } From c6a19b93b943cbe5dac0e611d32e35b7fbd25bc2 Mon Sep 17 00:00:00 2001 From: liss <1780094091@qq.com> Date: Mon, 3 Nov 2025 17:51:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?BUG-erp=E5=BA=93=E4=BD=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8=E6=8A=9B?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/erp/ErpWarehouseServiceImpl.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpWarehouseServiceImpl.java b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpWarehouseServiceImpl.java index 129e3a9b..7b41adfe 100644 --- a/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpWarehouseServiceImpl.java +++ b/zt-module-erp/zt-module-erp-server/src/main/java/com/zt/plat/module/erp/service/erp/ErpWarehouseServiceImpl.java @@ -22,10 +22,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -56,18 +53,18 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService { // 插入 ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class); // 库位编码自动生成,格式 KW-0001,依次新增 - if (warehouse.getNumber() == null) { - String maxCode = erpWarehouseMapper.selectMaxCode(); - if (maxCode == null) { - warehouse.setNumber("KW-0001"); - } else { - String prefix = "KW-"; - String numberPart = maxCode.substring(prefix.length()); - int nextNumber = Integer.parseInt(numberPart) + 1; - String nextCode = prefix + String.format("%04d", nextNumber); - warehouse.setNumber(nextCode); - } - } +// if (warehouse.getNumber() == null) { +// String maxCode = erpWarehouseMapper.selectMaxCode(); +// if (maxCode == null) { +// warehouse.setNumber("KW-0001"); +// } else { +// String prefix = "KW-"; +// String numberPart = maxCode.substring(prefix.length()); +// int nextNumber = Integer.parseInt(numberPart) + 1; +// String nextCode = prefix + String.format("%04d", nextNumber); +// warehouse.setNumber(nextCode); +// } +// } warehouse.setType("SPLY"); warehouse.setIsEnable("1"); erpWarehouseMapper.insert(warehouse); @@ -120,7 +117,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService { private void validateErpFactoryExistsNumber(String number, String factoryNumber) { List list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX()).stream() .filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number)) - .filter(erpWarehouseDO -> erpWarehouseDO.getFactoryNumber().equals(factoryNumber)) + .filter(erpWarehouseDO -> Objects.equals(erpWarehouseDO.getFactoryNumber(), factoryNumber)) .toList(); if (!list.isEmpty()) { throw exception(ERP_WAREHOUSE_EXISTS); From bb96b9b6dd674793e03ec476e4e4bb7cd0c7d8dc Mon Sep 17 00:00:00 2001 From: guojunyun Date: Tue, 4 Nov 2025 15:30:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=9B=BD=E8=B4=B82.0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=90=88=E5=90=8C=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=EF=BC=9A?= =?UTF-8?q?=E5=90=88=E5=90=8C=E6=9C=89=E6=95=88=E6=9C=9F=E8=B5=B7=E3=80=81?= =?UTF-8?q?=E5=90=88=E5=90=8C=E6=9C=89=E6=95=88=E6=9C=9F=E6=AD=A2=E3=80=81?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6=E5=9C=B0=E3=80=81=E7=AD=BE=E7=BA=A6=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=EF=BC=9B=E5=8E=BB=E9=99=A4=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=EF=BC=9A=E5=90=88=E5=90=8C=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../international/IntContractPageReq.java | 20 ++- .../contractorder/api/ContractApiImpl.java | 145 +++++++++++------- 2 files changed, 108 insertions(+), 57 deletions(-) diff --git a/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/api/vo/contract/international/IntContractPageReq.java b/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/api/vo/contract/international/IntContractPageReq.java index abddecab..477b8012 100644 --- a/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/api/vo/contract/international/IntContractPageReq.java +++ b/zt-module-contract-order/zt-module-contract-order-api/src/main/java/com/zt/plat/module/contractorder/api/vo/contract/international/IntContractPageReq.java @@ -6,8 +6,24 @@ import lombok.Data; @Data public class IntContractPageReq extends PageParam { - @Schema(description = "合同编号") - private String contractCode; + + // 合同名称:模糊搜索 @Schema(description = "合同名称") private String contractName; + // 合同有效期起:日期选择 + @Schema(description = "合同有效期起") + private String contractStartDate; + // 合同有效期止:日期选择 + @Schema(description = "合同有效期止") + private String contractEndDate; + // 合同版本号:精确搜索 TODO 不确定 + // 签约地:模糊搜索 + @Schema(description = "签约地") + private String signSite; + // 经办人姓名:模糊搜索 + @Schema(description = "经办人姓名") + private String createdUserName; + // 签约日期: 模糊搜索 + @Schema(description = "签约日期") + private String signDate; } diff --git a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/api/ContractApiImpl.java b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/api/ContractApiImpl.java index 3b68e79c..fde683fb 100644 --- a/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/api/ContractApiImpl.java +++ b/zt-module-contract-order/zt-module-contract-order-server/src/main/java/com/zt/plat/module/contractorder/api/ContractApiImpl.java @@ -42,7 +42,9 @@ import org.springframework.web.bind.annotation.RestController; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -250,6 +252,12 @@ public class ContractApiImpl implements ContractApi { return success(true); } + /** + * 国贸合同信息未映射合同主信息字段保存到动态条款 + * + * @param reqVO 国贸合同信息 + * @param contractId 合同主信息ID + */ private void saveIntContractFields(IntContract reqVO, Long contractId) { try { @@ -370,10 +378,28 @@ public class ContractApiImpl implements ContractApi { DictEnum.SPLY_BSN_TP_03BX.getCode() ) ); - // 合同编号 - queryWrapperX.likeIfPresent(ContractMainDO::getContractPaperNumber, pageReq.getContractCode()); - // 合同名称 + // 合同名称:模糊搜索 queryWrapperX.likeIfPresent(ContractMainDO::getContractName, pageReq.getContractName()); + // 合同有效期起:日期选择 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); + queryWrapperX.geIfPresent(ContractMainDO::getStartDate, + pageReq.getContractStartDate() != null + ? LocalDateTime.of(LocalDate.parse(pageReq.getContractStartDate(), formatter), LocalTime.MIN) + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + : null); + // 合同有效期止:日期选择 + queryWrapperX.leIfPresent(ContractMainDO::getEndDate, + pageReq.getContractEndDate() != null + ? LocalDateTime.of(LocalDate.parse(pageReq.getContractEndDate(), formatter), LocalTime.MAX) + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + : null); + // 签约地:模糊搜索 + queryWrapperX.likeIfPresent(ContractMainDO::getSignPlace, pageReq.getSignSite()); + // 经办人姓名:模糊搜索 + // 签约日期: 模糊搜索 + if (pageReq.getSignDate() != null) { + queryWrapperX.apply("to_char(SGN_DT, 'yyyymmdd') like concat('%',{0},'%')", pageReq.getSignDate()); + } // 查询 PageResult pageResult = contractMainMapper.selectPage(pageReq, queryWrapperX); @@ -387,63 +413,66 @@ public class ContractApiImpl implements ContractApi { // 遍历查询结果,设置返回数据列表 if (pageResult.getTotal() > 0) { - pageResult.getList().forEach(contractMainDO -> { - - // 合同ID - Long mainDOId = contractMainDO.getId(); - - // 合同动态条款查询 - List otherFormDOs = contractOtherFormMapper.selectList( - new LambdaQueryWrapperX() - .eq(ContractOtherFormDO::getContractMainId, mainDOId) - ); - // 合同动态条款明细查询 - List otherFieldDOs = contractOtherFieldMapper.selectList( - new LambdaQueryWrapperX() - .eq(ContractOtherFieldDO::getContractMainId, mainDOId) - ); - - JSONObject resultJson = new JSONObject(); - - // 设置主信息 - otherFieldDOs.stream() - .filter(otherFieldDO -> otherFieldDO.getRelativityId() == null) - .forEach(otherFieldDO - -> resultJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue())); - - // 设置明细信息 - otherFormDOs.stream() - .collect(Collectors.groupingBy(ContractOtherFormDO::getFormNumber)) - .forEach((key, value) -> { - JSONArray detailsJson = new JSONArray(); - value.forEach(detail -> { - // 根据条款id筛选条款明细 - Stream 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)); - }); + pageResult.getList().forEach(contractMainDO + -> resultList.add(getIntContractByMainId(contractMainDO.getId()))); } return success(result); } + /** + * 获取国贸合同信息通过合同主信息ID + * + * @param mainId 同主信息ID + * @return 国贸合同信息 + */ + private IntContract getIntContractByMainId(Long mainId) { + // 合同动态条款查询 + List otherFormDOs = contractOtherFormMapper.selectList( + new LambdaQueryWrapperX() + .eq(ContractOtherFormDO::getContractMainId, mainId) + ); + // 合同动态条款明细查询 + List otherFieldDOs = contractOtherFieldMapper.selectList( + new LambdaQueryWrapperX() + .eq(ContractOtherFieldDO::getContractMainId, mainId) + ); + + JSONObject resultJson = new JSONObject(); + + // 设置主信息 + otherFieldDOs.stream() + .filter(otherFieldDO -> otherFieldDO.getRelativityId() == null) + .forEach(otherFieldDO + -> resultJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue())); + + // 设置明细信息 + otherFormDOs.stream() + .collect(Collectors.groupingBy(ContractOtherFormDO::getFormNumber)) + .forEach((key, value) -> { + JSONArray detailsJson = new JSONArray(); + value.forEach(detail -> { + // 根据条款id筛选条款明细 + Stream 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); + }); + return resultJson.toBean(IntContract.class); + } + @Override public CommonResult> getOrderByOrderIds(List ids) { if (ids == null || ids.isEmpty()) { @@ -475,6 +504,12 @@ public class ContractApiImpl implements ContractApi { return CommonResult.success(purchaseOrderDetails); } + /** + * 国贸合同信息映射到合同主信息 + * + * @param reqVO 国贸合同信息 + * @return 合同主信息 + */ private ContractMainDO internationalToMainDO(IntContract reqVO) { // 合同主信息表映射