webcad拆单对图纸id为空的校验优化

This commit is contained in:
gaoqr
2026-02-24 11:54:51 +08:00
parent 79364d8fb1
commit 3fe95953cc
8 changed files with 42 additions and 7 deletions
@@ -134,7 +134,13 @@ public class OrderComponentServiceImpl implements OrderComponentService {
@Override
public List<OrderComponentRespVO> getComponentListOnTopId(OrderDetailComponentListReqVO reqVO) {
Set<Long> componentIds = reqVO.getComponentIds();
if(CollUtil.isEmpty(componentIds)) {
return Collections.emptyList();
}
// 校验订单
Long orderId = reqVO.getOrderId();
OrderDO orderDO = orderMapper.selectById(orderId);
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
// 1、查询部件
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
@@ -172,7 +178,13 @@ public class OrderComponentServiceImpl implements OrderComponentService {
@Override
public PageResult<OrderViewPlatePageRespVO> getViewComponentPage(OrderDetailComponentPageReqVO pageReqVO) {
Set<Long> componentIds = pageReqVO.getComponentIds();
if (CollUtil.isEmpty(componentIds)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
// 校验订单
Long orderId = pageReqVO.getOrderId();
OrderDO orderDO = orderMapper.selectById(orderId);
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
// 1、查询顶级
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
@@ -248,15 +260,26 @@ public class OrderComponentServiceImpl implements OrderComponentService {
return Collections.emptyList();
}
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
// 查询所有板件的视图所需信息
PageDTO<OrderBodyViewPlatesPageDO> page = new PageDTO<>(1, PageParam.PAGE_SIZE_NONE);
IPage<OrderBodyViewPlatesPageDO> viewPlatesPage = orderItemMapper.selectBodyViewPlatesPage(page, orderId, null,
null, componentIds, true);
List<OrderBodyViewPlatesPageDO> records = viewPlatesPage.getRecords();
long total = viewPlatesPage.getTotal();
List<OrderViewPlatePageRespVO> resultList = new ArrayList<>();
if (CollUtil.isNotEmpty(records)) {
resultList = BeanUtil.copyToList(records, OrderViewPlatePageRespVO.class);
if(total > 0) {
resultList = records.stream().map(item -> {
OrderViewPlatePageRespVO vo = new OrderViewPlatePageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
}
return resultList;
}
@@ -24,5 +24,5 @@ public class ErrorCodeConstants {
public static final ErrorCode WEBCAD_ORDER_IMPORT_PEEK_NOT_EXIST_ERROR = new ErrorCode(1_005_000_014, "webcad.order.import.peek.not_exist");
public static final ErrorCode WEBCAD_ORDER_IMPORT_ORDER_UPDATE_CONCURRENCY_ERROR = new ErrorCode(1_005_000_015, "webcad.order.import.order.update.concurrent");
public static final ErrorCode WEBCAD_ORDER_IMPORT_GOODS_UPDATE_CONCURRENCY_ERROR = new ErrorCode(1_005_000_016, "webcad.order.import.goods.update.concurrent");
public static final ErrorCode WEBCAD_ORDER_IMPORT_CAD_VIEW_FILE_ID_EMPTY_ERROR = new ErrorCode(1_005_000_017, "webcad.order.import.cad.view.file.id.empty.error");
}
@@ -3,6 +3,7 @@ package com.cf.imes.module.plan.service.orderImport;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.util.i18n.core.util.I18nUtils;
import com.cf.imes.module.executor.enums.OrderImportStatusEnum;
import com.cf.imes.module.executor.enums.OrderImportTaskStatusEnum;
import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTaskDO;
@@ -26,6 +27,9 @@ public class OrderImportTaskServiceImpl implements OrderImportTaskService {
@Resource
private OrderImportTaskMapper orderImportTaskMapper;
@Resource
private I18nUtils i18nUtils;
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public OrderImportTaskDO confirmOrderImport(Long taskId) {
@@ -61,7 +65,7 @@ public class OrderImportTaskServiceImpl implements OrderImportTaskService {
}
String msg;
if (ex instanceof ServiceException) {
msg = ex.getMessage();
msg = i18nUtils.getMessage(ex.getMessage());
} else {
msg = ORDER_IMPORT_FAIL.getMsg();
}
@@ -9,6 +9,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ErrorCode;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
import com.cf.imes.framework.mq.rabbitmq.constant.RabbitMqConstants;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
@@ -31,6 +32,7 @@ import com.cf.imes.module.plan.dal.mysql.orderBody.OrderBodyMapper;
import com.cf.imes.module.plan.dal.mysql.orderImport.OrderImportTaskMapper;
import com.cf.imes.module.plan.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.plan.dal.mysql.rawgoods.RawGoodsMapper;
import com.cf.imes.module.plan.enums.ErrorCodeConstants;
import com.cf.imes.module.plan.service.customplateno.CustomPlateNoGenerateService;
import com.cf.imes.module.plan.service.order.OrderInputProcessor;
import com.cf.imes.module.plan.service.orderImport.factory.WebCadOrderImportFactory;
@@ -174,6 +176,7 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
// cad图纸文件id
cadViewFileId = webCadDataReqVO.getCadViewFileId();
AssertUtils.notEmpty(cadViewFileId, ErrorCodeConstants.WEBCAD_ORDER_IMPORT_CAD_VIEW_FILE_ID_EMPTY_ERROR);
webCadOrderImportFactory.analyzeTempData(webCadDataReqVO);
} else {
sync = false;
@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ErrorCode;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.mybatis.core.injector.BaseBatchMapper;
@@ -304,6 +305,7 @@ public class WebCadOrderImportAsyncFactory {
break;
case "CadViewFileId":
cadViewFileId = reader.readLong();
AssertUtils.notEmpty(cadViewFileId, ErrorCodeConstants.WEBCAD_ORDER_IMPORT_CAD_VIEW_FILE_ID_EMPTY_ERROR);
break;
case "ComponentGroupTree":
analyzeCadComponentList(reader);
@@ -29,4 +29,5 @@ webcad.order.import.plate_num.threshold.reach=部分导入成功,生产单{}
order.import.plate.goods.no_match=导入失败,板材库中无板材匹配,商品编码:{},商品名称:{},材质:{},颜色:{},厚度:{},品牌:{}
webcad.order.import.peek.not_exist=导入失败:数据源不存在,请检查消息可靠性
webcad.order.import.order.update.concurrent=导入失败:生产单号{}板件数量已发生改变,请重新导入
webcad.order.import.goods.update.concurrent=导入失败:材质{}板件数量已发生改变,请重新导入
webcad.order.import.goods.update.concurrent=导入失败:材质{}板件数量已发生改变,请重新导入
webcad.order.import.cad.view.file.id.empty.error=导入失败:请检查CAD图纸数据是否上传成功
@@ -29,4 +29,5 @@ webcad.order.import.plate_num.threshold.reach=部分匯入成功,生產單{}
order.import.plate.goods.no_match=匯入失敗,板材庫中無板材匹配,商品編碼:{},商品名稱:{},材質:{},顏色:{},厚度:{},品牌:{}
webcad.order.import.peek.not_exist=匯入失敗:資料來源不存在,請檢查訊息可靠性
webcad.order.import.order.update.concurrent=匯入失敗:生產單號{}板件數量已發生變更,請重新匯入
webcad.order.import.goods.update.concurrent=匯入失敗:材質{}板件數量已發生變更,請重新匯入
webcad.order.import.goods.update.concurrent=匯入失敗:材質{}板件數量已發生變更,請重新匯入
webcad.order.import.cad.view.file.id.empty.error=匯入失敗:請檢查CAD圖紙數據是否上傳成功
@@ -29,4 +29,5 @@ webcad.order.import.plate_num.threshold.reach=Partial import succeeded: the numb
order.import.plate.goods.no_match=Import failed: no matching plate found in plate library, product code: {}, product name: {}, material: {}, color: {}, thickness: {}, brand: {}
webcad.order.import.peek.not_exist=Import failed: data source does not exist, please check message reliability
webcad.order.import.order.update.concurrent=Import failed: plate quantity under production order {} has changed, please re-import
webcad.order.import.goods.update.concurrent=Import failed: plate quantity for material {} has changed, please re-import
webcad.order.import.goods.update.concurrent=Import failed: plate quantity for material {} has changed, please re-import
webcad.order.import.cad.view.file.id.empty.error=Import failed: Please check if the CAD drawing data was uploaded successfully