生产单异步导入:1、xml导入优化;2、excel/xml接入自定义版编号生成;

This commit is contained in:
gaoqr
2025-03-01 17:10:01 +08:00
parent 1a9a1bc503
commit 434a8bc8b7
33 changed files with 2617 additions and 787 deletions
@@ -95,20 +95,24 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
// 根据复位模式更新生产单的序号
for (OrderDO orderDO : orderDOS) {
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
orderCustomPlateNoSeqVO.setBodyNoSeq(null);
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
if (CollUtil.isNotEmpty(rooms)) {
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
roomVO.setBodyNoSeq(null);
}
resetOrder(orderDO, resetModeEnum);
}
}
private void resetOrder(OrderDO orderDO, ResetModeEnum resetModeEnum) {
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
orderCustomPlateNoSeqVO.setBodyNoSeq(null);
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
if (CollUtil.isNotEmpty(rooms)) {
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
roomVO.setBodyNoSeq(null);
}
}
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
}
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
}
}
@@ -1,13 +1,13 @@
package com.cf.imes.module.executor.util.fileConversion.admin.files.xml;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.dict.core.util.DictFrameworkUtils;
@@ -27,6 +27,7 @@ import com.cf.imes.module.executor.util.fileConversion.admin.ToolUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.AssemblyXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.BlockXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.CorrelationXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.CorrelationXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.CuttingOutlineXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.EdgingXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.GrooveXmlVO;
@@ -36,7 +37,9 @@ import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.Hardwa
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.HoleXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.HoleXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.IsletXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.IsletXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OffsetLineXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OffsetLineXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OutlineXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.PlateXmlVO;
@@ -44,6 +47,7 @@ import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.PointX
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.PointXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.RawOutlineXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.RemarkXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.RemarkXmlVOS;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.RoomBoxXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.RoomXmlVO;
import jodd.util.StringUtil;
@@ -64,6 +68,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -133,19 +138,26 @@ public class DefaultOrderImportXmlParserHandler {
// 全局对象,一般用于下级获取属性或者信息提示
private RoomXmlVO roomXmlVO;
private RawOutlineXmlVO rawOutlineXmlVO;
private BlockXmlVO blockXmlVO;
private PointXmlVOS pointXmlVOS;
private OutlineXmlVO outlineXmlVO;
private CuttingOutlineXmlVO cuttingOutlineXmlVO;
private RawOutlineXmlVO rawOutlineXmlVO;
private HoleXmlVOS holeXmlVOS;
private GrooveXmlVOS grooveXmlVOS;
private GrooveXmlVO grooveXmlVO;
private IsletXmlVOS isletXmlVOS;
private IsletXmlVO isletXmlVO;
private CorrelationXmlVOS correlationXmlVOS;
private RemarkXmlVOS remarkXmlVOS;
private OffsetLineXmlVOS offsetLineXmlVOS;
private StartElement se;
// 全局编码标记,如进入plate时设置plateItemCode,结束时设为null
private String plateItemCode;
private String blockProductionCode;
private String partItemCode;
private String outerId;
// 全局标签标记,如进入block时inBlock设为true,结束block时设为false
private boolean inBlock;
// 全局标签标记,如进入outLine时inOutline设为true,结束时设为false
private boolean inOutline;
private boolean inCuttingOutline;
private boolean inRawOutline;
@@ -153,8 +165,6 @@ public class DefaultOrderImportXmlParserHandler {
private boolean inPoints;
private boolean inIslet;
private int pointNum;
private OrderImportTempDataMapper orderImportTempDataMapper;
private OrderService orderService;
@@ -273,20 +283,32 @@ public class DefaultOrderImportXmlParserHandler {
analyzeGroove(attributes);
break;
case "Points":
analyzeGroovePoints(attributes);
analyzePoints(attributes);
break;
case "offsetLines":
analyzeOffsetLines(attributes);
break;
case "offsetLine":
analyzeOffsetLine(attributes);
break;
case "Islets":
analyzeIslets(attributes);
break;
case "Islet":
analyzeIslet(attributes);
break;
case "Correlations":
analyzeCorrelations(attributes);
break;
case "Correlation":
analyzeCorrelation(attributes);
break;
case "Point":
analyzePoint(attributes);
break;
case "Remarks":
analyzeRemarks(attributes);
break;
case "Remark":
analyzeRemark(attributes);
break;
@@ -296,7 +318,7 @@ public class DefaultOrderImportXmlParserHandler {
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
cachedDataList.clear();
}
} else if (en.isEndElement()) {
// 根据标签tag选择对应的解析方式
@@ -334,7 +356,7 @@ public class DefaultOrderImportXmlParserHandler {
endGroove();
break;
case "Points":
endGroovePoints();
endPoints();
break;
case "Islet":
endIslet();
@@ -657,19 +679,13 @@ public class DefaultOrderImportXmlParserHandler {
*/
private void analyzeBlockXml(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成block对象
BlockXmlVO blockXmlVO = getJavaBeanFromXmlAttr(BlockXmlVO.class, attributes);
blockXmlVO = getJavaBeanFromXmlAttr(BlockXmlVO.class, attributes);
if (ObjectUtil.isNull(blockXmlVO)) {
blockXmlVO = new BlockXmlVO();
}
// 校验板件
checkBlock(blockXmlVO);
// 全局参数
inBlock = true;
String productionCode = blockXmlVO.getProductionCode();
blockProductionCode = StringUtils.isNotEmpty(productionCode) ? productionCode : String.valueOf(snowFlakeGenerator.nextId(null));
blockXmlVO.setProductionCode(blockProductionCode);
// 如果有未命名的房间编号、柜体编号,直接在临时表创建这个柜体
String roomCode = blockXmlVO.getRoomCode();
String boxCode = blockXmlVO.getBoxCode();
@@ -677,20 +693,9 @@ public class DefaultOrderImportXmlParserHandler {
// 校验检查房间、柜体、加工组编号
checkRoomBoxGroup(se, roomCode, blockXmlVO.getRoomName(), boxCode, blockXmlVO.getBoxName(), groupCodes);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.PLATE.getType())
.innerGoodsId(plateItemCode)
.roomCode(roomCode)
.bodyCode(boxCode)
.groupCode(groupCodes)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(blockXmlVO)))
.sort(sort++)
.build());
blockXmlVO.setRoomCode(roomCode);
blockXmlVO.setBoxCode(boxCode);
blockXmlVO.setGroupCodes(groupCodes);
}
@@ -739,8 +744,32 @@ public class DefaultOrderImportXmlParserHandler {
* block标签结束
*/
private void endBlockXml() {
// 全局inBlock结束
inBlock = false;
blockXmlVO.setOutlineXmlVO(outlineXmlVO);
blockXmlVO.setCuttingOutlineXmlVO(cuttingOutlineXmlVO);
blockXmlVO.setRawOutlineXmlVO(rawOutlineXmlVO);
blockXmlVO.setHoleXmlVOS(holeXmlVOS);
blockXmlVO.setGrooveXmlVOS(grooveXmlVOS);
blockXmlVO.setIsletXmlVOS(isletXmlVOS);
blockXmlVO.setCorrelationXmlVOS(correlationXmlVOS);
blockXmlVO.setRemarkXmlVOS(remarkXmlVOS);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.PLATE.getType())
.innerGoodsId(plateItemCode)
.roomCode(blockXmlVO.getRoomCode())
.bodyCode(blockXmlVO.getBoxCode())
.groupCode(blockXmlVO.getGroupCodes())
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(blockXmlVO)))
.sort(sort++)
.build());
// 清空全局参数
points.clear();
}
/**
@@ -968,24 +997,23 @@ public class DefaultOrderImportXmlParserHandler {
private void analyzeOutline(Iterator<Attribute> attributes) throws Exception {
// 设置全局参数
inOutline = true;
if (inGroove) {
outlineXmlVO = getJavaBeanFromXmlAttr(OutlineXmlVO.class, attributes);
}
outlineXmlVO = getJavaBeanFromXmlAttr(OutlineXmlVO.class, attributes);
}
/**
* Outline标签结束
*/
private void endOutline() {
// 校验count和point数量
// 校验point数量
if (inGroove) {
if (ObjectUtils.isNotNull(outlineXmlVO) && pointNum == 0) {
if (CollUtil.isEmpty(points)) {
throw ServiceExceptionUtil.exception(ORDER_IMPORT_DETAIL_VALID_ERROR, "原始造型(外)轮廓点阵列表不能为空");
}
}
outlineXmlVO.setPointXmlVOList(ListUtil.toList(points));
// 重置全局参数
points.clear();
inOutline = false;
pointNum = 0;
}
/**
@@ -998,31 +1026,20 @@ public class DefaultOrderImportXmlParserHandler {
// 设置全局参数
inCuttingOutline = true;
// 从标签属性生成cuttingoutline对象
CuttingOutlineXmlVO cuttingOutlineXmlVO = getJavaBeanFromXmlAttr(CuttingOutlineXmlVO.class, attributes);
cuttingOutlineXmlVO = getJavaBeanFromXmlAttr(CuttingOutlineXmlVO.class, attributes);
// 校验
isEmptyBackAndNumber(cuttingOutlineXmlVO::getReferenceOffsetX, Double.class, "referenceOffsetX");
isEmptyBackAndNumber(cuttingOutlineXmlVO::getReferenceOffsetY, Double.class, "referenceOffsetY");
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_CUTTINGOUTLINE.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(cuttingOutlineXmlVO)))
.sort(sort++)
.build());
}
/**
* CuttingOutline标签结束
*/
private void endCuttingOutline() {
cuttingOutlineXmlVO.setPointXmlVOList(ListUtil.toList(points));
// 重置全局参数
points.clear();
inCuttingOutline = false;
pointNum = 0;
}
/**
@@ -1042,13 +1059,16 @@ public class DefaultOrderImportXmlParserHandler {
* RawOutline标签结束
*/
private void endRawOutline() {
if (pointNum > 0 && ObjectUtil.isNotNull(rawOutlineXmlVO)) {
if (CollUtil.isNotEmpty(points) && ObjectUtil.isNotNull(rawOutlineXmlVO)) {
isEmptyBackAndNumber(rawOutlineXmlVO::getReferenceOffsetX, Double.class, "referenceOffsetX" + rawOutlineXmlVO.getReferenceOffsetX());
isEmptyBackAndNumber(rawOutlineXmlVO::getReferenceOffsetY, Double.class, "referenceOffsetY" + rawOutlineXmlVO.getReferenceOffsetY());
}
if (ObjectUtil.isNotNull(rawOutlineXmlVO)) {
rawOutlineXmlVO.setPointXmlVOList(ListUtil.toList(points));
}
// 重置全局参数
inRawOutline = false;
pointNum = 0;
points.clear();
}
/**
@@ -1059,23 +1079,13 @@ public class DefaultOrderImportXmlParserHandler {
*/
private void analyzeHoles(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成hole对象
HoleXmlVOS holeXmlVOS = getJavaBeanFromXmlAttr(HoleXmlVOS.class, attributes);
holeXmlVOS = getJavaBeanFromXmlAttr(HoleXmlVOS.class, attributes);
if (ObjectUtil.isNull(holeXmlVOS)) {
return;
}
// 校验holes
checkHoles(holeXmlVOS);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_HOLES.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(holeXmlVOS)))
.sort(sort++)
.build());
holeXmlVOS.setHoleXmlVOList(new ArrayList<>());
}
/**
@@ -1113,17 +1123,7 @@ public class DefaultOrderImportXmlParserHandler {
}
// 校验holes
checkHole(holeXmlVO);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_HOLE.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(holeXmlVO)))
.sort(sort++)
.build());
holeXmlVOS.getHoleXmlVOList().add(holeXmlVO);
}
/**
@@ -1165,21 +1165,11 @@ public class DefaultOrderImportXmlParserHandler {
*/
private void analyzeGrooves(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成grooves对象
GrooveXmlVOS grooveXmlVOS = getJavaBeanFromXmlAttr(GrooveXmlVOS.class, attributes);
grooveXmlVOS = getJavaBeanFromXmlAttr(GrooveXmlVOS.class, attributes);
if (ObjectUtil.isNotNull(grooveXmlVOS)) {
// 校验grooves
checkGooves(grooveXmlVOS);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVES.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(grooveXmlVOS)))
.sort(sort++)
.build());
grooveXmlVOS.setGrooveXmlVOList(new ArrayList<>());
}
}
@@ -1213,26 +1203,11 @@ public class DefaultOrderImportXmlParserHandler {
private void analyzeGroove(Iterator<Attribute> attributes) throws Exception {
// 设置全局参数
inGroove = true;
// 从标签属性生成grooves对象
GrooveXmlVO grooveXmlVO = getJavaBeanFromXmlAttr(GrooveXmlVO.class, attributes);
// 从标签属性生成groove对象
grooveXmlVO = getJavaBeanFromXmlAttr(GrooveXmlVO.class, attributes);
if (ObjectUtil.isNotNull(grooveXmlVO)) {
// 校验grooves
// 校验groove
checkGroove(grooveXmlVO);
// 设计端id
String grooveOuterId = grooveXmlVO.getId();
outerId = grooveOuterId;
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE.getType())
.outerId(grooveOuterId)
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(grooveXmlVO)))
.sort(sort++)
.build());
}
}
@@ -1240,9 +1215,11 @@ public class DefaultOrderImportXmlParserHandler {
* Groove标签结束
*/
private void endGroove() {
grooveXmlVO.setOutlineXmlVO(outlineXmlVO);
grooveXmlVO.setPointXmlVOS(pointXmlVOS);
grooveXmlVOS.getGrooveXmlVOList().add(grooveXmlVO);
// 重置全局参数
inGroove = false;
outerId = null;
}
/**
@@ -1287,7 +1264,7 @@ public class DefaultOrderImportXmlParserHandler {
* @param attributes
* @throws Exception
*/
private void analyzeGroovePoints(Iterator<Attribute> attributes) throws Exception {
private void analyzePoints(Iterator<Attribute> attributes) throws Exception {
// 设置全局参数
inPoints = true;
// 从标签属性生成points对象
@@ -1297,14 +1274,29 @@ public class DefaultOrderImportXmlParserHandler {
/**
* Points标签结束
*/
private void endGroovePoints() {
private void endPoints() {
// 校验point数量
if (ObjectUtil.isNotNull(pointXmlVOS) && pointNum == 0) {
if (ObjectUtil.isNotNull(pointXmlVOS) && CollUtil.isEmpty(points)) {
throw ServiceExceptionUtil.exception(ORDER_IMPORT_DETAIL_VALID_ERROR, inIslet ? "孤岛点阵列表不可为空" : "槽点坐标列表不可为空");
}
pointXmlVOS.setPointXmlVOList(ListUtil.toList(points));
// 重置全局参数
points.clear();
inPoints = false;
pointNum = 0;
}
/**
* 解析偏移刀路
*
* @param attributes
* @throws Exception
*/
private void analyzeOffsetLines(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成offsetLines对象
offsetLineXmlVOS = getJavaBeanFromXmlAttr(OffsetLineXmlVOS.class, attributes);
if (ObjectUtil.isNotNull(offsetLineXmlVOS)) {
offsetLineXmlVOS.setOffsetLineXmlVOList(new ArrayList<>());
}
}
/**
@@ -1314,24 +1306,12 @@ public class DefaultOrderImportXmlParserHandler {
* @throws Exception
*/
private void analyzeOffsetLine(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成grooves对象
// 从标签属性生成OffsetLine对象
OffsetLineXmlVO offsetLineXmlVO = getJavaBeanFromXmlAttr(OffsetLineXmlVO.class, attributes);
if (ObjectUtil.isNotNull(offsetLineXmlVO)) {
// 校验grooves
// 校验OffsetLine
checkOffsetLine(offsetLineXmlVO);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE_OFFSETLINE.getType())
.outerGoodsId(blockProductionCode)
.outerSubId(outerId)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(offsetLineXmlVO)))
.sort(sort++)
.build());
offsetLineXmlVOS.getOffsetLineXmlVOList().add(offsetLineXmlVO);
}
}
@@ -1347,6 +1327,22 @@ public class DefaultOrderImportXmlParserHandler {
isEmptyAddAndPositiveNumber(offsetLineXmlVO::getTangentAngle, offsetLineXmlVO::setTangentAngle, "0", Double.class, "tangentAngle");
}
/**
* 解析孤岛
*
* @param attributes
* @throws Exception
*/
private void analyzeIslets(Iterator<Attribute> attributes) throws Exception {
// 设置全局参数
inIslet = true;
// 从标签属性生成grooves对象
isletXmlVOS = getJavaBeanFromXmlAttr(IsletXmlVOS.class, attributes);
if (ObjectUtil.isNotNull(isletXmlVOS)) {
isletXmlVOS.setIsletXmlVOList(new ArrayList<>());
}
}
/**
* 解析孤岛
*
@@ -1357,22 +1353,9 @@ public class DefaultOrderImportXmlParserHandler {
// 设置全局参数
inIslet = true;
// 从标签属性生成grooves对象
IsletXmlVO isletXmlVO = getJavaBeanFromXmlAttr(IsletXmlVO.class, attributes);
isletXmlVO = getJavaBeanFromXmlAttr(IsletXmlVO.class, attributes);
if (ObjectUtil.isNotNull(isletXmlVO)) {
isEmptyAndBack(isletXmlVO::getId, "孤岛ID");
outerId = isletXmlVO.getId();
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE_ISLET.getType())
.outerGoodsId(blockProductionCode)
.outerId(outerId)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(isletXmlVO)))
.sort(sort++)
.build());
}
}
@@ -1380,10 +1363,28 @@ public class DefaultOrderImportXmlParserHandler {
* Islet标签结束
*/
private void endIslet() {
if (ObjectUtil.isNotNull(isletXmlVO)) {
isletXmlVO.setPointXmlVOS(pointXmlVOS);
isletXmlVOS.getIsletXmlVOList().add(isletXmlVO);
}
// 重置全局参数
points.clear();
inIslet = false;
pointNum = 0;
outerId = null;
}
/**
* 解析关联配件
*
* @param attributes
* @throws Exception
*/
private void analyzeCorrelations(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成correlation对象
correlationXmlVOS = getJavaBeanFromXmlAttr(CorrelationXmlVOS.class, attributes);
if (ObjectUtil.isNotNull(correlationXmlVOS)) {
correlationXmlVOS.setCorrelationXmlVOList(new ArrayList<>());
}
}
/**
@@ -1400,10 +1401,12 @@ public class DefaultOrderImportXmlParserHandler {
isEmptyAndBack(correlationXmlVO::getName, "name");
}
isEmptyBackAndPositiveNumber(correlationXmlVO::getCount, FIELD_COUNT, Integer.class);
correlationXmlVOS.getCorrelationXmlVOList().add(correlationXmlVO);
}
}
List<PointXmlVO> points = new ArrayList<>();
/**
* 解析点明细
*
@@ -1420,93 +1423,24 @@ public class DefaultOrderImportXmlParserHandler {
if (inOutline) {
if (inGroove) {
checkPoint(pointXmlVO, "原始造型(外)轮廓");
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE_OUTLINE_POINT.getType())
.outerGoodsId(blockProductionCode)
.outerSubId(outerId)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
} else {
checkOutlinePoint(pointXmlVO);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_OUTLINE_POINT.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
}
}
if (inCuttingOutline) {
checkPointRemoveZ(pointXmlVO, "开料成型轮廓信息");
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_CUTTINGOUTLINE_POINT.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
}
if (inRawOutline) {
checkPointRemoveZ(pointXmlVO, "坯料轮廓信息");
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_RAWOUTLINE_POINT.getType())
.outerGoodsId(blockProductionCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
}
if (inPoints) {
if (inIslet) {
checkPointRemoveZ(pointXmlVO, "孤岛");
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE_ISLET_POINTS_POINT.getType())
.outerGoodsId(blockProductionCode)
.outerSubId(outerId)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
} else {
checkPoint(pointXmlVO, "刀路点阵");
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(OrderImportTmpDataTypeEnum.BLOCK_GROOVE_POINTS_POINT.getType())
.outerGoodsId(blockProductionCode)
.outerSubId(outerId)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(pointXmlVO)))
.sort(sort++)
.build());
}
}
// 列表数量累加
pointNum++;
points.add(pointXmlVO);
}
/**
@@ -1520,6 +1454,18 @@ public class DefaultOrderImportXmlParserHandler {
isEmptyBackAndNumber(pointXmlVO::getPointZ, Double.class, name + "pointZ");
}
/**
* 解析备注
*
* @param attributes
* @throws Exception
*/
private void analyzeRemarks(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成correlation对象
remarkXmlVOS = new RemarkXmlVOS();
remarkXmlVOS.setRemarkXmlVOList(new ArrayList<>());
}
/**
* 解析备注
*
@@ -1529,18 +1475,7 @@ public class DefaultOrderImportXmlParserHandler {
private void analyzeRemark(Iterator<Attribute> attributes) throws Exception {
// 从标签属性生成correlation对象
RemarkXmlVO remarkXmlVO = getJavaBeanFromXmlAttr(RemarkXmlVO.class, attributes);
// 添加到临时表
cachedDataList.add(OrderImportTempDataDO.builder()
.id((Long) snowFlakeGenerator.nextId(null))
.orderId(orderId)
.taskId(taskId)
.type(inBlock ? OrderImportTmpDataTypeEnum.BLOCK_REMKAR.getType() : OrderImportTmpDataTypeEnum.PART_REMARK.getType())
.outerSubId(inBlock ? blockProductionCode : partItemCode)
.createTime(LocalDateTime.now())
.detail(JsonUtils.zipString(JSON.toJSONString(remarkXmlVO)))
.sort(sort++)
.build());
remarkXmlVOS.getRemarkXmlVOList().add(remarkXmlVO);
}
/**
@@ -1809,7 +1744,6 @@ public class DefaultOrderImportXmlParserHandler {
* 非空判断+数据类型+数据正数
*
* @param getter:
* @param setter:
* @param name: 字段错误名称
* @param targetType: 数字类型
*/