修复 销售订单审核 规格问题

This commit is contained in:
yf 2025-10-07 17:21:50 +08:00
parent f68e17ea0e
commit ef41c1b22b
2 changed files with 56 additions and 30 deletions

View File

@ -246,7 +246,11 @@ public class FuncUtil extends StringUtils {
}
public static Double toDouble(Object value, Double defaultValue) {
return value != null ? Double.valueOf(FuncUtil.toStr(value).trim()) : defaultValue;
try {
return value != null ? Double.valueOf(FuncUtil.toStr(value).trim()) : defaultValue;
}catch (Exception var3) {
return defaultValue;
}
}
public static Float toFloat(Object value) {

View File

@ -345,15 +345,15 @@ public class SaleOrderServiceImpl implements SaleOrderService {
if (entrys == null || entrys.isEmpty()) {
throw new ServiceException(001, "产品明细为空");
}
verifySaleContractCodeIsExist(saleOrder,saleContractCode);
verifySaleContractCodeIsExist(saleOrder, saleContractCode);
for (SaleOrderEntryDO entry : entrys) {
Integer qty = entry.getQty();
BigDecimal price = entry.getPrice();
if (price == null){
if (price == null) {
throw new ServiceException(ErrorCodeConstants.SALE_ORDER_ENTRY_PRICE_NOT_NULL);
}
if (qty == null || qty <=0) {
if (qty == null || qty <= 0) {
throw new ServiceException(ErrorCodeConstants.SALE_ORDER_ENTRY_QTY_NOT_NULL);
}
}
@ -442,6 +442,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
/**
* 验证销售合约号是否存在
*
* @param saleOrder
* @param saleContractCode
*/
@ -450,7 +451,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
lambdaQueryWrapper.ne(SaleOrderDO::getId, saleOrder.getId());
lambdaQueryWrapper.eq(SaleOrderDO::getSaleContractCode, saleContractCode);
List<SaleOrderDO> saleOrderDOS = saleOrderMapper.selectList(lambdaQueryWrapper);
if(saleOrderDOS.size()>0){
if (saleOrderDOS.size() > 0) {
throw new ServiceException(001, "销售合约号已重复使用,");
}
}
@ -497,10 +498,10 @@ public class SaleOrderServiceImpl implements SaleOrderService {
saveReqVO.setProduceDate(LocalDateTime.now());
saveReqVO.setInspectionDate(LocalDateTime.now());
saveReqVO.setDeliverydate(LocalDateTime.now());
if(saleOrderSkuDO!=null&&saleOrderSkuDO.size()>0 && 7l == productInfo.getProductTypeId()){
if (saleOrderSkuDO != null && saleOrderSkuDO.size() > 0 && 7l == productInfo.getProductTypeId()) {
String remarks = "";
for (SaleOrderSkuDO orderSkuDO : saleOrderSkuDO) {
remarks = remarks += orderSkuDO.getLabelSize() + " " + orderSkuDO.getOrderQty()+"; ";
remarks = remarks += orderSkuDO.getLabelSize() + " " + orderSkuDO.getOrderQty() + "; ";
}
saveReqVO.setRemarks(remarks);
}
@ -568,7 +569,28 @@ public class SaleOrderServiceImpl implements SaleOrderService {
Double specSizeHeight = productInfo.getSpecSizeHeight();
Double specSizeWidth = productInfo.getSpecSizeWidth();
Double specSizeThk = productInfo.getSpecSizeThk();
String spec = specSizeWidth.doubleValue() + " * " + specSizeHeight.doubleValue() + " " + specSizeThk.doubleValue();
StringBuilder specBuilder = new StringBuilder();
// 处理宽度
Double width = FuncUtil.toDouble(specSizeWidth, 0d);
if (width > 0) {
specBuilder.append(width);
}
Double height = FuncUtil.toDouble(specSizeHeight, 0d);
if ( height > 0) {
if (specBuilder.length() > 0) {
specBuilder.append(" * ");
}
specBuilder.append(height);
}
Double thickness = FuncUtil.toDouble(specSizeThk, 0d);
if (thickness > 0) {
if (specBuilder.length() > 0) {
specBuilder.append(" ");
}
specBuilder.append(thickness);
}
String spec = specBuilder.toString();
int j = i + 1;
context.setVariable("item" + j, j + "");
context.setVariable("explain" + j, code);
@ -764,7 +786,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
Long customerId = order.getCustomerId();
CustomerDO customerDO = customerMapper.selectById(customerId);
String orderFollowerUser = order.getOrderFollowerUser();
if (StringUtils.isNotBlank(orderFollowerUser) && customerDO!=null) {
if (StringUtils.isNotBlank(orderFollowerUser) && customerDO != null) {
AdminUserDO user = adminUserService.getUser(Long.valueOf(orderFollowerUser));
String email = user.getEmail();
MailSendMessage message = new MailSendMessage();
@ -772,7 +794,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
message.setMail(email);
message.setTitle("OMS订单系统");
StringBuffer content = new StringBuffer();
content.append("您好,客户:"+customerDO.getName()+" 来新的订单啦,订单号:" + order.getBillno() + ",下单时间:"+DateUtil.date().toString()+" 请进行处理!");
content.append("您好,客户:" + customerDO.getName() + " 来新的订单啦,订单号:" + order.getBillno() + ",下单时间:" + DateUtil.date().toString() + " 请进行处理!");
message.setContent(content.toString());
mailSendService.doSendMail(message);
}
@ -784,7 +806,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
@Transactional(rollbackFor = Exception.class)
public Long editOrder(Long id, CreateSaleOrderDTO dto) {
SaleOrderDO saleOrderDO = checkEditOrder(id,null);
SaleOrderDO saleOrderDO = checkEditOrder(id, null);
// 校验订单
SaleOrderDO order = new SaleOrderDO(dto);
order.setId(saleOrderDO.getId());
@ -1137,9 +1159,9 @@ public class SaleOrderServiceImpl implements SaleOrderService {
}
@Override
public CreateSaleOrderDTO queryEditOrder(Long id,String type) {
public CreateSaleOrderDTO queryEditOrder(Long id, String type) {
CreateSaleOrderDTO res = new CreateSaleOrderDTO();
SaleOrderDO saleOrderDO = checkEditOrder(id,type);
SaleOrderDO saleOrderDO = checkEditOrder(id, type);
BeanUtil.copyProperties(saleOrderDO, res);
LambdaQueryWrapper<SaleOrderEntryDO> entryQueryWrapper = new LambdaQueryWrapper<>();
entryQueryWrapper.eq(SaleOrderEntryDO::getParentId, saleOrderDO.getId());
@ -1206,23 +1228,23 @@ public class SaleOrderServiceImpl implements SaleOrderService {
queryWrapper.in(SaleOrderEntryDO::getParentId, ids);
queryWrapper.eq(SaleOrderEntryDO::getDeleted, false);
List<SaleOrderEntryDO> entryDOS = saleOrderEntryMapper.selectList(queryWrapper);
if(FuncUtil.isEmpty(entryDOS)){
if (FuncUtil.isEmpty(entryDOS)) {
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
}
List<Long> entryIds = new ArrayList<>();
Map<String,String> codeMap = new HashMap<>();
Map<String, String> codeMap = new HashMap<>();
for (SaleOrderEntryDO entryDO : entryDOS) {
Long materialId = entryDO.getMaterialId();
ProductInfoDO infoDO = productInfoMapper.selectById(materialId);
if(FuncUtil.isNotEmpty(infoDO)){
if (FuncUtil.isNotEmpty(infoDO)) {
String templateType = infoDO.getTemplateType();
if("1".equals(templateType)){
if ("1".equals(templateType)) {
// 有模板物料
entryIds.add(entryDO.getId());
// 获取销售订单
SaleOrderDO saleOrderDO = saleOrderMapper.selectById(entryDO.getParentId());
String code = infoDO.getCode();
if(FuncUtil.isNotEmpty(saleOrderDO)){
if (FuncUtil.isNotEmpty(saleOrderDO)) {
String billno = saleOrderDO.getBillno();
code = billno + "-" + code;
}
@ -1230,7 +1252,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
}
}
}
if(FuncUtil.isEmpty(entryIds)){
if (FuncUtil.isEmpty(entryIds)) {
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
}
// 获取 sku
@ -1238,7 +1260,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
skuWrapper.in(SaleOrderSkuDO::getEntryId, entryIds);
skuWrapper.eq(SaleOrderSkuDO::getDeleted, false);
List<SaleOrderSkuDO> skuDOS = skuOrderSkuMapper.selectList(skuWrapper);
if(FuncUtil.isEmpty(skuDOS)){
if (FuncUtil.isEmpty(skuDOS)) {
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
}
@ -1247,23 +1269,23 @@ public class SaleOrderServiceImpl implements SaleOrderService {
pathUrl = pathUrl.replaceAll("//", "/");
File file1 = new File(pathUrl);
if (!file1.exists()) {
System.out.println("创建目录:"+pathUrl);
System.out.println("创建目录:" + pathUrl);
file1.mkdirs();
}
System.out.println("codeMap"+codeMap);
System.out.println("codeMap" + codeMap);
List<File> files = new ArrayList<>();
List<String> delFiles = new ArrayList<>();
for (SaleOrderSkuDO skuDO : skuDOS) {
String sourceFile = skuDO.getSourceFile();
if(FuncUtil.isNotEmpty(sourceFile)){
if (FuncUtil.isNotEmpty(sourceFile)) {
// 生成文件
Long entryId = skuDO.getEntryId();
String s = FuncUtil.toStr(codeMap.get(entryId.toString()),skuDO.getId().toString());
String s = FuncUtil.toStr(codeMap.get(entryId.toString()), skuDO.getId().toString());
Integer orderQty = skuDO.getOrderQty();
String name = DateUtil.format(LocalDateTime.now(), "yyyyMMdd")
+"-"+IdUtil.simpleUUID().substring(0, 4);
+ "-" + IdUtil.simpleUUID().substring(0, 4);
// 创建文件
String templatePath2 = StrUtil.format(pathUrl + "/{}_{}.html",(s+"_"+orderQty),name);
String templatePath2 = StrUtil.format(pathUrl + "/{}_{}.html", (s + "_" + orderQty), name);
try {
FileUtil.touch(templatePath2);
} catch (Exception e) {
@ -1276,7 +1298,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
delFiles.add(templatePath2);
}
}
if(FuncUtil.isEmpty(files)){
if (FuncUtil.isEmpty(files)) {
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
}
@ -1284,7 +1306,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
// 压缩到的位置
File zipFile = new File(zipFileName);
System.out.println("文件:"+zipFileName);
System.out.println("文件:" + zipFileName);
ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()]));
// 设置响应类型
@ -1345,7 +1367,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
}
}
private SaleOrderDO checkEditOrder(Long id,String type) {
private SaleOrderDO checkEditOrder(Long id, String type) {
SaleOrderDO saleOrderDO = saleOrderMapper.selectById(id);
AssertUtil.isEmpty(saleOrderDO, "订单不存在");
String billStatus = saleOrderDO.getBillStatus();
@ -1353,7 +1375,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
boolean order1 = BillStatusEnum.isCanEditOrder(billStatus);
BillStatusEnum byValue = BillStatusEnum.getByValue(billStatus);
AssertUtil.isEmpty(byValue, "订单状态异常");
if(StringUtils.isBlank(type)){
if (StringUtils.isBlank(type)) {
AssertUtil.isTrue(!order1, byValue.getName() + "状态不允许修改");
}
return saleOrderDO;