diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/DictTypeConstants.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/DictTypeConstants.java index fa8a13453..abb691764 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/DictTypeConstants.java +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/DictTypeConstants.java @@ -7,13 +7,16 @@ public class DictTypeConstants { public static final String HOLE_FACE = "hole_face";//加工面 public static final String HOLE_DIRECTION = "hole_direction";// 方向 + public static final String IS_NOT_MARK = "is_not_mark";// 是否标识 // ========== PLATE 模块 ========== public static final String TYPOGRAPHY_TYPE = "typographyType"; // 排版面 public static final String GRAIN_TYPE = "grainType";// 小板纹路类型 public static final String DOOR_OPENING_DIRECTIONS = "doorOpeningDirections";//开门方向 public static final String PLATE_TYPE = "order_plate_type"; // 板类型 - + public static final String PLATE_TEXTURE_TYPE = "plate_texture_type";// 板材纹路:0有 1无 + public static final String COATING_TYPE = "coatingType";// xml 设计饰面 + public static final String ODDMENT_MARK = "oddment_mark";// xml 设计饰面 // ========== HOLE 模块 ========== public static final String HOLE_TYPE = "hole_type";//孔类型 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index 2049136f9..3eaf14637 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -398,7 +398,7 @@ public class OrderController { @Parameter(name = "deleted", description = "是否删除", example = "false") }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") - public CommonResult> getModule(@RequestParam("orderId") Long orderId, + public CommonResult>> getModule(@RequestParam("orderId") Long orderId, @RequestParam(value = "deleted", required = false, defaultValue = "false") Boolean deleted) { if (deleted == null) { deleted = false; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/dto/Point.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/dto/Point.java index c8550b3ba..eb6a6164f 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/dto/Point.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/dto/Point.java @@ -1,12 +1,15 @@ package com.cf.imes.module.executor.controller.admin.plan.dto; +import lombok.Builder; import lombok.Data; /** * @author Beal */ @Data +@Builder public class Point { private Double x; private Double y; + private Double z; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java index 322c70bfa..9650a3358 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java @@ -62,7 +62,7 @@ public interface OrderService { * @param orderId: 生产单Id * @return Map> */ - Map getModule(Long orderId, Integer deleted); + Map> getModule(Long orderId, Integer deleted); /** * @param orderId: 生产单id diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java index 0e7250c6e..7f88b53aa 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java @@ -12,7 +12,6 @@ import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.util.Assert.AssertUtils; import com.cf.imes.framework.common.util.object.BeanUtils; -import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; @@ -52,10 +51,6 @@ import com.cf.imes.module.executor.enums.OrderStatusEnum; import com.cf.imes.module.executor.service.plan.PlanService; import com.cf.imes.module.executor.util.deviseData.structure.PlateDetail; import com.cf.imes.module.executor.util.fileConversion.admin.SnowflakeIdWorker3rd; -import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve; -import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize; -import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTypeRealize; -import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XmlTypeRealize; import org.springframework.aop.framework.AopContext; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -131,20 +126,9 @@ public class OrderServiceImpl implements OrderService { @Resource private IdentifierGenerator identifierGenerator; - @Resource - private SnowFlakeGenerator snowFlakeGenerator; - - @Resource - private ApiDataAchieve apiDataAchieve; - @Resource private SnowflakeIdWorker3rd idWorker; - @Resource - private ApiTypeRealize apiTypeRealize; - - @Resource - private ExcelTypeRealize excelTypeRealize; private static final String SUBMIT_STATE = "1"; // 空订单 原生产系统 @@ -154,8 +138,6 @@ public class OrderServiceImpl implements OrderService { String ORDER_REMAIN_PLATE_MODEL = "imes_order_optimize_plate_model"; - @Resource - private XmlTypeRealize xmlTypeRealize; @Resource private PlanService planService; @@ -226,14 +208,14 @@ public class OrderServiceImpl implements OrderService { } @Override - public Map getModule(Long orderId, Integer deleted) { + public Map> getModule(Long orderId, Integer deleted) { // 柜体信息 List orderModuleRespVOList = orderBodyMapper.selectModuleByOrderId(orderId, getUserOrganId(), deleted); // 配件 List orderItemDOS = orderItemMapper.selectPartsByOrderId(orderId, getUserOrganId(), deleted); - Map map = new HashMap<>(); + Map> map = new HashMap<>(); map.put("module", orderModuleRespVOList); map.put("parts", orderItemDOS); return map; @@ -423,9 +405,8 @@ public class OrderServiceImpl implements OrderService { return order.get(0).getId(); } - @Override - @Transactional(rollbackFor = Exception.class) - public void importExcelData(OrderDO orderDO, Integer index, Map> listMap) { + // 生产单插入 + private void insertOrder(OrderDO orderDO, Integer index) { if (index == 0) { String nickName = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getNickname(); if (orderDO.getSalesman() == null || orderDO.getSalesman().equals("")) { @@ -436,55 +417,66 @@ public class OrderServiceImpl implements OrderService { } orderMapper.insert(orderDO); } - if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus())) { - List rawGoodsDO = (List) listMap.get("rawGoodsDOS"); - List goodsDO = (List) listMap.get("goodsDOS"); + } - List bodyDO = (List) listMap.get("orderBodyDOS"); - List groupDO = (List) listMap.get("orderGroupDOS"); - List plateDO = (List) listMap.get("plateDOS"); - List partsDO = (List) listMap.get("orderPartsDOS"); - List itemDO = (List) listMap.get("orderItemDOS"); - List orderModelDOS = (List) listMap.get("orderModelDOS"); - List orderPartsRemarks = (List) listMap.get("orderPartsRemarks"); - List plateDetail = (List) listMap.get("plateDetail"); - // 板材库匹配 - Map> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在 excel - goodsDO = (List) map.get(GOODSDO_KEY); - List plateGoodDOS = (List) map.get(PLATE_GOODS_LIST_KEY); + @Override + @Transactional(rollbackFor = Exception.class) + public void importExcelData(OrderDO orderDO, Integer index, Map> listMap) { + insertOrder(orderDO, index); + + if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus())) { + return; + } - if (index != 0) { - roomCabinetProcessGroupMatch(orderDO.getId(), bodyDO, itemDO); - if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus())) { - orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus()); - updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); - } - if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.FINISH_PRODUCTION.getStatus())) { - orderDO.setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus()); - updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); - } - if (Objects.equals(orderDO.getPackaged(), OrderPackageStatusEnum.PACKAGED.getStatus())) { - orderDO.setPackaged(OrderPackageStatusEnum.PACKAGED.getStatus()); - updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); - } + List rawGoodsDO = (List) listMap.get("rawGoodsDOS"); + List goodsDO = (List) listMap.get("goodsDOS"); + + List bodyDO = (List) listMap.get("orderBodyDOS"); + List groupDO = (List) listMap.get("orderGroupDOS"); + List plateDO = (List) listMap.get("plateDOS"); + List partsDO = (List) listMap.get("orderPartsDOS"); + List itemDO = (List) listMap.get("orderItemDOS"); + List orderModelDOS = (List) listMap.get("orderModelDOS"); + List orderPartsRemarks = (List) listMap.get("orderPartsRemarks"); + List plateDetail = (List) listMap.get("plateDetail"); + // 板材库匹配 + Map> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在 excel + goodsDO = (List) map.get(GOODSDO_KEY); + List plateGoodDOS = (List) map.get(PLATE_GOODS_LIST_KEY); + + + if (index != 0) { + roomCabinetProcessGroupMatch(orderDO.getId(), bodyDO, itemDO); + if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus())) { + orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus()); + updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); } - orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS); - if (orderModelDOS != null && orderModelDOS.size() > 0) { - orderInputProcessor.batchSaveModel(orderModelDOS); + if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.FINISH_PRODUCTION.getStatus())) { + orderDO.setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus()); + updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); } - if (plateDetail != null){ - List orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class); - if (orderModelDOs.size() > 0) { - orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(orderDO.getId())); - System.out.println("----" + orderModelDOs); - orderInputProcessor.batchSaveModel(orderModelDOs); - } - } - if (orderPartsRemarks != null && orderPartsRemarks.size() > 0) { - orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks); + if (Objects.equals(orderDO.getPackaged(), OrderPackageStatusEnum.PACKAGED.getStatus())) { + orderDO.setPackaged(OrderPackageStatusEnum.PACKAGED.getStatus()); + updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class)); } } + orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS); + if (orderModelDOS != null && orderModelDOS.size() > 0) { + orderInputProcessor.batchSaveModel(orderModelDOS); + } + if (plateDetail != null){ + List orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class); + if (orderModelDOs.size() > 0) { + orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(orderDO.getId())); + System.out.println("----" + orderModelDOs); + orderInputProcessor.batchSaveModel(orderModelDOs); + } + } + if (orderPartsRemarks != null && orderPartsRemarks.size() > 0) { + orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks); + } + } @@ -697,6 +689,14 @@ public class OrderServiceImpl implements OrderService { return bodyIds; } + private PlateGoodDO getPlateGood(String goodsId, Long organId) { + List plateGoodDOs = plateGoodMapper.selectGoodOne(goodsId, organId); + if (plateGoodDOs.size() > 0) { + return plateGoodDOs.get(0); + } + return null; + } + private Map> getPlateGoods(List goodsLists) { Map> map = new HashMap<>(); List plateGoodLists = new ArrayList<>(); @@ -705,14 +705,14 @@ public class OrderServiceImpl implements OrderService { PlateGoodDO plateGoodDO = null; List plateGoodDOS = null; if (goodsDO.getGoodsId() != null) { // 有goodsId - List plateGoodlist = plateGoodMapper.selectGoodOne(goodsDO.getGoodsId(), OrganContextHolder.getOrganId()); - if (plateGoodlist.size() > 0) { - plateGoodDO = plateGoodlist.get(0); - } + plateGoodDO = getPlateGood(goodsDO.getGoodsId(), OrganContextHolder.getOrganId()); } else { // 没有goodsId 其他信息匹配 plateGoodDOS = plateGoodMapper.selectGood(goodsDO.getGoodsName(), goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getTexture(), goodsDO.getWidth(), goodsDO.getThickness(), goodsDO.getHeight(), goodsDO.getBrand(), goodsDO.getSpec(), OrganContextHolder.getOrganId()); + long plateNo = idWorker.nextId(); + long obtainingTime = idWorker.obtainingTime(); + goodsDO.setGoodsId((obtainingTime) + Long.toString(plateNo).substring(2)); } if (plateGoodDOS != null && plateGoodDOS.size() > 0) {//存在板材 @@ -722,14 +722,8 @@ public class OrderServiceImpl implements OrderService { } else { // 不存在板材 String goodsId = goodsDO.getGoodsId(); - if (goodsId == null) { - long plateNo = idWorker.nextId(); - long obtainingTime = idWorker.obtainingTime(); - goodsId = (obtainingTime) + Long.toString(plateNo).substring(2); - } Long plateGoods = (Long) identifierGenerator.nextId(null); -// Long goodsId = (Long) identifierGenerator.nextId(null); plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class) .setId(plateGoods) .setGoodsId(goodsId); @@ -752,7 +746,7 @@ public class OrderServiceImpl implements OrderService { public void roomCabinetProcessGroupMatch(Long orderId, List orderBodyList, List orderItemDOList) { Map> bodyMap = orderBodyList.stream().collect(Collectors.groupingBy(OrderBodyDO::getRoomName)); bodyMap.forEach((roomName, roomList) -> { - List sameBodyList = orderBodyMapper.selectByRoomName(orderId, roomName, SecurityFrameworkUtils.getLoginUser().getOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); + List sameBodyList = orderBodyMapper.selectByRoomName(orderId, roomName, OrganContextHolder.getOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); if (sameBodyList != null && sameBodyList.size() > 0) { Long originalRoomId = roomList.get(0).getRoomId(); @@ -760,25 +754,31 @@ public class OrderServiceImpl implements OrderService { Long roomId = sameBodyList.get(0).getRoomId(); // 修改roomId (orderBody中) - orderBodyList.forEach(room -> { - if (room.getRoomId().equals(originalRoomId)) { - room.setRoomId(roomId); - } - }); + updateRoomIdInOrderBodies(orderBodyList, originalRoomId, roomId); // 修改orderItem - orderItemDOList.forEach(item -> { - if (item.getRoomId() != null) { - if (item.getRoomId().equals(originalRoomId)) { - item.setRoomId(roomId); - } - } - }); + updateRoomIdInOrderItems(orderItemDOList, originalRoomId, roomId); } }); } + private void updateRoomIdInOrderBodies(List orderBodyList, Long originalRoomId, Long roomId) { + orderBodyList.forEach(room -> { + if (room.getRoomId().equals(originalRoomId)) { + room.setRoomId(roomId); + } + }); + } + + private void updateRoomIdInOrderItems(List orderItemDOList, Long originalRoomId, Long roomId) { + orderItemDOList.forEach(item -> { + if (item.getRoomId() != null && item.getRoomId().equals(originalRoomId)) { + item.setRoomId(roomId); + } + }); + } + // 根据ype 与 orderId获取相关信息 public Map getDataByOrderIdAndType(OrderDO orderDO, String type, Integer deleted) { String tableKey = "table"; @@ -787,32 +787,32 @@ public class OrderServiceImpl implements OrderService { map.put("orderDO", orderDO); switch (type) { case "配件明细1-模板.xlsx":// 配件明细 - map.put("partsListDetail", orderPartsMapper.selectPartDetail(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("partsListDetail", orderPartsMapper.selectPartDetail(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
配件明细单
生产单号:数据源自定义单号:数据源经销商:数据源订单日期:数据源
客户:数据源收货电话:数据源收货地址:数据源收货日期:数据源
备注:数据源
房间名数据源柜体名表数据源
名称品牌厂家型号规格数量单位备注
数据源数据源数据源数据源数据源数据源数据源数据源
"); break; case "配件汇总1-模板.xlsx":// 配件汇总 - map.put("partsSummary", orderPartsMapper.selectPartAll(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("partsSummary", orderPartsMapper.selectPartAll(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
配件汇总单
生产单号:自定单号:经销商:订单日期
客户:收货电话:收货地址:收货日期:
备注:
名称型号规格数量单位品牌备注
"); break; case "板材明细-按房间-模板.xlsx": - map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
板材明细单
生产单号:自定单号:经销商:订单日期
客户:收货电话:收货地址:收货日期:
备注:
房间名数据源柜体数据源列表条数表达式
板编号板名称材料颜色厚度面积异形造型左/右/上/下开门类型备注
小计:小计面积表达式
合计:合计面积表达式
"); - map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); break; case "板材明细-按板材-模板.xlsx": - map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
板材明细单
生产单号:自定单号:经销商:订单日期
客户:收货电话:收货地址:收货日期:
备注:
板材名称数据源板材颜色数据源板材厚度数据源列表条数表达式
房名柜名板编号板名称厚度面积异形造型左/右/上/下开门类型备注
小计:小计面积表达式
合计:合计面积表达式
"); - map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); break; case "板材汇总-按房间-模板.xlsx": - map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
板材汇总单
生产单号:自定单号:经销商:订单日期
客户:收货电话:收货地址:收货日期:
备注:
房间名称数据源柜体数据源列表条数表达式
板名称材料颜色厚度数量面积开门类型
小计:数量表达式面积表达式
合计:数量表达式面积表达式
"); - map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); break; case "板材汇总-按板材-模板.xlsx": - map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); map.put(tableKey, "SheetJS Table Export
板材汇总单
生产单号:数据源自定义单号:数据源经销商:数据源订单日期:数据源
客户:数据源收货电话:数据源收货地址:数据源收货日期:数据源
备注:数据源
板材名称数据源板材颜色数据源板材厚度数据源列表条数表达式
房名柜名板名称数量面积开门类型备注
数据源数据源数据源数据源数据源数据源数据源数据源数据源
小计:数量表达式面积表达式
合计:数量表达式面积表达式
"); - map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted)); + map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted)); break; default: // 处理默认情况,可以选择忽略或者做其他处理 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/process/OrderProcessServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/process/OrderProcessServiceImpl.java index 9ad7edac1..d8050c630 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/process/OrderProcessServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/process/OrderProcessServiceImpl.java @@ -2,6 +2,7 @@ package com.cf.imes.module.executor.service.process; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; +import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; @@ -83,10 +84,9 @@ public class OrderProcessServiceImpl implements OrderProcessService { private GoodsMapper goodsMapper; - @Override - @Transactional(rollbackFor = Exception.class) - public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) { - OrderDO order = orderMapper.selectOrderOne(createReqVO.getOrderId(), SecurityFrameworkUtils.getLoginUser().getOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); + // 生产单状态检测 + private void checkOrderStatus(Long orderId, Long organId, Integer status) { + OrderDO order = orderMapper.selectOrderOne(orderId, organId, status); // 当生产不为删除时,校验生产单存在 if (order == null) { throw exception(ORDER_NOT_EXISTS); @@ -96,14 +96,33 @@ public class OrderProcessServiceImpl implements OrderProcessService { throw exception(ORDER_STATUS_CONFLICT); } } -// 校验工序组存在 - if (!processGroupApi.getProcessGroup(createReqVO.getGroupId())) { + } + + // 校验工序组存在 + private void checkProcessGroup(Long id) { + if (!processGroupApi.getProcessGroup(id)) { throw exception(PROCESS_GROUP_NOT_EXISTS); } -// 校验是否已经存在该生产单对应的工序组 - if (orderProcessMapper.getOrderProcess(createReqVO.getOrderId(), SecurityFrameworkUtils.getLoginUser().getOrganId())) { + } + + // 校验是否已经存在该生产单对应的工序组 + private void checkOrderProcessExists(Long orderId, Long organId) { + if (orderProcessMapper.getOrderProcess(orderId, organId)) { throw exception(ORDER_PROCESS_EXISTS); } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) { + checkOrderStatus(createReqVO.getOrderId(), OrganContextHolder.getOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); + +// 校验工序组存在 + checkProcessGroup(createReqVO.getGroupId()); + +// 校验是否已经存在该生产单对应的工序组 + checkOrderProcessExists(createReqVO.getOrderId(), OrganContextHolder.getOrganId()); + // 插入 Long orderProcessId = (Long) identifierGenerator.nextId(null); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IContourData.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IContourData.java index 654e22e08..f6bc03c28 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IContourData.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IContourData.java @@ -21,8 +21,8 @@ import java.util.List; @Accessors(chain = false) // 设置 chain = false,避免生产单导入有问 public class IContourData { - @Schema(description = "点集(二维向量(x,y))") - private List pts; // + @Schema(description = "点集(二维向量(x,y,z))") + private Point pts; // @Schema(description = "凸度(0直线段 >0逆时针方向 <0顺时针方向)") - private Double[] buls; // + private Double buls; // } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IOriginModelingData.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IOriginModelingData.java index 5c165a247..004ac362c 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IOriginModelingData.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/deviseData/structure/IOriginModelingData.java @@ -28,9 +28,9 @@ public class IOriginModelingData { private Integer dir; @Schema(description = "轮廓,造型最外围的轮廓数据") - private IContourData outline; - @Schema(description = "孔轮廓") - private List holes; + private List outline; + @Schema(description = "孤岛轮廓") + private List> holes; @Schema(description = "槽加长") diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/ToolUtil.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/ToolUtil.java index 317f697ac..4f100a249 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/ToolUtil.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/ToolUtil.java @@ -35,19 +35,20 @@ public class ToolUtil { // 日期格式转换 public static Map changeDate(String date, DateTimeFormatter formatter) { String errorKey = "error"; + String dateKey = "date"; Map map = new HashMap<>(); LocalDate localDate; if (date == null){ localDate = LocalDate.now(); - map.put("date", localDate); + map.put(dateKey, localDate); map.put(errorKey, 0); }else { try { localDate = LocalDate.parse(date, formatter); - map.put("date", localDate); + map.put(dateKey, localDate); map.put(errorKey, 1); } catch (DateTimeParseException e) { - map.put("date", date); + map.put(dateKey, date); map.put(errorKey, -1); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java index 165fb3987..5d70ac25c 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java @@ -64,6 +64,7 @@ public class ApiDataAchieve { JSONObject jsonPlatesData = new JSONObject(); jsonPlatesData.put(ORDER_NO_KEY, "N" + orderNo);//生产单号需要传入赋值 jsonPlatesData.put("format", "json"); + jsonPlatesData.put("version", "3"); JSONObject dataPlates = apiDataProduction.getApiOrderMessage(token, jsonPlatesData); return new AsyncResult<>(dataPlates); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java index d07afbbc9..902b887f0 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRemark; +import com.cf.imes.module.executor.controller.admin.plan.dto.Point; import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO; @@ -743,6 +744,7 @@ public class ApiTypeRealize { System.err.println(dataPlates); if (ordersArray != null && !ordersArray.isEmpty()) { for (int i = 0; i < ordersArray.size(); i++) { + System.out.println("kkk " + ordersArray.get(i)); JSONObject order = ordersArray.getJSONObject(i); // 获取材料信息 if (order.getJSONArray("Materials") != null && !order.getJSONArray("Materials").isEmpty()) { @@ -928,30 +930,13 @@ public class ApiTypeRealize { offSetLists.add(OffSetList.builder() .value(Double.valueOf(offSet.getString("Value"))) .name(offSet.getString("Name")) - .radius(Double.valueOf(offSet.getString("Diameter")) / 2) + .radius(Double.parseDouble(offSet.getString("Diameter")) / 2) .angle(Double.valueOf(offSet.getString("Angle"))) .depth(Double.valueOf(offSet.getString("Depth"))) .build()); } } - List pointListInOrigin = new ArrayList<>(); - if (model.getJSONArray("OriginModeling") != null && !model.getJSONArray("OriginModeling").isEmpty()) { - for (int j = 0; j < model.getJSONArray("OriginModeling").size(); j++) { - JSONObject point = model.getJSONArray("OriginModeling").getJSONObject(j); - String[] points = splitAndTrim(point.getString("Pos")); - pointListInOrigin.add(PointList.builder() - .pointX(Double.valueOf(points[X])) - .pointY(Double.valueOf(points[Y])) - .pointZ(Double.valueOf(points[Z])) - .curve(Double.valueOf(point.getString("Curve"))) - .build()); - } - } - IOriginModelingData originModeling = IOriginModelingData.builder() - .pointList(pointListInOrigin) - .build(); - modelDetails.add(ModelDetail.builder() .depth(Double.valueOf(model.getString("Depth"))) .faceType(Integer.valueOf(model.getString("Face"))) @@ -959,7 +944,7 @@ public class ApiTypeRealize { .knifeRadius(Double.valueOf(model.getString("Diameter")) / 2) .pointList(pointLists) .offSetList(offSetLists) - .originModeling(originModeling) + .originModeling(getOriginModeling(model.getJSONObject("OriginModeling"))) .build()); } } @@ -967,6 +952,83 @@ public class ApiTypeRealize { return modelDetails; } + // 造型 --- OriginModeling + private IOriginModelingData getOriginModeling(JSONObject originModeling) { + + if (originModeling == null || originModeling.isEmpty()) { + return null; + } + + JSONArray outLine = originModeling.getJSONArray("Outline"); + JSONArray holes = originModeling.getJSONArray("Holes"); + + return IOriginModelingData.builder() + .thickness(Double.valueOf(originModeling.getString("Thickness"))) + .knifeRadius(Double.valueOf(originModeling.getString("KnifeRadius"))) + .dir(originModeling.getInteger("Dir")) + .outline(getOutlineOrOutline(outLine)) + .holes(getOutlineOrHoles(holes)) + .addLen(Double.valueOf(originModeling.getString("AddLen"))) + .addWidth(Double.valueOf(originModeling.getString("AddWidth"))) + .addDepth(Double.valueOf(originModeling.getString("AddDepth"))) + .build(); + } + + private List getOutlineOrOutline(JSONArray json) { + if (json == null || json.isEmpty()) { + return Collections.emptyList(); + } + + List contourDataList = new ArrayList<>(); + for (int i = 0; i < json.size(); i++) { + JSONObject element = json.getJSONObject(i); + String[] points = splitAndTrim(element.getString("Pos")); + Point pointVO = Point.builder() + .x(Double.valueOf(points[X])) + .y(Double.valueOf(points[Y])) + .z(Double.valueOf(points[Z])) + .build(); + IContourData iContourDataVO = IContourData.builder() + .pts(pointVO) + .buls(Double.valueOf(element.getString("Curve"))) + .build(); + contourDataList.add(iContourDataVO); + } + return contourDataList; + } + + private List> getOutlineOrHoles(JSONArray json) { + List> contourDataList = new ArrayList<>(); + + if (json == null || json.isEmpty()) { + return contourDataList; + } + + for (int i = 0; i < json.size(); i++) { + JSONArray element = json.getJSONArray(i); + if (element == null || element.isEmpty()) { + continue; + } + List contourData = new ArrayList<>(); + for (int j = 0; j < element.size(); j++) { + JSONObject point = element.getJSONObject(i); + String[] points = splitAndTrim(point.getString("Pos")); + Point pointVO = Point.builder() + .x(Double.valueOf(points[X])) + .y(Double.valueOf(points[Y])) + .z(Double.valueOf(points[Z])) + .build(); + IContourData iContourDataVO = IContourData.builder() + .pts(pointVO) + .buls(Double.valueOf(point.getString("Curve"))) + .build(); + contourData.add(iContourDataVO); + } + contourDataList.add(contourData); + } + return contourDataList; + } + // 排钻数据 private List getDrillsInfo(JSONObject block) { List drillsInfos = new ArrayList<>(); 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/XMLUtil.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XMLUtil.java index e708a54aa..ccd87fd31 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XMLUtil.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XMLUtil.java @@ -1,6 +1,7 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.xml; import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.shaded.com.google.common.base.Function; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.enums.DataTypeEnum; import com.cf.imes.module.executor.enums.DictTypeConstants; @@ -24,14 +25,19 @@ import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; +import java.util.function.Supplier; @Slf4j @Component public class XMLUtil { - final String TYPE_ERR = "数据类型错误"; - final String POSITIVE_ERR = "数据需为正数"; - final String LONG_ERR = "数据长度不符合(共8位整数位5位,小数位3位)"; + final String TYPE_ERR = "---< %s数据类型有误 >---"; + final String POSITIVE_ERR = "---< %s数据需为正数 >---"; + final String LONG_ERR = "---< %s数据长度不符合(共8位整数位5位,小数位3位) >---"; + final String IS_NULL = "---< %s不能为空 >---"; + final String INVALID = "---< %s数据无效 >---"; final String NOT_ASSIGNED = "未命名"; final String NOT_ASSIGNED_CODE = "未命编号"; @@ -86,53 +92,42 @@ public class XMLUtil { response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(name, StandardCharsets.UTF_8.name())); } - // 生产单数据格式验证 - public Map changeDate(OrderXmlVO orderXmlVO, Long organId) { - Map map = new HashMap<>(); + // 电话格式判断 + private void setIfInvalid(Supplier getter, Function errorMessageFactory, Consumer setter, boolean error) { + String phone = getter.get(); + if (phone != null && !ToolUtil.validatePhoneNumber(phone)) { + setter.accept(errorMessageFactory.apply(phone)); + error = false; + } + } + private boolean validatePhoneNumbers(OrderXmlVO orderXmlVO) { boolean error = true; - if (orderXmlVO.getCustomer() == null) { orderXmlVO.setCustomer("---< 客户名不能为空 >---"); error = false; } - if (orderXmlVO.getCustomerPhone() != null) { - if (!ToolUtil.validatePhoneNumber(orderXmlVO.getCustomerPhone())) { - orderXmlVO.setCustomerPhone("---< " + orderXmlVO.getCustomerPhone() + "客户电话格式错误 >---"); - error = false; - } - } - if (orderXmlVO.getDealerPhone() != null) { - if (!ToolUtil.validatePhoneNumber(orderXmlVO.getDealerPhone())) { - orderXmlVO.setDealerPhone("---< " + orderXmlVO.getDealerPhone() + "经销商电话格式错误 >---"); - error = false; - } - } - if (orderXmlVO.getSellerPhone() != null) { - if (!ToolUtil.validatePhoneNumber(orderXmlVO.getSellerPhone())) { - orderXmlVO.setSellerPhone("---< " + orderXmlVO.getSellerPhone() + "业务员电话格式错误 >---"); - error = false; - } - } - if (orderXmlVO.getDesignerPhone() != null) { - if (!ToolUtil.validatePhoneNumber(orderXmlVO.getDesignerPhone())) { - orderXmlVO.setDesignerPhone("---< " + orderXmlVO.getDesignerPhone() + "设计师电话格式错误 >---"); - error = false; - } - } - if (orderXmlVO.getAnalystPhone() != null) { - if (!ToolUtil.validatePhoneNumber(orderXmlVO.getAnalystPhone())) { - orderXmlVO.setAnalystPhone("---< " + orderXmlVO.getAnalystPhone() + "解单员电话格式错误 >---"); - error = false; - } - } + setIfInvalid(orderXmlVO::getCustomerPhone, s -> "---< " + s + "客户电话格式错误 >---", orderXmlVO::setCustomerPhone, error); + setIfInvalid(orderXmlVO::getDealerPhone, s -> "---< " + s + "经销商电话格式错误 >---", orderXmlVO::setDealerPhone, error); + setIfInvalid(orderXmlVO::getSellerPhone, s -> "---< " + s + "业务员电话格式错误 >---", orderXmlVO::setSellerPhone, error); + setIfInvalid(orderXmlVO::getDesignerPhone, s -> "---< " + s + "设计师电话格式错误 >---", orderXmlVO::setDesignerPhone, error); + setIfInvalid(orderXmlVO::getAnalystPhone, s -> "---< " + s + "解单员电话格式错误 >---", orderXmlVO::setAnalystPhone, error); + return error; + } + + // 生产单数据格式验证 + public Map changeDate(OrderXmlVO orderXmlVO, Long organId) { + Map map = new HashMap<>(); + boolean error = validatePhoneNumbers(orderXmlVO); + LocalDate orderDate = null; LocalDate deliverDate = null; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); Map mapDate = ToolUtil.changeDate(orderXmlVO.getOrderDate(), formatter); + Integer errorCode = (Integer) mapDate.get("error"); if (orderXmlVO.getOrderDate() == null) { orderDate = LocalDate.now(); } else { - if (mapDate.get("error") instanceof Integer && (Integer) mapDate.get("error") == -1) { + if (errorCode == -1) { orderXmlVO.setOrderDate("---< " + orderXmlVO.getOrderDate() + "订单日期格式错误 >---"); error = false; } else { @@ -143,7 +138,7 @@ public class XMLUtil { if (orderXmlVO.getDeliveryDate() == null) { deliverDate = orderDate.plus(30, ChronoUnit.DAYS); } else { - if (mapDate.get("error") instanceof Integer && (Integer) mapDate.get("error") == -1) { + if (errorCode == -1) { orderXmlVO.setDeliveryDate("---< " + orderXmlVO.getDeliveryDate() + "出货日期格式错误 >---"); error = false; } else { @@ -183,1108 +178,672 @@ public class XMLUtil { // 数据格式转换 public Boolean checkVO(OrderXmlVO orderXmlVO) { - Boolean flag = true; + AtomicBoolean error = new AtomicBoolean(true); + boolean flag = true; RoomXmlVOS roomXmlVOS = orderXmlVO.getRoomXmlVOS(); if (roomXmlVOS != null) { - checkRoom(roomXmlVOS, flag); + checkRoom(roomXmlVOS, error); } ModuleXmlVOS moduleXmlVOS = orderXmlVO.getModuleXmlVOS(); if (moduleXmlVOS != null) { - checkModules(moduleXmlVOS, flag); + checkModules(moduleXmlVOS, error); } GroupXmlVOS grooveXmlVOS = orderXmlVO.getGroupXmlVOS(); if (grooveXmlVOS != null) { - checkGroups(grooveXmlVOS, flag); + checkGroups(grooveXmlVOS, error); } MaterialXmlVO materialXmlVO = orderXmlVO.getMaterialXmlVO(); if (materialXmlVO != null) { PlateXmlVOS plateXmlVOS = materialXmlVO.getPlateXmlVOS(); if (plateXmlVOS != null && plateXmlVOS.getPlateXmlVOList().size() > 0) { - checkPlates(plateXmlVOS.getPlateXmlVOList(), flag); + checkPlates(plateXmlVOS.getPlateXmlVOList(), error); } AccessoryXmlVO accessoryXmlVO = materialXmlVO.getAccessoryXmlVO(); //配件 if (accessoryXmlVO != null) { - checkEdgings(accessoryXmlVO.getEdgingXmlVOS(), flag); - checkHardwares(accessoryXmlVO.getHardwareXmlVOS(), flag); + checkEdgings(accessoryXmlVO.getEdgingXmlVOS(), error); + checkHardwares(accessoryXmlVO.getHardwareXmlVOS(), error); } AssemblieXmlVOS assemblieXmlVOS = materialXmlVO.getAssemblieXmlVOS(); // 组件 if (assemblieXmlVOS != null && assemblieXmlVOS.getAssemblyXmlVOList() != null && assemblieXmlVOS.getAssemblyXmlVOList().size() > 0) { - checkAssemblies(assemblieXmlVOS, flag); + checkAssemblies(assemblieXmlVOS, error); } } return flag; } - private void checkAssemblies(AssemblieXmlVOS assemblieXmlVOS, Boolean flag) { + + /** + * + * 非空判断,错误返回 + * + * @param getter: + * @param name: 字段错误名称 + * @param setter: + * @param error: 错误赋值 + */ + private void isEmptyAndBack(Supplier getter, String name, Consumer setter, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + } + } + + /** + * + * 非空判断,空赋初始值 + * + * @param getter: + * @param setter: + * @param defaultValue: 赋值空值 + */ + + private void isEmptyAndAdd(Supplier getter, Consumer setter, String defaultValue) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(defaultValue); + } + } + + /** + * + * 数量类型+数量正数 + * + * @param value: + * @param name: 字段错误名称 + * @param setter: + * @param targetType: 需要转换的数字类型 + * @param error: 错误赋值 + */ + private void positiveNumber(String value, String name, Consumer setter, Class targetType, AtomicBoolean error) { + if (ToolUtil.convertToType(value, targetType)) { + if (!ToolUtil.checkNumber(value)) { + setter.accept(String.format(POSITIVE_ERR, name)); + error.set(false); + } + } else { + setter.accept(String.format(TYPE_ERR, name)); + error.set(false); + } + + } + + /** + * + * 数量类型+数量正数 + 返回值 + * + * @param value: + * @param name: 字段错误名称 + * @param setter: + * @param targetType: 需要转换的数字类型 + * @param error: 错误赋值 + */ + private boolean positiveNumberAndBack(String value, String name, Consumer setter, Class targetType, AtomicBoolean error) { + boolean index = true; + if (ToolUtil.convertToType(value, targetType)) { + if (!ToolUtil.checkNumber(value)) { + setter.accept(String.format(POSITIVE_ERR, name)); + error.set(false); + index = false; + } + } else { + setter.accept(String.format(TYPE_ERR, name)); + error.set(false); + index = false; + } + return index; + } + + /** + * + * 数量类型+数量正数+数据长度 + * + * @param value: 待校验数据 + * @param setter: + * @param targetType: 数据类型 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void positiveNumberSize(String value, Consumer setter, Class targetType, String name, Integer length, Integer decimalLength, AtomicBoolean error) { + if (ToolUtil.convertToType(value, targetType)) { + if (ToolUtil.checkNumber(value)) { + if (!ToolUtil.checkPrecision(value, length, decimalLength)) { + setter.accept(String.format(LONG_ERR, name)); + error.set(false); + } + } else { + setter.accept(String.format(POSITIVE_ERR, name)); + error.set(false); + } + } else { + setter.accept(String.format(TYPE_ERR, name)); + error.set(false); + } + } + + /** + * + * 非空错返+数量类型+数量正数 + * + * @param getter: + * @param name: 字段错误名称 + * @param setter: + * @param targetType: 需要转换的数字类型 + * @param error: 错误赋值 + */ + private void isEmptyBackAndPositiveNumber(Supplier getter, String name, Consumer setter, Class targetType, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + } else { + positiveNumber(value, name, setter, targetType, error); + } + } + + /** + * + * 非空错返+数量类型+数量正数 + 返回值 + * + * @param getter: + * @param name: 字段错误名称 + * @param setter: + * @param targetType: 需要转换的数字类型 + * @param error: 错误赋值 + */ + private boolean isEmptyBackAndPositiveNumberAndBack(Supplier getter, String name, Consumer setter, Class targetType, AtomicBoolean error) { + boolean index = true; + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + index = false; + } else { + index = positiveNumberAndBack(value, name, setter, targetType, error); + } + return index; + } + + /** + * + * 非空错返 +数量类型+数量正数+数据长度 + * + * @param getter: + * @param name: 字段错误名称 + * @param setter: + * @param targetType: 需要转换的数字类型 + * @param error: 错误赋值 + */ + private void isEmptyAndPositiveNumber(Supplier getter, String name, Consumer setter, Class targetType, Integer length, Integer decimalLength, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + } else { + positiveNumberSize(value, setter, targetType, name, length, decimalLength, error); + } + } + + /** + * + * 空值赋值 +数量类型+数量正数 + * + * @param getter: + * @param setter: + * @param defaultValue: 赋值数据 + * @param targetType: 数据类型 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyAddAndPositiveNumber(Supplier getter, Consumer setter, String defaultValue, Class targetType, String name, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(defaultValue); + } else { + positiveNumber(value, name, setter, targetType, error); + } + } + + /** + * + * 空值赋值+数量类型+数量正数+数据长度 + * + * @param getter: + * @param setter: + * @param defaultValue: 赋值数据 + * @param targetType: 数据类型 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyAddAndPositiveNumberSize(Supplier getter, Consumer setter, String defaultValue, Class targetType, String name, Integer length, Integer decimalLength, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(defaultValue); + } else { + positiveNumberSize(value, setter, targetType, name, length, decimalLength, error); + } + } + + /** + * + * 空值赋值+数量类型 + * + * @param getter: + * @param setter: + * @param defaultValue: 赋值数据 + * @param targetType: 数据类型 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyAddAndNumber(Supplier getter, Consumer setter, String defaultValue, Class targetType, String name, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(defaultValue); + } else { + if (!ToolUtil.convertToType(value.trim(), targetType)) { + setter.accept(String.format(TYPE_ERR, name)); + error.set(false); + } + } + } + + /** + * + * 空值错返+数量类型 + * + * @param getter: + * @param setter: + * @param targetType: 数据类型 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyBackAndNumber(Supplier getter, Consumer setter, Class targetType, String name, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + } else { + if (!ToolUtil.convertToType(value.trim(), targetType)) { + setter.accept(String.format(TYPE_ERR, name)); + error.set(false); + } + } + } + + /** + * + * 空值赋值+非空有效性判断 + * + * @param getter: + * @param setter: + * @param dictTypeConstants: 字典标签 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyBackAndInvalid(Supplier getter, Consumer setter, String dictTypeConstants, String name, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(String.format(IS_NULL, name)); + error.set(false); + } else { + DictDataRespDTO dictData = dictDataApi.parseDictData(dictTypeConstants, value.trim()).getData(); + if (dictData == null) { + setter.accept(String.format(INVALID, name)); + error.set(false); + } + } + } + + /** + * + * 空值返回+非空有效性判断 + * + * @param getter: + * @param setter: + * @param defaultValue: 赋值数据 + * @param dictTypeConstants: 字典标签 + * @param name: 字段错误名称 + * @param error: 错误赋值 + */ + private void isEmptyAddAndInvalid(Supplier getter, Consumer setter, String defaultValue, String dictTypeConstants, String name, AtomicBoolean error) { + String value = getter.get(); + if (StringUtils.isEmpty(value)) { + setter.accept(defaultValue); + } else { + DictDataRespDTO dictData = dictDataApi.parseDictData(dictTypeConstants, value.trim()).getData(); + if (dictData == null) { + setter.accept(String.format(INVALID, name)); + error.set(false); + } + } + } + + /** + * + * 非空判断+数据类型+数据正数 + * + * @param getter: + * @param setter: + * @param name: 字段错误名称 + * @param targetType: 数字类型 + * @param error: 错误赋值 + */ + private void notEmptyPositiveNumber(Supplier getter, Consumer setter, String name, Class targetType, AtomicBoolean error) { + String value = getter.get(); + if (!StringUtils.isEmpty(value)) { // 非空 + positiveNumber(value, name, setter, targetType, error); + } + } + + /** + * + * 非空判断 +数据类型+数据正数+数据长度 + * + * @param getter: + * @param setter: + * @param name: 字段错误名称 + * @param targetType: 数字类型 + * @param error: 错误赋值 + */ + private void notEmptyPositiveNumberSize(Supplier getter, Consumer setter, String name, Class targetType, Integer length, Integer decimalLength, AtomicBoolean error) { + String value = getter.get(); + if (!StringUtils.isEmpty(value)) { // 非空 + positiveNumberSize(value, setter, targetType, name, length, decimalLength, error); + } + } + + // + private void checkAssemblies(AssemblieXmlVOS assemblieXmlVOS, AtomicBoolean flag) { if (assemblieXmlVOS != null && assemblieXmlVOS.getAssemblyXmlVOList().size() > 0) { for (AssemblyXmlVO assemblyXmlVO : assemblieXmlVOS.getAssemblyXmlVOList()) { - if (StringUtils.isEmpty(assemblyXmlVO.getName())) { - assemblyXmlVO.setName("---< 组件名称不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(assemblyXmlVO.getMaterial())) { - assemblyXmlVO.setMaterial("---< 组件材质不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(assemblyXmlVO.getColor())) { - assemblyXmlVO.setColor("---< 组件颜色不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(assemblyXmlVO.getCount())) { - assemblyXmlVO.setCount("---< 组件数量不能为空 >---"); - flag = false; - } else { - if (!checkNumber(assemblyXmlVO.getCount().trim(), Double.class)) { - assemblyXmlVO.setCount(assemblyXmlVO.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - flag = false; - } - } - if (StringUtils.isEmpty(assemblyXmlVO.getUnitCount())) { - assemblyXmlVO.setUnit("---< 组件数量单位不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(assemblyXmlVO.getRoomCode())) { - assemblyXmlVO.setRoomCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(assemblyXmlVO.getRoomName())) { - assemblyXmlVO.setRoomName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(assemblyXmlVO.getBoxCode())) { - assemblyXmlVO.setBoxCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(assemblyXmlVO.getBoxName())) { - assemblyXmlVO.setBoxName(NOT_ASSIGNED); - } -// if (StringUtils.isEmpty(assemblyXmlVO.getGroupCode())) { -// assemblyXmlVO.setGroupCode(NOT_ASSIGNED_CODE); -// } -// if (StringUtils.isEmpty(assemblyXmlVO.getGroupName())) { -// assemblyXmlVO.setGroupName(NOT_ASSIGNED); -// } + isEmptyAndBack(assemblyXmlVO::getName, "组件名称", assemblyXmlVO::setName, flag); + isEmptyAndBack(assemblyXmlVO::getMaterial, "组件材质", assemblyXmlVO::setMaterial, flag); + isEmptyAndBack(assemblyXmlVO::getColor, "组件颜色", assemblyXmlVO::setColor, flag); + isEmptyBackAndPositiveNumber(assemblyXmlVO::getCount, "组件数量", assemblyXmlVO::setCount, Double.class, flag); + isEmptyAndBack(assemblyXmlVO::getUnitCount, "组件数量单位", assemblyXmlVO::setUnitCount, flag); + isEmptyAndAdd(assemblyXmlVO::getRoomCode, assemblyXmlVO::setRoomCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(assemblyXmlVO::getRoomName, assemblyXmlVO::setRoomName, NOT_ASSIGNED); + isEmptyAndAdd(assemblyXmlVO::getBoxCode, assemblyXmlVO::setBoxCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(assemblyXmlVO::getBoxName, assemblyXmlVO::setBoxName, NOT_ASSIGNED); } } } - private void checkHardwares(HardwareXmlVOS hardwareXmlVOS, Boolean flag) { + private void checkHardwares(HardwareXmlVOS hardwareXmlVOS, AtomicBoolean flag) { if (hardwareXmlVOS != null && hardwareXmlVOS.getHardwareXmlVOList().size() > 0) { for (HardwareXmlVO hardwareXmlVO : hardwareXmlVOS.getHardwareXmlVOList()) { - if (StringUtils.isEmpty(hardwareXmlVO.getRoomCode())) { - hardwareXmlVO.setRoomCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(hardwareXmlVO.getRoomName())) { - hardwareXmlVO.setRoomName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(hardwareXmlVO.getBoxCode())) { - hardwareXmlVO.setBoxCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(hardwareXmlVO.getBoxName())) { - hardwareXmlVO.setBoxName(NOT_ASSIGNED); - } -// if (StringUtils.isEmpty(hardwareXmlVO.getGroupCode())) { -// hardwareXmlVO.setGroupCode(NOT_ASSIGNED_CODE); -// } -// if (StringUtils.isEmpty(hardwareXmlVO.getGroupName())) { -// hardwareXmlVO.setGroupName(NOT_ASSIGNED); -// } - if (StringUtils.isEmpty(hardwareXmlVO.getName())) { - hardwareXmlVO.setName("---< 五金名称不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(hardwareXmlVO.getMaterial())) { - hardwareXmlVO.setMaterial("---< 五金材质不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(hardwareXmlVO.getColor())) { - hardwareXmlVO.setColor("---< 五金条颜色不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(hardwareXmlVO.getCount())) { - hardwareXmlVO.setCount("---< 五金数量不能为空 >---"); - flag = false; - } else { - if (!checkNumber(hardwareXmlVO.getCount().trim(), Double.class)) { - hardwareXmlVO.setCount(hardwareXmlVO.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - flag = false; - } - } - if (StringUtils.isEmpty(hardwareXmlVO.getUnitCount())) { - hardwareXmlVO.setUnitCount("---< 五金数量单位不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(hardwareXmlVO.getUnit())) { - hardwareXmlVO.setUnit("---< 五金单位不能为空 >---"); - flag = false; - } + isEmptyAndAdd(hardwareXmlVO::getRoomCode, hardwareXmlVO::setRoomCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(hardwareXmlVO::getRoomName, hardwareXmlVO::setRoomName, NOT_ASSIGNED); + isEmptyAndAdd(hardwareXmlVO::getBoxCode, hardwareXmlVO::setBoxCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(hardwareXmlVO::getBoxName, hardwareXmlVO::setBoxName, NOT_ASSIGNED); + isEmptyAndBack(hardwareXmlVO::getName, "五金名称", hardwareXmlVO::setName, flag); + isEmptyAndBack(hardwareXmlVO::getMaterial, "五金材质", hardwareXmlVO::setMaterial, flag); + isEmptyAndBack(hardwareXmlVO::getColor, "五金颜色", hardwareXmlVO::setColor, flag); + isEmptyBackAndPositiveNumber(hardwareXmlVO::getCount, "五金数量", hardwareXmlVO::setCount, Double.class, flag); + isEmptyAndBack(hardwareXmlVO::getUnitCount, "五金数量单位", hardwareXmlVO::setUnitCount, flag); + isEmptyAndBack(hardwareXmlVO::getUnit, "五金单位", hardwareXmlVO::setUnit, flag); } } } - private void checkEdgings(EdgingXmlVOS edgingXmlVOS, Boolean flag) { + private void checkEdgings(EdgingXmlVOS edgingXmlVOS, AtomicBoolean flag) { if (edgingXmlVOS != null && edgingXmlVOS.getEdgingXmlVOList().size() > 0) { for (EdgingXmlVO edgingXmlVO : edgingXmlVOS.getEdgingXmlVOList()) { - if (StringUtils.isEmpty(edgingXmlVO.getRoomCode())) { - edgingXmlVO.setRoomCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(edgingXmlVO.getRoomName())) { - edgingXmlVO.setRoomName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(edgingXmlVO.getBoxCode())) { - edgingXmlVO.setBoxCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(edgingXmlVO.getBoxName())) { - edgingXmlVO.setBoxName(NOT_ASSIGNED); - } -// if (StringUtils.isEmpty(edgingXmlVO.getGroupCode())) { -// edgingXmlVO.setGroupCode(NOT_ASSIGNED_CODE); -// } -// if (StringUtils.isEmpty(edgingXmlVO.getGroupName())) { -// edgingXmlVO.setGroupName(NOT_ASSIGNED); -// } - if (StringUtils.isEmpty(edgingXmlVO.getName())) { - edgingXmlVO.setName("---< 封边条名称不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getMaterial())) { - edgingXmlVO.setMaterial("---< 封边条材质不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getColor())) { - edgingXmlVO.setColor("---< 封边条颜色不能为空 >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getLength())) { - edgingXmlVO.setLength("---< 封边条长度不能为空 >---"); - flag = false; - } else if (!checkNumber(edgingXmlVO.getLength().trim(), Double.class)) { - edgingXmlVO.setLength(edgingXmlVO.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getWidth())) { - edgingXmlVO.setWidth("---< 封边条宽度不能为空 >---"); - flag = false; - } else if (!checkNumber(edgingXmlVO.getWidth().trim(), Double.class)) { - edgingXmlVO.setWidth(edgingXmlVO.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getThickness())) { - edgingXmlVO.setThickness("---< 封边条厚度不能为空 >---"); - flag = false; - } else if (!checkNumber(edgingXmlVO.getThickness().trim(), Double.class)) { - edgingXmlVO.setThickness(edgingXmlVO.getThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - } - if (StringUtils.isEmpty(edgingXmlVO.getUnit())) { - edgingXmlVO.setUnit("mm"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_LENGTH, edgingXmlVO.getUnit().trim()).getData(); - if (dictData == null) { - edgingXmlVO.setUnit(edgingXmlVO.getUnit() + "---< " + "封边条长度单位无效 >---"); - flag = false; - } - } - if (StringUtils.isEmpty(edgingXmlVO.getCount())) { - edgingXmlVO.setCount("---< 封边条数量不能为空 >---"); - flag = false; - } else if (!checkNumber(edgingXmlVO.getCount().trim(), Double.class)) { - edgingXmlVO.setCount(edgingXmlVO.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - flag = false; - } - if (StringUtils.isEmpty(edgingXmlVO.getUnitCount())) { - edgingXmlVO.setUnitCount("m"); - flag = false; - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_LENGTH, edgingXmlVO.getUnitCount().trim()).getData(); - if (dictData == null) { - edgingXmlVO.setUnitCount(edgingXmlVO.getUnitCount() + "---< " + "封边条数量单位无效 >---"); - } - } + isEmptyAndAdd(edgingXmlVO::getRoomCode, edgingXmlVO::setRoomCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(edgingXmlVO::getRoomName, edgingXmlVO::setRoomName, NOT_ASSIGNED); + isEmptyAndAdd(edgingXmlVO::getBoxCode, edgingXmlVO::setBoxCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(edgingXmlVO::getBoxName, edgingXmlVO::setBoxName, NOT_ASSIGNED); + isEmptyAndBack(edgingXmlVO::getName, "封边条名称", edgingXmlVO::setName, flag); + isEmptyAndBack(edgingXmlVO::getMaterial, "封边条材质", edgingXmlVO::setMaterial, flag); + isEmptyAndBack(edgingXmlVO::getColor, "封边条颜色", edgingXmlVO::setColor, flag); + isEmptyBackAndPositiveNumber(edgingXmlVO::getLength, "封边条长度", edgingXmlVO::setLength, Double.class, flag); + isEmptyBackAndPositiveNumber(edgingXmlVO::getWidth, "封边条宽度", edgingXmlVO::setWidth, Double.class, flag); + isEmptyBackAndPositiveNumber(edgingXmlVO::getThickness, "封边条厚度", edgingXmlVO::setThickness, Double.class, flag); + isEmptyAddAndInvalid(edgingXmlVO::getUnit, edgingXmlVO::setUnit, "mm", DictTypeConstants.UNIT_LENGTH, "封边条长度单位", flag); + isEmptyBackAndPositiveNumber(edgingXmlVO::getCount, "封边条数量", edgingXmlVO::setCount, Double.class, flag); + isEmptyAddAndInvalid(edgingXmlVO::getUnitCount, edgingXmlVO::setUnitCount, "m", DictTypeConstants.UNIT_LENGTH, "封边条数量单位", flag); } } } // 房间数据格式验证 - public void checkRoom(RoomXmlVOS roomXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(roomXmlVOS.getCount())) { - if (ToolUtil.convertToType(roomXmlVOS.getCount().trim(), Integer.class)) { - if (!ToolUtil.checkNumber(roomXmlVOS.getCount().trim())) { - roomXmlVOS.setCount(roomXmlVOS.getCount() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } else { - roomXmlVOS.setCount(roomXmlVOS.getCount() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } + public void checkRoom(RoomXmlVOS roomXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(roomXmlVOS::getCount, roomXmlVOS::setCount, "房间数量", Integer.class, flag); + for (RoomXmlVO room : roomXmlVOS.getRoomXmlVOList()) { - if (StringUtils.isEmpty(room.getName())) { - room.setName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(room.getCode())) { - room.setCode(NOT_ASSIGNED_CODE); - } - if (room != null) { - if (!StringUtils.isEmpty(room.getHeight())) { - Boolean flag = checkNumber(room.getHeight().trim(), Double.class); - if (!flag) { - room.setHeight(room.getHeight() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setHeight("0"); - } - if (!StringUtils.isEmpty(room.getLength())) { - Boolean flag = checkNumber(room.getLength().trim(), Double.class); - if (!flag) { - room.setLength(room.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setLength("0"); - } - if (!StringUtils.isEmpty(room.getWidth())) { - Boolean flag = checkNumber(room.getWidth().trim(), Double.class); - if (!flag) { - room.setWidth(room.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setWidth("0"); - } - if (!StringUtils.isEmpty(room.getMultipleNumber())) { - Boolean flag = checkNumber(room.getMultipleNumber().trim(), Integer.class); - if (!flag) { - room.setMultipleNumber(room.getMultipleNumber() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setMultipleNumber("1"); - } - if (!StringUtils.isEmpty(room.getMultipleNo())) { - Boolean flag = checkNumber(room.getMultipleNo().trim(), Integer.class); - if (!flag) { - room.setMultipleNo(room.getMultipleNo() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setMultipleNo("1"); - } - if (!StringUtils.isEmpty(room.getBasePointX())) { - if (!ToolUtil.convertToType(room.getBasePointX().trim(), Double.class)) { - room.setBasePointX(room.getBasePointX() + "---< " + TYPE_ERR + " >---"); - error = false; - } - }else { - room.setBasePointX("0"); - } - if (!StringUtils.isEmpty(room.getBasePointY())) { - if (!ToolUtil.convertToType(room.getBasePointY().trim(), Double.class)) { - room.setBasePointY(room.getBasePointY() + "---< " + TYPE_ERR + " >---"); - error = false; - } - }else { - room.setBasePointY("0"); - } - if (!StringUtils.isEmpty(room.getBasePointZ())) { - if (!ToolUtil.convertToType(room.getBasePointZ().trim(), Double.class)) { - room.setBasePointZ(room.getBasePointZ() + "---< " + TYPE_ERR + " >---"); - error = false; - } - }else { - room.setBasePointZ("0"); - } - if (!StringUtils.isEmpty(room.getAxisXrotate())) { - if (!ToolUtil.convertToType(room.getAxisXrotate().trim(), Double.class)) { - room.setAxisXrotate(room.getAxisXrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setAxisXrotate("0"); - } - if (!StringUtils.isEmpty(room.getAxisYrotate())) { - if (!ToolUtil.convertToType(room.getAxisYrotate().trim(), Double.class)) { - room.setAxisYrotate(room.getAxisYrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setAxisYrotate("0"); - } - if (!StringUtils.isEmpty(room.getAxisZrotate())) { - if (!ToolUtil.convertToType(room.getAxisZrotate().trim(), Double.class)) { - room.setAxisZrotate(room.getAxisZrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - room.setAxisZrotate("0"); - } + isEmptyAndAdd(room::getCode, room::setCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(room::getName, room::setName, NOT_ASSIGNED); + + isEmptyAddAndPositiveNumberSize(room::getHeight, room::setHeight, "0", Double.class, "房间高度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(room::getLength, room::setLength, "0", Double.class, "房间长度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(room::getWidth, room::setWidth, "0", Double.class, "房间宽度", 8, 3, flag); + isEmptyAddAndPositiveNumber(room::getMultipleNumber, room::setMultipleNumber, "1", Integer.class, "房间成倍拆单数量", flag); + isEmptyAddAndPositiveNumber(room::getMultipleNo, room::setMultipleNo, "1", Integer.class, "房间成倍拆单序号", flag); + isEmptyAddAndNumber(room::getBasePointX, room::setBasePointX, "0", Double.class, "基点坐标X", flag); + isEmptyAddAndNumber(room::getBasePointY, room::setBasePointY, "0", Double.class, "基点坐标Y", flag); + isEmptyAddAndNumber(room::getBasePointZ, room::setBasePointZ, "0", Double.class, "基点坐标Z", flag); + isEmptyAddAndNumber(room::getAxisXrotate, room::setAxisXrotate, "0", Double.class, "绕X轴旋转角度", flag); + isEmptyAddAndNumber(room::getAxisYrotate, room::setAxisYrotate, "0", Double.class, "绕Y轴旋转角度", flag); + isEmptyAddAndNumber(room::getAxisZrotate, room::setAxisZrotate, "0", Double.class, "绕Z轴旋转角度", flag); + // 柜体数据格式验证 if (room.getBoxXmlVOList() != null && room.getBoxXmlVOList().size() > 0) { - checkBoxList(room.getBoxXmlVOList(), error); - } + checkBoxList(room.getBoxXmlVOList(), flag); + } } } // 柜体数据格式验证 - public void checkBoxList(List boxXmlVOList, Boolean error) { + public void checkBoxList(List boxXmlVOList, AtomicBoolean flag) { for (BoxXmlVO box : boxXmlVOList) { - if (!StringUtils.isEmpty(box.getHeight())) { - Boolean flag = checkNumber(box.getHeight().trim(), Double.class); - if (!flag) { - box.setHeight(box.getHeight() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - box.setHeight("0"); - } - if (!StringUtils.isEmpty(box.getLength())) { - Boolean flag = checkNumber(box.getLength().trim(), Double.class); - if (!flag) { - box.setLength(box.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - box.setLength("0"); - } - if (!StringUtils.isEmpty(box.getWidth())) { - Boolean flag = checkNumber(box.getWidth().trim(), Double.class); - if (!flag) { - box.setWidth(box.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - box.setWidth("0"); - } - if (!StringUtils.isEmpty(box.getMultipleNumber())) { - Boolean flag = checkNumber(box.getMultipleNumber().trim(), Integer.class); - if (!flag) { - box.setMultipleNumber(box.getMultipleNumber() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - box.setMultipleNumber("1"); - } - if (!StringUtils.isEmpty(box.getMultipleNo())) { - Boolean flag = checkNumber(box.getMultipleNo().trim(), Integer.class); - if (!flag) { - box.setMultipleNo(box.getMultipleNo() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - box.setMultipleNo("1"); - } - if (!StringUtils.isEmpty(box.getBasePointX())) { - if (!ToolUtil.convertToType(box.getBasePointX().trim(), Double.class)) { - box.setBasePointX(box.getBasePointX() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setBasePointX("0"); - } - if (!StringUtils.isEmpty(box.getBasePointY())) { - if (!ToolUtil.convertToType(box.getBasePointY().trim(), Double.class)) { - box.setBasePointY(box.getBasePointY() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setBasePointY("0"); - } - if (!StringUtils.isEmpty(box.getBasePointZ())) { - if (!ToolUtil.convertToType(box.getBasePointZ().trim(), Double.class)) { - box.setBasePointZ(box.getBasePointZ() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setBasePointZ("0"); - } - if (!StringUtils.isEmpty(box.getAxisYrotate())) { - if (!ToolUtil.convertToType(box.getAxisYrotate().trim(), Double.class)) { - box.setAxisYrotate(box.getAxisYrotate() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setAxisYrotate("0"); - } - if (!StringUtils.isEmpty(box.getAxisXrotate())) { - if (!ToolUtil.convertToType(box.getAxisXrotate().trim(), Double.class)) { - box.setAxisXrotate(box.getAxisXrotate() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setAxisXrotate("0"); - } - if (!StringUtils.isEmpty(box.getAxisZrotate())) { - if (!ToolUtil.convertToType(box.getAxisZrotate().trim(), Double.class)) { - box.setAxisZrotate(box.getAxisZrotate() + "---< " + TYPE_ERR + " >---"); - } - } else { - box.setAxisZrotate("0"); - } - if (StringUtils.isEmpty(box.getName())) { - box.setName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(box.getCode())) { - box.setCode(NOT_ASSIGNED_CODE); - } + isEmptyAddAndPositiveNumberSize(box::getHeight, box::setHeight, "0", Double.class, "柜体高度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(box::getLength, box::setLength, "0", Double.class, "柜体长度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(box::getWidth, box::setWidth, "0", Double.class, "柜体宽度", 8, 3, flag); + isEmptyAddAndPositiveNumber(box::getMultipleNumber, box::setMultipleNumber, "1", Integer.class, "柜体成倍拆单数量", flag); + isEmptyAddAndPositiveNumber(box::getMultipleNo, box::setMultipleNo, "1", Integer.class, "柜体成倍拆单序号", flag); + isEmptyAddAndNumber(box::getBasePointX, box::setBasePointX, "0", Double.class, "基点坐标X", flag); + isEmptyAddAndNumber(box::getBasePointY, box::setBasePointY, "0", Double.class, "基点坐标Y", flag); + isEmptyAddAndNumber(box::getBasePointZ, box::setBasePointZ, "0", Double.class, "基点坐标Z", flag); + isEmptyAddAndNumber(box::getAxisXrotate, box::setAxisXrotate, "0", Double.class, "绕X轴旋转角度", flag); + isEmptyAddAndNumber(box::getAxisYrotate, box::setAxisYrotate, "0", Double.class, "绕Y轴旋转角度", flag); + isEmptyAddAndNumber(box::getAxisZrotate, box::setAxisZrotate, "0", Double.class, "绕Z轴旋转角度", flag); + isEmptyAndAdd(box::getCode, box::setCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(box::getName, box::setName, NOT_ASSIGNED); } } // 模块数据格式验证 - public void checkModules(ModuleXmlVOS moduleXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(moduleXmlVOS.getCount())) { - if (ToolUtil.convertToType(moduleXmlVOS.getCount().trim(), Integer.class)) { - if (!ToolUtil.checkNumber(moduleXmlVOS.getCount().trim())) { - moduleXmlVOS.setCount(moduleXmlVOS.getCount() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } else { - moduleXmlVOS.setCount(moduleXmlVOS.getCount() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } + public void checkModules(ModuleXmlVOS moduleXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(moduleXmlVOS::getCount, moduleXmlVOS::setCount, "模块数量", Integer.class, flag); + if (moduleXmlVOS.getModuleXmlVOList() != null && moduleXmlVOS.getModuleXmlVOList().size() > 0) { - checkModuleList(moduleXmlVOS.getModuleXmlVOList(), error); + checkModuleList(moduleXmlVOS.getModuleXmlVOList(), flag); } } // 模块数据格式验证 - public void checkModuleList(List moduleXmlVOSList, Boolean error) { + public void checkModuleList(List moduleXmlVOSList, AtomicBoolean flag) { for (ModuleXmlVO module : moduleXmlVOSList) { - if (StringUtils.isEmpty(module.getName())) { - module.setName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(module.getCode())) { - module.setCode(NOT_ASSIGNED_CODE); - } - if (!StringUtils.isEmpty(module.getLength())) { - Boolean flag = checkNumber(module.getLength().trim(), Double.class); - if (!flag) { - module.setLength(module.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - module.setLength("0"); - } - if (!StringUtils.isEmpty(module.getWidth())) { - Boolean flag = checkNumber(module.getWidth().trim(), Double.class); - if (!flag) { - module.setWidth(module.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - module.setWidth("0"); - } - if (!StringUtils.isEmpty(module.getHeight())) { - Boolean flag = checkNumber(module.getHeight().trim(), Double.class); - if (!flag) { - module.setHeight(module.getHeight() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - module.setHeight("0"); - } + isEmptyAndAdd(module::getCode, module::setCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(module::getName, module::setName, NOT_ASSIGNED); + + isEmptyAddAndPositiveNumberSize(module::getLength, module::setLength, "0", Double.class, "模块长度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(module::getWidth, module::setWidth, "0", Double.class, "模块宽度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(module::getHeight, module::setHeight, "0", Double.class, "模块高度", 8, 3, flag); } } // 加工组数据格式验证 - public void checkGroups(GroupXmlVOS groupXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(groupXmlVOS.getCount())) { - if (ToolUtil.convertToType(groupXmlVOS.getCount().trim(), Integer.class)) { - if (!ToolUtil.checkNumber(groupXmlVOS.getCount().trim())) { - groupXmlVOS.setCount(groupXmlVOS.getCount() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } else { - groupXmlVOS.setCount(groupXmlVOS.getCount() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } + public void checkGroups(GroupXmlVOS groupXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(groupXmlVOS::getCount, groupXmlVOS::setCount, "加工组数量", Integer.class, flag); + if (groupXmlVOS.getGroupXmlVOList() != null && groupXmlVOS.getGroupXmlVOList().size() > 0) { - checkGroupList(groupXmlVOS.getGroupXmlVOList(), error); + checkGroupList(groupXmlVOS.getGroupXmlVOList(), flag); } } // 加工组数据格式验证 - public void checkGroupList(List groupXmlVOList, Boolean error) { + public void checkGroupList(List groupXmlVOList, AtomicBoolean flag) { for (GroupXmlVO group : groupXmlVOList) { - if (StringUtils.isEmpty(group.getName())) { - group.setName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(group.getCode())) { - group.setCode(NOT_ASSIGNED_CODE); - } - if (!StringUtils.isEmpty(group.getLength())) { - Boolean flag = checkNumber(group.getLength().trim(), Double.class); - if (!flag) { - group.setLength(group.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - group.setLength("0"); - } - if (!StringUtils.isEmpty(group.getWidth())) { - Boolean flag = checkNumber(group.getWidth().trim(), Double.class); - if (!flag) { - group.setWidth(group.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - group.setWidth("0"); - } - if (!StringUtils.isEmpty(group.getHeight())) { - Boolean flag = checkNumber(group.getHeight().trim(), Double.class); - if (!flag) { - group.setHeight(group.getHeight() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - group.setHeight("0"); - } + isEmptyAndAdd(group::getCode, group::setCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(group::getName, group::setName, NOT_ASSIGNED); + + isEmptyAddAndPositiveNumberSize(group::getLength, group::setLength, "0", Double.class, "模块长度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(group::getWidth, group::setWidth, "0", Double.class, "模块宽度", 8, 3, flag); + isEmptyAddAndPositiveNumberSize(group::getHeight, group::setHeight, "0", Double.class, "模块高度", 8, 3, flag); + } } // 板材数据格式验证 - public void checkPlates(List plateXmlVOList, Boolean error) { + public void checkPlates(List plateXmlVOList, AtomicBoolean flag) { for (PlateXmlVO plate : plateXmlVOList) { - if (StringUtils.isEmpty(plate.getName())) { - plate.setName("---< 板材名称不能为空 >---"); - error = false; - } - if (StringUtils.isEmpty(plate.getMaterial())) { - plate.setItemCode("---< 板材材质不能为空 >---"); - error = false; - } + isEmptyAndBack(plate::getItemCode, "板材名称", plate::setItemCode, flag); + isEmptyAndBack(plate::getMaterial, "板材材质", plate::setMaterial, flag); + // 纹理有效性判断 - if (StringUtils.isEmpty(plate.getGrained())) { - plate.setGrained("有"); - } else { - if (!StringUtils.equals(plate.getGrained().trim(), "无") && !StringUtils.equals(plate.getGrained().trim(), "有")) { - plate.setGrained(plate.getGrained() + "---< " + " 板材纹理无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(plate.getCoating())) { - plate.setCoating("双面"); - } else { - if (!StringUtils.equals(plate.getCoating().trim(), "双面") && !StringUtils.equals(plate.getCoating().trim(), "单面") && - !StringUtils.equals(plate.getCoating().trim(), "无")) { - plate.setCoating(plate.getCoating() + "---< " + " 板材纹理无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(plate.getLength())) { - plate.setLength("---< 板材长度不可为空>---"); - error = false; - } else { - Boolean flag = checkNumber(plate.getLength().trim(), Double.class); - if (!flag) { - plate.setLength(plate.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getLength().trim(), 5, 3)) { - plate.setLength(plate.getLength() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (StringUtils.isEmpty(plate.getWidth())) { - plate.setWidth("---< 板材宽度不可为空>---"); - error = false; - } else { - Boolean flag = checkNumber(plate.getWidth().trim(), Double.class); - if (!flag) { - plate.setWidth(plate.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getWidth().trim(), 5, 3)) { - plate.setWidth(plate.getWidth() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (StringUtils.isEmpty(plate.getThickness())) { - plate.setThickness("---< 板材宽度不可为空>---"); - error = false; - } else { - Boolean flag = checkNumber(plate.getThickness().trim(), Double.class); - if (!flag) { - plate.setThickness(plate.getThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getThickness().trim(), 5, 3)) { - plate.setThickness(plate.getThickness() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (!StringUtils.isEmpty(plate.getOddmentLength())) { - Boolean flag = checkNumber(plate.getOddmentLength().trim(), Double.class); - if (!flag) { - plate.setOddmentLength(plate.getOddmentLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getOddmentLength().trim(), 5, 3)) { - plate.setOddmentLength(plate.getOddmentLength() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (!StringUtils.isEmpty(plate.getOddmentWidth())) { - Boolean flag = checkNumber(plate.getOddmentWidth().trim(), Double.class); - if (!flag) { - plate.setOddmentWidth(plate.getOddmentWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getOddmentWidth().trim(), 5, 3)) { - plate.setOddmentWidth(plate.getOddmentWidth() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (!StringUtils.isEmpty(plate.getOddmentThickness())) { - Boolean flag = checkNumber(plate.getOddmentThickness().trim(), Double.class); - if (!flag) { - plate.setOddmentThickness(plate.getOddmentThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkPrecision(plate.getOddmentThickness().trim(), 5, 3)) { - plate.setOddmentThickness(plate.getOddmentThickness() + "---< " + LONG_ERR + " >---"); - error = false; - } - } - } - if (!StringUtils.isEmpty(plate.getOddment())) { - if (!StringUtils.equals(plate.getOddment().trim(), "是") && !StringUtils.equals(plate.getOddment().trim(), "否")) { - plate.setOddment(plate.getOddment() + "---< " + "板材是否余料标识无效无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(plate.getUnitLength().trim())) { - plate.setUnitLength("mm"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_LENGTH, plate.getUnitLength().trim()).getData(); - if (dictData == null) { - plate.setUnitLength(plate.getUnitLength() + "---< " + "板块长度单位无效 >---"); - error = false; - } - } - if (!StringUtils.isEmpty(plate.getArea())) { - Boolean flag = checkNumber(plate.getArea(), Double.class); - if (!flag) { - plate.setArea(plate.getArea() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(plate.getUnitArea())) { - plate.setUnitArea("m²"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_AREA, plate.getUnitArea().trim()).getData(); - if (dictData == null) { - plate.setUnitLength(plate.getUnitArea() + "---< " + "板块面积单位无效 >---"); - error = false; - } - } - if (!StringUtils.isEmpty(plate.getCount())) { - if (ToolUtil.convertToType(plate.getCount().trim(), Integer.class)) { - if (!ToolUtil.checkNumber(plate.getCount().trim())) { - plate.setCount(plate.getCount() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } else { - plate.setCount(plate.getCount() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } + isEmptyAddAndInvalid(plate::getGrained, plate::setGrained, "有", DictTypeConstants.PLATE_TEXTURE_TYPE, "板材纹理", flag); + isEmptyAddAndInvalid(plate::getCoating, plate::setCoating, "双面", DictTypeConstants.COATING_TYPE, "板材设计饰面", flag); + isEmptyAndPositiveNumber(plate::getLength, "板材长度", plate::setLength, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(plate::getWidth, "板材宽度", plate::setWidth, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(plate::getThickness, "板材厚度", plate::setThickness, Double.class, 5, 3, flag); + notEmptyPositiveNumberSize(plate::getOddmentLength, plate::setOddmentLength, "余料长", Double.class, 5, 3, flag); + notEmptyPositiveNumberSize(plate::getOddmentWidth, plate::setOddmentWidth, "余料宽", Double.class, 5, 3, flag); + notEmptyPositiveNumberSize(plate::getOddmentThickness, plate::setOddmentThickness, "余料厚", Double.class, 5, 3, flag); + isEmptyAddAndInvalid(plate::getOddment, plate::setOddment, "否", DictTypeConstants.ODDMENT_MARK, "板材是否余料标识", flag); + isEmptyAddAndInvalid(plate::getUnitLength, plate::setUnitLength, "mm", DictTypeConstants.UNIT_LENGTH, "板块长度单位", flag); + notEmptyPositiveNumber(plate::getArea, plate::setArea, "板块面积", Double.class, flag); + isEmptyAddAndInvalid(plate::getUnitArea, plate::setUnitArea, "m²", DictTypeConstants.UNIT_AREA, "板块面积单位", flag); + notEmptyPositiveNumber(plate::getCount, plate::setCount, "板块数量", Integer.class, flag); + + if (plate.getBlockXmlVOS() != null) { - checkBlocks(plate.getBlockXmlVOS(), error); + checkBlocks(plate.getBlockXmlVOS(), flag); } } } // 小板数据格式验证 - public void checkBlocks(BlockXmlVOS blockXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(blockXmlVOS.getCount())) { - Boolean flag = checkNumber(blockXmlVOS.getCount(), Integer.class); - if (!flag) { - blockXmlVOS.setCount(blockXmlVOS.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkNumber(blockXmlVOS.getCount())) { - blockXmlVOS.setCount(blockXmlVOS.getCount() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } - } - if (!StringUtils.isEmpty(blockXmlVOS.getArea())) { - Boolean flag = checkNumber(blockXmlVOS.getArea(), Integer.class); - if (!flag) { - blockXmlVOS.setArea(blockXmlVOS.getArea() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } else { - if (!ToolUtil.checkNumber(blockXmlVOS.getArea())) { - blockXmlVOS.setArea(blockXmlVOS.getArea() + "---< " + POSITIVE_ERR + " >---"); - error = false; - } - } - } - if (StringUtils.isEmpty(blockXmlVOS.getCount())) { - blockXmlVOS.setArea("m²"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_AREA, blockXmlVOS.getUnit().trim()).getData(); - if (dictData == null) { - blockXmlVOS.setUnit(blockXmlVOS.getUnit() + "---< " + "小板总面积单位无效 >---"); - error = false; - } - } + public void checkBlocks(BlockXmlVOS blockXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(blockXmlVOS::getCount, blockXmlVOS::setCount, "小板数量", Integer.class, flag); + notEmptyPositiveNumber(blockXmlVOS::getArea, blockXmlVOS::setArea, "小板总面积", Double.class, flag); + isEmptyAddAndInvalid(blockXmlVOS::getUnit, blockXmlVOS::setUnit, "m²", DictTypeConstants.UNIT_AREA, "小板总面积单位", flag); if (blockXmlVOS.getBlockXmlVOList() != null && blockXmlVOS.getBlockXmlVOList().size() > 0) { - checkBlockList(blockXmlVOS.getBlockXmlVOList(), error); + checkBlockList(blockXmlVOS.getBlockXmlVOList(), flag); } } // 板块数据格式验证 - public void checkBlockList(List blockXmlVOList, Boolean error) { + public void checkBlockList(List blockXmlVOList, AtomicBoolean flag) { if (blockXmlVOList.size() > 0) { for (BlockXmlVO blockXmlVO : blockXmlVOList) { - if (StringUtils.isEmpty(blockXmlVO.getName())) { - blockXmlVO.setName("未命名"); - } - if (StringUtils.isEmpty(blockXmlVO.getType())) { - blockXmlVO.setType("背板"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.PLATE_TYPE, blockXmlVO.getType()).getData(); - if (dictData == null) { - blockXmlVO.setType(blockXmlVO.getType() + "---< " + "板块类型无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getOpenDirection())) { - blockXmlVO.setOpenDirection("非门板"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, blockXmlVO.getOpenDirection()).getData(); - if (dictData == null) { - blockXmlVO.setOpenDirection(blockXmlVO.getOpenDirection() + "---< " + "板块开门方向无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getTexture())) { - blockXmlVO.setTexture("正纹"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.GRAIN_TYPE, blockXmlVO.getTexture()).getData(); - if (dictData == null) { - blockXmlVO.setTexture(blockXmlVO.getTexture() + "---< " + "板块设计纹路无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getLayoutFace())) { - blockXmlVO.setLayoutFace("随意面"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.TYPOGRAPHY_TYPE, blockXmlVO.getLayoutFace()).getData(); - if (dictData == null) { - blockXmlVO.setLayoutFace(blockXmlVO.getLayoutFace() + "---< " + "板块排版面无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getCoatingType())) { - blockXmlVO.setCoatingType("双面"); - } else if (!StringUtils.equals(blockXmlVO.getCoatingType().trim(), "双面") && !StringUtils.equals(blockXmlVO.getCoatingType().trim(), "无") && - !StringUtils.equals(blockXmlVO.getCoatingType().trim(), "单面")) { - blockXmlVO.setCoatingType(blockXmlVO.getCoatingType() + "---< " + "小板设计饰面无效 >---"); - error = false; - } -// if (StringUtils.isEmpty(blockXmlVO.getCoatingObverse())) { -// blockXmlVO.setCoatingObverse("---< 板块正面颜色不可为空 >---"); -// error = false; -// } -// if (StringUtils.isEmpty(blockXmlVO.getCoatingObverse())) { -// blockXmlVO.setCoatingReverse("---< 板块反面颜色不可为空 >---"); -// error = false; -// } - if (StringUtils.isEmpty(blockXmlVO.getLength())) { - blockXmlVO.setLength("---< 板块长度不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getLength(), Double.class, 5, 3)) { - blockXmlVO.setLength(blockXmlVO.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getWidth())) { - blockXmlVO.setWidth("---< 板块宽度不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getWidth(), Double.class, 5, 3)) { - blockXmlVO.setWidth(blockXmlVO.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getThickness())) { - blockXmlVO.setThickness("---< 板块厚度不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getThickness(), Double.class, 5, 3)) { - blockXmlVO.setThickness(blockXmlVO.getThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getCuttingLength())) { - blockXmlVO.setCuttingLength("---< 板块开料长不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getThickness(), Double.class, 5, 3)) { - blockXmlVO.setCuttingLength(blockXmlVO.getCuttingLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getCuttingWidth())) { - blockXmlVO.setCuttingWidth("---< 板块开料宽不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getCuttingWidth(), Double.class, 5, 3)) { - blockXmlVO.setCuttingWidth(blockXmlVO.getCuttingWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getCuttingThickness())) { - blockXmlVO.setCuttingThickness("---< 板块开料厚不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getCuttingThickness(), Double.class, 5, 3)) { - blockXmlVO.setCuttingThickness(blockXmlVO.getCuttingThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getRawLength())) { - blockXmlVO.setRawLength("---< 板块胚料长不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getRawLength(), Double.class, 5, 3)) { - blockXmlVO.setRawLength(blockXmlVO.getRawLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getRawWidth())) { - blockXmlVO.setRawWidth("---< 板块胚料宽不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getRawWidth(), Double.class, 5, 3)) { - blockXmlVO.setRawWidth(blockXmlVO.getRawWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getRawThickness())) { - blockXmlVO.setRawThickness("---< 板块胚料厚不可为空 >---"); - error = false; - } else { - if (!checkNumber(blockXmlVO.getRawThickness(), Double.class, 5, 3)) { - blockXmlVO.setRawThickness(blockXmlVO.getRawThickness() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + "或是" + LONG_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getUnit())) { - blockXmlVO.setUnit("mm"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(blockXmlVO.getUnit(), DictTypeConstants.UNIT_LENGTH).getData(); - if (dictData == null) { - blockXmlVO.setUnit(blockXmlVO.getUnit() + "---< " + " 长度单位无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getMultipleNumber())) { - blockXmlVO.setMultipleNumber("1"); - } else { - if (!checkNumber(blockXmlVO.getMultipleNumber().trim(), Integer.class)) { - blockXmlVO.setMultipleNumber(blockXmlVO.getMultipleNumber() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getMultipleNo())) { - blockXmlVO.setMultipleNo("1"); - } else { - if (!checkNumber(blockXmlVO.getMultipleNo().trim(), Integer.class)) { - blockXmlVO.setMultipleNo(blockXmlVO.getMultipleNo() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getUnregular())) { - blockXmlVO.setUnregular("否"); - } else { - if (!StringUtils.equals(blockXmlVO.getUnregular().trim(), "是") && !StringUtils.equals(blockXmlVO.getUnregular().trim(), "否")) { - blockXmlVO.setUnregular(blockXmlVO.getUnregular() + "---< " + "板材是否异形数据无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getDrilling())) { - blockXmlVO.setDrilling("否"); - } else { - if (!StringUtils.equals(blockXmlVO.getDrilling().trim(), "是") && !StringUtils.equals(blockXmlVO.getDrilling().trim(), "否")) { - blockXmlVO.setDrilling(blockXmlVO.getDrilling() + "---< " + "板材是否钻孔数据无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getSlotting())) { - blockXmlVO.setSlotting("否"); - } else { - if (!StringUtils.equals(blockXmlVO.getSlotting().trim(), "是") && !StringUtils.equals(blockXmlVO.getSlotting().trim(), "否")) { - blockXmlVO.setSlotting(blockXmlVO.getSlotting() + "---< " + "板材是否挖槽数据无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(blockXmlVO.getRoomCode())) { - blockXmlVO.setRoomCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(blockXmlVO.getRoomName())) { - blockXmlVO.setRoomName(NOT_ASSIGNED); - } - if (StringUtils.isEmpty(blockXmlVO.getBoxCode())) { - blockXmlVO.setBoxCode(NOT_ASSIGNED_CODE); - } - if (StringUtils.isEmpty(blockXmlVO.getBoxName())) { - blockXmlVO.setBoxName(NOT_ASSIGNED); - } -// if (StringUtils.isEmpty(blockXmlVO.getGroupCode())) { -// blockXmlVO.setGroupCode(NOT_ASSIGNED_CODE); -// } -// if (StringUtils.isEmpty(blockXmlVO.getGroupName())) { -// blockXmlVO.setGroupName(NOT_ASSIGNED); -// } - if (!StringUtils.isEmpty(blockXmlVO.getBasePointX())) { - if (!ToolUtil.convertToType(blockXmlVO.getBasePointX(), Double.class)) { - blockXmlVO.setBasePointX(blockXmlVO.getBasePointX() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setBasePointX("0"); - } - if (!StringUtils.isEmpty(blockXmlVO.getBasePointY())) { - if (!ToolUtil.convertToType(blockXmlVO.getBasePointY(), Double.class)) { - blockXmlVO.setBasePointY(blockXmlVO.getBasePointY() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setBasePointY("0"); - } - if (!StringUtils.isEmpty(blockXmlVO.getBasePointZ())) { - if (!ToolUtil.convertToType(blockXmlVO.getBasePointZ(), Double.class)) { - blockXmlVO.setBasePointZ(blockXmlVO.getBasePointZ() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setBasePointZ("0"); - } - if (!StringUtils.isEmpty(blockXmlVO.getAxisXrotate())) { - if (!ToolUtil.convertToType(blockXmlVO.getAxisXrotate(), Double.class)) { - blockXmlVO.setAxisXrotate(blockXmlVO.getAxisXrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setAxisXrotate("0"); - } - if (!StringUtils.isEmpty(blockXmlVO.getAxisYrotate())) { - if (!ToolUtil.convertToType(blockXmlVO.getAxisYrotate(), Double.class)) { - blockXmlVO.setAxisYrotate(blockXmlVO.getAxisYrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setAxisYrotate("0"); - } - if (!StringUtils.isEmpty(blockXmlVO.getAxisZrotate())) { - if (!ToolUtil.convertToType(blockXmlVO.getAxisZrotate(), Double.class)) { - blockXmlVO.setAxisZrotate(blockXmlVO.getAxisZrotate() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } else { - blockXmlVO.setAxisZrotate("0"); - } + isEmptyAndAdd(blockXmlVO::getName, blockXmlVO::setName, NOT_ASSIGNED); + isEmptyAddAndInvalid(blockXmlVO::getType, blockXmlVO::setType, "背板", DictTypeConstants.PLATE_TYPE, "板块类型", flag); + isEmptyAddAndInvalid(blockXmlVO::getOpenDirection, blockXmlVO::setOpenDirection, "非门板", DictTypeConstants.DOOR_OPENING_DIRECTIONS, "板块开门方向", flag); + isEmptyAddAndInvalid(blockXmlVO::getTexture, blockXmlVO::setTexture, "正纹", DictTypeConstants.GRAIN_TYPE, "板块设计纹路", flag); + isEmptyAddAndInvalid(blockXmlVO::getLayoutFace, blockXmlVO::setLayoutFace, "随意面", DictTypeConstants.TYPOGRAPHY_TYPE, "板块排版面", flag); + isEmptyAddAndInvalid(blockXmlVO::getCoatingType, blockXmlVO::setCoatingType, "双面", DictTypeConstants.COATING_TYPE, "板块设计饰面", flag); + isEmptyAndPositiveNumber(blockXmlVO::getLength, "板块长度", blockXmlVO::setLength, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getWidth, "板块宽度", blockXmlVO::setWidth, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getThickness, "板块厚度", blockXmlVO::setThickness, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getCuttingLength, "板块开料长", blockXmlVO::setCuttingLength, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getCuttingWidth, "板块开料宽", blockXmlVO::setCuttingWidth, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getCuttingThickness, "板块开料厚", blockXmlVO::setCuttingThickness, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getRawLength, "板块胚料长", blockXmlVO::setRawLength, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getRawWidth, "板块胚料宽", blockXmlVO::setRawWidth, Double.class, 5, 3, flag); + isEmptyAndPositiveNumber(blockXmlVO::getRawThickness, "板块胚料厚", blockXmlVO::setRawThickness, Double.class, 5, 3, flag); + isEmptyAddAndInvalid(blockXmlVO::getUnit, blockXmlVO::setUnit, "mm", DictTypeConstants.UNIT_LENGTH, "小板长度单位", flag); + isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNumber, blockXmlVO::setMultipleNumber, "1", Integer.class, "小板成倍拆单数量", flag); + isEmptyAddAndPositiveNumber(blockXmlVO::getMultipleNo, blockXmlVO::setMultipleNo, "1", Integer.class, "小板成倍拆单序号", flag); + isEmptyAddAndInvalid(blockXmlVO::getUnregular, blockXmlVO::setUnregular, "否", DictTypeConstants.IS_NOT_MARK, "板块是否异形数据", flag); + isEmptyAddAndInvalid(blockXmlVO::getDrilling, blockXmlVO::setDrilling, "否", DictTypeConstants.IS_NOT_MARK, "板块是否钻孔数据", flag); + isEmptyAddAndInvalid(blockXmlVO::getSlotting, blockXmlVO::setSlotting, "否", DictTypeConstants.IS_NOT_MARK, "板块是否挖槽数据", flag); + + isEmptyAndAdd(blockXmlVO::getRoomCode, blockXmlVO::setRoomCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(blockXmlVO::getRoomName, blockXmlVO::setRoomName, NOT_ASSIGNED); + isEmptyAndAdd(blockXmlVO::getBoxCode, blockXmlVO::setBoxCode, NOT_ASSIGNED_CODE); + isEmptyAndAdd(blockXmlVO::getBoxName, blockXmlVO::setBoxName, NOT_ASSIGNED); + + isEmptyAddAndNumber(blockXmlVO::getBasePointX, blockXmlVO::setBasePointX, "0", Double.class, "小板基点坐标X", flag); + isEmptyAddAndNumber(blockXmlVO::getBasePointY, blockXmlVO::setBasePointY, "0", Double.class, "小板基点坐标Y", flag); + isEmptyAddAndNumber(blockXmlVO::getBasePointZ, blockXmlVO::setBasePointZ, "0", Double.class, "小板基点坐标Z", flag); + isEmptyAddAndNumber(blockXmlVO::getAxisXrotate, blockXmlVO::setAxisXrotate, "0", Double.class, "小板绕X轴旋转角度", flag); + isEmptyAddAndNumber(blockXmlVO::getAxisYrotate, blockXmlVO::setAxisYrotate, "0", Double.class, "小板绕Y轴旋转角度", flag); + isEmptyAddAndNumber(blockXmlVO::getAxisZrotate, blockXmlVO::setAxisZrotate, "0", Double.class, "小板绕Z轴旋转角度", flag); + + if (blockXmlVO.getOutlineXmlVO() != null) { - checkOutline(blockXmlVO.getOutlineXmlVO(), error); + checkOutline(blockXmlVO.getOutlineXmlVO(), flag); } if (blockXmlVO.getCuttingOutlineXmlVO() != null) { - checkCuttingOutline(blockXmlVO.getCuttingOutlineXmlVO(), error); + checkCuttingOutline(blockXmlVO.getCuttingOutlineXmlVO(), flag); } if (blockXmlVO.getRawOutlineXmlVO() != null && blockXmlVO.getRawOutlineXmlVO().getPointXmlVOList() != null && blockXmlVO.getRawOutlineXmlVO().getPointXmlVOList().size() > 0) { - checkRawOutline(blockXmlVO.getRawOutlineXmlVO(), error); + checkRawOutline(blockXmlVO.getRawOutlineXmlVO(), flag); } if (blockXmlVO.getHoleXmlVOS() != null) { - checkHoles(blockXmlVO.getHoleXmlVOS(), error); + checkHoles(blockXmlVO.getHoleXmlVOS(), flag); } if (blockXmlVO.getGrooveXmlVOS() != null) { - checkGrooves(blockXmlVO.getGrooveXmlVOS(), error); + checkGrooves(blockXmlVO.getGrooveXmlVOS(), flag); } if (blockXmlVO.getIsletXmlVOS() != null && blockXmlVO.getIsletXmlVOS().getIsletXmlVOList() != null && blockXmlVO.getIsletXmlVOS().getIsletXmlVOList().size() > 0) { - checkIslets(blockXmlVO.getIsletXmlVOS(), error); + checkIslets(blockXmlVO.getIsletXmlVOS(), flag); } if (blockXmlVO.getCorrelationXmlVOS() != null) { - checkCorrelations(blockXmlVO.getCorrelationXmlVOS(), error); + checkCorrelations(blockXmlVO.getCorrelationXmlVOS(), flag); } } } } - private void checkCorrelations(CorrelationXmlVOS correlationXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(correlationXmlVOS.getCount())) { - if (!checkNumber(correlationXmlVOS.getCount(), Integer.class)) { - correlationXmlVOS.setCount(correlationXmlVOS.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } + private void checkCorrelations(CorrelationXmlVOS correlationXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(correlationXmlVOS::getCount, correlationXmlVOS::setCount, "关联配件数量", Integer.class, flag); + if (correlationXmlVOS.getCorrelationXmlVOList() != null && correlationXmlVOS.getCorrelationXmlVOList().size() > 0) { for (CorrelationXmlVO correlationXmlVO : correlationXmlVOS.getCorrelationXmlVOList()) { if (StringUtils.isEmpty(correlationXmlVO.getItemCode())) { - if (StringUtils.isEmpty(correlationXmlVO.getItemCode())) { - correlationXmlVO.setName("---< 关联配件(五金)/组件物料编码 >---"); - error = false; - } - } - if (!StringUtils.isEmpty(correlationXmlVO.getCount())) { - if (!checkNumber(correlationXmlVO.getCount(), Integer.class)) { - correlationXmlVO.setCount(correlationXmlVO.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - correlationXmlVO.setCount("---< 关联配件(五金)/组件数量不可为空 >---"); - error = false; + isEmptyAndBack(correlationXmlVO::getName, "关联配件名称", correlationXmlVO::setName, flag); } + isEmptyBackAndPositiveNumber(correlationXmlVO::getCount, "关联配件数量", correlationXmlVO::setCount, Integer.class, flag); } } } - private void checkIslets(IsletXmlVOS isletXmlVOS, Boolean error) { - Boolean index = true; - if (StringUtils.isEmpty(isletXmlVOS.getCount())) { - isletXmlVOS.setCount("---< 孤岛数量不可为空 >---"); - error = false; - index = false; - } else { - Boolean flag = checkNumber(isletXmlVOS.getCount().trim(), Integer.class); - if (!flag) { - isletXmlVOS.setCount(isletXmlVOS.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - index = false; - } - } + private void checkIslets(IsletXmlVOS isletXmlVOS, AtomicBoolean flag) { + boolean index = isEmptyBackAndPositiveNumberAndBack(isletXmlVOS::getCount, "孤岛数量 "+ isletXmlVOS.getCount(), isletXmlVOS::setCount, Integer.class, flag); + if (index) { if (isletXmlVOS.getIsletXmlVOList() == null) { isletXmlVOS.setCount("---< 孤岛数量与孤岛列表数量不一致 >---"); - error = false; + flag.set(false); } else if (isletXmlVOS.getIsletXmlVOList().size() > 0) { - if (Integer.valueOf(isletXmlVOS.getCount()) != isletXmlVOS.getIsletXmlVOList().size()) { + if (Integer.parseInt(isletXmlVOS.getCount()) != isletXmlVOS.getIsletXmlVOList().size()) { isletXmlVOS.setCount("---< 孤岛数量与孤岛列表数量不一致 >---"); - error = false; + flag.set(false); } else { for (IsletXmlVO isletXmlVO : isletXmlVOS.getIsletXmlVOList()) { - checkIslet(isletXmlVO, error); + checkIslet(isletXmlVO, flag); } } } @@ -1292,39 +851,27 @@ public class XMLUtil { } - private void checkIslet(IsletXmlVO isletXmlVO, Boolean error) { - if (StringUtils.isEmpty(isletXmlVO.getId())) { - isletXmlVO.setId("---< 孤岛ID不可为空 >---"); - error = false; - } + private void checkIslet(IsletXmlVO isletXmlVO, AtomicBoolean flag) { + isEmptyAndBack(isletXmlVO::getId, "孤岛ID", isletXmlVO::setId, flag); + // 造型内孤岛 两个 if (isletXmlVO.getPointXmlVOS() != null) { - Boolean index = true; - if (StringUtils.isEmpty(isletXmlVO.getPointXmlVOS().getCount())) { - isletXmlVO.getPointXmlVOS().setCount("---< 孤岛点阵数量不可为空 >---"); - error = false; - index = false; - } else { - Boolean flag = checkNumber(isletXmlVO.getPointXmlVOS().getCount().trim(), Integer.class); - if (!flag) { - isletXmlVO.getPointXmlVOS().setCount(isletXmlVO.getPointXmlVOS().getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - index = false; - } - } + PointXmlVOS pointXmlVOS = isletXmlVO.getPointXmlVOS(); + boolean index = isEmptyBackAndPositiveNumberAndBack(pointXmlVOS::getCount, "孤岛点阵数量 "+ pointXmlVOS.getCount(), pointXmlVOS::setCount, Integer.class, flag); + if (index) { - if (isletXmlVO.getPointXmlVOS().getPointXmlVOList() == null) { - isletXmlVO.getPointXmlVOS().setCount("---< 孤岛点阵数量与孤岛点阵列表数量不一致 >---"); - error = false; - } else if (isletXmlVO.getPointXmlVOS().getPointXmlVOList().size() > 0) { - if (Integer.valueOf(isletXmlVO.getPointXmlVOS().getCount()) != isletXmlVO.getPointXmlVOS().getPointXmlVOList().size()) { - isletXmlVO.getPointXmlVOS().setCount("---< 孤岛点阵数量与孤岛点阵列表数量不一致 >---"); - error = false; + if (pointXmlVOS.getPointXmlVOList() == null) { + pointXmlVOS.setCount("---< 孤岛点阵数量与孤岛点阵列表数量不一致 >---"); + flag.set(false); + } else if (pointXmlVOS.getPointXmlVOList().size() > 0) { + if (Integer.parseInt(pointXmlVOS.getCount()) != pointXmlVOS.getPointXmlVOList().size()) { + pointXmlVOS.setCount("---< 孤岛点阵数量与孤岛点阵列表数量不一致 >---"); + flag.set(false); } else { - for (PointXmlVO pointXmlVO : isletXmlVO.getPointXmlVOS().getPointXmlVOList()) { - checkPoint(pointXmlVO, error); + for (PointXmlVO pointXmlVO : pointXmlVOS.getPointXmlVOList()) { + checkPoint(pointXmlVO, flag); } } } @@ -1333,706 +880,189 @@ public class XMLUtil { } - private void checkHoles(HoleXmlVOS holeXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(holeXmlVOS.getCount())) { - Boolean flag = checkNumber(holeXmlVOS.getCount().trim(), Double.class); - if (!flag) { - holeXmlVOS.setCount(holeXmlVOS.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCount("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountFaceA())) { - Boolean flag = checkNumber(holeXmlVOS.getCountFaceA().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountFaceA(holeXmlVOS.getCountFaceA() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountFaceA("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountFaceB())) { - Boolean flag = checkNumber(holeXmlVOS.getCountFaceB().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountFaceB(holeXmlVOS.getCountFaceB() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountFaceB("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountSide())) { - Boolean flag = checkNumber(holeXmlVOS.getCountSide().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountSide(holeXmlVOS.getCountSide() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountSide("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountSideL())) { - Boolean flag = checkNumber(holeXmlVOS.getCountSideL().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountSideL(holeXmlVOS.getCountSideL() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountSideL("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountSideR())) { - Boolean flag = checkNumber(holeXmlVOS.getCountSideR().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountSideR(holeXmlVOS.getCountSideR() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountSideR("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountSideU())) { - Boolean flag = checkNumber(holeXmlVOS.getCountSideU().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountSideU(holeXmlVOS.getCountSideU() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountSideU("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountSideD())) { - Boolean flag = checkNumber(holeXmlVOS.getCountSideD().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountSideD(holeXmlVOS.getCountSideD() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountSideD("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountBevelled())) { - Boolean flag = checkNumber(holeXmlVOS.getCountBevelled().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountBevelled(holeXmlVOS.getCountBevelled() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountBevelled("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountLocking())) { - Boolean flag = checkNumber(holeXmlVOS.getCountLocking().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountLocking(holeXmlVOS.getCountLocking() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountLocking("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountBuildIn())) { - Boolean flag = checkNumber(holeXmlVOS.getCountBuildIn().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountBuildIn(holeXmlVOS.getCountBuildIn() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountBuildIn("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountHinge())) { - Boolean flag = checkNumber(holeXmlVOS.getCountHinge().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountHinge(holeXmlVOS.getCountHinge() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountHinge("0"); - } - if (!StringUtils.isEmpty(holeXmlVOS.getCountThrough())) { - Boolean flag = checkNumber(holeXmlVOS.getCountThrough().trim(), Integer.class); - if (!flag) { - holeXmlVOS.setCountThrough(holeXmlVOS.getCountThrough() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - holeXmlVOS.setCountThrough("0"); - } + private void checkHoles(HoleXmlVOS holeXmlVOS, AtomicBoolean flag) { + isEmptyAddAndPositiveNumber(holeXmlVOS::getCount, holeXmlVOS::setCount, "0", Integer.class, "孔数量 " + holeXmlVOS.getCount(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountFaceA, holeXmlVOS::setCountFaceA, "0", Integer.class, "正面垂直孔数量 " + holeXmlVOS.getCountFaceA(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountFaceB, holeXmlVOS::setCountFaceB, "0", Integer.class, "反面垂直孔数量 " + holeXmlVOS.getCountFaceB(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountSide, holeXmlVOS::setCountSide, "0", Integer.class, "水平侧孔数量 " + holeXmlVOS.getCountSide(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountSideL, holeXmlVOS::setCountSideL, "0", Integer.class, "左侧孔数量 " + holeXmlVOS.getCountSideL(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountSideR, holeXmlVOS::setCountSideR, "0", Integer.class, "右侧孔数量 " + holeXmlVOS.getCountSideR(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountSideU, holeXmlVOS::setCountSideU, "0", Integer.class, "上侧孔数量 " + holeXmlVOS.getCountSideU(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountSideD, holeXmlVOS::setCountSideD, "0", Integer.class, "下侧孔数量 " + holeXmlVOS.getCountSideD(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountBevelled, holeXmlVOS::setCountBevelled, "0", Integer.class, "斜孔数量 " + holeXmlVOS.getCountBevelled(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountLocking, holeXmlVOS::setCountLocking, "0", Integer.class, "偏心轮/锁定孔数量 " + holeXmlVOS.getCountLocking(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountBuildIn, holeXmlVOS::setCountBuildIn, "0", Integer.class, "预埋件/插入孔数量 " + holeXmlVOS.getCountBuildIn(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountHinge, holeXmlVOS::setCountHinge, "0", Integer.class, "铰链孔数量 " + holeXmlVOS.getCountHinge(), flag); + isEmptyAddAndPositiveNumber(holeXmlVOS::getCountThrough, holeXmlVOS::setCountThrough, "0", Integer.class, "穿孔数量 " + holeXmlVOS.getCountThrough(), flag); + if (holeXmlVOS.getHoleXmlVOList() != null && holeXmlVOS.getHoleXmlVOList().size() > 0) { for (HoleXmlVO holeXmlVO : holeXmlVOS.getHoleXmlVOList()) { - checkHole(holeXmlVO, error); + checkHole(holeXmlVO, flag); } } } - private void checkHole(HoleXmlVO holeXmlVO, Boolean error) { - if (StringUtils.isEmpty(holeXmlVO.getFace())) { - holeXmlVO.setFace("---< 小板孔加工面不可为空 >---"); - error = false; - } else { - DictDataRespDTO dictDataVO = dictDataApi.parseDictData(DictTypeConstants.HOLE_FACE, holeXmlVO.getFace()).getData(); - if (dictDataVO == null) { - holeXmlVO.setFace(holeXmlVO.getFace() + "---< " + " 小板孔加工面数据无效 >---"); - error = false; - } - } - if (StringUtils.isEmpty(holeXmlVO.getDirection())) { - holeXmlVO.setDirection("---< 小板孔加工方向不可为空 >---"); - error = false; - } else { - DictDataRespDTO dictDataVO = dictDataApi.parseDictData(DictTypeConstants.HOLE_DIRECTION, holeXmlVO.getDirection()).getData(); - if (dictDataVO == null) { - holeXmlVO.setDirection(holeXmlVO.getDirection() + "---< " + " 小板孔加工方向数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getDiameter())) { - holeXmlVO.setDiameter("---< 小板孔直径不可为空 >---"); - error = false; - } else { - Boolean flag = checkNumber(holeXmlVO.getDiameter().trim(), Double.class); - if (!flag) { - holeXmlVO.setDiameter(holeXmlVO.getDiameter() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } + private void checkHole(HoleXmlVO holeXmlVO, AtomicBoolean flag) { + isEmptyBackAndInvalid(holeXmlVO::getType, holeXmlVO::setType, DictTypeConstants.HOLE_FACE, "小板孔加工面 ", flag); + isEmptyBackAndInvalid(holeXmlVO::getDirection, holeXmlVO::setDirection, DictTypeConstants.HOLE_DIRECTION, "小板孔加工方向 ", flag); + isEmptyBackAndPositiveNumber(holeXmlVO::getDiameter, "小板孔直径", holeXmlVO::setDiameter, Double.class , flag); if (StringUtils.isNotEmpty(holeXmlVO.getType()) && holeXmlVO.getType().equals("沉头孔")) { - if (StringUtils.isEmpty(holeXmlVO.getDiameterInner())) { - holeXmlVO.setDiameterInner("---< 当小板孔类型为沉头孔时,小板孔沉头孔内径不可为空 >---"); - error = false; - } else { - Boolean flag = checkNumber(holeXmlVO.getDiameterInner().trim(), Double.class); - if (!flag) { - holeXmlVO.setDiameterInner(holeXmlVO.getDiameterInner() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getDepthInner())) { - holeXmlVO.setDepthInner("---< 当小板孔类型为沉头孔时,沉头孔的深度不可为空 >---"); - error = false; - } else { - Boolean flag = checkNumber(holeXmlVO.getDepthInner().trim(), Double.class); - if (!flag) { - holeXmlVO.setDepthInner(holeXmlVO.getDepthInner() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - } - } - } - if (StringUtils.isEmpty(holeXmlVO.getDepth())) { - holeXmlVO.setDepth("---< 小板孔深度不可为空 >---"); - error = false; - } else { - Boolean flag = checkNumber(holeXmlVO.getDepth().trim(), Double.class); - if (!flag) { - holeXmlVO.setDepth(holeXmlVO.getDepth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getGroupNumber())) { - Boolean flag = checkNumber(holeXmlVO.getGroupNumber().trim(), Integer.class); - if (!flag) { - holeXmlVO.setGroupNumber(holeXmlVO.getGroupNumber() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(holeXmlVO.getGroupXoffset())) { - holeXmlVO.setGroupXoffset("0"); - } else { - Boolean flag = ToolUtil.convertToType(holeXmlVO.getGroupXoffset().trim(), Double.class); - if (!flag) { - holeXmlVO.setGroupXoffset(holeXmlVO.getGroupXoffset() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(holeXmlVO.getGroupYoffset())) { - holeXmlVO.setGroupYoffset("0"); - } else { - Boolean flag = ToolUtil.convertToType(holeXmlVO.getGroupYoffset().trim(), Double.class); - if (!flag) { - holeXmlVO.setGroupYoffset(holeXmlVO.getGroupYoffset() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(holeXmlVO.getGroupZoffset())) { - holeXmlVO.setGroupZoffset("0"); - } else { - Boolean flag = ToolUtil.convertToType(holeXmlVO.getGroupZoffset().trim(), Double.class); - if (!flag) { - holeXmlVO.setGroupZoffset(holeXmlVO.getGroupZoffset() + "---< " + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(holeXmlVO.getStartX())) { - holeXmlVO.setStartX("---< 小板孔起点坐标X不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getStartX().trim(), Double.class)) { - holeXmlVO.setStartX(holeXmlVO.getStartX() + "---< " + " 小板孔起点坐标X数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getStartY())) { - holeXmlVO.setStartY("---< 小板孔起点坐标Y不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getStartY().trim(), Double.class)) { - holeXmlVO.setStartY(holeXmlVO.getStartY() + "---< " + " 小板孔起点坐标Y数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getStartZ())) { - holeXmlVO.setStartZ("---< 小板孔起点坐标Z不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getStartZ().trim(), Double.class)) { - holeXmlVO.setStartZ(holeXmlVO.getStartZ() + "---< " + " 小板孔起点坐标Z数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getEndX())) { - holeXmlVO.setEndX("---< 小板孔终点坐标X不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getEndX().trim(), Double.class)) { - holeXmlVO.setEndX(holeXmlVO.getEndX() + "---< " + " 小板孔终点坐标X数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getEndY())) { - holeXmlVO.setEndY("---< 小板孔终点坐标Y不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getEndY().trim(), Double.class)) { - holeXmlVO.setEndY(holeXmlVO.getEndY() + "---< " + " 小板孔终点坐标Y数据无效 >---"); - } - } - if (StringUtils.isEmpty(holeXmlVO.getEndZ())) { - holeXmlVO.setEndZ("---< 小板孔终点坐标Z不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(holeXmlVO.getEndZ().trim(), Double.class)) { - holeXmlVO.setEndZ(holeXmlVO.getEndZ() + "---< " + " 小板孔终点坐标Z数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolStartRotateX())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolStartRotateX().trim(), Double.class)) { - holeXmlVO.setToolStartRotateX(holeXmlVO.getToolStartRotateX() + "---< " + " 小板孔起点旋转角度X数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolStartRotateY())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolStartRotateY().trim(), Double.class)) { - holeXmlVO.setToolStartRotateY(holeXmlVO.getToolStartRotateY() + "---< " + " 小板孔起点旋转角度Y数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolStartRotateZ())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolStartRotateZ().trim(), Double.class)) { - holeXmlVO.setToolStartRotateZ("---< " + holeXmlVO.getToolStartRotateZ() + " 小板孔起点旋转角度Z数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolEndRotateX())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolEndRotateX().trim(), Double.class)) { - holeXmlVO.setToolEndRotateX("---< " + holeXmlVO.getToolEndRotateX() + " 小板孔终点旋转角度X数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolEndRotateY())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolEndRotateY().trim(), Double.class)) { - holeXmlVO.setToolEndRotateY("---< " + holeXmlVO.getToolEndRotateY() + " 小板孔终点旋转角度Y数据无效 >---"); - } - } - if (!StringUtils.isEmpty(holeXmlVO.getToolEndRotateZ())) { - if (!ToolUtil.convertToType(holeXmlVO.getToolEndRotateZ().trim(), Double.class)) { - holeXmlVO.setToolEndRotateZ("---< " + holeXmlVO.getToolEndRotateZ() + " 小板孔终点旋转角度Z数据无效 >---"); - } + isEmptyBackAndPositiveNumber(holeXmlVO::getDiameterInner,"当小板孔类型为沉头孔时,小板孔沉头孔内径", holeXmlVO::setDiameterInner, Double.class , flag); + isEmptyBackAndPositiveNumber(holeXmlVO::getDepthInner, "当小板孔类型为沉头孔时,沉头孔的深度", holeXmlVO::setDepthInner, Double.class , flag); } + isEmptyBackAndPositiveNumber(holeXmlVO::getDepth, "小板孔深度", holeXmlVO::setDepth, Double.class , flag); + notEmptyPositiveNumber(holeXmlVO::getGroupNumber, holeXmlVO::setGroupNumber, "版面组号", Integer.class, flag); + isEmptyAddAndNumber(holeXmlVO::getGroupXoffset, holeXmlVO::setGroupXoffset, "0", Double.class ,"孔组X坐标偏移", flag); + isEmptyAddAndNumber(holeXmlVO::getGroupYoffset, holeXmlVO::setGroupYoffset, "0", Double.class ,"孔组Y坐标偏移", flag); + isEmptyAddAndNumber(holeXmlVO::getGroupZoffset, holeXmlVO::setGroupZoffset, "0", Double.class ,"孔组Z坐标偏移", flag); + isEmptyBackAndNumber(holeXmlVO::getStartX, holeXmlVO::setStartX, Double.class ,"小板孔起点坐标X", flag); + isEmptyBackAndNumber(holeXmlVO::getStartY, holeXmlVO::setStartY, Double.class ,"小板孔起点坐标Y", flag); + isEmptyBackAndNumber(holeXmlVO::getStartZ, holeXmlVO::setStartZ, Double.class ,"小板孔起点坐标Z", flag); + isEmptyBackAndNumber(holeXmlVO::getEndX, holeXmlVO::setEndX, Double.class ,"小板孔终点坐标X", flag); + isEmptyBackAndNumber(holeXmlVO::getEndY, holeXmlVO::setEndY, Double.class ,"小板孔终点坐标Y", flag); + isEmptyBackAndNumber(holeXmlVO::getEndZ, holeXmlVO::setEndZ, Double.class ,"小板孔终点坐标Z", flag); + notEmptyPositiveNumber(holeXmlVO::getToolStartRotateX, holeXmlVO::setToolStartRotateX, "小板孔起点旋转角度X", Double.class, flag); + notEmptyPositiveNumber(holeXmlVO::getToolStartRotateY, holeXmlVO::setToolStartRotateY, "小板孔起点旋转角度Y", Double.class, flag); + notEmptyPositiveNumber(holeXmlVO::getToolStartRotateZ, holeXmlVO::setToolStartRotateZ, "小板孔起点旋转角度Z", Double.class, flag); + notEmptyPositiveNumber(holeXmlVO::getToolEndRotateX, holeXmlVO::setToolEndRotateX, "小板孔终点旋转角度X", Double.class, flag); + notEmptyPositiveNumber(holeXmlVO::getToolEndRotateY, holeXmlVO::setToolEndRotateY, "小板孔终点旋转角度Y", Double.class, flag); + notEmptyPositiveNumber(holeXmlVO::getToolEndRotateZ, holeXmlVO::setToolEndRotateZ, "小板孔终点旋转角度Z", Double.class, flag); + } - private void checkGrooves(GrooveXmlVOS grooveXmlVOS, Boolean error) { - if (!StringUtils.isEmpty(grooveXmlVOS.getCount())) { - Boolean flag = checkNumber(grooveXmlVOS.getCount().trim(), Double.class); - if (!flag) { - grooveXmlVOS.setCount(grooveXmlVOS.getCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountFaceA())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountFaceA().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountFaceA(grooveXmlVOS.getCountFaceA() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountFaceB())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountFaceB().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountFaceB(grooveXmlVOS.getCountFaceB() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountSide())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountSide().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountSide(grooveXmlVOS.getCountSide() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountSideL())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountSideL().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountSideL(grooveXmlVOS.getCountSideL() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountSideR())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountSideR().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountSideR(grooveXmlVOS.getCountSideR() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountSideU())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountSideU().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountSideU(grooveXmlVOS.getCountSideU() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountSideD())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountSideD().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountSideD(grooveXmlVOS.getCountSideD() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountBevelled())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountBevelled().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountBevelled(grooveXmlVOS.getCountBevelled() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountRectangle())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountRectangle().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountRectangle(grooveXmlVOS.getCountRectangle() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCountThrough())) { - Boolean flag = checkNumber(grooveXmlVOS.getCountThrough().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCountThrough(grooveXmlVOS.getCountThrough() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCount2V())) { - Boolean flag = checkNumber(grooveXmlVOS.getCount2V().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCount2V(grooveXmlVOS.getCount2V() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVOS.getCount3D())) { - Boolean flag = checkNumber(grooveXmlVOS.getCount3D().trim(), Integer.class); - if (!flag) { - grooveXmlVOS.setCount3D(grooveXmlVOS.getCount3D() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } + private void checkGrooves(GrooveXmlVOS grooveXmlVOS, AtomicBoolean flag) { + notEmptyPositiveNumber(grooveXmlVOS::getCount, grooveXmlVOS::setCount, "造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountFaceA, grooveXmlVOS::setCountFaceA, "正面造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountFaceB, grooveXmlVOS::setCountFaceB, "反面造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountSide, grooveXmlVOS::setCountSide, "侧面造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountSideL, grooveXmlVOS::setCountSideL, "左侧造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountSideR, grooveXmlVOS::setCountSideR, "右侧造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountSideU, grooveXmlVOS::setCountSideU, "上侧造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountSideD, grooveXmlVOS::setCountSideD, "下侧造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountBevelled, grooveXmlVOS::setCountBevelled, "斜面造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountRectangle, grooveXmlVOS::setCountRectangle, "矩形凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCountThrough, grooveXmlVOS::setCountThrough, "挖穿造型/凹槽数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCount2V, grooveXmlVOS::setCount2V, "二维刀路数量", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVOS::getCount3D, grooveXmlVOS::setCount3D, "三维刀路(浮雕)数量", Double.class, flag); + if (grooveXmlVOS.getGrooveXmlVOList() != null && grooveXmlVOS.getGrooveXmlVOList().size() > 0) { for (GrooveXmlVO grooveXmlVO : grooveXmlVOS.getGrooveXmlVOList()) { - checkGroove(grooveXmlVO, error); + checkGroove(grooveXmlVO, flag); } } } - private void checkGroove(GrooveXmlVO grooveXmlVO, Boolean error) { - if (StringUtils.isEmpty(grooveXmlVO.getId())) { - grooveXmlVO.setId("---< 凹槽信息ID不可为空 >---"); - error = false; - } + private void checkGroove(GrooveXmlVO grooveXmlVO, AtomicBoolean flag) { + isEmptyAndBack(grooveXmlVO::getId, "凹槽信息ID", grooveXmlVO::setId, flag); + // 父孤岛id + isEmptyAndBack(grooveXmlVO::getType, "槽类型数据", grooveXmlVO::setType, flag); + isEmptyBackAndInvalid(grooveXmlVO::getFace, grooveXmlVO::setFace, DictTypeConstants.HOLE_FACE, "槽加工面数据", flag); - if (StringUtils.isEmpty(grooveXmlVO.getType())) { - grooveXmlVO.setType("---< 槽类型数据不可以为空 >---"); - error = false; - } - if (StringUtils.isEmpty(grooveXmlVO.getFace())) { - grooveXmlVO.setFace("---< 槽面不可为空 >---"); - error = false; - } else { - DictDataRespDTO dictDataDO = dictDataApi.parseDictData(DictTypeConstants.HOLE_FACE, grooveXmlVO.getFace().trim()).getData(); - if (dictDataDO == null) { - grooveXmlVO.setFace(grooveXmlVO.getFace() + "---< 槽加工面数据无效 >---"); - error = false; - } - } if (grooveXmlVO.getType().trim().equals("矩形槽")) { - if (StringUtils.isEmpty(grooveXmlVO.getWidth())) { - grooveXmlVO.setWidth("---< 当槽为矩形时,槽宽度不可为空 >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVO.getWidth())) { - Boolean flag = checkNumber(grooveXmlVO.getWidth().trim(), Double.class); - if (!flag) { - grooveXmlVO.setWidth(grooveXmlVO.getWidth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVO.getLength())) { - Boolean flag = checkNumber(grooveXmlVO.getLength().trim(), Double.class); - if (!flag) { - grooveXmlVO.setLength(grooveXmlVO.getLength() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(grooveXmlVO.getDepth())) { - grooveXmlVO.setDepth("---< 槽深度不可为空 >---"); - error = false; - } else { - Boolean flag = checkNumber(grooveXmlVO.getDepth().trim(), Double.class); - if (!flag) { - grooveXmlVO.setDepth(grooveXmlVO.getDepth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVO.getWidthExtend())) { - Boolean flag = checkNumber(grooveXmlVO.getWidthExtend().trim(), Double.class); - if (!flag) { - grooveXmlVO.setWidthExtend(grooveXmlVO.getWidthExtend() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setWidthExtend("0"); - } - if (!StringUtils.isEmpty(grooveXmlVO.getLengthExtend())) { - Boolean flag = checkNumber(grooveXmlVO.getLengthExtend().trim(), Double.class); - if (!flag) { - grooveXmlVO.setLengthExtend(grooveXmlVO.getLengthExtend() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setLengthExtend("0"); - } - if (!StringUtils.isEmpty(grooveXmlVO.getDepthExtend())) { - Boolean flag = checkNumber(grooveXmlVO.getDepthExtend().trim(), Double.class); - if (!flag) { - grooveXmlVO.setDepthExtend(grooveXmlVO.getDepthExtend() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setDepthExtend("0"); - } - if (!StringUtils.isEmpty(grooveXmlVO.getRound())) { - Boolean flag = checkNumber(grooveXmlVO.getRound().trim(), Double.class); - if (!flag) { - grooveXmlVO.setRound(grooveXmlVO.getRound() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setRound("0"); + isEmptyAndBack(grooveXmlVO::getLength, "当槽为矩形时,槽宽度", grooveXmlVO::setLength, flag); + } + notEmptyPositiveNumber(grooveXmlVO::getWidth, grooveXmlVO::setWidth, "槽宽度", Double.class, flag); + notEmptyPositiveNumber(grooveXmlVO::getLength, grooveXmlVO::setLength, "槽长度", Double.class, flag); + isEmptyBackAndPositiveNumber(grooveXmlVO::getDepth, "槽深度", grooveXmlVO::setDepth, Double.class, flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getWidthExtend, grooveXmlVO::setWidthExtend, "0", Double.class, "槽宽度延长", flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getLengthExtend, grooveXmlVO::setLengthExtend, "0", Double.class, "槽长度延长", flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getDepthExtend, grooveXmlVO::setDepthExtend, "0", Double.class, "槽深度延长", flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getRound, grooveXmlVO::setRound, "0", Double.class, "圆角半径", flag); + if (grooveXmlVO.getType().trim().equals("路径槽") || grooveXmlVO.getType().trim().equals("折返路径槽")) { - if (StringUtils.isEmpty(grooveXmlVO.getToolDiameter())) { - grooveXmlVO.setToolDiameter("---< 当槽为路径槽或是折返路径槽时,刀直径不可为空 >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVO.getToolDiameter())) { - Boolean flag = checkNumber(grooveXmlVO.getToolDiameter().trim(), Double.class); - if (!flag) { - grooveXmlVO.setToolDiameter(grooveXmlVO.getToolDiameter() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(grooveXmlVO.getRedundance())) { - Boolean flag = checkNumber(grooveXmlVO.getRedundance().trim(), Double.class); - if (!flag) { - grooveXmlVO.setRedundance(grooveXmlVO.getRedundance() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setRedundance("0"); - } - if (!StringUtils.isEmpty(grooveXmlVO.getTangentAngle())) { - Boolean flag = checkNumber(grooveXmlVO.getTangentAngle().trim(), Double.class); - if (!flag) { - grooveXmlVO.setTangentAngle(grooveXmlVO.getTangentAngle() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setTangentAngle("0"); - } - if (!StringUtils.isEmpty(grooveXmlVO.getIsletCount())) { - Boolean flag = checkNumber(grooveXmlVO.getIsletCount().trim(), Integer.class); - if (!flag) { - grooveXmlVO.setIsletCount(grooveXmlVO.getIsletCount() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - grooveXmlVO.setIsletCount("0"); + isEmptyAndBack(grooveXmlVO::getToolDiameter, "当槽为路径槽或是折返路径槽时,刀直径", grooveXmlVO::setToolDiameter, flag); + } + notEmptyPositiveNumber(grooveXmlVO::getToolDiameter, grooveXmlVO::setToolDiameter, "刀直径", Double.class, flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getRedundance, grooveXmlVO::setRedundance, "0", Double.class, "刀路冗余量(偏移重叠量)", flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getTangentAngle, grooveXmlVO::setTangentAngle, "0", Double.class, "角度(二维刀路V型刀提角/清角用)", flag); + isEmptyAddAndPositiveNumber(grooveXmlVO::getIsletCount, grooveXmlVO::setIsletCount, "0", Integer.class, "孤岛数量", flag); + if (grooveXmlVO.getPointXmlVOS() == null || grooveXmlVO.getPointXmlVOS().getPointXmlVOList() == null || grooveXmlVO.getPointXmlVOS().getPointXmlVOList().size() < 1) { grooveXmlVO.setResult("---< 槽点坐标列表不可为空 >---"); - error = false; + flag.set(false); } else { for (PointXmlVO pointXmlVO : grooveXmlVO.getPointXmlVOS().getPointXmlVOList()) { - checkPoint(pointXmlVO, error); + checkPoint(pointXmlVO, flag); } } if (grooveXmlVO.getOffsetLineXmlVOS() != null && grooveXmlVO.getOffsetLineXmlVOS().getOffsetLineXmlVOList() != null && grooveXmlVO.getOffsetLineXmlVOS().getOffsetLineXmlVOList().size() > 0) { for (OffsetLineXmlVO offsetLineXmlVO : grooveXmlVO.getOffsetLineXmlVOS().getOffsetLineXmlVOList()) { - checkOffsetLine(offsetLineXmlVO, error); + checkOffsetLine(offsetLineXmlVO, flag); } } } - private void checkOffsetLine(OffsetLineXmlVO offsetLineXmlVO, Boolean error) { - if (StringUtils.isEmpty(offsetLineXmlVO.getOffset())) { - offsetLineXmlVO.setOffset("---< 偏移刀路偏移量不可为空 >---"); - error = false; - } else { - Boolean flag = ToolUtil.convertToType(offsetLineXmlVO.getOffset().trim(), Double.class); - if (!flag) { - offsetLineXmlVO.setOffset(offsetLineXmlVO.getOffset() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(offsetLineXmlVO.getDepth())) { - offsetLineXmlVO.setDepth("---< 偏移刀路深度不可为空 >---"); - error = false; - } else { - Boolean flag = ToolUtil.convertToType(offsetLineXmlVO.getDepth().trim(), Double.class); - if (!flag) { - offsetLineXmlVO.setDepth(offsetLineXmlVO.getDepth() + "---< " + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - } - } - if (StringUtils.isEmpty(offsetLineXmlVO.getToolDiameter())) { - offsetLineXmlVO.setToolDiameter("---< 偏移刀路所用刀的直径不可为空 >---"); - error = false; - } else { - Boolean flag = ToolUtil.convertToType(offsetLineXmlVO.getToolDiameter().trim(), Double.class); - if (!flag) { - offsetLineXmlVO.setToolDiameter("---< " + offsetLineXmlVO.getToolDiameter() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (!StringUtils.isEmpty(offsetLineXmlVO.getTangentAngle())) { - Boolean flag = checkNumber(offsetLineXmlVO.getTangentAngle().trim(), Double.class); - if (!flag) { - offsetLineXmlVO.setTangentAngle("---< " + offsetLineXmlVO.getTangentAngle() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } else { - offsetLineXmlVO.setTangentAngle("0"); - } + private void checkOffsetLine(OffsetLineXmlVO offsetLineXmlVO, AtomicBoolean flag) { + isEmptyBackAndPositiveNumber(offsetLineXmlVO::getOffset, "偏移刀路偏移量", offsetLineXmlVO::setOffset, Double.class, flag); + isEmptyBackAndPositiveNumber(offsetLineXmlVO::getDepth, "偏移刀路深度", offsetLineXmlVO::setDepth, Double.class, flag); + isEmptyBackAndPositiveNumber(offsetLineXmlVO::getToolDiameter, "偏移刀路所用刀的直径", offsetLineXmlVO::setToolDiameter, Double.class, flag); + isEmptyAddAndPositiveNumber(offsetLineXmlVO::getTangentAngle, offsetLineXmlVO::setTangentAngle, "0", Double.class, "角度(二维刀路V型刀提角/清角用)", flag); + } - private void checkRawOutline(RawOutlineXmlVO rawOutlineXmlVO, Boolean error) { - Boolean index = true; - if (StringUtils.isEmpty(rawOutlineXmlVO.getCount())) { - rawOutlineXmlVO.setCount("---< 小板坯料(精加工)轮廓点阵列表数量不可为空 >---"); - error = false; - index = false; - } else { - Boolean flag = checkNumber(rawOutlineXmlVO.getCount().trim(), Integer.class); - if (!flag) { - rawOutlineXmlVO.setCount("---< " + rawOutlineXmlVO.getCount() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - index = false; - } - } - if (StringUtils.isEmpty(rawOutlineXmlVO.getReferenceOffsetX())) { - rawOutlineXmlVO.setReferenceOffsetX("---< 小板开坯料(精加工)轮廓参考点X坐标不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(rawOutlineXmlVO.getReferenceOffsetX().trim(), Double.class)) { - rawOutlineXmlVO.setReferenceOffsetX("---< " + rawOutlineXmlVO.getReferenceOffsetX() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(rawOutlineXmlVO.getReferenceOffsetY())) { - rawOutlineXmlVO.setReferenceOffsetY("---< 小板坯料(精加工)轮廓参考点Y坐标不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(rawOutlineXmlVO.getReferenceOffsetY().trim(), Double.class)) { - rawOutlineXmlVO.setReferenceOffsetY("---< " + rawOutlineXmlVO.getReferenceOffsetY() + TYPE_ERR + " >---"); - error = false; - } - } + private void checkRawOutline(RawOutlineXmlVO rawOutlineXmlVO, AtomicBoolean flag) { + boolean index = isEmptyBackAndPositiveNumberAndBack(rawOutlineXmlVO::getCount, "小板坯料(精加工)轮廓点阵列表数量 "+ rawOutlineXmlVO.getCount(), rawOutlineXmlVO::setCount, Integer.class, flag); + isEmptyBackAndNumber(rawOutlineXmlVO::getReferenceOffsetX, rawOutlineXmlVO::setReferenceOffsetX, Double.class, "小板坯料(精加工)轮廓参考点X坐标不可为空 " +rawOutlineXmlVO.getReferenceOffsetX() , flag); + isEmptyBackAndNumber(rawOutlineXmlVO::getReferenceOffsetY, rawOutlineXmlVO::setReferenceOffsetY, Double.class, "小板坯料(精加工)轮廓参考点Y坐标不可为空 " +rawOutlineXmlVO.getReferenceOffsetY() , flag); + if (rawOutlineXmlVO.getPointXmlVOList() != null && rawOutlineXmlVO.getPointXmlVOList().size() > 0) { if (index) { if (Integer.parseInt(rawOutlineXmlVO.getCount()) != rawOutlineXmlVO.getPointXmlVOList().size()) { rawOutlineXmlVO.setCount("---< 小板坯料(精加工)点阵数量与实际数量不一致 >---"); - error = false; + flag.set(false); } else { for (PointXmlVO pointXmlVO : rawOutlineXmlVO.getPointXmlVOList()) { - checkPoint(pointXmlVO, error); + checkPoint(pointXmlVO, flag); } } } } } - private void checkCuttingOutline(CuttingOutlineXmlVO cuttingOutlineXmlVO, Boolean error) { - Boolean index = true; - if (StringUtils.isEmpty(cuttingOutlineXmlVO.getCount())) { - cuttingOutlineXmlVO.setCount("---< 小板开料轮廓点阵列表数量不可为空 >---"); - error = false; - index = false; - } else { - Boolean flag = checkNumber(cuttingOutlineXmlVO.getCount().trim(), Integer.class); - if (!flag) { - cuttingOutlineXmlVO.setCount("---< " + cuttingOutlineXmlVO.getCount() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - index = false; - } - } - if (StringUtils.isEmpty(cuttingOutlineXmlVO.getReferenceOffsetX())) { - cuttingOutlineXmlVO.setReferenceOffsetX("---< 小板开料轮廓参考点X坐标不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(cuttingOutlineXmlVO.getReferenceOffsetX().trim(), Double.class)) { - cuttingOutlineXmlVO.setReferenceOffsetX("---< " + cuttingOutlineXmlVO.getReferenceOffsetX() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(cuttingOutlineXmlVO.getReferenceOffsetY())) { - cuttingOutlineXmlVO.setReferenceOffsetY("---< 小板开料轮廓参考点Y坐标不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(cuttingOutlineXmlVO.getReferenceOffsetY().trim(), Double.class)) { - cuttingOutlineXmlVO.setReferenceOffsetY("---< " + cuttingOutlineXmlVO.getReferenceOffsetY() + TYPE_ERR + " >---"); - error = false; - } - } + private void checkCuttingOutline(CuttingOutlineXmlVO cuttingOutlineXmlVO, AtomicBoolean flag) { + boolean index = isEmptyBackAndPositiveNumberAndBack(cuttingOutlineXmlVO::getCount, "小板开料轮廓点阵列表数量", cuttingOutlineXmlVO::setCount, Integer.class, flag); + isEmptyBackAndNumber(cuttingOutlineXmlVO::getReferenceOffsetX, cuttingOutlineXmlVO::setReferenceOffsetX, Double.class, "小板开料轮廓参考点X坐标" , flag); + isEmptyBackAndNumber(cuttingOutlineXmlVO::getReferenceOffsetY, cuttingOutlineXmlVO::setReferenceOffsetY, Double.class, "小板开料轮廓参考点Y坐标" , flag); + if (cuttingOutlineXmlVO.getPointXmlVOList() != null && cuttingOutlineXmlVO.getPointXmlVOList().size() > 0) { if (index) { if (Integer.parseInt(cuttingOutlineXmlVO.getCount()) != cuttingOutlineXmlVO.getPointXmlVOList().size()) { cuttingOutlineXmlVO.setCount("---< 小板轮廓点阵数量与实际数量不一致 >---"); - error = false; + flag.set(false); } else { for (PointXmlVO pointXmlVO : cuttingOutlineXmlVO.getPointXmlVOList()) { - checkPoint(pointXmlVO, error); + checkPoint(pointXmlVO, flag); } } } } } - public void checkOutline(OutlineXmlVO outlineXmlVO, Boolean error) { - Boolean index = true; - if (StringUtils.isEmpty(outlineXmlVO.getCount())) { - outlineXmlVO.setCount("---< 小板成品轮廓点阵列表数量不可为空 >---"); - error = false; - index = false; - } else { - Boolean flag = checkNumber(outlineXmlVO.getCount().trim(), Integer.class); - if (!flag) { - outlineXmlVO.setCount("---< " + outlineXmlVO.getCount() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - index = false; - } - } + public void checkOutline(OutlineXmlVO outlineXmlVO, AtomicBoolean flag) { + boolean index = isEmptyBackAndPositiveNumberAndBack(outlineXmlVO::getCount, "小板成品轮廓点阵列表数量", outlineXmlVO::setCount, Integer.class, flag); if (outlineXmlVO.getPointXmlVOList() != null && outlineXmlVO.getPointXmlVOList().size() > 0) { if (index) { if (Integer.parseInt(outlineXmlVO.getCount()) != outlineXmlVO.getPointXmlVOList().size()) { outlineXmlVO.setCount("---< 小板轮廓点阵数量与实际数量不一致 >---"); - error = false; + flag.set(false); } for (PointXmlVO pointXmlVO : outlineXmlVO.getPointXmlVOList()) { - checkPoint(pointXmlVO, error); + isEmptyBackAndNumber(pointXmlVO::getPointX, pointXmlVO::setPointX, Double.class, "小板起点坐标X", flag); + isEmptyBackAndNumber(pointXmlVO::getPointY, pointXmlVO::setPointY, Double.class, "小板起点坐标Y", flag); + isEmptyBackAndNumber(pointXmlVO::getCurvature, pointXmlVO::setCurvature, Double.class, "小板轮廓边圆弧凹凸度", flag); + isEmptyBackAndNumber(pointXmlVO::getRadius, pointXmlVO::setRadius, Double.class, "小板轮廓边圆弧半径", flag); + + + checkPoint(pointXmlVO, flag); if (!(StringUtils.isEmpty(pointXmlVO.getItemCode()) && StringUtils.isEmpty(pointXmlVO.getEdgingName()) && StringUtils.isEmpty(pointXmlVO.getEdgingColor()) && StringUtils.isEmpty(pointXmlVO.getEdgingMaterial()) && (StringUtils.isEmpty(pointXmlVO.getEdgingThickness()) || pointXmlVO.getEdgingThickness().trim().equals("0")))) { @@ -2042,60 +1072,19 @@ public class XMLUtil { if (StringUtils.isEmpty(pointXmlVO.getItemCode())) { if (StringUtils.isEmpty(pointXmlVO.getEdgingColor()) || StringUtils.isEmpty(pointXmlVO.getEdgingMaterial())) { pointXmlVO.setItemCode("---< 当封边条没有物料编码时,封边条颜色、材质不可为空 >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getEdgingThickness())) { - pointXmlVO.setEdgingThickness("0"); - } else { - if (!checkNumber(pointXmlVO.getEdgingThickness().trim(), Double.class)) { - pointXmlVO.setEdgingThickness("---< " + pointXmlVO.getEdgingThickness() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getEdgingExtend())) { - pointXmlVO.setEdgingExtend("0"); - } else { - if (!checkNumber(pointXmlVO.getEdgingExtend().trim(), Double.class)) { - pointXmlVO.setEdgingExtend("---< " + pointXmlVO.getEdgingExtend() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; + flag.set(false); } } + isEmptyAddAndPositiveNumber(pointXmlVO::getEdgingThickness, pointXmlVO::setEdgingThickness, "0", Double.class, "封边条宽度", flag); + isEmptyAddAndPositiveNumber(pointXmlVO::getEdgingExtend, pointXmlVO::setEdgingExtend, "0", Double.class, "封边条余量(两头各延长)", flag); + } - if (StringUtils.isEmpty(pointXmlVO.getPreMilling())) { - pointXmlVO.setPreMilling("0"); - } else { - if (!checkNumber(pointXmlVO.getPreMilling().trim(), Double.class)) { - pointXmlVO.setPreMilling("---< " + pointXmlVO.getPreMilling() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getScale())) { - pointXmlVO.setScale("0"); - } else { - if (!ToolUtil.convertToType(pointXmlVO.getScale().trim(), Double.class)) { - pointXmlVO.setScale("---< " + pointXmlVO.getScale() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getCount())) { - pointXmlVO.setCount("0"); - } else { - if (!checkNumber(pointXmlVO.getCount().trim(), Double.class)) { - pointXmlVO.setRadius("---< " + pointXmlVO.getRadius() + POSITIVE_ERR + "或是" + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getCountUnit())) { - pointXmlVO.setCountUnit("m"); - } else { - DictDataRespDTO dictData = dictDataApi.parseDictData(DictTypeConstants.UNIT_LENGTH, pointXmlVO.getCountUnit().trim()).getData(); - if (dictData == null) { - pointXmlVO.setCountUnit(pointXmlVO.getCountUnit() + "---< " + "封边条长度单位无效 >---"); - error = false; - } - } + isEmptyAddAndPositiveNumber(pointXmlVO::getPreMilling, pointXmlVO::setPreMilling, "0", Double.class, "预铣/精修量", flag); + isEmptyAddAndNumber(pointXmlVO::getScale, pointXmlVO::setScale, "0", Double.class, "延展/收缩量", flag); + isEmptyAddAndPositiveNumber(pointXmlVO::getCount, pointXmlVO::setCount, "0", Double.class, "单边封边尺寸", flag); + isEmptyAddAndPositiveNumber(pointXmlVO::getCountUnit, pointXmlVO::setCountUnit, "m", String.class, "封边条长度单位", flag); + } } @@ -2129,42 +1118,11 @@ public class XMLUtil { } // point 验证 - private void checkPoint(PointXmlVO pointXmlVO, Boolean error) { - if (StringUtils.isEmpty(pointXmlVO.getPointX())) { - pointXmlVO.setPointX("---< 小板轮廓起点坐标X不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(pointXmlVO.getPointX(), Double.class)) { - pointXmlVO.setPointX("---< " + pointXmlVO.getPointX() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getPointY())) { - pointXmlVO.setPointY("---< 小板轮廓起点坐标Y不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(pointXmlVO.getPointY(), Double.class)) { - pointXmlVO.setPointY("---< " + pointXmlVO.getPointY() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getCurvature())) { - pointXmlVO.setPointZ("---< 小板轮廓边圆弧凹凸度不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(pointXmlVO.getCurvature(), Double.class)) { - pointXmlVO.setCurvature("---< " + pointXmlVO.getCurvature() + TYPE_ERR + " >---"); - error = false; - } - } - if (StringUtils.isEmpty(pointXmlVO.getRadius())) { - pointXmlVO.setRadius("---< 小板轮廓边圆弧半径不可为空 >---"); - error = false; - } else { - if (!ToolUtil.convertToType(pointXmlVO.getRadius(), Double.class)) { - pointXmlVO.setRadius("---< " + pointXmlVO.getRadius() + TYPE_ERR + " >---"); - error = false; - } - } + private void checkPoint(PointXmlVO pointXmlVO, AtomicBoolean flag) { + isEmptyBackAndNumber(pointXmlVO::getPointX, pointXmlVO::setPointX, Double.class, pointXmlVO.getPointX(), flag); + isEmptyBackAndNumber(pointXmlVO::getPointY, pointXmlVO::setPointY, Double.class, pointXmlVO.getPointY(), flag); + isEmptyBackAndNumber(pointXmlVO::getCurvature, pointXmlVO::setCurvature, Double.class, pointXmlVO.getCurvature(), flag); + isEmptyBackAndNumber(pointXmlVO::getRadius, pointXmlVO::setRadius, Double.class, pointXmlVO.getRadius(), flag); + } } 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/XmlTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java index 740d76f65..c2d5e23ef 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java @@ -1303,7 +1303,7 @@ public class XmlTypeRealize { .round(Double.parseDouble(grooveXmlVO.getRound())) .redundance(Double.parseDouble(grooveXmlVO.getRedundance())) .tangentAngle(Double.parseDouble(grooveXmlVO.getTangentAngle())) - .originModeling(getOriginModelingData(grooveXmlVO)) +// .originModeling(getOriginModelingData(grooveXmlVO)) .offSetList(addOffSetDetail(grooveXmlVO.getOffsetLineXmlVOS())) .build(); } @@ -1316,7 +1316,7 @@ public class XmlTypeRealize { .addLen(Double.valueOf(grooveXmlVO.getLengthExtend())) .addDepth(Double.valueOf(grooveXmlVO.getDepthExtend())) .addWidth(Double.valueOf(grooveXmlVO.getWidthExtend())) - .pointList(addPointDetail(grooveXmlVO.getPointXmlVOS())) +// .pointList(addPointDetail(grooveXmlVO.getPointXmlVOS())) .build(); }