diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/DefaultOrderImportXmlParserHandler.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/DefaultOrderImportXmlParserHandler.java index d02e4405d..c3b69e4da 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/DefaultOrderImportXmlParserHandler.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/DefaultOrderImportXmlParserHandler.java @@ -167,6 +167,25 @@ public class DefaultOrderImportXmlParserHandler { .put("true%false", false) .build(); + // 基础常量 + private static final String FIELD_AXISXROTATE = "axisXrotate"; + private static final String FIELD_AXISYROTATE = "axisYrotate"; + private static final String FIELD_AXISZROTATE = "axisZrotate"; + private static final String FIELD_BASEPOINTX = "basePointX"; + private static final String FIELD_BASEPOINTY = "basePointY"; + private static final String FIELD_BASEPOINTZ = "basePointZ"; + private static final String FIELD_MULTIPLENUMBER = "multipleNumber"; + private static final String FIELD_MULTIPLENO = "multipleNo"; + private static final String FIELD_HEIGHT = "height"; + private static final String FIELD_DEPTH = "depth"; + private static final String FIELD_COLOR = "color"; + private static final String FIELD_WIDTH = "width"; + private static final String FIELD_LENGTH = "length"; + private static final String FIELD_UNITCOUNT = "unitCount"; + private static final String FIELD_COUNT = "count"; + private static final String FIELD_THICKNESS = "thickness"; + private static final String FIELD_ORDERCODE = "orderCode"; + public DefaultOrderImportXmlParserHandler(OrderImportTempDataMapper orderImportTempDataMapper, OrderService orderService, SnowFlakeGenerator snowFlakeGenerator, Long orderId, Long taskId) { this.orderImportTempDataMapper = orderImportTempDataMapper; this.orderService = orderService; @@ -432,17 +451,17 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndAdd(room::getCode, room::setCode, NOT_ASSIGNED_CODE); isEmptyAndAdd(room::getName, room::setName, NOT_ASSIGNED); - isEmptyAddAndPositiveNumberSize(room::getHeight, room::setHeight, "0", Double.class, "height", 8, 3); - isEmptyAddAndPositiveNumberSize(room::getLength, room::setLength, "0", Double.class, "length", 8, 3); - isEmptyAddAndPositiveNumberSize(room::getWidth, room::setWidth, "0", Double.class, "width", 8, 3); - isEmptyAddAndPositiveNumber(room::getMultipleNumber, room::setMultipleNumber, "1", Integer.class, "multipleNumber"); - isEmptyAddAndPositiveNumber(room::getMultipleNo, room::setMultipleNo, "1", Integer.class, "multipleNo"); - isEmptyAddAndNumber(room::getBasePointX, room::setBasePointX, "0", Double.class, "basePointX"); - isEmptyAddAndNumber(room::getBasePointY, room::setBasePointY, "0", Double.class, "basePointY"); - isEmptyAddAndNumber(room::getBasePointZ, room::setBasePointZ, "0", Double.class, "basePointZ"); - isEmptyAddAndNumber(room::getAxisXrotate, room::setAxisXrotate, "0", Double.class, "axisXrotate"); - isEmptyAddAndNumber(room::getAxisYrotate, room::setAxisYrotate, "0", Double.class, "axisYrotate"); - isEmptyAddAndNumber(room::getAxisZrotate, room::setAxisZrotate, "0", Double.class, "axisZrotate"); + isEmptyAddAndPositiveNumberSize(room::getHeight, room::setHeight, "0", Double.class, FIELD_HEIGHT, 8, 3); + isEmptyAddAndPositiveNumberSize(room::getLength, room::setLength, "0", Double.class, FIELD_LENGTH, 8, 3); + isEmptyAddAndPositiveNumberSize(room::getWidth, room::setWidth, "0", Double.class, FIELD_WIDTH, 8, 3); + isEmptyAddAndPositiveNumber(room::getMultipleNumber, room::setMultipleNumber, "1", Integer.class, FIELD_MULTIPLENUMBER); + isEmptyAddAndPositiveNumber(room::getMultipleNo, room::setMultipleNo, "1", Integer.class, FIELD_MULTIPLENO); + isEmptyAddAndNumber(room::getBasePointX, room::setBasePointX, "0", Double.class, FIELD_BASEPOINTX); + isEmptyAddAndNumber(room::getBasePointY, room::setBasePointY, "0", Double.class, FIELD_BASEPOINTY); + isEmptyAddAndNumber(room::getBasePointZ, room::setBasePointZ, "0", Double.class, FIELD_BASEPOINTZ); + isEmptyAddAndNumber(room::getAxisXrotate, room::setAxisXrotate, "0", Double.class, FIELD_AXISXROTATE); + isEmptyAddAndNumber(room::getAxisYrotate, room::setAxisYrotate, "0", Double.class, FIELD_AXISYROTATE); + isEmptyAddAndNumber(room::getAxisZrotate, room::setAxisZrotate, "0", Double.class, FIELD_AXISZROTATE); } /** @@ -502,17 +521,17 @@ public class DefaultOrderImportXmlParserHandler { * @param box */ public void checkBox(RoomBoxXmlVO box) { - isEmptyAddAndPositiveNumberSize(box::getHeight, box::setHeight, "0", Double.class, "height", 8, 3); - isEmptyAddAndPositiveNumberSize(box::getLength, box::setLength, "0", Double.class, "length", 8, 3); - isEmptyAddAndPositiveNumberSize(box::getWidth, box::setWidth, "0", Double.class, "width", 8, 3); - isEmptyAddAndPositiveNumber(box::getMultipleNumber, box::setMultipleNumber, "1", Integer.class, "multipleNumber"); - isEmptyAddAndPositiveNumber(box::getMultipleNo, box::setMultipleNo, "1", Integer.class, "multipleNo"); - isEmptyAddAndNumber(box::getBasePointX, box::setBasePointX, "0", Double.class, "basePointX"); - isEmptyAddAndNumber(box::getBasePointY, box::setBasePointY, "0", Double.class, "basePointY"); - isEmptyAddAndNumber(box::getBasePointZ, box::setBasePointZ, "0", Double.class, "basePointZ"); - isEmptyAddAndNumber(box::getAxisXrotate, box::setAxisXrotate, "0", Double.class, "axisXrotate"); - isEmptyAddAndNumber(box::getAxisYrotate, box::setAxisYrotate, "0", Double.class, "axisYrotate"); - isEmptyAddAndNumber(box::getAxisZrotate, box::setAxisZrotate, "0", Double.class, "axisZrotate"); + isEmptyAddAndPositiveNumberSize(box::getHeight, box::setHeight, "0", Double.class, FIELD_HEIGHT, 8, 3); + isEmptyAddAndPositiveNumberSize(box::getLength, box::setLength, "0", Double.class, FIELD_LENGTH, 8, 3); + isEmptyAddAndPositiveNumberSize(box::getWidth, box::setWidth, "0", Double.class, FIELD_WIDTH, 8, 3); + isEmptyAddAndPositiveNumber(box::getMultipleNumber, box::setMultipleNumber, "1", Integer.class, FIELD_MULTIPLENUMBER); + isEmptyAddAndPositiveNumber(box::getMultipleNo, box::setMultipleNo, "1", Integer.class, FIELD_MULTIPLENO); + isEmptyAddAndNumber(box::getBasePointX, box::setBasePointX, "0", Double.class, FIELD_BASEPOINTX); + isEmptyAddAndNumber(box::getBasePointY, box::setBasePointY, "0", Double.class, FIELD_BASEPOINTY); + isEmptyAddAndNumber(box::getBasePointZ, box::setBasePointZ, "0", Double.class, FIELD_BASEPOINTZ); + isEmptyAddAndNumber(box::getAxisXrotate, box::setAxisXrotate, "0", Double.class, FIELD_AXISXROTATE); + isEmptyAddAndNumber(box::getAxisYrotate, box::setAxisYrotate, "0", Double.class, FIELD_AXISYROTATE); + isEmptyAddAndNumber(box::getAxisZrotate, box::setAxisZrotate, "0", Double.class, FIELD_AXISZROTATE); isEmptyAndAdd(box::getCode, box::setCode, NOT_ASSIGNED_CODE); isEmptyAndAdd(box::getName, box::setName, NOT_ASSIGNED); } @@ -560,9 +579,9 @@ public class DefaultOrderImportXmlParserHandler { private void checkGroup(GroupXmlVO group) { isEmptyAndAdd(group::getCode, group::setCode, NOT_ASSIGNED_CODE); isEmptyAndAdd(group::getName, group::setName, NOT_ASSIGNED); - isEmptyAddAndPositiveNumberSize(group::getLength, group::setLength, "0", Double.class, "length", 8, 3); - isEmptyAddAndPositiveNumberSize(group::getWidth, group::setWidth, "0", Double.class, "width", 8, 3); - isEmptyAddAndPositiveNumberSize(group::getHeight, group::setHeight, "0", Double.class, "height", 8, 3); + isEmptyAddAndPositiveNumberSize(group::getLength, group::setLength, "0", Double.class, FIELD_LENGTH, 8, 3); + isEmptyAddAndPositiveNumberSize(group::getWidth, group::setWidth, "0", Double.class, FIELD_WIDTH, 8, 3); + isEmptyAddAndPositiveNumberSize(group::getHeight, group::setHeight, "0", Double.class, FIELD_HEIGHT, 8, 3); } /** @@ -609,9 +628,9 @@ public class DefaultOrderImportXmlParserHandler { // 纹理有效性判断 isEmptyAddAndInvalid(plate::getGrained, plate::setGrained, "有", DictTypeConstants.PLATE_TEXTURE_TYPE, "grained"); isEmptyAddAndInvalid(plate::getCoating, plate::setCoating, "双面", DictTypeConstants.COATING_TYPE, "coating"); - isEmptyAndPositiveNumber(plate::getLength, "length", plate::setLength, Double.class, 5, 3); - isEmptyAndPositiveNumber(plate::getWidth, "width", plate::setWidth, Double.class, 5, 3); - isEmptyAndPositiveNumber(plate::getThickness, "thickness", plate::setThickness, Double.class, 5, 3); + isEmptyAndPositiveNumber(plate::getLength, FIELD_LENGTH, plate::setLength, Double.class, 5, 3); + isEmptyAndPositiveNumber(plate::getWidth, FIELD_WIDTH, plate::setWidth, Double.class, 5, 3); + isEmptyAndPositiveNumber(plate::getThickness, FIELD_THICKNESS, plate::setThickness, Double.class, 5, 3); notEmptyPositiveNumberSize(plate::getOddmentLength, plate::setOddmentLength, "oddmentLength", Double.class, 5, 3); notEmptyPositiveNumberSize(plate::getOddmentWidth, plate::setOddmentWidth, "oddmentWidth", Double.class, 5, 3); notEmptyPositiveNumberSize(plate::getOddmentThickness, plate::setOddmentThickness, "oddmentThickness", Double.class, 5, 3); @@ -619,7 +638,7 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAddAndInvalid(plate::getUnitLength, plate::setUnitLength, "mm", DictTypeConstants.UNIT_LENGTH, "unitLength"); notEmptyPositiveNumber(plate::getArea, "area", Double.class); isEmptyAddAndInvalid(plate::getUnitArea, plate::setUnitArea, "m²", DictTypeConstants.UNIT_AREA, "unitArea"); - notEmptyPositiveNumber(plate::getCount, "count", Integer.class); + notEmptyPositiveNumber(plate::getCount, FIELD_COUNT, Integer.class); } /** @@ -687,9 +706,9 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAddAndInvalid(blockXmlVO::getTexture, blockXmlVO::setTexture, "正纹", DictTypeConstants.GRAIN_TYPE, "texture"); isEmptyAddAndInvalid(blockXmlVO::getLayoutFace, blockXmlVO::setLayoutFace, "随意面", DictTypeConstants.TYPOGRAPHY_TYPE, "layoutFace"); isEmptyAddAndInvalid(blockXmlVO::getCoatingType, blockXmlVO::setCoatingType, "双面", DictTypeConstants.COATING_TYPE, "coatingType"); - isEmptyAndPositiveNumber(blockXmlVO::getLength, "length", blockXmlVO::setLength, Double.class, 5, 3); - isEmptyAndPositiveNumber(blockXmlVO::getWidth, "width", blockXmlVO::setWidth, Double.class, 5, 3); - isEmptyAndPositiveNumber(blockXmlVO::getThickness, "thickness", blockXmlVO::setThickness, Double.class, 5, 3); + isEmptyAndPositiveNumber(blockXmlVO::getLength, FIELD_LENGTH, blockXmlVO::setLength, Double.class, 5, 3); + isEmptyAndPositiveNumber(blockXmlVO::getWidth, FIELD_WIDTH, blockXmlVO::setWidth, Double.class, 5, 3); + isEmptyAndPositiveNumber(blockXmlVO::getThickness, FIELD_THICKNESS, blockXmlVO::setThickness, Double.class, 5, 3); isEmptyAndPositiveNumber(blockXmlVO::getCuttingLength, "cuttingLength", blockXmlVO::setCuttingLength, Double.class, 5, 3); isEmptyAndPositiveNumber(blockXmlVO::getCuttingWidth, "cuttingWidth", blockXmlVO::setCuttingWidth, Double.class, 5, 3); isEmptyAndPositiveNumber(blockXmlVO::getCuttingThickness, "cuttingThickness", blockXmlVO::setCuttingThickness, Double.class, 5, 3); @@ -697,8 +716,8 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndPositiveNumber(blockXmlVO::getRawWidth, "rawWidth", blockXmlVO::setRawWidth, Double.class, 5, 3); isEmptyAndPositiveNumber(blockXmlVO::getRawThickness, "rawThickness", blockXmlVO::setRawThickness, Double.class, 5, 3); isEmptyAddAndInvalid(blockXmlVO::getUnit, blockXmlVO::setUnit, "mm", DictTypeConstants.UNIT_LENGTH, "unit"); - isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNumber, blockXmlVO::setMultipleNumber, "1", Integer.class, "multipleNumber"); - isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNo, blockXmlVO::setMultipleNo, "1", Integer.class, "multipleNo"); + isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNumber, blockXmlVO::setMultipleNumber, "1", Integer.class, FIELD_MULTIPLENUMBER); + isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNo, blockXmlVO::setMultipleNo, "1", Integer.class, FIELD_MULTIPLENO); isEmptyAddAndInvalid(blockXmlVO::getUnregular, blockXmlVO::setUnregular, "否", DictTypeConstants.IS_NOT_MARK, "unregular"); isEmptyAddAndInvalid(blockXmlVO::getDrilling, blockXmlVO::setDrilling, "否", DictTypeConstants.IS_NOT_MARK, "drilling"); isEmptyAddAndInvalid(blockXmlVO::getSlotting, blockXmlVO::setSlotting, "否", DictTypeConstants.IS_NOT_MARK, "slotting"); @@ -708,12 +727,12 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndAdd(blockXmlVO::getBoxCode, blockXmlVO::setBoxCode, NOT_ASSIGNED_CODE); isEmptyAndAdd(blockXmlVO::getBoxName, blockXmlVO::setBoxName, NOT_ASSIGNED); - isEmptyAddAndNumber(blockXmlVO::getBasePointX, blockXmlVO::setBasePointX, "0", Double.class, "basePointX"); - isEmptyAddAndNumber(blockXmlVO::getBasePointY, blockXmlVO::setBasePointY, "0", Double.class, "basePointY"); - isEmptyAddAndNumber(blockXmlVO::getBasePointZ, blockXmlVO::setBasePointZ, "0", Double.class, "basePointZ"); - isEmptyAddAndNumber(blockXmlVO::getAxisXrotate, blockXmlVO::setAxisXrotate, "0", Double.class, "axisXrotate"); - isEmptyAddAndNumber(blockXmlVO::getAxisYrotate, blockXmlVO::setAxisYrotate, "0", Double.class, "axisYrotate"); - isEmptyAddAndNumber(blockXmlVO::getAxisZrotate, blockXmlVO::setAxisZrotate, "0", Double.class, "axisZrotate"); + isEmptyAddAndNumber(blockXmlVO::getBasePointX, blockXmlVO::setBasePointX, "0", Double.class, FIELD_BASEPOINTX); + isEmptyAddAndNumber(blockXmlVO::getBasePointY, blockXmlVO::setBasePointY, "0", Double.class, FIELD_BASEPOINTY); + isEmptyAddAndNumber(blockXmlVO::getBasePointZ, blockXmlVO::setBasePointZ, "0", Double.class, FIELD_BASEPOINTZ); + isEmptyAddAndNumber(blockXmlVO::getAxisXrotate, blockXmlVO::setAxisXrotate, "0", Double.class, FIELD_AXISXROTATE); + isEmptyAddAndNumber(blockXmlVO::getAxisYrotate, blockXmlVO::setAxisYrotate, "0", Double.class, FIELD_AXISYROTATE); + isEmptyAddAndNumber(blockXmlVO::getAxisZrotate, blockXmlVO::setAxisZrotate, "0", Double.class, FIELD_AXISZROTATE); } /** @@ -789,13 +808,13 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndAdd(edgingXmlVO::getBoxName, edgingXmlVO::setBoxName, NOT_ASSIGNED); isEmptyAndBack(edgingXmlVO::getName, "name"); isEmptyAndBack(edgingXmlVO::getMaterial, "material"); - isEmptyAndBack(edgingXmlVO::getColor, "color"); - isEmptyBackAndPositiveNumber(edgingXmlVO::getLength, "length", Double.class); - isEmptyBackAndPositiveNumber(edgingXmlVO::getWidth, "width", Double.class); - isEmptyBackAndPositiveNumber(edgingXmlVO::getThickness, "thickness", Double.class); + isEmptyAndBack(edgingXmlVO::getColor, FIELD_COLOR); + isEmptyBackAndPositiveNumber(edgingXmlVO::getLength, FIELD_LENGTH, Double.class); + isEmptyBackAndPositiveNumber(edgingXmlVO::getWidth, FIELD_WIDTH, Double.class); + isEmptyBackAndPositiveNumber(edgingXmlVO::getThickness, FIELD_THICKNESS, Double.class); isEmptyAddAndInvalid(edgingXmlVO::getUnit, edgingXmlVO::setUnit, "mm", DictTypeConstants.UNIT_LENGTH, "unit"); - isEmptyBackAndPositiveNumber(edgingXmlVO::getCount, "count", Double.class); - isEmptyAddAndInvalid(edgingXmlVO::getUnitCount, edgingXmlVO::setUnitCount, "m", DictTypeConstants.UNIT_LENGTH, "unitCount"); + isEmptyBackAndPositiveNumber(edgingXmlVO::getCount, FIELD_COUNT, Double.class); + isEmptyAddAndInvalid(edgingXmlVO::getUnitCount, edgingXmlVO::setUnitCount, "m", DictTypeConstants.UNIT_LENGTH, FIELD_UNITCOUNT); } /** @@ -855,9 +874,9 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndAdd(hardwareXmlVO::getBoxName, hardwareXmlVO::setBoxName, NOT_ASSIGNED); isEmptyAndBack(hardwareXmlVO::getName, "name"); isEmptyAndBack(hardwareXmlVO::getMaterial, "material"); - isEmptyAndBack(hardwareXmlVO::getColor, "color"); - isEmptyBackAndPositiveNumber(hardwareXmlVO::getCount, "count", Double.class); - isEmptyAndBack(hardwareXmlVO::getUnitCount, "unitCount"); + isEmptyAndBack(hardwareXmlVO::getColor, FIELD_COLOR); + isEmptyBackAndPositiveNumber(hardwareXmlVO::getCount, FIELD_COUNT, Double.class); + isEmptyAndBack(hardwareXmlVO::getUnitCount, FIELD_UNITCOUNT); isEmptyAndBack(hardwareXmlVO::getUnit, "unit"); } @@ -923,9 +942,9 @@ public class DefaultOrderImportXmlParserHandler { private void checkAssemblie(AssemblyXmlVO assemblyXmlVO) { isEmptyAndBack(assemblyXmlVO::getName, "name"); isEmptyAndBack(assemblyXmlVO::getMaterial, "name"); - isEmptyAndBack(assemblyXmlVO::getColor, "color"); - isEmptyBackAndPositiveNumber(assemblyXmlVO::getCount, "count", Double.class); - isEmptyAndBack(assemblyXmlVO::getUnitCount, "unitCount"); + isEmptyAndBack(assemblyXmlVO::getColor, FIELD_COLOR); + isEmptyBackAndPositiveNumber(assemblyXmlVO::getCount, FIELD_COUNT, Double.class); + isEmptyAndBack(assemblyXmlVO::getUnitCount, FIELD_UNITCOUNT); isEmptyAndAdd(assemblyXmlVO::getRoomCode, assemblyXmlVO::setRoomCode, NOT_ASSIGNED_CODE); isEmptyAndAdd(assemblyXmlVO::getRoomName, assemblyXmlVO::setRoomName, NOT_ASSIGNED); isEmptyAndAdd(assemblyXmlVO::getBoxCode, assemblyXmlVO::setBoxCode, NOT_ASSIGNED_CODE); @@ -1119,7 +1138,7 @@ public class DefaultOrderImportXmlParserHandler { isEmptyBackAndPositiveNumber(holeXmlVO::getDiameterInner, "当小板孔类型为沉头孔时,小板孔沉头孔内径", Double.class); isEmptyBackAndPositiveNumber(holeXmlVO::getDepthInner, "当小板孔类型为沉头孔时,沉头孔的深度", Double.class); } - isEmptyBackAndPositiveNumber(holeXmlVO::getDepth, "depth", Double.class); + isEmptyBackAndPositiveNumber(holeXmlVO::getDepth, FIELD_DEPTH, Double.class); notEmptyPositiveNumber(holeXmlVO::getGroupNumber, "groupNumber", Integer.class); isEmptyAddAndNumber(holeXmlVO::getGroupXoffset, holeXmlVO::setGroupXoffset, "0", Double.class, "groupXoffset"); isEmptyAddAndNumber(holeXmlVO::getGroupYoffset, holeXmlVO::setGroupYoffset, "0", Double.class, "groupYoffset"); @@ -1170,7 +1189,7 @@ public class DefaultOrderImportXmlParserHandler { * @param grooveXmlVOS */ private void checkGooves(GrooveXmlVOS grooveXmlVOS) { - isEmptyAddAndPositiveNumber(grooveXmlVOS::getCount, grooveXmlVOS::setCount, "0", Double.class, "count"); + isEmptyAddAndPositiveNumber(grooveXmlVOS::getCount, grooveXmlVOS::setCount, "0", Double.class, FIELD_COUNT); isEmptyAddAndPositiveNumber(grooveXmlVOS::getCountFaceA, grooveXmlVOS::setCountFaceA, "0", Double.class, "countFaceA"); isEmptyAddAndPositiveNumber(grooveXmlVOS::getCountFaceB, grooveXmlVOS::setCountFaceB, "0", Double.class, "countFaceB"); isEmptyAddAndPositiveNumber(grooveXmlVOS::getCountSide, grooveXmlVOS::setCountSide, "0", Double.class, "countSide"); @@ -1242,9 +1261,9 @@ public class DefaultOrderImportXmlParserHandler { isEmptyAndBack(grooveXmlVO::getWidth, "当槽为矩形时,槽宽度"); } - isEmptyAddAndPositiveNumber(grooveXmlVO::getWidth, grooveXmlVO::setWidth, "0", Double.class, "width"); - isEmptyAddAndPositiveNumber(grooveXmlVO::getLength, grooveXmlVO::setLength, "0", Double.class, "length"); - isEmptyBackAndPositiveNumber(grooveXmlVO::getDepth, "depth", Double.class); + isEmptyAddAndPositiveNumber(grooveXmlVO::getWidth, grooveXmlVO::setWidth, "0", Double.class, FIELD_WIDTH); + isEmptyAddAndPositiveNumber(grooveXmlVO::getLength, grooveXmlVO::setLength, "0", Double.class, FIELD_LENGTH); + isEmptyBackAndPositiveNumber(grooveXmlVO::getDepth, FIELD_DEPTH, Double.class); isEmptyAddAndPositiveNumber(grooveXmlVO::getWidthExtend, grooveXmlVO::setWidthExtend, "0", Double.class, "widthExtend"); isEmptyAddAndPositiveNumber(grooveXmlVO::getLengthExtend, grooveXmlVO::setLengthExtend, "0", Double.class, "lengthExtend"); isEmptyAddAndPositiveNumber(grooveXmlVO::getDepthExtend, grooveXmlVO::setDepthExtend, "0", Double.class, "depthExtend"); @@ -1323,7 +1342,7 @@ public class DefaultOrderImportXmlParserHandler { */ private void checkOffsetLine(OffsetLineXmlVO offsetLineXmlVO) { isEmptyBackAndNumber(offsetLineXmlVO::getOffset, Double.class, "offset"); - isEmptyBackAndPositiveNumber(offsetLineXmlVO::getDepth, "depth", Double.class); + isEmptyBackAndPositiveNumber(offsetLineXmlVO::getDepth, FIELD_DEPTH, Double.class); isEmptyBackAndPositiveNumber(offsetLineXmlVO::getToolDiameter, "toolDiameter", Double.class); isEmptyAddAndPositiveNumber(offsetLineXmlVO::getTangentAngle, offsetLineXmlVO::setTangentAngle, "0", Double.class, "tangentAngle"); } @@ -1380,7 +1399,7 @@ public class DefaultOrderImportXmlParserHandler { if (StringUtils.isEmpty(correlationXmlVO.getItemCode())) { isEmptyAndBack(correlationXmlVO::getName, "name"); } - isEmptyBackAndPositiveNumber(correlationXmlVO::getCount, "count", Integer.class); + isEmptyBackAndPositiveNumber(correlationXmlVO::getCount, FIELD_COUNT, Integer.class); } } @@ -1579,9 +1598,9 @@ public class DefaultOrderImportXmlParserHandler { */ public void validOrderInfo(OrderXmlVO orderXmlVO) { // 自定义单号校验 - validCustomOrderNo("orderCode", orderXmlVO.getOrderCode()); + validCustomOrderNo(FIELD_ORDERCODE, orderXmlVO.getOrderCode()); // 校验非空 - validOrderInfoEmpty("orderCode", orderXmlVO.getOrderCode()); + validOrderInfoEmpty(FIELD_ORDERCODE, orderXmlVO.getOrderCode()); validOrderInfoEmpty("customer", orderXmlVO.getCustomer()); validOrderInfoEmpty("dealer", orderXmlVO.getDealer()); validOrderInfoEmpty("customerAddress", orderXmlVO.getCustomerAddress()); @@ -1589,7 +1608,7 @@ public class DefaultOrderImportXmlParserHandler { validOrderInfoEmpty("deliveryDate", orderXmlVO.getDeliveryDate()); // 长度校验 - validOrderInfoLength("orderCode", orderXmlVO.getOrderCode(), 32); + validOrderInfoLength(FIELD_ORDERCODE, orderXmlVO.getOrderCode(), 32); validOrderInfoLength("customer", orderXmlVO.getCustomer(), 255); validOrderInfoLength("dealer", orderXmlVO.getDealer(), 255); validOrderInfoLength("customerAddress", orderXmlVO.getCustomerAddress(), 255); @@ -1993,23 +2012,6 @@ public class DefaultOrderImportXmlParserHandler { } } - /** - * 数量类型+数量正数 + 返回值 - * - * @param value: - * @param name: 字段错误名称 - * @param targetType: 需要转换的数字类型 - */ - private void positiveNumberAndBack(String value, String name, Class targetType) { - if (ToolUtil.convertToType(value, targetType)) { - if (!ToolUtil.checkNumber(value)) { - throw ServiceExceptionUtil.exception(ORDER_IMPORT_DETAIL_VALID_ERROR, String.format(se.toString() + POSITIVE_ERR, name)); - } - } else { - throw ServiceExceptionUtil.exception(ORDER_IMPORT_DETAIL_VALID_ERROR, String.format(se.toString() + TYPE_ERR, name)); - } - } - /** * 空值错返+数量类型 * diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/DefaultXmlOrderImportFactory.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/DefaultXmlOrderImportFactory.java index a027e020f..0f0201e9a 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/DefaultXmlOrderImportFactory.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/DefaultXmlOrderImportFactory.java @@ -94,6 +94,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import static com.cf.imes.module.executor.enums.OrderImportConstants.NOT_ASSIGNED; import static com.cf.imes.module.plan.enums.ErrorCodeConstants.ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS; @@ -538,7 +539,7 @@ public class DefaultXmlOrderImportFactory { .orderId(orderId) .type(OrderItemTypeEnum.PLATE_ITEM.getStatus()) .plateId(plateId) - .groupId(ObjectUtil.isNotNull(groupTempDataDO) ? groupTempDataDO.getInnerGroupId() : 0L) + .groupId(Optional.ofNullable(groupTempDataDO).map(OrderImportTempDataDO::getInnerGroupId).orElse(0L)) .roomId(roomBodyTempDataDO.getInnerRoomId()) .bodyId(roomBodyTempDataDO.getInnerBodyId()) .num(1.0) @@ -604,9 +605,7 @@ public class DefaultXmlOrderImportFactory { addRemark(blockProductionCode, plateDO, orderModelDO); // 查询大板id用于小板轮廓goodsId GoodsDO goodsDO = goodsMapper.selectById(goodsId); - if (ObjectUtil.isNull(goodsDO)) { - throw ServiceExceptionUtil.exception(ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS, orderId, goodsId); - } + Optional.ofNullable(goodsDO).orElseThrow(() -> ServiceExceptionUtil.exception(ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS, orderId, goodsId)); orderModelDO.setGoodsId(goodsDO.getGoodsId()); orderModelDO.setPlateGoodsId(goodsId); orderModelDO.setOrganId(organId); @@ -642,10 +641,8 @@ public class DefaultXmlOrderImportFactory { .eq(OrderImportTempDataDO::getOuterGoodsId, blockProductionCode) .eq(OrderImportTempDataDO::getOrganId, organId) ); - BigDecimal sealLeft = BigDecimal.valueOf(0); - BigDecimal sealRight = BigDecimal.valueOf(0); - BigDecimal sealUp = BigDecimal.valueOf(0); - BigDecimal sealDown = BigDecimal.valueOf(0); + BigDecimal[] sealPositions = new BigDecimal[4]; + Arrays.fill(sealPositions, BigDecimal.ZERO); ExtraVO extraVO = ExtraVO.builder() .edgeRemarks(new ArrayList<>()) @@ -666,20 +663,8 @@ public class DefaultXmlOrderImportFactory { addSealEdgePart(orderItemDO, pointXmlVO); } - if (!plateDO.getIsSpecialShaped()) { - if (x == 0 && y == 0) { - sealDown = size; - } - if (x != 0 && y == 0) { - sealRight = size; - } - if (x != 0 && y != 0) { - sealUp = size; - } - if (x == 0 && y != 0) { - sealLeft = size; - } - } + // 计算封边条厚度 + calculateSealPositions(plateDO, pointXmlVO, sealPositions); orderModelDO.getRawPointDetail().add(PointDetail.builder() .pointX(x) @@ -701,9 +686,40 @@ public class DefaultXmlOrderImportFactory { String jsonString = JSON.toJSONString(extraVO); JSONObject jsonObject = JSON.parseObject(jsonString); orderModelDO.setPlateExtraRemark(jsonObject); - plateDO.setSealUp(sealUp).setSealDown(sealDown).setSealLeft(sealLeft).setSealRight(sealRight); + plateDO.setSealLeft(sealPositions[0]).setSealRight(sealPositions[1]).setSealUp(sealPositions[2]).setSealDown(sealPositions[3]); } + + /** + * 计算封边条上下左右厚度 + * + * @param plateDO + * @param pointXmlVO + * @param sealPositions + */ + private void calculateSealPositions(PlateDO plateDO, PointXmlVO pointXmlVO, BigDecimal[] sealPositions) { + if (!plateDO.getIsSpecialShaped()) { + double x = Double.parseDouble(pointXmlVO.getPointX()); + double y = Double.parseDouble(pointXmlVO.getPointY()); + BigDecimal size = new BigDecimal(pointXmlVO.getEdgingThickness()); + + if (x == 0 && y != 0) { + sealPositions[0] = size; // sealLeft + } + if (x != 0 && y == 0) { + sealPositions[1] = size; // sealRight + } + if (x != 0 && y != 0) { + sealPositions[2] = size; // sealUp + } + if (x == 0 && y == 0) { + sealPositions[3] = size; // sealDown + } + + } + } + + /** * 新增封边条配件 *