mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增cad三维看图能力相关
This commit is contained in:
+3
-2
@@ -18,6 +18,9 @@ public class WebCadDataReqVO {
|
||||
@JsonProperty(value = "OrderNo")
|
||||
private String orderNo;
|
||||
|
||||
@JsonProperty(value = "CadViewFileId")
|
||||
private Long cadViewFileId;
|
||||
|
||||
@JsonProperty(value = "Materials")
|
||||
private List<WebCadDataMaterialReqVO> Materials;
|
||||
|
||||
@@ -33,6 +36,4 @@ public class WebCadDataReqVO {
|
||||
|
||||
@JsonProperty(value = "Blocks")
|
||||
private List<WebCadDataDoubleRoomTreeReqVO> blocks;
|
||||
|
||||
private String cadViewPath;
|
||||
}
|
||||
|
||||
-5
@@ -157,9 +157,4 @@ public class OrderDO extends BaseDO {
|
||||
* 版本号:乐观锁用
|
||||
*/
|
||||
private int version;
|
||||
|
||||
/**
|
||||
* cad图纸路径
|
||||
*/
|
||||
private String cadViewPath;
|
||||
}
|
||||
|
||||
+5
@@ -301,4 +301,9 @@ public class PlateDO extends BaseDO {
|
||||
* cad图纸数据
|
||||
*/
|
||||
private String cadData;
|
||||
|
||||
/**
|
||||
* cad自定义板编号
|
||||
*/
|
||||
private String cadPlateNo;
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.plan.framework.rpc.config;
|
||||
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.system.api.customplateno.CustomPlateNoSeqApi;
|
||||
import com.cf.imes.module.system.api.dict.DictDataApi;
|
||||
import com.cf.imes.module.system.api.systemconfig.SystemConfigApi;
|
||||
@@ -11,6 +12,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @author there
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {AdminUserApi.class, DictDataApi.class, SystemConfigApi.class, CustomPlateNoSeqApi.class,})
|
||||
@EnableFeignClients(clients = {AdminUserApi.class, DictDataApi.class, SystemConfigApi.class, CustomPlateNoSeqApi.class, FileApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
+28
@@ -21,6 +21,7 @@ import com.cf.imes.module.executor.enums.OrderImportStatusEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderImportTaskStatusEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderImportTypeEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataReqVO;
|
||||
import com.cf.imes.module.plan.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTaskDO;
|
||||
@@ -118,6 +119,9 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
|
||||
@Resource
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
private static final String REDIS_UNIQUEKEY = "webcad";
|
||||
|
||||
@Resource
|
||||
@@ -134,6 +138,8 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
|
||||
Long taskId = null;
|
||||
OrderDO orderDO = null;
|
||||
JsonFactory factory = new JsonFactory();
|
||||
|
||||
Long cadViewFileId = null;
|
||||
try (GZIPInputStream gzipInputStream = new GZIPInputStream(file.getInputStream());
|
||||
JsonParser parser = factory.createParser(gzipInputStream)) {
|
||||
factory.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
|
||||
@@ -165,6 +171,9 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
|
||||
WebCadDataReqVO webCadDataReqVO = mapper.readValue(parser, WebCadDataReqVO.class);
|
||||
WebCadOrderImportFactory webCadOrderImportFactory = new WebCadOrderImportFactory(organId, orderDO, snowFlakeGenerator, orderMapper, orderBodyMapper, plateMapper,
|
||||
idWorker, orderInputProcessor, goodsMapper, rawGoodsMapper, customPlateNoGenerateService, systemConfigApi, webCadImportProperties.getCadImportPlateNumThreshold(), jdbcTemplate);
|
||||
|
||||
// cad图纸文件id
|
||||
cadViewFileId = webCadDataReqVO.getCadViewFileId();
|
||||
webCadOrderImportFactory.analyzeTempData(webCadDataReqVO);
|
||||
} else {
|
||||
sync = false;
|
||||
@@ -190,11 +199,15 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
|
||||
}
|
||||
}
|
||||
} catch (ServiceException se) {
|
||||
// 删除cad图纸数据
|
||||
removeCadFileWhenException(cadViewFileId);
|
||||
// 移除临时文件
|
||||
removeCacheFileWhenException(sync, taskId);
|
||||
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
// 删除cad图纸数据
|
||||
removeCadFileWhenException(cadViewFileId);
|
||||
// 移除临时文件
|
||||
removeCacheFileWhenException(sync, taskId);
|
||||
|
||||
@@ -333,4 +346,19 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除cad图纸文件数据
|
||||
*
|
||||
* @param cadViewFileId
|
||||
*/
|
||||
private void removeCadFileWhenException(Long cadViewFileId) {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(cadViewFileId)) {
|
||||
fileApi.deleteFileById(cadViewFileId);
|
||||
}
|
||||
} catch (IORuntimeException e) {
|
||||
log.error("删除cad图纸数据文件失败: {}", cadViewFileId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -5,17 +5,16 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
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;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.redis.config.ChenfengCacheProperties;
|
||||
import com.cf.imes.framework.redis.constants.RedisKeyConstants;
|
||||
import com.cf.imes.framework.redis.util.RedisLockUtil;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTaskDO;
|
||||
import com.cf.imes.module.plan.dal.mysql.goods.GoodsMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.orderBody.OrderBodyMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.orderGroup.OrderGroupMapper;
|
||||
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;
|
||||
@@ -65,9 +64,6 @@ public class WebCadOrderImportConsumer {
|
||||
@Resource
|
||||
private PlateMapper plateMapper;
|
||||
|
||||
@Resource
|
||||
private OrderGroupMapper orderGroupMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@@ -107,6 +103,9 @@ public class WebCadOrderImportConsumer {
|
||||
@Resource
|
||||
private ChenfengCacheProperties chenfengCacheProperties;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@RabbitListener(queues = "#{@orderImportWebCadQueueName}")
|
||||
@DS("imes_prod")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -150,8 +149,9 @@ public class WebCadOrderImportConsumer {
|
||||
|
||||
log.info("====================【webcad异步拆单处理临时数据开始】====================");
|
||||
WebCadOrderImportAsyncFactory webCadOrderImportAsyncFactory =
|
||||
new WebCadOrderImportAsyncFactory(organId, orderMapper, snowFlakeGenerator, orderBodyMapper, plateMapper, orderGroupMapper, idWorker,
|
||||
orderImportTaskMapper, orderInputProcessor, goodsMapper, rawGoodsMapper, customPlateNoGenerateService, systemConfigApi, orderImportTaskDO.getCreator(), cadImportPlateNumThreshold, jdbcTemplate);
|
||||
new WebCadOrderImportAsyncFactory(organId, orderMapper, snowFlakeGenerator, orderBodyMapper, plateMapper, idWorker,
|
||||
orderImportTaskMapper, orderInputProcessor, goodsMapper, rawGoodsMapper, customPlateNoGenerateService, systemConfigApi, orderImportTaskDO.getCreator(),
|
||||
cadImportPlateNumThreshold, jdbcTemplate, fileApi);
|
||||
webCadOrderImportAsyncFactory.analyzeTempData(taskId, webCadImportProperties.getTempFilePath());
|
||||
log.info("====================【webcad异步拆单处理临时数据结束】====================");
|
||||
|
||||
|
||||
+51
-34
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.plan.service.orderImport.factory;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
@@ -23,6 +24,7 @@ import com.cf.imes.module.executor.enums.DataTypeEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderImportStatusEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderItemTypeEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataBlockRemarkVO;
|
||||
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataBlockReqVO;
|
||||
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataDoubleRoomTreeReqVO;
|
||||
@@ -51,7 +53,6 @@ import com.cf.imes.module.plan.dal.elasticsearch.PointList;
|
||||
import com.cf.imes.module.plan.dal.mysql.goods.GoodsMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.orderBody.OrderBodyMapper;
|
||||
import com.cf.imes.module.plan.dal.mysql.orderGroup.OrderGroupMapper;
|
||||
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;
|
||||
@@ -113,8 +114,6 @@ public class WebCadOrderImportAsyncFactory {
|
||||
|
||||
private PlateMapper plateMapper;
|
||||
|
||||
private OrderGroupMapper orderGroupMapper;
|
||||
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
private OrderImportTaskMapper orderImportTaskMapper;
|
||||
@@ -131,6 +130,8 @@ public class WebCadOrderImportAsyncFactory {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private FileApi fileApi;
|
||||
|
||||
private Long organId;
|
||||
|
||||
// 批次id
|
||||
@@ -202,15 +203,14 @@ public class WebCadOrderImportAsyncFactory {
|
||||
|
||||
private String tempFilePath;
|
||||
|
||||
// cad图纸路径
|
||||
private String cadViewPath;
|
||||
// cad图纸文件id
|
||||
private Long cadViewFileId;
|
||||
|
||||
public WebCadOrderImportAsyncFactory(Long organId,
|
||||
OrderMapper orderMapper,
|
||||
SnowFlakeGenerator snowFlakeGenerator,
|
||||
OrderBodyMapper orderBodyMapper,
|
||||
PlateMapper plateMapper,
|
||||
OrderGroupMapper orderGroupMapper,
|
||||
SnowflakeIdWorker3rd idWorker,
|
||||
OrderImportTaskMapper orderImportTaskMapper,
|
||||
OrderInputProcessor orderInputProcessor,
|
||||
@@ -220,13 +220,13 @@ public class WebCadOrderImportAsyncFactory {
|
||||
SystemConfigApi systemConfigApi,
|
||||
String operatorName,
|
||||
int cadImportPlateNumThreshold,
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcTemplate jdbcTemplate,
|
||||
FileApi fileApi) {
|
||||
this.organId = organId;
|
||||
this.orderMapper = orderMapper;
|
||||
this.snowFlakeGenerator = snowFlakeGenerator;
|
||||
this.orderBodyMapper = orderBodyMapper;
|
||||
this.plateMapper = plateMapper;
|
||||
this.orderGroupMapper = orderGroupMapper;
|
||||
this.idWorker = idWorker;
|
||||
this.orderImportTaskMapper = orderImportTaskMapper;
|
||||
this.orderInputProcessor = orderInputProcessor;
|
||||
@@ -240,6 +240,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
sealEdgeConfigList = new ArrayList<>();
|
||||
this.cadImportPlateNumThreshold = cadImportPlateNumThreshold;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.fileApi = fileApi;
|
||||
}
|
||||
|
||||
public void analyzeTempData(Long taskId, String webcadJsonCachePath) throws FileNotFoundException {
|
||||
@@ -254,6 +255,9 @@ public class WebCadOrderImportAsyncFactory {
|
||||
|
||||
performPostProcessing(taskId);
|
||||
} catch (Exception e) {
|
||||
// 删除cad图纸数据
|
||||
removeCadFileWhenException(cadViewFileId);
|
||||
|
||||
handleProcessingException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
@@ -272,9 +276,6 @@ public class WebCadOrderImportAsyncFactory {
|
||||
analyzeOrder(reader.readString());
|
||||
log.debug("====================【cad拆单解析生产单结束】====================");
|
||||
break;
|
||||
case "cadViewPath":
|
||||
cadViewPath = reader.readString();
|
||||
break;
|
||||
case "Materials":
|
||||
log.debug("====================【cad拆单解析板材开始】====================");
|
||||
analyzeMaterials(reader);
|
||||
@@ -296,6 +297,9 @@ public class WebCadOrderImportAsyncFactory {
|
||||
case "Parts":
|
||||
processParts(reader);
|
||||
break;
|
||||
case "CadViewFileId":
|
||||
cadViewFileId = reader.readLong();
|
||||
break;
|
||||
default:
|
||||
// 跳过未知字段
|
||||
reader.readObject();
|
||||
@@ -434,7 +438,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
.eq("deleted", false));
|
||||
if (CollUtil.isNotEmpty(orderPlateSumResult)) {
|
||||
Map<String, Object> resultMap = orderPlateSumResult.get(0);
|
||||
if(ObjectUtil.isNotNull(resultMap)) {
|
||||
if (ObjectUtil.isNotNull(resultMap)) {
|
||||
currentPlateArea = (BigDecimal) resultMap.get("area");
|
||||
}
|
||||
}
|
||||
@@ -623,7 +627,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
reader.startObject();
|
||||
String roomName = null;
|
||||
Long roomId = null;
|
||||
|
||||
|
||||
while (reader.hasNext()) {
|
||||
String key = reader.readString();
|
||||
if ("name".equals(key)) {
|
||||
@@ -646,7 +650,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
if (existRoomId != null) {
|
||||
return existRoomId;
|
||||
}
|
||||
|
||||
|
||||
Long roomId = queryExistingRoomId(roomName);
|
||||
if (roomId == null) {
|
||||
roomId = (Long) snowFlakeGenerator.nextId(null);
|
||||
@@ -660,15 +664,15 @@ public class WebCadOrderImportAsyncFactory {
|
||||
*/
|
||||
private Long queryExistingRoomId(String roomName) {
|
||||
List<Long> existRoomIds = orderBodyMapper.selectList(new LambdaQueryWrapper<OrderBodyDO>()
|
||||
.select(OrderBodyDO::getRoomId)
|
||||
.eq(OrderBodyDO::getOrderId, orderId)
|
||||
.eq(OrderBodyDO::getOrganId, organId)
|
||||
.eq(OrderBodyDO::getDeleted, false)
|
||||
.eq(OrderBodyDO::getRoomName, roomName))
|
||||
.select(OrderBodyDO::getRoomId)
|
||||
.eq(OrderBodyDO::getOrderId, orderId)
|
||||
.eq(OrderBodyDO::getOrganId, organId)
|
||||
.eq(OrderBodyDO::getDeleted, false)
|
||||
.eq(OrderBodyDO::getRoomName, roomName))
|
||||
.stream()
|
||||
.map(OrderBodyDO::getRoomId)
|
||||
.toList();
|
||||
|
||||
|
||||
return CollUtil.isNotEmpty(existRoomIds) ? existRoomIds.get(0) : null;
|
||||
}
|
||||
|
||||
@@ -1390,11 +1394,10 @@ public class WebCadOrderImportAsyncFactory {
|
||||
// 配置不为空时,生成自定义板编号
|
||||
if (ObjectUtil.isNotNull(plateNoGenerateConfigVO)) {
|
||||
customPlateNoGenerateService.generateCustomPlateNo(orderId, plateDO, plateNoGenerateConfigVO, isFirstPlate);
|
||||
} else {
|
||||
// 配置为空的时候,使用cad的板编号
|
||||
if (ObjectUtil.isNotNull(cadCustBlockNo)) {
|
||||
plateDO.setCustomPlateNo(String.valueOf(cadCustBlockNo));
|
||||
}
|
||||
}
|
||||
// cad的板编号
|
||||
if (ObjectUtil.isNotNull(cadCustBlockNo)) {
|
||||
plateDO.setCadPlateNo(String.valueOf(cadCustBlockNo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1419,7 +1422,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
reader.startObject();
|
||||
String roomName = null;
|
||||
Long roomId = null;
|
||||
|
||||
|
||||
while (reader.hasNext()) {
|
||||
String key = reader.readString();
|
||||
if ("name".equals(key)) {
|
||||
@@ -1849,7 +1852,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
private void orderPlateBatchInsertWithinThreshold(List<PlateDO> list, boolean isLast) {
|
||||
// 达到批量的阈值就做一次插入
|
||||
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
|
||||
String sql = "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_view_id, cad_data) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
String sql = "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_view_id, cad_data, cad_plate_no) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int index) throws SQLException {
|
||||
@@ -1922,8 +1925,8 @@ public class WebCadOrderImportAsyncFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPlate(){
|
||||
plateDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
private void clearPlate() {
|
||||
plateDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
}
|
||||
|
||||
private void orderItemBatchInsertWithinThreshold(List<OrderItemDO> list, boolean isLast) {
|
||||
@@ -1966,8 +1969,8 @@ public class WebCadOrderImportAsyncFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearItem(){
|
||||
orderItemDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
private void clearItem() {
|
||||
orderItemDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
}
|
||||
|
||||
private void orderPartBatchInsertWithinThreshold(List<OrderPartsDO> list, boolean isLast) {
|
||||
@@ -2021,8 +2024,8 @@ public class WebCadOrderImportAsyncFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPart(){
|
||||
orderPartsDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
private void clearPart() {
|
||||
orderPartsDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2215,7 +2218,6 @@ public class WebCadOrderImportAsyncFactory {
|
||||
.eq(OrderDO::getVersion, version)
|
||||
.set(OrderDO::getPlateNum, currentPlateNum)
|
||||
.set(OrderDO::getArea, currentPlateArea)
|
||||
.set(OrderDO::getCadViewPath, cadViewPath)
|
||||
.set(OrderDO::getVersion, version + 1));
|
||||
if (updated == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_UPDATE_CONCURRENCY_ERROR, orderId);
|
||||
@@ -2255,4 +2257,19 @@ public class WebCadOrderImportAsyncFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除cad图纸文件数据
|
||||
*
|
||||
* @param cadViewFileId
|
||||
*/
|
||||
private void removeCadFileWhenException(Long cadViewFileId) {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(cadViewFileId)) {
|
||||
fileApi.deleteFileById(cadViewFileId);
|
||||
}
|
||||
} catch (IORuntimeException e) {
|
||||
log.error("删除cad图纸数据文件失败: {}", cadViewFileId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-10
@@ -189,6 +189,9 @@ public class WebCadOrderImportFactory {
|
||||
// 板件数量是否已达到阈值
|
||||
private boolean plateNumReachThreshold = false;
|
||||
|
||||
// cad图纸文件id
|
||||
private Long cadViewFileId;
|
||||
|
||||
public WebCadOrderImportFactory(Long organId,
|
||||
OrderDO orderDO,
|
||||
SnowFlakeGenerator snowFlakeGenerator,
|
||||
@@ -258,7 +261,9 @@ public class WebCadOrderImportFactory {
|
||||
|
||||
orderItemBatchInsertWithinThreshold(orderItemDOS, true);
|
||||
log.debug("====================【cad拆单全局保存开始】====================");
|
||||
|
||||
// 保存数据柜体、加工组
|
||||
cadViewFileId = webCadDataReqVO.getCadViewFileId();
|
||||
saveData();
|
||||
log.debug("====================【cad拆单全局保存结束】====================");
|
||||
|
||||
@@ -266,7 +271,7 @@ public class WebCadOrderImportFactory {
|
||||
insertOrUpdatePlateNumGoods();
|
||||
|
||||
// 更新生产单板件数量
|
||||
updateOrderPlateNum(webCadDataReqVO.getCadViewPath());
|
||||
updateOrderPlateNum();
|
||||
|
||||
// 所有自定义板编号生成完成后更新配置到生产单
|
||||
customPlateNoGenerateService.updateCustomPlateNoGenerateConfig(plateNoGenerateConfigVO, orderDO);
|
||||
@@ -1158,11 +1163,10 @@ public class WebCadOrderImportFactory {
|
||||
// 配置不为空时,生成自定义板编号
|
||||
if (ObjectUtil.isNotNull(plateNoGenerateConfigVO)) {
|
||||
customPlateNoGenerateService.generateCustomPlateNo(orderId, plateDO, plateNoGenerateConfigVO, isFirstPlate);
|
||||
} else {
|
||||
// 配置为空的时候,使用cad的板编号
|
||||
if (ObjectUtil.isNotNull(cadCustBlockNo)) {
|
||||
plateDO.setCustomPlateNo(String.valueOf(cadCustBlockNo));
|
||||
}
|
||||
}
|
||||
// cad的板编号
|
||||
if (ObjectUtil.isNotNull(cadCustBlockNo)) {
|
||||
plateDO.setCadPlateNo(String.valueOf(cadCustBlockNo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1700,7 +1704,7 @@ public class WebCadOrderImportFactory {
|
||||
private void orderPlateBatchInsertWithinThreshold(List<PlateDO> list, boolean isLast) {
|
||||
// 达到批量的阈值就做一次插入
|
||||
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
|
||||
String sql = "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_view_id, cad_data) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
String sql = "INSERT INTO order_plate (id,organ_id,order_id,name,plate_no,type,goods_id,width,height,thickness,split_width,split_height,split_thickness,seal_left,seal_right,seal_up,seal_down,area,texture,hole_face,hole_arrange,unregular_point_count,front_hole_count,back_hole_count,side_hole_count,front_model_count,back_model_count,is_door,open_door_type,offset_x,offset_y,is_arc_across,module_type_id,is_special_shaped,is_sculpt,is_side_sculpt,is_2v,is_side_2v,is_row_hole,is_optimized,is_cutted,filter_type,remark,is_cancel,deleted,custom_plate_no,create_time,update_time,creator,updater, cad_view_id, cad_data, cad_plate_no) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int index) throws SQLException {
|
||||
@@ -1757,6 +1761,7 @@ public class WebCadOrderImportFactory {
|
||||
ps.setString(50, item.getUpdater());
|
||||
ps.setInt(51, item.getCadViewId());
|
||||
ps.setString(52, item.getCadData());
|
||||
ps.setString(53, item.getCadPlateNo());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1914,7 +1919,7 @@ public class WebCadOrderImportFactory {
|
||||
*/
|
||||
private void saveBody(List<List<OrderBodyDO>> bodyList) {
|
||||
for (List<OrderBodyDO> bodys : bodyList) {
|
||||
String sql = "INSERT INTO order_body (id, organ_id, order_id, room_id, room_name, name, width, height, depth, multi_num, plate_num, unregular_num, filename, remark, deleted,create_time,update_time,creator,updater) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String sql = "INSERT INTO order_body (id, organ_id, order_id, room_id, room_name, name, width, height, depth, multi_num, plate_num, unregular_num, filename, remark, deleted,create_time,update_time,creator,updater, cad_view_file_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int index) throws SQLException {
|
||||
@@ -1938,6 +1943,7 @@ public class WebCadOrderImportFactory {
|
||||
ps.setTimestamp(17, Timestamp.valueOf(orderBodyDO.getUpdateTime()));
|
||||
ps.setString(18, orderBodyDO.getCreator());
|
||||
ps.setString(19, orderBodyDO.getUpdater());
|
||||
ps.setLong(20, cadViewFileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2016,7 +2022,7 @@ public class WebCadOrderImportFactory {
|
||||
/**
|
||||
* 更新生产单的板件总数
|
||||
*/
|
||||
private void updateOrderPlateNum(String cadViewPath) {
|
||||
private void updateOrderPlateNum() {
|
||||
int version = orderDO.getVersion();
|
||||
Long orderId = orderDO.getId();
|
||||
int updated = orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
|
||||
@@ -2025,7 +2031,6 @@ public class WebCadOrderImportFactory {
|
||||
.eq(OrderDO::getVersion, version)
|
||||
.set(OrderDO::getPlateNum, currentPlateNum)
|
||||
.set(OrderDO::getArea, currentPlateArea)
|
||||
.set(OrderDO::getCadViewPath, cadViewPath)
|
||||
.set(OrderDO::getVersion, version + 1));
|
||||
if (updated == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_UPDATE_CONCURRENCY_ERROR, orderId);
|
||||
|
||||
Reference in New Issue
Block a user