修改审核方法

This commit is contained in:
Mrking 2024-12-14 22:45:18 +08:00
parent c7142816db
commit bdc4983c21
1 changed files with 47 additions and 5 deletions

View File

@ -988,15 +988,17 @@ public class SaleOrderServiceImpl implements SaleOrderService {
private SaleContractSaveReqVO toSaleContractVO(SaleOrderDO saleOrder, List<SaleOrderEntryDO> entrys) {
CustomerDO customer = customerService.getCustomer(saleOrder.getCustomerId());
SaleContractSaveReqVO saveReqVO = new SaleContractSaveReqVO();
// 优先使用销售订单合同号
String billno = saleOrder.getContractCode();
if (FuncUtil.isEmpty(billno)) {
billno = getNewContractCode2();
}
String billno = getNewOrderCode2();
String contractType = saleOrder.getContractType();
if(StringUtils.isNotBlank(contractType)){
billno = billno.replace("XSHY-",contractType+"-");
}
/* // 优先使用销售订单合同号
String billno = saleOrder.getContractCode();
if (FuncUtil.isEmpty(billno)) {
billno = getNewContractCode2();
}*/
saveReqVO.setBillno(billno);
saveReqVO.setCustomerId(saleOrder.getCustomerId());
saveReqVO.setCustomerName(customer.getName());
@ -1176,4 +1178,44 @@ public class SaleOrderServiceImpl implements SaleOrderService {
return saleOrderDO;
}
private String getNewOrderCode2() {
String s = "";
int count = 10;
while (true){
count --;
try {
s = CodingRulesUtils.generateCode(saleContractCodeId, false);
checkCode2(null,s);
return s;
}catch (ServiceException e){
log.warn("重复或者下一个编码");
if(count < 0){
log.error("编码获取失败");
return "";
}
}
}
}
private void checkCode2(Long id,String code){
if(FuncUtil.isNotEmpty(code)){
LambdaQueryWrapper<SaleContractDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(SaleContractDO::getId,SaleContractDO::getBillno, BaseDO::getDeleted);
lambdaQueryWrapper.eq(SaleContractDO::getBillno, code);
lambdaQueryWrapper.eq(SaleContractDO::getDeleted,false);
List<SaleContractDO> dos = saleContractMapper.selectList(lambdaQueryWrapper);
if(FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)){
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
}
if (FuncUtil.isNotEmpty(id) && FuncUtil.isNotEmpty(dos)) {
for (SaleContractDO aDo : dos) {
// 出现重复并当前id 不一致
if(!FuncUtil.equals(aDo.getId(), id)){
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
}
}
}
}
}
}