1、新增cad同步异步拆单接入部件;2、新增订单详情部件列表、cad视图列表、部件板件分页、部件cad板件列表接口;

This commit is contained in:
gaoqr
2026-02-02 17:48:53 +08:00
parent 018a710036
commit 5dddcc1606
27 changed files with 1128 additions and 209 deletions
@@ -95,6 +95,9 @@ public class WebCadDataBlockReqVO {
private List<Integer> groupIds = new ArrayList<>();
// 组件id
private Integer componentId;
public void setIsSpecialShape(boolean specialShape) {
isSpecialShape = specialShape;
}
@@ -0,0 +1,56 @@
package com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author Gqr
* @since 2026/1/29 15:18
*/
@NoArgsConstructor
@Schema(description = "管理后台 - webcad部件分组 - RequestVO")
@Data
public class WebCadDataComponentGroupReqVO {
/**
* 组ID
*/
@JsonProperty("groupID")
private Integer groupId;
/**
* 部件名称
*/
private String name;
@Valid
private BoxSizeDTO boxSize = new BoxSizeDTO();
@Valid
private List<WebCadDataComponentGroupReqVO> children = new ArrayList<>();
@NoArgsConstructor
@Data
public static class BoxSizeDTO {
@Max(value = 99999, message = "部件宽度不能超过99999")
@Min(value = 0, message = "部件宽度最小值为0")
private Double width;
@Max(value = 99999, message = "部件高度不能超过99999")
@Min(value = 0, message = "部件高度最小值为0")
private Double height;
@Max(value = 99999, message = "部件深度不能超过99999")
@Min(value = 0, message = "部件深度最小值为0")
private Double depth;
}
}
@@ -31,6 +31,10 @@ public class WebCadDataReqVO {
@Valid
private List<WebCadDataProcessGroupReqVO> ProcessGroup;
@JsonProperty(value = "ComponentGroupTree")
@Valid
private List<WebCadDataComponentGroupReqVO> ComponentGroup;
@Valid
private List<WebCadDataDoubleRoomTreeReqVO> douleRoomTree;
@@ -0,0 +1,111 @@
package com.cf.imes.module.plan.dal.dataobject.ordecomponent;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* 贴皮表 order_component_{N} DO
*
* @author Gqr
* @since 2026/1/27 14:00
*/
@TableName(value = "order_component", autoResultMap = true)
@KeySequence("order_component_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderComponentDO extends BaseDO {
public static final Long PARENT_ID_ROOT = 0L;
/**
* 主键
*/
private Long id;
/**
* 订单id
*/
private Long orderId;
/**
* 组织id
*/
private Long organId;
/**
* 柜体id
*/
private Long bodyId;
/**
* 房间id
*/
@TableField(exist = false)
private Long roomId;
/**
* 父id
*/
private Long pid;
/**
* 顶级id
*/
private Long topId;
/**
* 层级,顶级为0
*/
private int level;
/**
* 部件名称
*/
private String name;
/**
* 模块宽度
*/
private Double width;
/**
* 模块高度
*/
private Double height;
/**
* 模块深度
*/
private Double depth;
/**
* 规格
*/
private String spec;
/**
* cad图纸文件id
*/
private Long cadViewFileId;
/**
* 备注
*/
private String remark;
/**
* 加工状态
*/
private Integer processStatus;
}
@@ -24,22 +24,6 @@ import lombok.ToString;
@NoArgsConstructor
@AllArgsConstructor
public class OrderItemDO {
public OrderItemDO(OrderItemDO item) {
this.id = item.getId();
this.orderId = item.getOrderId();
this.type = item.getType();
this.roomId = item.getRoomId();
this.bodyId = item.getBodyId();
this.planId = item.getPlanId();
this.plateId = item.getPlateId();
this.packageId = item.getPackageId();
this.groupId = item.getGroupId();
this.partsId = item.getPartsId();
this.num = item.getNum();
this.organId = item.getOrganId();
}
/**
* 明细编号
*/
@@ -90,4 +74,9 @@ public class OrderItemDO {
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long organId;
/**
* 部件id
*/
private Long compId;
}
@@ -0,0 +1,30 @@
package com.cf.imes.module.plan.enums.ordercomponent;
import com.cf.imes.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* 部件加工状态枚举
*
* @author Gqr
* @since 2026/1/29 11:03
*/
@RequiredArgsConstructor
@Getter
public enum OrderComponentProcessStatusEnum implements IntArrayValuable {
NOT_PROCESS(0),
UNPROCESSED(1),
PROCESSED(2);
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(OrderComponentProcessStatusEnum::getStatus).toArray();
@Override
public int[] array() {
return ARRAYS;
}
private final Integer status;
}
@@ -27,12 +27,14 @@ 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.WebCadDataComponentGroupReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataDoubleRoomTreeReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataGroupInfoReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataMaterialReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataPartsReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataProcessGroupReqVO;
import com.cf.imes.module.plan.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.plan.dal.dataobject.ordecomponent.OrderComponentDO;
import com.cf.imes.module.plan.dal.dataobject.order.OrderDO;
import com.cf.imes.module.plan.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.plan.dal.dataobject.orderGroup.OrderGroupDO;
@@ -57,6 +59,7 @@ 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.enums.ordercomponent.OrderComponentProcessStatusEnum;
import com.cf.imes.module.plan.service.customplateno.CustomPlateNoGenerateService;
import com.cf.imes.module.plan.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
import com.cf.imes.module.plan.service.order.OrderInputProcessor;
@@ -86,7 +89,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import static com.cf.imes.framework.common.util.json.JsonUtils.zipString;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_GET_ORG_SEALEDGE_ERROR;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_CHECK_ERROR;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORG_SEALEDGE_ANALYZE_ERROR;
@@ -175,15 +177,18 @@ public class WebCadOrderImportAsyncFactory {
// 加工组缓存
private Map<Integer, WebCadDataGroupInfoReqVO> processGroupMap = new HashMap<>();
// 部件缓存:{cad groupIdimes部件id}
private Map<Integer, Long> componentGroupMap = new HashMap<>();
private List<PlateDO> plateDOS = new ArrayList<>();
private List<OrderItemDO> orderItemDOS = new ArrayList<>();
private List<OrderPartsDO> orderPartsDOS = new ArrayList<>();
private List<OrderModelDO> orderModelDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
private List<RawGoodsDO> rawGoodsDOS = new ArrayList<>();
private List<GoodsDO> goodsDOS = new ArrayList<>();
private List<OrderComponentDO> orderComponentDOS = new ArrayList<>();
private List<SystemConfigSealEdgeRespDTO> sealEdgeConfigList;
private static final String PART_CATEGORY_ONE = "封边条";
private static final String PART_CATEGORY_TWO = "五金";
private static final String PART_CATEGORY_THREE = "组件";
@@ -300,6 +305,9 @@ public class WebCadOrderImportAsyncFactory {
case "CadViewFileId":
cadViewFileId = reader.readLong();
break;
case "ComponentGroupTree":
analyzeCadComponentList(reader);
break;
default:
// 跳过未知字段
reader.readObject();
@@ -511,9 +519,9 @@ public class WebCadOrderImportAsyncFactory {
.texture(materialReqVO.getTexture())
.color(materialReqVO.getColor())
.colorBlack(EMPTY_STRING)
.width(BigDecimal.valueOf(getZeroDouble(materialReqVO.getWidth())))
.height(BigDecimal.valueOf(getZeroDouble(materialReqVO.getHeight())))
.thickness(BigDecimal.valueOf(materialReqVO.getThickness()))
.width(getBigDecimalOrNull(getZeroDouble(materialReqVO.getWidth())))
.height(getBigDecimalOrNull(getZeroDouble(materialReqVO.getHeight())))
.thickness(getBigDecimalOrNull(materialReqVO.getThickness()))
.spec(getEmpty(materialReqVO.getSpec()))
.brand(getEmpty(materialReqVO.getBrand()))
.remark(EMPTY_STRING)
@@ -808,6 +816,16 @@ public class WebCadOrderImportAsyncFactory {
goodsDO.setPlateNum(goodsDO.getPlateNum() + 1);
goodsDO.setArea(goodsDO.getArea() + area);
// 获取缓存的部件id
Integer cadGroupId = block.getComponentId();
Long plateComponentId = null;
if (ObjectUtil.isNotNull(cadGroupId)) {
Long componentId = componentGroupMap.get(cadGroupId);
if (ObjectUtil.isNotNull(componentId)) {
plateComponentId = componentId;
}
}
// 创建order_plate
PlateDO plateDO = PlateDO.builder()
.id(plateId)
@@ -816,13 +834,13 @@ public class WebCadOrderImportAsyncFactory {
.plateNo(obtainingTime + Long.toString(plateNo).substring(2))
.type(block.getType())
.goodsId(goodsDO.getId())
.width(BigDecimal.valueOf(block.getWidth()))
.height(BigDecimal.valueOf(block.getHeight()))
.thickness(BigDecimal.valueOf(block.getThickness()))
.width(getBigDecimalOrNull(block.getWidth()))
.height(getBigDecimalOrNull(block.getHeight()))
.thickness(getBigDecimalOrNull(block.getThickness()))
.splitHeight(BigDecimal.valueOf(NumberUtil.parseDouble(StringUtils.isNotEmpty(splitHeight) ? splitHeight : String.valueOf(block.getKaiLiaoHeight()))))
.splitThickness(BigDecimal.valueOf(NumberUtil.parseDouble(block.getSpliteThickness())))
.splitWidth(BigDecimal.valueOf(NumberUtil.parseDouble(StringUtils.isNotEmpty(spliteWidth) ? spliteWidth : String.valueOf(block.getKaiLiaoWidth()))))
.area(BigDecimal.valueOf(area))
.area(getBigDecimalOrNull(area))
.texture(block.getTexture())
.holeFace(block.getHoleFace())
.isDoor(block.getIsDoor())
@@ -841,18 +859,18 @@ public class WebCadOrderImportAsyncFactory {
.sideHoleCount(block.getSideHoleCount())
.frontModelCount(block.getFrontModelCount())
.backModelCount(block.getBackModelCount())
.offsetX(BigDecimal.valueOf(block.getOffsetX()))
.offsetY(BigDecimal.valueOf(block.getOffsetY()))
.offsetX(getBigDecimalOrNull(block.getOffsetX()))
.offsetY(getBigDecimalOrNull(block.getOffsetY()))
.isArcAcross(getDefaultFalse(block.getIsArcBase()))
.moduleTypeId(0L)
.isOptimized(false)
.isCutted(0)
.isCancel(false)
.filterType(EMPTY_STRING)
.sealLeft(BigDecimal.valueOf(block.getSealLeft()))
.sealRight(BigDecimal.valueOf(block.getSealRight()))
.sealUp(BigDecimal.valueOf(block.getSealUp()))
.sealDown(BigDecimal.valueOf(block.getSealDown()))
.sealLeft(getBigDecimalOrNull(block.getSealLeft()))
.sealRight(getBigDecimalOrNull(block.getSealRight()))
.sealUp(getBigDecimalOrNull(block.getSealUp()))
.sealDown(getBigDecimalOrNull(block.getSealDown()))
.remark(remark.toString())
.deleted(false)
.organId(organId)
@@ -888,7 +906,7 @@ public class WebCadOrderImportAsyncFactory {
orderModelsBatchInsertWithinThreshold(false);
// 遍历加工组信息,生成对应的加工组和item
analyzeBlockProcessGroup(orderBodyDO, block, plateId);
analyzeBlockProcessGroup(orderBodyDO, block, plateId, plateComponentId);
}
/**
@@ -898,7 +916,7 @@ public class WebCadOrderImportAsyncFactory {
* @param block
* @param plateId
*/
private void analyzeBlockProcessGroup(OrderBodyDO orderBodyDO, WebCadDataBlockReqVO block, Long plateId) {
private void analyzeBlockProcessGroup(OrderBodyDO orderBodyDO, WebCadDataBlockReqVO block, Long plateId, Long componentId) {
Long bodyId = orderBodyDO.getId();
Long roomId = orderBodyDO.getRoomId();
@@ -973,6 +991,7 @@ public class WebCadOrderImportAsyncFactory {
.partsId(0L)
.num(1.0)
.organId(organId)
.compId(componentId)
.build();
orderItemDOS.add(orderItemDO);
orderItemBatchInsertWithinThreshold(orderItemDOS, false);
@@ -993,10 +1012,10 @@ public class WebCadOrderImportAsyncFactory {
.texture(block.getTexture())
.typographicFace(block.getHoleArrange())
.openDoorType(block.getOpenDoorType())
.splitLength(BigDecimal.valueOf(block.getKaiLiaoHeight()))
.splitWidth(BigDecimal.valueOf(block.getKaiLiaoWidth()))
.offsetX(BigDecimal.valueOf(block.getOffsetX()))
.offsetY(BigDecimal.valueOf(block.getOffsetY()))
.splitLength(getBigDecimalOrNull(block.getKaiLiaoHeight()))
.splitWidth(getBigDecimalOrNull(block.getKaiLiaoWidth()))
.offsetX(getBigDecimalOrNull(block.getOffsetX()))
.offsetY(getBigDecimalOrNull(block.getOffsetY()))
.pointDetail(getPointDetail(pointInfo.getPointDetail()))
.rawPointDetail(getRawPointDetail(pointInfo.getOrgPointDetail()))
.holeDetail(getHoleDetail(pointInfo.getHoleDetail()))
@@ -1278,7 +1297,9 @@ public class WebCadOrderImportAsyncFactory {
*/
private List<ModelDetail> getSideDetail(List<WebCadDataBlockReqVO.PointInfoDTO.SideModelDetailDTO> cadSideModelDetailList, List<WebCadDataBlockReqVO.PointInfoDTO.SideModelDetailDTO> cadSide2DModelDetail) {
// 合并侧面2v刀路列表
cadSideModelDetailList.addAll(cadSide2DModelDetail);
if (CollUtil.isNotEmpty(cadSide2DModelDetail)) {
cadSideModelDetailList.addAll(cadSide2DModelDetail);
}
if (CollUtil.isNotEmpty(cadSideModelDetailList)) {
List<ModelDetail> modelDetails = new ArrayList<>();
// 侧面造型和侧面2v刀路合并,序号从头计算不使用cad的
@@ -1709,6 +1730,110 @@ public class WebCadOrderImportAsyncFactory {
}
}
/**
* 处理cad部件数据
*/
private void analyzeCadComponentList(JSONReader reader) {
log.debug("====================【cad拆单解析部件开始】====================");
processComponentList(reader);
log.debug("====================【cad拆单解析部件结束】====================");
}
/**
* 解析部件列表
*
* @param reader
*/
private void processComponentList(JSONReader reader) {
reader.startArray();
while (reader.hasNext()) {
processComponent(reader, null, null, 0);
}
reader.endArray();
orderComponentBatchInsertWithinThreshold(orderComponentDOS, true);
}
/**
* 解析单个部件
*
* @param reader
*/
private void processComponent(JSONReader reader, Long parentId, Long topId, int level) {
if (parentId == null) {
parentId = OrderComponentDO.PARENT_ID_ROOT;
}
Integer cadGroupId = null;
String name = null;
WebCadDataComponentGroupReqVO.BoxSizeDTO boxSize = null;
reader.startObject();
List<JSONReader> childrenReaders = new ArrayList<>();
while (reader.hasNext()) {
String key = reader.readString();
switch (key) {
case "groupID":
cadGroupId = reader.readInteger();
break;
case "name":
name = reader.readString();
break;
case "boxSize":
boxSize = reader.readObject(WebCadDataComponentGroupReqVO.BoxSizeDTO.class);
break;
case "children":
// 当前节点生成 OrderComponentDO
Long componentId = (Long) snowFlakeGenerator.nextId(null);
if (topId == null) {
topId = componentId;
}
OrderComponentDO componentDO = OrderComponentDO.builder()
.id(componentId)
.organId(organId)
.orderId(orderId)
.pid(parentId)
.topId(topId)
.name(name)
.width(boxSize != null ? boxSize.getWidth() : null)
.height(boxSize != null ? boxSize.getHeight() : null)
.depth(boxSize != null ? boxSize.getDepth() : null)
.cadViewFileId(cadViewFileId)
.processStatus(OrderComponentProcessStatusEnum.UNPROCESSED.getStatus())
.level(level)
.build();
componentDO.setCreateTime(now);
componentDO.setUpdateTime(now);
componentDO.setCreator(operatorName);
componentDO.setUpdater(operatorName);
componentDO.setDeleted(false);
// 缓存组件id
componentGroupMap.put(cadGroupId, componentId);
// 逐条加入批量入库
orderComponentDOS.add(componentDO);
orderComponentBatchInsertWithinThreshold(orderComponentDOS, false);
reader.startArray();
while (reader.hasNext()) {
// 递归子节点
processComponent(reader, componentId, topId, level); // 子节点在递归中生成组件DO
}
reader.endArray();
break;
default:
// 其他字段直接跳过
reader.readObject();
}
}
reader.endObject();
}
/**
* 从规格中获取属性,例:material、color
*
@@ -1811,6 +1936,20 @@ public class WebCadOrderImportAsyncFactory {
return ObjectUtil.defaultIfNull(value, false);
}
/**
* value不可转返回null
*
* @param value
* @return
*/
private BigDecimal getBigDecimalOrNull(Double value) {
try {
return BigDecimal.valueOf(value);
} catch (Exception e) {
return null;
}
}
/**
* 配件类型转换
*
@@ -1932,7 +2071,7 @@ public class WebCadOrderImportAsyncFactory {
// 达到批量的阈值就做一次插入
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
String sql = "INSERT INTO order_item (id,order_id,type,room_id,body_id,package_id,group_id,plate_id,parts_id,num,organ_id) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
String sql = "INSERT INTO order_item (id,order_id,type,room_id,body_id,package_id,group_id,plate_id,parts_id,num,organ_id,comp_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int index) throws SQLException {
@@ -1952,6 +2091,11 @@ public class WebCadOrderImportAsyncFactory {
ps.setLong(9, item.getPartsId());
ps.setDouble(10, item.getNum());
ps.setLong(11, item.getOrganId());
if (item.getCompId() != null) {
ps.setLong(12, item.getCompId());
} else {
ps.setNull(12, Types.BIGINT);
}
}
@Override
@@ -2027,6 +2171,95 @@ public class WebCadOrderImportAsyncFactory {
orderPartsDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
}
private void orderComponentBatchInsertWithinThreshold(List<OrderComponentDO> list, boolean isLast) {
// 达到批量的阈值就做一次插入
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
String sql = """
INSERT INTO order_component (
id,
order_id,
organ_id,
pid,
top_id,
name,
width,
height,
depth,
spec,
cad_view_file_id,
process_status,
remark,
creator,
create_time,
updater,
update_time,
deleted,
level
) VALUES (
?,?,?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,
?,?
)
""";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int index) throws SQLException {
OrderComponentDO item = list.get(index);
ps.setLong(1, item.getId());
ps.setLong(2, item.getOrderId());
ps.setLong(3, item.getOrganId());
ps.setLong(4, item.getPid());
ps.setLong(5, item.getTopId());
ps.setString(6, item.getName());
if (item.getWidth() != null) {
ps.setDouble(7, item.getWidth());
} else {
ps.setNull(7, Types.DOUBLE);
}
if (item.getHeight() != null) {
ps.setDouble(8, item.getHeight());
} else {
ps.setNull(8, Types.DOUBLE);
}
if (item.getDepth() != null) {
ps.setDouble(9, item.getDepth());
} else {
ps.setNull(9, Types.DOUBLE);
}
ps.setString(10, item.getSpec());
ps.setLong(11, item.getCadViewFileId());
ps.setInt(12, item.getProcessStatus());
ps.setString(13, item.getRemark());
ps.setString(14, item.getCreator());
ps.setTimestamp(15, Timestamp.valueOf(item.getCreateTime()));
ps.setString(16, item.getUpdater());
ps.setTimestamp(17, Timestamp.valueOf(item.getUpdateTime()));
ps.setBoolean(18, item.getDeleted());
ps.setInt(19, item.getLevel());
}
@Override
public int getBatchSize() {
return list.size();
}
});
if (!isLast) {
// 存储完成清理 list
clearComponent();
}
}
}
private void clearComponent() {
orderComponentDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
}
/**
* 每达到阈值就批量插入一次生产单造型数据和压缩数据
*
@@ -2175,6 +2408,7 @@ public class WebCadOrderImportAsyncFactory {
processGroupMap = null;
existRoomIdMap = null;
orderPartMap = null;
componentGroupMap = null;
plateDOS = null;
orderItemDOS = null;
@@ -2182,6 +2416,7 @@ public class WebCadOrderImportAsyncFactory {
orderModelDOS = null;
rawGoodsDOS = null;
goodsDOS = null;
orderComponentDOS = null;
sealEdgeConfigList = null;
}
@@ -22,6 +22,7 @@ import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.executor.enums.OrderItemTypeEnum;
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.WebCadDataComponentGroupReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataDoubleRoomTreeReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataGroupInfoReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataMaterialReqVO;
@@ -29,6 +30,7 @@ import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadData
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataProcessGroupReqVO;
import com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo.WebCadDataReqVO;
import com.cf.imes.module.plan.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.plan.dal.dataobject.ordecomponent.OrderComponentDO;
import com.cf.imes.module.plan.dal.dataobject.order.OrderDO;
import com.cf.imes.module.plan.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.plan.dal.dataobject.orderGroup.OrderGroupDO;
@@ -51,6 +53,7 @@ import com.cf.imes.module.plan.dal.mysql.orderBody.OrderBodyMapper;
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.enums.ordercomponent.OrderComponentProcessStatusEnum;
import com.cf.imes.module.plan.service.customplateno.CustomPlateNoGenerateService;
import com.cf.imes.module.plan.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
import com.cf.imes.module.plan.service.order.OrderInputProcessor;
@@ -75,7 +78,6 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import static com.cf.imes.framework.common.util.json.JsonUtils.zipString;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_GET_ORG_SEALEDGE_ERROR;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_CHECK_ERROR;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_REACH_THRESHOLD_ERROR;
@@ -160,15 +162,18 @@ public class WebCadOrderImportFactory {
// 加工组缓存
private Map<Integer, WebCadDataGroupInfoReqVO> processGroupMap = new HashMap<>();
// 部件缓存:{cad groupIdimes部件id}
private Map<Integer, Long> componentGroupMap = new HashMap<>();
private List<PlateDO> plateDOS = new ArrayList<>();
private List<OrderItemDO> orderItemDOS = new ArrayList<>();
private List<OrderPartsDO> orderPartsDOS = new ArrayList<>();
private List<OrderModelDO> orderModelDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
private List<RawGoodsDO> rawGoodsDOS = new ArrayList<>();
private List<GoodsDO> goodsDOS = new ArrayList<>();
private List<OrderComponentDO> orderComponentDOS = new ArrayList<>();
private List<SystemConfigSealEdgeRespDTO> sealEdgeConfigList;
private static final String PART_CATEGORY_ONE = "封边条";
private static final String PART_CATEGORY_TWO = "五金";
private static final String PART_CATEGORY_THREE = "组件";
@@ -229,6 +234,8 @@ public class WebCadOrderImportFactory {
public void analyzeTempData(WebCadDataReqVO webCadDataReqVO) {
try {
cadViewFileId = webCadDataReqVO.getCadViewFileId();
log.debug("====================【cad拆单校验板件数量开始】====================");
// 校验板件数量
analyzePlateNum();
@@ -249,6 +256,11 @@ public class WebCadOrderImportFactory {
analyzeRoomBody(webCadDataReqVO.getDouleRoomTree());
log.debug("====================【cad拆单解析成倍柜体结束】====================");
// 缓存部件信息
log.debug("====================【cad拆单解析部件开始】====================");
analyzeComponentGroup(webCadDataReqVO.getComponentGroup());
log.debug("====================【cad拆单解析部件结束】====================");
log.debug("====================【cad拆单解析板件开始】====================");
// 解析板件列表
analyzeBlockList(webCadDataReqVO.getBlocks());
@@ -263,7 +275,6 @@ public class WebCadOrderImportFactory {
log.debug("====================【cad拆单全局保存开始】====================");
// 保存数据柜体、加工组
cadViewFileId = webCadDataReqVO.getCadViewFileId();
saveData();
log.debug("====================【cad拆单全局保存结束】====================");
@@ -355,7 +366,7 @@ public class WebCadOrderImportFactory {
.eq(DELETED_FIELD, 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");
}
}
@@ -432,9 +443,9 @@ public class WebCadOrderImportFactory {
.texture(materialReqVO.getTexture())
.color(materialReqVO.getColor())
.colorBlack(EMPTY_STRING)
.width(BigDecimal.valueOf(getZeroDouble(materialReqVO.getWidth())))
.height(BigDecimal.valueOf(getZeroDouble(materialReqVO.getHeight())))
.thickness(BigDecimal.valueOf(materialReqVO.getThickness()))
.width(getBigDecimalOrNull(getZeroDouble(materialReqVO.getWidth())))
.height(getBigDecimalOrNull(getZeroDouble(materialReqVO.getHeight())))
.thickness(getBigDecimalOrNull(materialReqVO.getThickness()))
.spec(getEmpty(materialReqVO.getSpec()))
.brand(getEmpty(materialReqVO.getBrand()))
.remark(EMPTY_STRING)
@@ -508,6 +519,73 @@ public class WebCadOrderImportFactory {
}
}
/**
* 解析部件信息
*
* @param componentGroupReqVOS
*/
private void analyzeComponentGroup(List<WebCadDataComponentGroupReqVO> componentGroupReqVOS) {
if (CollUtil.isEmpty(componentGroupReqVOS)) {
return;
}
for (WebCadDataComponentGroupReqVO componentGroupReqVO : componentGroupReqVOS) {
createAndCacheComponent(componentGroupReqVO, null, null, 0);
}
// 部件入库
orderComponentBatchInsertWithinThreshold(orderComponentDOS, true);
}
/**
* 创建部件并缓存
*
* @param componentGroupReqVO cad部件数据
* @param parentId 父级部件id
* @param topId 顶级部件id
* @param level 层级从0开始计算
*/
private void createAndCacheComponent(WebCadDataComponentGroupReqVO componentGroupReqVO, Long parentId, Long topId, int level) {
if (ObjectUtil.isNull(parentId)) {
parentId = OrderComponentDO.PARENT_ID_ROOT;
}
Integer cadGroupId = componentGroupReqVO.getGroupId();
Long componentId = (Long) snowFlakeGenerator.nextId(null);
// 顶级节点创建过一次后后续继续使用
if (ObjectUtil.isNull(topId)) {
topId = componentId;
}
OrderComponentDO componentDO = OrderComponentDO.builder()
.id(componentId)
.organId(organId)
.orderId(orderId)
.pid(parentId)
.topId(topId)
.name(componentGroupReqVO.getName())
.width(componentGroupReqVO.getBoxSize().getWidth())
.height(componentGroupReqVO.getBoxSize().getHeight())
.depth(componentGroupReqVO.getBoxSize().getDepth())
.cadViewFileId(cadViewFileId)
.processStatus(OrderComponentProcessStatusEnum.UNPROCESSED.getStatus())
.level(level)
.build();
componentDO.setCreateTime(now);
componentDO.setUpdateTime(now);
componentDO.setCreator(operatorName);
componentDO.setUpdater(operatorName);
componentDO.setDeleted(false);
// 缓存部件
componentGroupMap.put(cadGroupId, componentId);
// 部件入库
orderComponentDOS.add(componentDO);
orderComponentBatchInsertWithinThreshold(orderComponentDOS, false);
// 继续处理下级
if (!componentGroupReqVO.getChildren().isEmpty()) {
for (WebCadDataComponentGroupReqVO children : componentGroupReqVO.getChildren()) {
createAndCacheComponent(children, componentId, topId, ++level);
}
}
}
/**
* 解析生产单信息板材列表
*
@@ -662,6 +740,16 @@ public class WebCadOrderImportFactory {
goodsDO.setPlateNum(goodsDO.getPlateNum() + 1);
goodsDO.setArea(goodsDO.getArea() + area);
// 获取缓存的部件id
Integer cadGroupId = block.getComponentId();
Long plateComponentId = null;
if (ObjectUtil.isNotNull(cadGroupId)) {
Long componentId = componentGroupMap.get(cadGroupId);
if (ObjectUtil.isNotNull(componentId)) {
plateComponentId = componentId;
}
}
String splitHeight = block.getSpliteHeight();
String spliteWidth = block.getSpliteWidth();
@@ -673,13 +761,13 @@ public class WebCadOrderImportFactory {
.plateNo(obtainingTime + Long.toString(plateNo).substring(2))
.type(block.getType())
.goodsId(goodsDO.getId())
.width(BigDecimal.valueOf(block.getWidth()))
.height(BigDecimal.valueOf(block.getHeight()))
.thickness(BigDecimal.valueOf(block.getThickness()))
.width(getBigDecimalOrNull(block.getWidth()))
.height(getBigDecimalOrNull(block.getHeight()))
.thickness(getBigDecimalOrNull(block.getThickness()))
.splitHeight(BigDecimal.valueOf(NumberUtil.parseDouble(StringUtils.isNotEmpty(splitHeight) ? splitHeight : String.valueOf(block.getKaiLiaoHeight()))))
.splitThickness(BigDecimal.valueOf(NumberUtil.parseDouble(block.getSpliteThickness())))
.splitWidth(BigDecimal.valueOf(NumberUtil.parseDouble(StringUtils.isNotEmpty(spliteWidth) ? spliteWidth : String.valueOf(block.getKaiLiaoWidth()))))
.area(BigDecimal.valueOf(area))
.area(getBigDecimalOrNull(area))
.texture(block.getTexture())
.holeFace(block.getHoleFace())
.isDoor(block.getIsDoor())
@@ -698,18 +786,18 @@ public class WebCadOrderImportFactory {
.sideHoleCount(block.getSideHoleCount())
.frontModelCount(block.getFrontModelCount())
.backModelCount(block.getBackModelCount())
.offsetX(BigDecimal.valueOf(block.getOffsetX()))
.offsetY(BigDecimal.valueOf(block.getOffsetY()))
.offsetX(getBigDecimalOrNull(block.getOffsetX()))
.offsetY(getBigDecimalOrNull(block.getOffsetY()))
.isArcAcross(getDefaultFalse(block.getIsArcBase()))
.moduleTypeId(0L)
.isOptimized(false)
.isCutted(0)
.isCancel(false)
.filterType(EMPTY_STRING)
.sealLeft(BigDecimal.valueOf(block.getSealLeft()))
.sealRight(BigDecimal.valueOf(block.getSealRight()))
.sealUp(BigDecimal.valueOf(block.getSealUp()))
.sealDown(BigDecimal.valueOf(block.getSealDown()))
.sealLeft(getBigDecimalOrNull(block.getSealLeft()))
.sealRight(getBigDecimalOrNull(block.getSealRight()))
.sealUp(getBigDecimalOrNull(block.getSealUp()))
.sealDown(getBigDecimalOrNull(block.getSealDown()))
.remark(remark.toString())
.deleted(false)
.organId(organId)
@@ -745,7 +833,7 @@ public class WebCadOrderImportFactory {
orderModelsBatchInsertWithinThreshold(false);
// 遍历加工组信息,生成对应的加工组和item
analyzeBlockProcessGroup(orderBodyDO, block, plateId);
analyzeBlockProcessGroup(orderBodyDO, block, plateId, plateComponentId);
}
/**
@@ -762,10 +850,10 @@ public class WebCadOrderImportFactory {
.texture(block.getTexture())
.typographicFace(block.getHoleArrange())
.openDoorType(block.getOpenDoorType())
.splitLength(BigDecimal.valueOf(block.getKaiLiaoHeight()))
.splitWidth(BigDecimal.valueOf(block.getKaiLiaoWidth()))
.offsetX(BigDecimal.valueOf(block.getOffsetX()))
.offsetY(BigDecimal.valueOf(block.getOffsetY()))
.splitLength(getBigDecimalOrNull(block.getKaiLiaoHeight()))
.splitWidth(getBigDecimalOrNull(block.getKaiLiaoWidth()))
.offsetX(getBigDecimalOrNull(block.getOffsetX()))
.offsetY(getBigDecimalOrNull(block.getOffsetY()))
.pointDetail(getPointDetail(pointInfo.getPointDetail()))
.rawPointDetail(getRawPointDetail(pointInfo.getOrgPointDetail()))
.holeDetail(getHoleDetail(pointInfo.getHoleDetail()))
@@ -1047,7 +1135,9 @@ public class WebCadOrderImportFactory {
*/
private List<ModelDetail> getSideDetail(List<WebCadDataBlockReqVO.PointInfoDTO.SideModelDetailDTO> cadSideModelDetailList, List<WebCadDataBlockReqVO.PointInfoDTO.SideModelDetailDTO> cadSide2DModelDetail) {
// 合并侧面2v刀路列表
cadSideModelDetailList.addAll(cadSide2DModelDetail);
if (CollUtil.isNotEmpty(cadSide2DModelDetail)) {
cadSideModelDetailList.addAll(cadSide2DModelDetail);
}
if (CollUtil.isNotEmpty(cadSideModelDetailList)) {
List<ModelDetail> modelDetails = new ArrayList<>();
// 侧面造型和侧面2v刀路合并,序号从头计算不使用cad的
@@ -1176,7 +1266,7 @@ public class WebCadOrderImportFactory {
* @param block
* @param plateId
*/
private void analyzeBlockProcessGroup(OrderBodyDO orderBodyDO, WebCadDataBlockReqVO block, Long plateId) {
private void analyzeBlockProcessGroup(OrderBodyDO orderBodyDO, WebCadDataBlockReqVO block, Long plateId, Long componentId) {
Long bodyId = orderBodyDO.getId();
Long roomId = orderBodyDO.getRoomId();
@@ -1251,6 +1341,7 @@ public class WebCadOrderImportFactory {
.partsId(0L)
.num(1.0)
.organId(organId)
.compId(componentId)
.build();
orderItemDOS.add(orderItemDO);
orderItemBatchInsertWithinThreshold(orderItemDOS, false);
@@ -1663,6 +1754,20 @@ public class WebCadOrderImportFactory {
return ObjectUtil.defaultIfNull(value, false);
}
/**
* value不可转返回null
*
* @param value
* @return
*/
private BigDecimal getBigDecimalOrNull(Double value) {
try {
return BigDecimal.valueOf(value);
} catch (Exception e) {
return null;
}
}
/**
* 配件类型转换
*
@@ -1776,15 +1881,15 @@ public class WebCadOrderImportFactory {
}
}
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) {
// 达到批量的阈值就做一次插入
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
String sql = "INSERT INTO order_item (id,order_id,type,room_id,body_id,package_id,group_id,plate_id,parts_id,num,organ_id) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
String sql = "INSERT INTO order_item (id,order_id,type,room_id,body_id,package_id,group_id,plate_id,parts_id,num,organ_id,comp_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int index) throws SQLException {
@@ -1804,6 +1909,11 @@ public class WebCadOrderImportFactory {
ps.setLong(9, item.getPartsId());
ps.setDouble(10, item.getNum());
ps.setLong(11, item.getOrganId());
if (item.getCompId() != null) {
ps.setLong(12, item.getCompId());
} else {
ps.setNull(12, Types.BIGINT);
}
}
@Override
@@ -1820,8 +1930,8 @@ public class WebCadOrderImportFactory {
}
}
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) {
@@ -1875,8 +1985,97 @@ public class WebCadOrderImportFactory {
}
}
private void clearPart(){
orderPartsDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
private void clearPart() {
orderPartsDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
}
private void orderComponentBatchInsertWithinThreshold(List<OrderComponentDO> list, boolean isLast) {
// 达到批量的阈值就做一次插入
if (CollUtil.isNotEmpty(list) && (list.size() >= BATCH_THRESHOLD_NUMBER || isLast)) {
String sql = """
INSERT INTO order_component (
id,
order_id,
organ_id,
pid,
top_id,
name,
width,
height,
depth,
spec,
cad_view_file_id,
process_status,
remark,
creator,
create_time,
updater,
update_time,
deleted,
level
) VALUES (
?,?,?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,
?,?
)
""";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int index) throws SQLException {
OrderComponentDO item = list.get(index);
ps.setLong(1, item.getId());
ps.setLong(2, item.getOrderId());
ps.setLong(3, item.getOrganId());
ps.setLong(4, item.getPid());
ps.setLong(5, item.getTopId());
ps.setString(6, item.getName());
if (item.getWidth() != null) {
ps.setDouble(7, item.getWidth());
} else {
ps.setNull(7, Types.DOUBLE);
}
if (item.getHeight() != null) {
ps.setDouble(8, item.getHeight());
} else {
ps.setNull(8, Types.DOUBLE);
}
if (item.getDepth() != null) {
ps.setDouble(9, item.getDepth());
} else {
ps.setNull(9, Types.DOUBLE);
}
ps.setString(10, item.getSpec());
ps.setLong(11, item.getCadViewFileId());
ps.setInt(12, item.getProcessStatus());
ps.setString(13, item.getRemark());
ps.setString(14, item.getCreator());
ps.setTimestamp(15, Timestamp.valueOf(item.getCreateTime()));
ps.setString(16, item.getUpdater());
ps.setTimestamp(17, Timestamp.valueOf(item.getUpdateTime()));
ps.setBoolean(18, item.getDeleted());
ps.setInt(19, item.getLevel());
}
@Override
public int getBatchSize() {
return list.size();
}
});
if (!isLast) {
// 存储完成清理 list
clearComponent();
}
}
}
private void clearComponent() {
orderComponentDOS = ListUtils.newArrayListWithExpectedSize(BATCH_THRESHOLD_NUMBER);
}
/**
@@ -2080,6 +2279,7 @@ public class WebCadOrderImportFactory {
processGroupMap = null;
existRoomIdMap = null;
orderPartMap = null;
componentGroupMap = null;
plateDOS = null;
orderItemDOS = null;
@@ -2087,6 +2287,7 @@ public class WebCadOrderImportFactory {
orderModelDOS = null;
rawGoodsDOS = null;
goodsDOS = null;
orderComponentDOS = null;
sealEdgeConfigList = null;
}
}