diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java index 41603dc42..f6d2b6994 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java @@ -113,4 +113,6 @@ public class ErrorCodeConstants { // ========== manage板材 1_003_005_000 ========== public static final ErrorCode PLATE_IMPORT_QUERY_INTERRUPT_ERROR = new ErrorCode(1_003_005_000, "配件导入查询异常中断,请稍后再试"); public static final ErrorCode PLATE_IMPORT_INTERRUPT_ERROR = new ErrorCode(1_003_005_001, "配件导入异常中断,请稍后再试"); + + public static final ErrorCode PLATE_ATTRIBUTE_NOT_EXIST = new ErrorCode(1_003_005_002,"商品编码:{},商品名称:{},材质:{},颜色:{},厚度{} 的板材不存在,请在板材管理里创建对应板材再进行导入"); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderSaveReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderSaveReqVO.java index 68d9931de..87b5c0f3f 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderSaveReqVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderSaveReqVO.java @@ -1,5 +1,6 @@ package com.cf.imes.module.executor.controller.admin.order.vo.order; +import com.cf.imes.framework.common.validation.Telephone; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -43,34 +44,43 @@ public class OrderSaveReqVO { private Integer status; @Schema(description = "自定义单号") + @Size(max = 32, message = "自定义单号长度不能超过32个字符") private String customOrderNo; @Schema(description = "客户", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "客户不能为空") + @Size(max = 255, message = "客户长度不能超过255个字符") private String customer; @Schema(description = "客户地址", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "客户地址不能为空") + @Size(max = 255, message = "客户地址长度不能超过255个字符") private String address; @Schema(description = "客户电话", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "客户电话不能为空") + @Telephone private String phoneNumber; @Schema(description = "经销商", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "经销商不能为空") + @Size(max = 255, message = "经销商长度不能超过255个字符") private String dealer; @Schema(description = "经销商电话", requiredMode = Schema.RequiredMode.REQUIRED) + @Telephone private String dealerPhoneNumber; @Schema(description = "业务员") + @Size(max = 64, message = "业务员长度不能超过64个字符") private String salesman; @Schema(description = "拆单员") + @Size(max = 64, message = "拆单员长度不能超过64个字符") private String splitter; @Schema(description = "备注", example = "你猜") + @Size(max = 255, message = "备注长度不能超过255个字符") private String remark; private Boolean deleted; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateGoodMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateGoodMapper.java index 7de78a1c0..7374e17d3 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateGoodMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateGoodMapper.java @@ -1,5 +1,6 @@ package com.cf.imes.module.executor.dal.mysql.plate; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; @@ -19,6 +20,7 @@ import java.util.List; * @author 晨丰科技 */ @Mapper +@DS("imes_prod") public interface PlateGoodMapper extends BaseMapperX { // goodsId匹配 @@ -61,9 +63,7 @@ public interface PlateGoodMapper extends BaseMapperX { .eq(PlateGoodDO::getThickness, thickness) .eq(PlateGoodDO::getDeleted, 0) .eq(PlateGoodDO::getOrganId, organId); - if (brand == null) { - queryWrapper.eq(PlateGoodDO::getBrand,""); - }else { + if (brand != null) { queryWrapper.eq(PlateGoodDO::getBrand, brand); } return selectList(queryWrapper); 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 d30fe44d1..d528f0a5a 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 @@ -848,7 +848,52 @@ public class OrderServiceImpl implements OrderService { return partsDOS; } - private Map> getPlateGoods(List goodsLists) { // order_goods list +// private Map> getPlateGoods(List goodsLists) { // order_goods list +// Map> map = new HashMap<>(); +// List plateGoodLists = new ArrayList<>(); +// +// if (goodsLists == null) { +// return Collections.emptyMap(); +// } +// for (GoodsDO goodsDO : goodsLists) { +// PlateGoodDO plateGoodDO = null; +// if (goodsDO.getGoodsId() != null && !goodsDO.getGoodsId().isEmpty()) { // 有goodsId,匹配goodsId +// plateGoodDO = getPlateGood(goodsDO.getGoodsId(), OrganContextHolder.getOrganId()); +// } +// +// // 直接匹配字段 +// List plateGoodDOS = plateGoodMapper.selectGood(goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness(), +// goodsDO.getBrand(),goodsDO.getGoodsName(), OrganContextHolder.getOrganId()); +// +// if (plateGoodDO != null) {//存在板材 +// goodsDO.setGoodsId(plateGoodDO.getGoodsId()); +// } else if (plateGoodDOS != null && !plateGoodDOS.isEmpty()) { // 存在板材 +// goodsDO.setGoodsId(plateGoodDOS.get(0).getGoodsId()); +// } else { // 不存在板材 +//// throw exception(ORDER_MATCH_NOT); +// long plateNo = idWorker.nextId(); +// long obtainingTime = idWorker.obtainingTime(); +// +// String goodsId = goodsDO.getGoodsId() == null ? (obtainingTime) + Long.toString(plateNo).substring(2) : goodsDO.getGoodsId(); +// goodsDO.setGoodsId(goodsId); +// +// +// Long plateGoods = (Long) identifierGenerator.nextId(null); +// +// plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class) +// .setId(plateGoods) +// .setGoodsId(goodsId); +// +// plateGoodLists.add(plateGoodDO); +// } +// +// } +// map.put(FieldConstants.GOODS, goodsLists); +// map.put(FieldConstants.PLATE_GOODS_LIST_KEY, plateGoodLists); +// return map; +// } + + private Map> getPlateGoods(List goodsLists) { // order_goods list 不存在抛出错误 Map> map = new HashMap<>(); List plateGoodLists = new ArrayList<>(); @@ -856,35 +901,21 @@ public class OrderServiceImpl implements OrderService { return Collections.emptyMap(); } for (GoodsDO goodsDO : goodsLists) { - PlateGoodDO plateGoodDO = null; + List plateGoodDOs; + if (goodsDO.getGoodsId() != null && !goodsDO.getGoodsId().isEmpty()) { // 有goodsId,匹配goodsId - plateGoodDO = getPlateGood(goodsDO.getGoodsId(), OrganContextHolder.getOrganId()); + plateGoodDOs = plateGoodMapper.selectGoodOne(goodsDO.getGoodsId() , getUserOrganId()); + }else { + plateGoodDOs = plateGoodMapper.selectGood(goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness(), + goodsDO.getBrand(),goodsDO.getGoodsName(), OrganContextHolder.getOrganId()); } // 直接匹配字段 - List plateGoodDOS = plateGoodMapper.selectGood(goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness(), - goodsDO.getBrand(),goodsDO.getGoodsName(), OrganContextHolder.getOrganId()); - - if (plateGoodDO != null) {//存在板材 - goodsDO.setGoodsId(plateGoodDO.getGoodsId()); - } else if (plateGoodDOS != null && !plateGoodDOS.isEmpty()) { // 存在板材 - goodsDO.setGoodsId(plateGoodDOS.get(0).getGoodsId()); + if (plateGoodDOs != null && !plateGoodDOs.isEmpty()) {//存在板材 + goodsDO.setGoodsId(plateGoodDOs.get(0).getGoodsId()); } else { // 不存在板材 -// throw exception(ORDER_MATCH_NOT); - long plateNo = idWorker.nextId(); - long obtainingTime = idWorker.obtainingTime(); + throw exception(PLATE_ATTRIBUTE_NOT_EXIST, goodsDO.getGoodsId() == null ? "" : goodsDO.getGoodsId(), goodsDO.getGoodsName(), goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness()); - String goodsId = goodsDO.getGoodsId() == null ? (obtainingTime) + Long.toString(plateNo).substring(2) : goodsDO.getGoodsId(); - goodsDO.setGoodsId(goodsId); - - - Long plateGoods = (Long) identifierGenerator.nextId(null); - - plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class) - .setId(plateGoods) - .setGoodsId(goodsId); - - plateGoodLists.add(plateGoodDO); } } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelCheckListUtil.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelCheckListUtil.java index 5d7ce678d..93d595ecd 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelCheckListUtil.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelCheckListUtil.java @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.nacos.common.utils.StringUtils; import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; +import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO; +import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper; import com.cf.imes.module.executor.enums.*; import com.cf.imes.module.executor.util.fileConversion.admin.ToolUtil; import com.cf.imes.module.system.api.dict.DictDataApi; @@ -14,18 +16,18 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.lang.reflect.Field; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; +import static com.cf.imes.framework.organ.core.context.OrganContextHolder.setOrganId; + /** * Excel文件数据校验器 */ @@ -36,6 +38,9 @@ public class ExcelCheckListUtil { @Resource private DictDataApi dictDataApi; + @Resource + private PlateGoodMapper plateGoodMapper; + private static final String ERR = "error"; private static final String DEALER_PHONE = "dealerPhoneNumber"; private static final String NUMBER_TYPE_ERR = "数量类型错误"; @@ -44,6 +49,7 @@ public class ExcelCheckListUtil { private static final String ACCORD_ENUM = "请按照提示词语选择填入"; private static final String POSITIVE_ERR = "数据需为正数"; private static final String NUMBER_LENGTH_ERR = "数据长度过长"; + final String PLATE_NOT_EXIST = "当前对应的板材不存在,请在板材管理里创建对应板材再进行导入"; // 校验文件订单数据, 当有错时返回Map,当数据完全正确时,返回OrderDO public ExcelCheckVO checkExcelList(Map orderMap) { @@ -141,6 +147,8 @@ public class ExcelCheckListUtil { List>> futures = new ArrayList<>(); AtomicBoolean flag = new AtomicBoolean(true); + Long organId = OrganContextHolder.getOrganId(); + // 遍历分片 for (int i = 0; i < batchCount; i++) { int start = i * batchSize; @@ -148,7 +156,12 @@ public class ExcelCheckListUtil { List subList = list.subList(start, end); - CompletableFuture> future = CompletableFuture.supplyAsync(() -> checkData(subList, flag)); +// CompletableFuture> future = CompletableFuture.supplyAsync(() -> checkData(subList, flag)); + CompletableFuture> future = CompletableFuture.supplyAsync(() -> { + + setOrganId(organId); + return checkData(subList, flag); + }); futures.add(future); } @@ -179,9 +192,11 @@ public class ExcelCheckListUtil { isEmpty(vo.getGoodsNumber(), errList, "数量", 10000000 ,flag); // 检查商品物料编码或是商品名称、规格、材质、颜色不可全为空 - if (StringUtils.isEmpty(vo.getGoodsName()) || StringUtils.isEmpty(vo.getSpec()) - || StringUtils.isEmpty(vo.getMaterial()) || StringUtils.isEmpty(vo.getColor()) || StringUtils.isEmpty(vo.getUnit())) { - errList.add("商品商品名称、规格、材质、颜色、单位不可为空"); + if (StringUtils.isEmpty(vo.getGoodsName()) + || StringUtils.isEmpty(vo.getMaterial()) + || StringUtils.isEmpty(vo.getColor()) + || StringUtils.isEmpty(vo.getUnit())) { + errList.add("商品商品名称、材质、颜色、单位不可为空"); flag.set(false); } @@ -242,6 +257,13 @@ public class ExcelCheckListUtil { errList.add(errValue + NOT_EMPTY); flag.set(false); } else { + isNotEmptyToBack(value, enumClass, errList, errValue, length , flag); + } + } + + // 非空,判断判断是否符合枚举类 + private void isNotEmptyToBack(String value, Class> enumClass, List errList, String errValue, int length , AtomicBoolean flag) { + if (!StringUtils.isEmpty(value)) { isEmptyAndSize(value, length, errList, errValue, flag); try { // 获取枚举类的所有值 @@ -327,12 +349,12 @@ public class ExcelCheckListUtil { public void checkPlate(OrderPlateImportExcelVO vo, List errList , AtomicBoolean flag) { // 数量类型判断 isEmptyAndPositiveNumber(vo.getGoodsNumber(), Integer.class, errList, "板材数量", flag); - // 板材纹理 - isNotEmptyAndBack(vo.getWave(), IsHavaeEnum.class, errList, "板材纹理", 4, flag); + // 板材纹理 默认有,不需要必填 + isNotEmptyToBack(StringUtils.isNotEmpty(vo.getWave()) ? vo.getWave() : "有", IsHavaeEnum.class, errList, "板材纹理", 4, flag); // 大板的长宽厚存在以及是否符合数个 - isNotEmptyAndBack(vo.getGoodsWidth(), errList, "板材长度", flag); +// isNotEmptyAndBack(vo.getGoodsWidth(), errList, "板材长度", flag); isEmptyAndPositiveNumberSize(vo.getGoodsWidth(), Double.class, 5, 3, errList, "板材长度", flag); - isNotEmptyAndBack(vo.getGoodsHeight(), errList, "板材宽度", flag); +// isNotEmptyAndBack(vo.getGoodsHeight(), errList, "板材宽度", flag); isEmptyAndPositiveNumberSize(vo.getGoodsHeight(), Double.class, 5, 3, errList, "板材宽度", flag); isNotEmptyAndBack(vo.getGoodsThickness(), errList, "板材厚度", flag); isEmptyAndPositiveNumberSize(vo.getGoodsThickness(), Double.class, 5, 3, errList, "板材厚度", flag); @@ -359,6 +381,7 @@ public class ExcelCheckListUtil { isEmptyAndPositiveNumberSize(vo.getSealUp(), Double.class, 5, 3, errList, "上封边", flag); isNotEmptyAndBack(vo.getSealDown(), errList, "下封边", flag); isEmptyAndPositiveNumberSize(vo.getSealDown(), Double.class, 5, 3, errList, "下封边", flag); + isPlateExists(vo, errList, flag); // 排版面、纹路、开门方向 isNotEmptyAndDict(vo.getTypographicFace(), DictTypeConstants.TYPOGRAPHY_TYPE, errList, "排版面", flag); isNotEmptyAndDict(vo.getTexture(), DictTypeConstants.GRAIN_TYPE, errList, "纹路", flag); @@ -366,6 +389,29 @@ public class ExcelCheckListUtil { } + // 板件是否存在判断,优先goodsId,没有判断(名称,材料,颜色,厚度,品牌(存在判断)) + private void isPlateExists(OrderPlateImportExcelVO plate, List errList, AtomicBoolean flag) { + PlateGoodDO plateGoodDO = null; + List plateGoodDOs; + if (StringUtils.isNotEmpty(plate.getGoodsId())) { // 判断 goodsId + plateGoodDOs = plateGoodMapper.selectGoodOne(plate.getGoodsId(), OrganContextHolder.getOrganId()); + } else { // 判断(名称,材料,颜色,后端,品牌(存在判断)) + plateGoodDOs = plateGoodMapper.selectGood(plate.getMaterial(), plate.getColor(), + BigDecimal.valueOf(Long.parseLong(plate.getThickness())), + plate.getBrand(),plate.getGoodsName(), OrganContextHolder.getOrganId()); + } + + if (!plateGoodDOs.isEmpty()) { + plateGoodDO = plateGoodDOs.get(0); + } + + if (plateGoodDO == null) { + errList.add(PLATE_NOT_EXIST); + flag.set(false); + } + + } + // 判断非空,字典值判断 public void isNotEmptyAndDict(String value, String dictType, List errList, String errValue, AtomicBoolean flag) { if (StringUtils.isEmpty(value)) { diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java index fad23fb95..0c2e1769c 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java @@ -87,11 +87,11 @@ public class ExcelTypeRealize { .collect(Collectors.groupingBy( p -> Arrays.asList(p.getGoodsName(), p.getMaterial(), - p.getWave(), // 纹理 +// p.getWave(), // 纹理 p.getColor(), - p.getSpec(), - p.getGoodsHeight(), - p.getGoodsWidth(), +// p.getSpec(), +// p.getGoodsHeight(), +// p.getGoodsWidth(), p.getGoodsThickness(), p.getBrand()), Collectors.toList() 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 629db0209..ec12aa8ad 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 @@ -2,7 +2,10 @@ 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.framework.organ.core.context.OrganContextHolder; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; +import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO; +import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper; import com.cf.imes.module.executor.enums.DataTypeEnum; import com.cf.imes.module.executor.enums.DictTypeConstants; import com.cf.imes.module.executor.enums.OrderTypeEnum; @@ -17,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.LocalDate; @@ -49,10 +53,14 @@ public class XMLUtil { final String BODY_CODE = "boxCode"; final String MODULE_CODE = "moduleCode"; final String GROUP_CODE = "groupCode"; + final String PLATE_NOT_EXIST = "板材不存在,请先录入板材,在进行订单导入"; @Resource private DictDataApi dictDataApi; + @Resource + private PlateGoodMapper plateGoodMapper; + public static Object read(MultipartFile file, Class clazz) throws IOException { @@ -801,6 +809,7 @@ public class XMLUtil { isEmptyAndBack(plate::getMaterial, "板材材质", plate::setMaterial, flag); // 纹理有效性判断 + plate.setGrained(StringUtils.isEmpty(plate.getGrained()) ? "有" : plate.getGrained()); 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); @@ -814,7 +823,7 @@ public class XMLUtil { 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); - + isPlateExists(plate, flag); if (plate.getBlockXmlVOS() != null) { checkBlocks(plate.getBlockXmlVOS(), flag); @@ -822,6 +831,29 @@ public class XMLUtil { } } + // 板件是否存在判断,优先goodsId,没有判断(名称,材料,颜色,厚度,品牌(存在判断)) + private void isPlateExists(PlateXmlVO plate, AtomicBoolean flag) { + PlateGoodDO plateGoodDO = null; + List plateGoodDOs; + if (StringUtils.isNotEmpty(plate.getItemCode())) { // 判断 goodsId + plateGoodDOs = plateGoodMapper.selectGoodOne(plate.getItemCode(), OrganContextHolder.getOrganId()); + } else { // 判断(名称,材料,颜色,后端,品牌(存在判断)) + plateGoodDOs = plateGoodMapper.selectGood(plate.getMaterial(), plate.getCoatingObverse(), + BigDecimal.valueOf(Long.parseLong(plate.getThickness())), + plate.getBrand(),plate.getName(), OrganContextHolder.getOrganId()); + } + + if (!plateGoodDOs.isEmpty()) { + plateGoodDO = plateGoodDOs.get(0); + } + + if (plateGoodDO != null) { + plate.setItemCode(plateGoodDO.getGoodsId()); + } else { + plate.setItemCode(PLATE_NOT_EXIST); + flag.set(false); + } + } // 小板数据格式验证 public void checkBlocks(BlockXmlVOS blockXmlVOS, AtomicBoolean flag) { notEmptyPositiveNumber(blockXmlVOS::getCount, blockXmlVOS::setCount, "小板数量", Integer.class, flag);