mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
getOrderSource增加组件排单id、板件id列表、订单id列表
This commit is contained in:
+9
@@ -32,6 +32,15 @@ import java.util.List;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class OrderSource {
|
||||
|
||||
@Schema(description = "组件生产系统来源订单 ID 列表")
|
||||
private List<String> sourceOrderIds;
|
||||
|
||||
@Schema(description = "组件生产系统来源板件 ID 列表")
|
||||
private List<String> sourceBlockItemList;
|
||||
|
||||
@Schema(description = "组件生产系统生产排单 ID")
|
||||
private Long producingPlanOrderId;
|
||||
|
||||
@Schema(description = "优化后的大板数据")
|
||||
private List<OptimizeBoardModelDO> optimizeBoardModelDOS;
|
||||
|
||||
|
||||
+7
-16
@@ -22,7 +22,6 @@ import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 订单开料排单 Mapper
|
||||
@@ -142,22 +141,14 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
|
||||
List<OrderGoodsResp> selectPlanGoodsList(@Param("planId") Long planId, @Param("organId") Long organId);
|
||||
|
||||
/**
|
||||
* 统计涉及移除小板的排单下还存在的排单数量
|
||||
* 查询指定排单当前剩余的全部订单 ID。
|
||||
*
|
||||
* @param planIds
|
||||
* @param organId
|
||||
* @return
|
||||
* @param planIds 排单 ID 列表
|
||||
* @param organId 组织 ID
|
||||
* @return 排单与剩余订单 ID 的对应关系列表
|
||||
*/
|
||||
List<OrderPlanPlateStatisticsRespVO> countDeletePlanPlate(@Param("planIds") List<Long> planIds, @Param("orderIds") Set<Long> orderIds, @Param("organId") Long organId);
|
||||
|
||||
/**
|
||||
* 查询排单下订单id的列表
|
||||
*
|
||||
* @param planIds
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
List<OrderPlanPlateStatisticsRespVO> selectPlanOrderIds(@Param("planIds") List<Long> planIds, @Param("orderIds") Set<Long> orderIds, @Param("organId") Long organId);
|
||||
List<OrderPlanPlateStatisticsRespVO> selectPlanOrderIds(@Param("planIds") List<Long> planIds,
|
||||
@Param("organId") Long organId);
|
||||
|
||||
/**
|
||||
* 查询排单+订单下订单材质orderGoodsId
|
||||
@@ -201,4 +192,4 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
|
||||
* @return
|
||||
*/
|
||||
int physicalDeleteByIds(@Param("ids") Collection<Long> ids, @Param("organId") Long organId);
|
||||
}
|
||||
}
|
||||
|
||||
+23
-1
@@ -474,4 +474,26 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectPlanIdsByOrderCondition(@Param("orderIds") List<Long> orderIds, @Param("customer") String customer, @Param("organId") Long organId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单下组件生产系统的来源板件 ID 列表。
|
||||
*
|
||||
* @param orderId 订单 ID
|
||||
* @param organId 组织 ID
|
||||
* @return 来源板件 ID 列表
|
||||
*/
|
||||
List<String> selectSourceBlockItemIdsByOrderId(@Param("orderId") Long orderId,
|
||||
@Param("organId") Long organId);
|
||||
|
||||
/**
|
||||
* 查询排单下组件生产系统的来源板件 ID 列表。
|
||||
*
|
||||
* @param orderIds 排单关联的订单 ID 列表,用于匹配 organ_id、order_id、plan_id 联合索引
|
||||
* @param planId 排单 ID
|
||||
* @param organId 组织 ID
|
||||
* @return 来源板件 ID 列表
|
||||
*/
|
||||
List<String> selectSourceBlockItemIdsByPlanId(@Param("orderIds") List<Long> orderIds,
|
||||
@Param("planId") Long planId,
|
||||
@Param("organId") Long organId);
|
||||
}
|
||||
|
||||
+29
@@ -303,6 +303,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// }
|
||||
|
||||
return OrderSource.builder()
|
||||
.sourceOrderIds(collectSourceOrderIds(Collections.singletonList(orderDO)))
|
||||
.sourceBlockItemList(normalizeSourceIds(
|
||||
plateMapper.selectSourceBlockItemIdsByOrderId(orderId, getUserOrganId())))
|
||||
.orderList(Collections.singletonList(orderDO))
|
||||
.goodsList(goodsDOS)
|
||||
.plateList(BeanUtil.copyToList(plateDOS, PlateDetailRespVO.class))
|
||||
@@ -386,6 +389,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// }
|
||||
|
||||
return OrderSource.builder()
|
||||
.sourceOrderIds(collectSourceOrderIds(orderDOS))
|
||||
.sourceBlockItemList(normalizeSourceIds(
|
||||
plateMapper.selectSourceBlockItemIdsByPlanId(orderIds, planId, getUserOrganId())))
|
||||
.producingPlanOrderId(planDO.getProducingPlanOrderId())
|
||||
.orderList(orderDOS)
|
||||
.plan(planDO)
|
||||
.goodsList(goodsDOS)
|
||||
@@ -399,6 +406,28 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<String> collectSourceOrderIds(List<OrderDO> orders) {
|
||||
if (CollUtil.isEmpty(orders)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return normalizeSourceIds(orders.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(OrderDO::getSourceOrderIds)
|
||||
.filter(CollUtil::isNotEmpty)
|
||||
.flatMap(Collection::stream)
|
||||
.toList());
|
||||
}
|
||||
|
||||
private List<String> normalizeSourceIds(List<String> sourceIds) {
|
||||
if (CollUtil.isEmpty(sourceIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return sourceIds.stream()
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 保存优化后的数据
|
||||
|
||||
+19
-20
@@ -1337,31 +1337,30 @@ public class PlanServiceImpl implements PlanService {
|
||||
// 移除排单板件 & 重新计算订单和材质下的数量和面积
|
||||
removePlanOrderAndGoodsPlate(plateDOS, deleteOrderIds);
|
||||
|
||||
// 删除已无排单板件的排单
|
||||
List<Long> deleteEmptyPlanIdList = planMapper.countDeletePlanPlate(deletePlanIds, deleteOrderIds, organId)
|
||||
.stream().filter(m -> m.getCount() == 0).map(OrderPlanPlateStatisticsRespVO::getPlanId).distinct().collect(Collectors.toList());
|
||||
// 查询受影响排单的全部剩余订单,同时用于重算订单列表和识别空排单
|
||||
List<OrderPlanPlateStatisticsRespVO> orderPlanOrderIdList =
|
||||
planMapper.selectPlanOrderIds(deletePlanIds, organId);
|
||||
Map<Long, List<Long>> planIdToOrderIds = orderPlanOrderIdList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
OrderPlanPlateStatisticsRespVO::getPlanId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.mapping(OrderPlanPlateStatisticsRespVO::getOrderId,
|
||||
Collectors.collectingAndThen(Collectors.toList(),
|
||||
orderIds -> orderIds.stream().distinct().toList()))));
|
||||
|
||||
List<Long> deleteEmptyPlanIdList = deletePlanIds.stream()
|
||||
.filter(planId -> !planIdToOrderIds.containsKey(planId))
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(deleteEmptyPlanIdList)) {
|
||||
planMapper.physicalDeleteByIds(deleteEmptyPlanIdList, getUserOrganId());
|
||||
planMapper.physicalDeleteByIds(deleteEmptyPlanIdList, organId);
|
||||
}
|
||||
|
||||
// 更新排单下的订单列表
|
||||
List<OrderPlanPlateStatisticsRespVO> orderPlanOrderIdList = planMapper.selectPlanOrderIds(deletePlanIds, deleteOrderIds, organId);
|
||||
if(CollUtil.isNotEmpty(orderPlanOrderIdList)){
|
||||
Map<Long, List<Long>> planIdToOrderIds = orderPlanOrderIdList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
row -> row.getPlanId(),
|
||||
Collectors.mapping(OrderPlanPlateStatisticsRespVO::getOrderId, Collectors.toList())
|
||||
));
|
||||
for (Map.Entry<Long, List<Long>> entry : planIdToOrderIds.entrySet()) {
|
||||
Long planId = entry.getKey();
|
||||
String orderNos = entry.getValue().toString();
|
||||
|
||||
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
|
||||
.eq(PlanDO::getId, planId)
|
||||
.eq(PlanDO::getOrganId, organId)
|
||||
.set(PlanDO::getOrderNos, orderNos));
|
||||
}
|
||||
for (Map.Entry<Long, List<Long>> entry : planIdToOrderIds.entrySet()) {
|
||||
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
|
||||
.eq(PlanDO::getId, entry.getKey())
|
||||
.eq(PlanDO::getOrganId, organId)
|
||||
.set(PlanDO::getOrderNos, entry.getValue().toString()));
|
||||
}
|
||||
syncDeletedProducingPlanBlocks(
|
||||
deletePlans, sourceBlockIdsByPlanId, new HashSet<>(deleteEmptyPlanIdList));
|
||||
|
||||
+2
-24
@@ -272,25 +272,6 @@
|
||||
and op.plan_id = #{planId};
|
||||
</select>
|
||||
|
||||
<select id="countDeletePlanPlate" resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanPlateStatisticsRespVO">
|
||||
select op.plan_id as planId,
|
||||
count(op.id) as count
|
||||
from order_plate op
|
||||
where
|
||||
op.organ_id = #{organId}
|
||||
and op.plan_id != 0
|
||||
and op.plan_id in
|
||||
<foreach collection="planIds" item="planId" open="(" close=")" separator=",">
|
||||
#{planId}
|
||||
</foreach>
|
||||
and op.order_id in
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
and op.deleted = false
|
||||
group by op.plan_id;
|
||||
</select>
|
||||
|
||||
<select id="selectPlanOrderIds" resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanPlateStatisticsRespVO">
|
||||
select distinct op.plan_id, op.order_id
|
||||
from order_plate op
|
||||
@@ -301,11 +282,8 @@
|
||||
<foreach collection="planIds" item="planId" open="(" close=")" separator=",">
|
||||
#{planId}
|
||||
</foreach>
|
||||
and op.order_id in
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
and op.deleted = false
|
||||
order by op.plan_id, op.order_id
|
||||
</select>
|
||||
|
||||
<select id="selectPlanOrderGoodsId" resultType="java.lang.Long">
|
||||
@@ -396,4 +374,4 @@
|
||||
</foreach>
|
||||
and organ_id = #{organId}
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
+26
-1
@@ -1756,4 +1756,29 @@
|
||||
<result property="multiSort" column="multiSort"/>
|
||||
|
||||
</resultMap>
|
||||
</mapper>
|
||||
<select id="selectSourceBlockItemIdsByOrderId" resultType="java.lang.String">
|
||||
SELECT op.source_block_item_id
|
||||
FROM order_plate op
|
||||
WHERE op.organ_id = #{organId}
|
||||
AND op.order_id = #{orderId}
|
||||
AND op.deleted = false
|
||||
AND op.source_block_item_id IS NOT NULL
|
||||
AND op.source_block_item_id != ''
|
||||
ORDER BY op.id
|
||||
</select>
|
||||
|
||||
<select id="selectSourceBlockItemIdsByPlanId" resultType="java.lang.String">
|
||||
SELECT op.source_block_item_id
|
||||
FROM order_plate op
|
||||
WHERE op.organ_id = #{organId}
|
||||
AND op.order_id IN
|
||||
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
AND op.plan_id = #{planId}
|
||||
AND op.deleted = false
|
||||
AND op.source_block_item_id IS NOT NULL
|
||||
AND op.source_block_item_id != ''
|
||||
ORDER BY op.id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user