mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
订单新增来源组件订单列表
This commit is contained in:
+11
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.cf.imes.framework.mybatis.core.type.CompressStringTypeHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -15,6 +16,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单表 order_{N} DO
|
||||
@@ -54,6 +56,15 @@ public class OrderDO extends BaseDO {
|
||||
* 源订单号
|
||||
*/
|
||||
private String apiOrderId;
|
||||
|
||||
/**
|
||||
* 组件生产系统来源订单 ID 列表。
|
||||
*
|
||||
* <p>同一个 iMES 订单可以接收多个组件生产订单的拆单数据。</p>
|
||||
*/
|
||||
@TableField(value = "source_order_ids", typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> sourceOrderIds;
|
||||
|
||||
/**
|
||||
* 订单日期
|
||||
*/
|
||||
|
||||
+28
-3
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.id.core.util.SnowflakeIdWorker3rd;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.module.executor.enums.DataTypeEnum;
|
||||
@@ -30,6 +31,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_IMPORT_ORDER_PLATENUM_REACH_THRESHOLD_ERROR;
|
||||
import static com.cf.imes.module.plan.enums.ErrorCodeConstants.WEBCAD_ORDER_NOT_EXISTS_ERROR;
|
||||
|
||||
@@ -97,7 +102,7 @@ public class ProducingOrderImportTransactionalService {
|
||||
logStage(request, "convert", stageStartedAt);
|
||||
|
||||
stageStartedAt = System.nanoTime();
|
||||
updateOrderForImport(order);
|
||||
updateOrderForImport(order, request.getSourceOrderId());
|
||||
logStage(request, "update-order-state", stageStartedAt);
|
||||
|
||||
ProducingOrderImportFactory factory = new ProducingOrderImportFactory(
|
||||
@@ -162,13 +167,17 @@ public class ProducingOrderImportTransactionalService {
|
||||
/**
|
||||
* 沿用原拆单规则调整订单数据来源、生产状态和打包状态。
|
||||
*/
|
||||
private void updateOrderForImport(OrderDO order) {
|
||||
private void updateOrderForImport(OrderDO order, String sourceOrderId) {
|
||||
Integer status = order.getStatus();
|
||||
List<String> sourceOrderIds = mergeSourceOrderId(order.getSourceOrderIds(), sourceOrderId);
|
||||
order.setSourceOrderIds(sourceOrderIds);
|
||||
LambdaUpdateWrapper<OrderDO> update = new LambdaUpdateWrapper<OrderDO>()
|
||||
.eq(OrderDO::getId, order.getId())
|
||||
.eq(OrderDO::getOrganId, order.getOrganId())
|
||||
.eq(OrderDO::getDeleted, false)
|
||||
.set(OrderDO::getDataType, DataTypeEnum.API_IMPORT.getStatus());
|
||||
.set(OrderDO::getDataType, DataTypeEnum.API_IMPORT.getStatus())
|
||||
// setSql 的参数仍由 MyBatis 绑定,避免直接拼接 JSON 字符串。
|
||||
.setSql("source_order_ids = {0}", JsonUtils.toJsonString(sourceOrderIds));
|
||||
if (OrderStatusEnum.EMPTY.getStatus().equals(status)) {
|
||||
update.set(OrderDO::getStatus, OrderStatusEnum.NEW_ORDER.getStatus());
|
||||
}
|
||||
@@ -180,4 +189,20 @@ public class ProducingOrderImportTransactionalService {
|
||||
}
|
||||
orderMapper.update(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本次来源订单加入目标订单的来源集合。
|
||||
*
|
||||
* <p>使用 {@link LinkedHashSet} 保留首次导入顺序,同时避免同一来源订单重复导入时
|
||||
* 在列表中产生重复 ID。</p>
|
||||
*/
|
||||
private List<String> mergeSourceOrderId(List<String> currentSourceOrderIds,
|
||||
String sourceOrderId) {
|
||||
LinkedHashSet<String> merged = new LinkedHashSet<>();
|
||||
if (currentSourceOrderIds != null) {
|
||||
merged.addAll(currentSourceOrderIds);
|
||||
}
|
||||
merged.add(sourceOrderId);
|
||||
return new ArrayList<>(merged);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user