excel、xml异步导入调整:同步板材库匹配逻辑

This commit is contained in:
gaoqr
2025-04-17 16:39:56 +08:00
parent 71f939168a
commit b3bb0fff73
10 changed files with 271 additions and 254 deletions
@@ -8,7 +8,7 @@ import com.cf.imes.framework.common.exception.ErrorCode;
*/
public class ErrorCodeConstants {
// ========== 生产单导入 1_005_000 ==========
public static final ErrorCode ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS = new ErrorCode(1_005_000_000, "{}小板数据不存在:{}");
public static final ErrorCode ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS = new ErrorCode(1_005_000_000, "{}生产单商品板材数据不存在:{}");
public static final ErrorCode ORDER_IMPORT_ORGANID_NOT_EXISTS = new ErrorCode(1_005_000_001, "不存在组织id,导入终止");
public static final ErrorCode ORDER_IMPORT_FAIL = new ErrorCode(1_005_000_002, "导入失败");
public static final ErrorCode WEBCAD_ORDER_NOT_EXISTS_ERROR = new ErrorCode(1_005_000_004, "导入失败:生产单号【{}】不存在");
@@ -20,4 +20,5 @@ public class ErrorCodeConstants {
public static final ErrorCode WEBCAD_ORDER_IMPORT_ORG_SEALEDGE_ANALYZE_ERROR = new ErrorCode(1_005_000_010, "导入失败:组织封边对应配置解析异常,请检查配置");
public static final ErrorCode WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_CHECK_ERROR = new ErrorCode(1_005_000_011, "导入失败:生产单【{}】下板件数量已达到20000片,无法继续导入");
public static final ErrorCode WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_REACH_THRESHOLD_ERROR = new ErrorCode(1_005_000_012, "部分导入成功,生产单【{}】下板件数量已达到20000片,本次拆单超出部分不计入生产单");
public static final ErrorCode ORDER_IMPORT_PLATE_GOODS_NOMATCH_ERROR = new ErrorCode(1_005_000_013, "导入失败,板材库中无板材匹配,商品编码:{},商品名称:{},材质:{},颜色:{},厚度:{},品牌:{}");
}
@@ -37,7 +37,7 @@ public interface OrderImportTempDataMapper extends BaseMapperX<OrderImportTempDa
List<OrderImportTempDataGoodsIdGroupDO> selectGoodsIdGroup(@Param("reqVO") OrderImportTempDataReqVO reqVO);
/**
* 基于商品名称、材料、纹理、颜色、规格、商品高、商品宽、商品厚、品牌分组的商品总数查询
* 基于商品名称、材料、颜色、商品厚、品牌分组的商品总数查询
*
* @param reqVO
* @return
@@ -14,13 +14,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.imes.framework.common.enums.OrderPlateTypeEnum;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.mybatis.core.injector.BaseBatchMapper;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.enums.DictTypeConstants;
import com.cf.imes.module.executor.enums.OrderImportConstants;
import com.cf.imes.module.executor.enums.OrderImportStatusEnum;
@@ -38,7 +36,6 @@ import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTempDataGoo
import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTempDataGoodsIdGroupDO;
import com.cf.imes.module.plan.dal.dataobject.orderItem.OrderItemDO;
import com.cf.imes.module.plan.dal.dataobject.orderParts.OrderPartsDO;
import com.cf.imes.module.plan.dal.dataobject.orderParts.PartsDO;
import com.cf.imes.module.plan.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.plan.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.plan.dal.dataobject.plate.PlateGoodDO;
@@ -70,6 +67,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.ORDER_IMPORT_PLATE_GOODS_NOMATCH_ERROR;
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS;
import static com.cf.imes.module.plan.service.order.OrderInputProcessor.ORDER_PARTS_REMARK_MODEL;
import static com.cf.imes.module.plan.service.order.OrderInputProcessor.ORDER_PLATE_MODEL;
@@ -326,11 +324,7 @@ public class DefaultExcelOrderImportFactory {
.eq(OrderImportTempDataDO::getType, PLATE_TYPE)
.eqIfPresent(OrderImportTempDataDO::getGoodsName, orderImportTempDataGoodsGroupDO.getGoodsName())
.eqIfPresent(OrderImportTempDataDO::getMaterial, orderImportTempDataGoodsGroupDO.getMaterial())
.eqIfPresent(OrderImportTempDataDO::getWave, orderImportTempDataGoodsGroupDO.getWave())
.eqIfPresent(OrderImportTempDataDO::getColor, orderImportTempDataGoodsGroupDO.getColor())
.eqIfPresent(OrderImportTempDataDO::getSpec, orderImportTempDataGoodsGroupDO.getSpec())
.eqIfPresent(OrderImportTempDataDO::getWidth, orderImportTempDataGoodsGroupDO.getWidth())
.eqIfPresent(OrderImportTempDataDO::getHeight, orderImportTempDataGoodsGroupDO.getHeight())
.eqIfPresent(OrderImportTempDataDO::getThickness, orderImportTempDataGoodsGroupDO.getThickness())
.eqIfPresent(OrderImportTempDataDO::getBrand, orderImportTempDataGoodsGroupDO.getBrand())
.set(OrderImportTempDataDO::getInnerGoodsId, innerGoodsId));
@@ -677,146 +671,146 @@ public class DefaultExcelOrderImportFactory {
Page<OrderImportTempDataDO> page = new Page<>(1, BATCH_THRESHOLD_NUMBER);
orderImportTempDataMapper.selectList(page, new LambdaQueryWrapperX<OrderImportTempDataDO>()
.eq(OrderImportTempDataDO::getTaskId, taskId)
.eq(OrderImportTempDataDO::getType, PLATE_TYPE)
.eq(OrderImportTempDataDO::getRoomName, roomName)
.eq(OrderImportTempDataDO::getBodyName, bodyName)
.eqIfPresent(OrderImportTempDataDO::getGroupTypeName, groupTypeName)
.eqIfPresent(OrderImportTempDataDO::getGroupName, groupName)
.eq(OrderImportTempDataDO::getOrganId, organId), new ResultHandler<>() {
int count = 0;
.eq(OrderImportTempDataDO::getTaskId, taskId)
.eq(OrderImportTempDataDO::getType, PLATE_TYPE)
.eq(OrderImportTempDataDO::getRoomName, roomName)
.eq(OrderImportTempDataDO::getBodyName, bodyName)
.eqIfPresent(OrderImportTempDataDO::getGroupTypeName, groupTypeName)
.eqIfPresent(OrderImportTempDataDO::getGroupName, groupName)
.eq(OrderImportTempDataDO::getOrganId, organId), new ResultHandler<>() {
int count = 0;
@Override
public void handleResult(ResultContext<? extends OrderImportTempDataDO> resultContext) {
OrderImportTempDataDO tempDataDO = resultContext.getResultObject();
@Override
public void handleResult(ResultContext<? extends OrderImportTempDataDO> resultContext) {
OrderImportTempDataDO tempDataDO = resultContext.getResultObject();
int num = tempDataDO.getNum().intValue();
String detail = JsonUtils.unzipString(tempDataDO.getDetail());
OrderPlateImportExcelVO combination = JSON.parseObject(detail, OrderPlateImportExcelVO.class);
// 根据数量生成num个小板数据
for (int i = 0; i < num; i++) {
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
long goodsId = Long.parseLong(tempDataDO.getInnerGoodsId());
// 成品宽
String width = combination.getWidth();
// 成品长
String height = combination.getHeight();
// 计算面积
BigDecimal area = BigDecimal.valueOf(Double.parseDouble(width))
.multiply(BigDecimal.valueOf(Double.parseDouble(height)))
.movePointLeft(6)
.setScale(2, RoundingMode.HALF_UP);
Long plateId = (Long) snowFlakeGenerator.nextId(null);
// 排版面 纹路 开门方向转换
DictDataRespDTO typographyDTO = dictDataApi.parseDictData(DictTypeConstants.TYPOGRAPHY_TYPE, combination.getTypographicFace()).getData();// 排版面
DictDataRespDTO grainDTO = dictDataApi.parseDictData(DictTypeConstants.GRAIN_TYPE, combination.getTexture()).getData();// 纹路
DictDataRespDTO doorDTO = dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, combination.getOpenDoorType()).getData();
int num = tempDataDO.getNum().intValue();
String detail = JsonUtils.unzipString(tempDataDO.getDetail());
OrderPlateImportExcelVO combination = JSON.parseObject(detail, OrderPlateImportExcelVO.class);
// 根据数量生成num个小板数据
for (int i = 0; i < num; i++) {
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
long goodsId = Long.parseLong(tempDataDO.getInnerGoodsId());
// 成品宽
String width = combination.getWidth();
// 成品长
String height = combination.getHeight();
// 计算面积
BigDecimal area = BigDecimal.valueOf(Double.parseDouble(width))
.multiply(BigDecimal.valueOf(Double.parseDouble(height)))
.movePointLeft(6)
.setScale(2, RoundingMode.HALF_UP);
Long plateId = (Long) snowFlakeGenerator.nextId(null);
// 排版面 纹路 开门方向转换
DictDataRespDTO typographyDTO = dictDataApi.parseDictData(DictTypeConstants.TYPOGRAPHY_TYPE, combination.getTypographicFace()).getData();// 排版面
DictDataRespDTO grainDTO = dictDataApi.parseDictData(DictTypeConstants.GRAIN_TYPE, combination.getTexture()).getData();// 纹路
DictDataRespDTO doorDTO = dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, combination.getOpenDoorType()).getData();
PlateDO plateDO = PlateDO.builder()
.id(plateId)
.orderId(orderId)
.name(combination.getName())
.plateNo(combination.getPlateNo())
.type(OrderPlateTypeEnum.LAYERBOARD.getType())
.goodsId(goodsId)
.width(BigDecimal.valueOf(Double.parseDouble(width)))
.plateNo(((obtainingTime) + Long.toString(plateNo).substring(2)))
.height(BigDecimal.valueOf(Double.parseDouble(height)))
.thickness(BigDecimal.valueOf(Double.parseDouble(combination.getThickness())))
.splitWidth(BigDecimal.valueOf(NumberUtil.parseDouble(combination.getSplitWidth())))
.splitHeight(BigDecimal.valueOf(NumberUtil.parseDouble(combination.getSplitHeight())))
.splitThickness(BigDecimal.valueOf(Double.parseDouble(tempDataDO.getThickness())))
.sealLeft(BigDecimal.valueOf(Double.parseDouble(combination.getSealLeft())))
.sealRight(BigDecimal.valueOf(Double.parseDouble(combination.getSealRight())))
.sealUp(BigDecimal.valueOf(Double.parseDouble(combination.getSealUp())))
.sealDown(BigDecimal.valueOf(Double.parseDouble(combination.getSealDown())))
.holeFace(Integer.valueOf(typographyDTO.getValue()))
.texture(Integer.valueOf(grainDTO.getValue()))
.area(area)
.openDoorType(Integer.valueOf(doorDTO.getValue()))
.isSpecialShaped(false)
.isSculpt(false)
.remark(remarkExtract(combination.remarkJSON()))
.roomName(roomName)
.bodyName(bodyName)
.customPlateNoBuilder(new StringBuilder())
.organId(organId)
.holeArrange(0)
.holeFace(0)
.unregularPointCount(0)
.frontHoleCount(0)
.backHoleCount(0)
.sideHoleCount(0)
.frontModelCount(0)
.backModelCount(0)
.isDoor(false)
.offsetX(BIG_ZERO)
.offsetY(BIG_ZERO)
.isArcAcross(false)
.moduleTypeId(0L)
.isRowHole(false)
.isOptimized(false)
.isCutted(0)
.isCancel(false)
.filterType(EMPTY_STRING)
.deleted(false)
.build();
plateDO.setCreator(operatorName);
plateDO.setUpdater(operatorName);
LocalDateTime now = LocalDateTime.now();
plateDO.setCreateTime(now);
plateDO.setUpdateTime(now);
PlateDO plateDO = PlateDO.builder()
.id(plateId)
.orderId(orderId)
.name(combination.getName())
.plateNo(combination.getPlateNo())
.type(OrderPlateTypeEnum.LAYERBOARD.getType())
.goodsId(goodsId)
.width(BigDecimal.valueOf(Double.parseDouble(width)))
.plateNo(((obtainingTime) + Long.toString(plateNo).substring(2)))
.height(BigDecimal.valueOf(Double.parseDouble(height)))
.thickness(BigDecimal.valueOf(Double.parseDouble(combination.getThickness())))
.splitWidth(BigDecimal.valueOf(NumberUtil.parseDouble(combination.getSplitWidth())))
.splitHeight(BigDecimal.valueOf(NumberUtil.parseDouble(combination.getSplitHeight())))
.splitThickness(BigDecimal.valueOf(Double.parseDouble(tempDataDO.getThickness())))
.sealLeft(BigDecimal.valueOf(Double.parseDouble(combination.getSealLeft())))
.sealRight(BigDecimal.valueOf(Double.parseDouble(combination.getSealRight())))
.sealUp(BigDecimal.valueOf(Double.parseDouble(combination.getSealUp())))
.sealDown(BigDecimal.valueOf(Double.parseDouble(combination.getSealDown())))
.holeFace(Integer.valueOf(typographyDTO.getValue()))
.texture(Integer.valueOf(grainDTO.getValue()))
.area(area)
.openDoorType(Integer.valueOf(doorDTO.getValue()))
.isSpecialShaped(false)
.isSculpt(false)
.remark(remarkExtract(combination.remarkJSON()))
.roomName(roomName)
.bodyName(bodyName)
.customPlateNoBuilder(new StringBuilder())
.organId(organId)
.holeArrange(0)
.holeFace(0)
.unregularPointCount(0)
.frontHoleCount(0)
.backHoleCount(0)
.sideHoleCount(0)
.frontModelCount(0)
.backModelCount(0)
.isDoor(false)
.offsetX(BIG_ZERO)
.offsetY(BIG_ZERO)
.isArcAcross(false)
.moduleTypeId(0L)
.isRowHole(false)
.isOptimized(false)
.isCutted(0)
.isCancel(false)
.filterType(EMPTY_STRING)
.deleted(false)
.build();
plateDO.setCreator(operatorName);
plateDO.setUpdater(operatorName);
LocalDateTime now = LocalDateTime.now();
plateDO.setCreateTime(now);
plateDO.setUpdateTime(now);
// 生成自定义板编号
generateCustomPlateNo(plateDO);
// 生成自定义板编号
generateCustomPlateNo(plateDO);
// 批量插入order_plate
plateDOS.add(plateDO);
orderInfoBatchInsertWithinThreshold(plateMapper, plateDOS, false);
// 批量插入order_plate
plateDOS.add(plateDO);
orderInfoBatchInsertWithinThreshold(plateMapper, plateDOS, false);
OrderItemDO orderItemDO = OrderItemDO.builder()
.orderId(orderId)
.type(OrderItemTypeEnum.PLATE_ITEM.getStatus())
.roomId(orderBodyDO.getRoomId())
.bodyId(orderBodyDO.getId())
.plateId(plateId)
.num(1.0)
.groupId(StringUtils.isNotEmpty(groupTypeName) ? groupId : 0L)
.organId(organId)
.packageId(0L)
.partsId(0L)
.build();
// 批量插入order_item
orderItemDOS.add(orderItemDO);
orderInfoBatchInsertWithinThreshold(orderItemMapper, orderItemDOS, false);
OrderItemDO orderItemDO = OrderItemDO.builder()
.orderId(orderId)
.type(OrderItemTypeEnum.PLATE_ITEM.getStatus())
.roomId(orderBodyDO.getRoomId())
.bodyId(orderBodyDO.getId())
.plateId(plateId)
.num(1.0)
.groupId(StringUtils.isNotEmpty(groupTypeName) ? groupId : 0L)
.organId(organId)
.packageId(0L)
.partsId(0L)
.build();
// 批量插入order_item
orderItemDOS.add(orderItemDO);
orderInfoBatchInsertWithinThreshold(orderItemMapper, orderItemDOS, false);
// 批量插入CAD板件信息
OrderModelDO orderModelDO = OrderModelDO.builder()
.orderId(orderId)
.batchId(batchId)
.plateId(plateId)
.typographicFace(Integer.valueOf(typographyDTO.getValue()))
.texture(plateDO.getTexture())
.openDoorType(plateDO.getOpenDoorType())
.build();
// 批量插入CAD板件信息
OrderModelDO orderModelDO = OrderModelDO.builder()
.orderId(orderId)
.batchId(batchId)
.plateId(plateId)
.typographicFace(Integer.valueOf(typographyDTO.getValue()))
.texture(plateDO.getTexture())
.openDoorType(plateDO.getOpenDoorType())
.build();
// 查询大板id用于小板轮廓goodsId
GoodsDO goodsDO = goodsMapper.selectById(goodsId);
if (ObjectUtil.isNull(goodsDO)) {
throw ServiceExceptionUtil.exception(ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS, orderId, goodsId);
}
orderModelDO.setGoodsId(goodsDO.getGoodsId());
orderModelDO.setPlateGoodsId(goodsId);
orderModelDO.setOrganId(organId);
orderModelDO.setCreator(operatorName);
orderModelDO.setUpdater(operatorName);
orderModelDOS.add(orderModelDO);
// 批量插入造型数据
orderModelsBatchInsertWithinThreshold(false);
}
// 查询大板id用于小板轮廓goodsId
GoodsDO goodsDO = goodsMapper.selectById(goodsId);
if (ObjectUtil.isNull(goodsDO)) {
throw ServiceExceptionUtil.exception(ORDER_IMPORT_PLATE_GOODS_NOT_EXISTS, orderId, goodsId);
}
orderModelDO.setGoodsId(goodsDO.getGoodsId());
orderModelDO.setPlateGoodsId(goodsId);
orderModelDO.setOrganId(organId);
orderModelDO.setCreator(operatorName);
orderModelDO.setUpdater(operatorName);
orderModelDOS.add(orderModelDO);
// 批量插入造型数据
orderModelsBatchInsertWithinThreshold(false);
}
}
});
@@ -1285,20 +1279,24 @@ public class DefaultExcelOrderImportFactory {
private void analyzePlateGoods(GoodsDO goodsDO) {
PlateGoodDO plateGoodDO = null;
List<PlateGoodDO> existPlateGoodDOS = new ArrayList<>();
if (StringUtils.isNotEmpty(goodsDO.getGoodsId())) {
String goodsId = goodsDO.getGoodsId();
String goodsName = goodsDO.getGoodsName();
String material = goodsDO.getMaterial();
String color = goodsDO.getColor();
BigDecimal thickness = goodsDO.getThickness();
String brand = goodsDO.getBrand();
if (StringUtils.isNotEmpty(goodsId)) {
// goodsId查询是否存在大板
plateGoodDO = getPlateGood(goodsDO.getGoodsId());
plateGoodDO = getPlateGood(goodsId);
} else {
// 没有goodsId,大板属性匹配大板
existPlateGoodDOS = plateGoodMapper.selectList(new LambdaQueryWrapperX<PlateGoodDO>()
.eq(PlateGoodDO::getGoodsName, goodsDO.getGoodsName())
.eq(PlateGoodDO::getMaterial, goodsDO.getMaterial())
.eq(PlateGoodDO::getColor, goodsDO.getColor())
.eqIfPresent(PlateGoodDO::getTexture, goodsDO.getTexture())
.eqIfPresent(PlateGoodDO::getWidth, goodsDO.getWidth())
.eqIfPresent(PlateGoodDO::getHeight, goodsDO.getHeight())
.eq(PlateGoodDO::getThickness, goodsDO.getThickness())
.eqIfPresent(PlateGoodDO::getSpec, goodsDO.getSpec())
.eq(PlateGoodDO::getGoodsName, goodsName)
.eq(PlateGoodDO::getMaterial, material)
.eq(PlateGoodDO::getColor, color)
.eq(PlateGoodDO::getThickness, thickness)
.eqIfPresent(PlateGoodDO::getBrand, brand)
.eq(PlateGoodDO::getDeleted, 0)
.eq(PlateGoodDO::getOrganId, organId));
}
@@ -1310,21 +1308,7 @@ public class DefaultExcelOrderImportFactory {
// 存在大板
goodsDO.setGoodsId(plateGoodDO.getGoodsId());
} else {
// 不存在大板,新增
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
// 大板id设置到orderGoodsDO
String goodsId = StringUtils.isEmpty(goodsDO.getGoodsId()) ? (obtainingTime) + Long.toString(plateNo).substring(2) : goodsDO.getGoodsId();
goodsDO.setGoodsId(goodsId);
plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
.setId((Long) snowFlakeGenerator.nextId(null))
.setGoodsId(goodsId);
// 批量插入plategood
plateGoodDOS.add(plateGoodDO);
orderInfoBatchInsertWithinThreshold(plateGoodMapper, plateGoodDOS, false);
throw ServiceExceptionUtil.exception(ORDER_IMPORT_PLATE_GOODS_NOMATCH_ERROR, goodsId, goodsName, material, color, thickness, brand);
}
}
@@ -14,13 +14,10 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.dict.core.util.DictFrameworkUtils;
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.mybatis.core.injector.BaseBatchMapper;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.enums.DictTypeConstants;
import com.cf.imes.module.executor.enums.OrderImportStatusEnum;
import com.cf.imes.module.executor.enums.OrderImportTmpDataTypeEnum;
@@ -61,7 +58,6 @@ import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTempDataPar
import com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTempDataPartRoomBodyGroupGroupDO;
import com.cf.imes.module.plan.dal.dataobject.orderItem.OrderItemDO;
import com.cf.imes.module.plan.dal.dataobject.orderParts.OrderPartsDO;
import com.cf.imes.module.plan.dal.dataobject.orderParts.PartsDO;
import com.cf.imes.module.plan.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.plan.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.plan.dal.dataobject.plate.PlateGoodDO;
@@ -283,7 +279,7 @@ public class DefaultXmlOrderImportFactory {
log.info("====================【生产单默认xml导入处理回显结束】====================");
// 删除临时数据
deleteTempData();
// deleteTempData();
// 完成所有流程后更新任务为导入成功
updateTaskSuccess();
} catch (Exception e) {
@@ -408,8 +404,6 @@ public class DefaultXmlOrderImportFactory {
goodsDO.setCreateTime(now);
goodsDO.setUpdateTime(now);
// 解析大板
analyzePlateGoods(goodsDO);
goodsDOS.add(goodsDO);
rawGoodsDOS.add(rawGoodsDO);
// 批量插入rawgoods、goods
@@ -1865,58 +1859,6 @@ public class DefaultXmlOrderImportFactory {
return sb.toString();
}
/**
* 解析大板
* 大板库没有新增,有就赋值goodsId
*
* @param goodsDO
*/
private void analyzePlateGoods(GoodsDO goodsDO) {
PlateGoodDO plateGoodDO = null;
List<PlateGoodDO> existPlateGoodDOS = new ArrayList<>();
if (StringUtils.isNotEmpty(goodsDO.getGoodsId())) {
// goodsId查询是否存在大板
plateGoodDO = getPlateGood(goodsDO.getGoodsId());
} else {
// 没有goodsId,大板属性匹配大板
existPlateGoodDOS = plateGoodMapper.selectList(new LambdaQueryWrapperX<PlateGoodDO>()
.eq(PlateGoodDO::getGoodsName, goodsDO.getGoodsName())
.eq(PlateGoodDO::getMaterial, goodsDO.getMaterial())
.eq(PlateGoodDO::getColor, goodsDO.getColor())
.eqIfPresent(PlateGoodDO::getTexture, goodsDO.getTexture())
.eqIfPresent(PlateGoodDO::getWidth, goodsDO.getWidth())
.eqIfPresent(PlateGoodDO::getHeight, goodsDO.getHeight())
.eq(PlateGoodDO::getThickness, goodsDO.getThickness())
.eqIfPresent(PlateGoodDO::getSpec, goodsDO.getSpec())
.eq(PlateGoodDO::getDeleted, 0)
.eq(PlateGoodDO::getOrganId, organId));
}
if (CollUtil.isNotEmpty(existPlateGoodDOS)) {
// 存在大板
goodsDO.setGoodsId(existPlateGoodDOS.get(0).getGoodsId());
} else if (plateGoodDO != null) {
// 存在大板
goodsDO.setGoodsId(plateGoodDO.getGoodsId());
} else {
// 不存在大板,新增
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
// 大板id设置到orderGoodsDO
String goodsId = StringUtils.isEmpty(goodsDO.getGoodsId()) ? (obtainingTime) + Long.toString(plateNo).substring(2) : goodsDO.getGoodsId();
goodsDO.setGoodsId(goodsId);
plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
.setId((Long) snowFlakeGenerator.nextId(null))
.setGoodsId(goodsId);
// 批量插入plategood
plateGoodDOS.add(plateGoodDO);
orderInfoBatchInsertWithinThreshold(plateGoodMapper, plateGoodDOS, false);
}
}
/**
* 查询大板信息
*
@@ -25,16 +25,12 @@
select count(1) from (
select goods_name,
material,
wave,
color,
spec,
height,
width,
thickness,
brand
from order_import_temp_data
where task_id = #{reqVO.taskId} and type = #{reqVO.type} and outer_goods_id = #{reqVO.goodsId}
group by goods_name,material, wave, color, spec, height, width, thickness, brand) temp
group by goods_name,material, color, thickness, brand) temp
</select>
<select id="selectCountPartGoodsGroup" resultType="java.lang.Integer">
@@ -61,11 +57,7 @@
<select id="selectPlateGoodsGroup" resultType="com.cf.imes.module.plan.dal.dataobject.orderImport.OrderImportTempDataGoodsGroupDO">
select goods_name,
material,
wave,
color,
spec,
height,
width,
thickness,
brand
<if test="reqVO.doPaging">
@@ -73,7 +65,7 @@
</if>
from order_import_temp_data
where task_id = #{reqVO.taskId} and type = #{reqVO.type} and outer_goods_id = #{reqVO.goodsId}
group by goods_name, material, wave, color, spec, height, width, thickness, brand
group by goods_name, material, color, thickness, brand
<if test="reqVO.doPaging">
order by sortn
limit #{reqVO.offset}, #{reqVO.size}