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

This commit is contained in:
qianshijiang
2025-11-04 16:15:47 +08:00
6 changed files with 161 additions and 97 deletions

View File

@@ -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, "规则模型不存在");

View File

@@ -33,4 +33,10 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
}
String selectMaxCode();
default WarehouseDO selectByCode(String code){
return selectOne(new LambdaQueryWrapperX<WarehouseDO>()
.eq(WarehouseDO::getCoding, code)
.last("LIMIT 1"));
};
}

View File

@@ -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<Long> ids) {
public void deleteWarehouseListByIds(List<Long> ids) {
// 校验存在
validateWarehouseExists(ids);
// 删除
warehouseMapper.deleteByIds(ids);
}
}
private void validateWarehouseExists(List<Long> ids) {
List<WarehouseDO> 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<WarehouseRespVO> saveReqVOS) {
List<WarehouseDO> updateObj = BeanUtils.toBean(saveReqVOS, WarehouseDO.class);
List<BatchResult> count = warehouseMapper.updateById(updateObj);
List<BatchResult> count = warehouseMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) {
throw exception(WAREHOUSE_NOT_EXISTS);
}

View File

@@ -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;
}

View File

@@ -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<ContractMainDO> 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<ContractOtherFormDO> otherFormDOs = contractOtherFormMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFormDO>()
.eq(ContractOtherFormDO::getContractMainId, mainDOId)
);
// 合同动态条款明细查询
List<ContractOtherFieldDO> otherFieldDOs = contractOtherFieldMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFieldDO>()
.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<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));
});
pageResult.getList().forEach(contractMainDO
-> resultList.add(getIntContractByMainId(contractMainDO.getId())));
}
return success(result);
}
/**
* 获取国贸合同信息通过合同主信息ID
*
* @param mainId 同主信息ID
* @return 国贸合同信息
*/
private IntContract getIntContractByMainId(Long mainId) {
// 合同动态条款查询
List<ContractOtherFormDO> otherFormDOs = contractOtherFormMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFormDO>()
.eq(ContractOtherFormDO::getContractMainId, mainId)
);
// 合同动态条款明细查询
List<ContractOtherFieldDO> otherFieldDOs = contractOtherFieldMapper.selectList(
new LambdaQueryWrapperX<ContractOtherFieldDO>()
.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<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);
});
return resultJson.toBean(IntContract.class);
}
@Override
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> 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) {
// 合同主信息表映射

View File

@@ -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<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).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);