新增排单-板材分组接口修改

This commit is contained in:
liuzhaotian
2024-07-04 15:26:49 +08:00
parent 3d7669a114
commit b0d4dc684d
5 changed files with 81 additions and 7 deletions
@@ -0,0 +1,19 @@
package com.cf.imes.module.executor.controller.admin.plan.bo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class GoodsNum {
@Schema(description = "生产单ID")
private Long orderId;
@Schema(description = "商品数量")
private Long goodsNum;
}
@@ -52,8 +52,6 @@ public class PlanSaveReqVO {
@Schema(description = "生产单id与商品id 列表",requiredMode = Schema.RequiredMode.REQUIRED)
private List<Item> itemList;
@Schema(description = "商品数量")
private Long goodsNum;
@Schema(description = "备注")
private String remark;
@@ -69,10 +67,15 @@ public class PlanSaveReqVO {
@Valid
@Data
public static class Item {
@Schema(description = "生产单的商品id")
@NotNull
private Long id;
@Schema(description = "生产单id")
@NotNull
private Long orderId;
@Schema(description = "商品id")
@Schema(description = "板材库大板id")
@NotNull
private Long goodsId;
}
@@ -13,6 +13,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.plan.bo.GoodsNum;
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds;
import com.cf.imes.module.executor.controller.admin.plan.vo.*;
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
@@ -135,4 +136,6 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
void deletedById(@Param("plateIds") List<Long> plateIds, @Param("organId") Long organId);
List<GoodsNum> selectGoodsNum(@Param("orderIds") List<Long> orderIds,@Param("organId") Long organId);
}
@@ -15,6 +15,7 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.cf.imes.framework.mybatis.core.query.QueryWrapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
import com.cf.imes.module.executor.controller.admin.plan.bo.GoodsNum;
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
@@ -107,14 +108,28 @@ public class PlanServiceImpl implements PlanService {
plan.setIsPay(Boolean.FALSE);
plan.setSort(0L);
plan.setPlanNo(identifierGenerator.nextId(null).toString());
String orderNos = itemList.stream().map(i -> i.getOrderId()).distinct().collect(Collectors.toList()).toString();
String orderNos = itemList.stream().map(PlanSaveReqVO.Item::getOrderId).distinct().toList().toString();
plan.setOrderNos(orderNos);
planMapper.insert(plan);
// 修改对应的生产单的状态为 生产中
List<Long> orderIds = JSON.parseArray(orderNos).toJavaList(Long.class);
List<OrderDO> orderDOS = orderMapper.selectBatchIds(orderIds).stream().map(m -> m.setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus())).collect(Collectors.toList());
orderMapper.updateBatch(orderDOS);
List<GoodsNum> goodsNums = plateMapper.selectGoodsNum(orderIds, getUserOrganId());
for (Long orderId : orderIds) {
// 传入的生产单的大板数量
int size1 = itemList.stream().filter(f -> Objects.equals(f.getOrderId(), orderId)).map(PlanSaveReqVO.Item::getGoodsId).distinct().toList().size();
// 当前生产单对应的大板数量
List<Long> list = goodsNums.stream().filter(f -> Objects.equals(f.getOrderId(), orderId)).map(GoodsNum::getGoodsNum).toList();
if(size1 == list.get(0)){
OrderDO orderDO = orderMapper.selectById(orderId).setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus());
orderMapper.updateById(orderDO);
}
}
Long planId = plan.getId();
@@ -426,6 +441,10 @@ public class PlanServiceImpl implements PlanService {
List<Long> orderIds = orderMapper.selectOrderIds(queryWrapperX);
if(orderIds.isEmpty()){
return new PageResult<>();
}
List<OrderIds> orderIdsList = plateMapper.selectOrderIds(orderIds,getUserOrganId());
@@ -72,7 +72,7 @@
and
op.goods_id in
<foreach collection="itemList" item="item" open="(" close=")" separator=",">
(#{item.goodsId})
(#{item.id})
</foreach>
</select>
@@ -452,4 +452,34 @@
</foreach>
order by a.order_id
</select>
<select id="selectGoodsNum" resultType="com.cf.imes.module.executor.controller.admin.plan.bo.GoodsNum">
select distinct
a.order_id as orderId,
count(distinct c.id) as goodsNum
from order_plate a
LEFT JOIN order_item oi on a.id = oi.plate_id and a.order_id = oi.order_id and a.organ_id = oi.organ_id
LEFT JOIN `orders` b on a.order_id = b.id and a.organ_id = b.organ_id
LEFT JOIN order_goods c on a.goods_id = c.id and a.organ_id = c.organ_id
left join order_plan_item opi on oi.id = opi.item_id and oi.organ_id = opi.organ_id
where
c.organ_id = #{organId}
and a.is_cancel = 0
and b.status = 2
and a.deleted = false
and opi.item_id is null
and c.order_id in
<foreach collection="orderIds" item="orderIds" open="(" close=")" separator=",">
#{orderIds}
</foreach>
group by orderId
</select>
</mapper>