Commit 00397ca9ac547ea0de11150ba9d6f09782b5ef88

Authored by yeqianyong
1 parent e1ea81cb

楚江erp:发货计划明细数据过滤

@@ -311,6 +311,7 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -311,6 +311,7 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde
311 } 311 }
312 // 根据日期批量查询 312 // 根据日期批量查询
313 LambdaQueryWrapper<PurchaseOrderLine> queryWrapper = Wrappers.lambdaQuery(PurchaseOrderLine.class); 313 LambdaQueryWrapper<PurchaseOrderLine> queryWrapper = Wrappers.lambdaQuery(PurchaseOrderLine.class);
  314 + queryWrapper.eq(PurchaseOrderLine::getDelFlag , Boolean.FALSE);
314 if (!includeShipment) { 315 if (!includeShipment) {
315 queryWrapper.eq(PurchaseOrderLine::getShipment, Boolean.FALSE); 316 queryWrapper.eq(PurchaseOrderLine::getShipment, Boolean.FALSE);
316 } 317 }
@@ -150,6 +150,7 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP @@ -150,6 +150,7 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
150 if (plan == null) { 150 if (plan == null) {
151 throw new DefaultClientException("发货计划不存在!"); 151 throw new DefaultClientException("发货计划不存在!");
152 } 152 }
  153 + vo.setWorkshopId(plan.getWorkshopId());
153 // 获取已经存在的明细数据 154 // 获取已经存在的明细数据
154 List<String> orderSpecIds = getBaseMapper().getExistsOrderSpecIds(plan.getAfTomoPreShipDate()); 155 List<String> orderSpecIds = getBaseMapper().getExistsOrderSpecIds(plan.getAfTomoPreShipDate());
155 if (CollectionUtils.isNotEmpty(orderSpecIds)) { 156 if (CollectionUtils.isNotEmpty(orderSpecIds)) {
@@ -223,7 +224,25 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP @@ -223,7 +224,25 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
223 // 获取订货单数据 224 // 获取订货单数据
224 Map<String, PurchaseOrderInfo> orderInfoMap = new HashMap<>(); 225 Map<String, PurchaseOrderInfo> orderInfoMap = new HashMap<>();
225 if (CollectionUtils.isNotEmpty(orderLineList)) { 226 if (CollectionUtils.isNotEmpty(orderLineList)) {
226 - List<String> orderIds = orderLineList.stream().map(PurchaseOrderLine::getPurchaseOrderId).collect(Collectors.toList()); 227 + List<String> orderIds = new ArrayList<>();
  228 + List<String> orderSpecIds = new ArrayList<>();
  229 + // 获取发货明细
  230 + for (PurchaseOrderLine orderLine : orderLineList) {
  231 + orderSpecIds.add(orderLine.getId());
  232 + String orderId = orderLine.getPurchaseOrderId();
  233 + if (StringUtils.isNotBlank(orderId) && !orderIds.contains(orderId)) {
  234 + orderIds.add(orderId);
  235 + }
  236 + }
  237 + QueryShipmentsPlanDetailVo detailVo = new QueryShipmentsPlanDetailVo();
  238 + detailVo.setOrderSpecIds(orderSpecIds);
  239 + detailVo.setCompleted(Boolean.TRUE);
  240 + List<ShipmentsPlanDetail> detailList = query(detailVo);
  241 + if (CollectionUtils.isNotEmpty(detailList)) {
  242 + List<String> orderSpecIdList = detailList.stream().map(ShipmentsPlanDetail::getOrderSpecId).distinct().collect(Collectors.toList());
  243 + // 过滤掉已发货的数据
  244 + orderLineList.removeIf(next -> orderSpecIdList.contains(next.getId()));
  245 + }
227 List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds); 246 List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds);
228 if (CollectionUtils.isNotEmpty(orderInfoList)) { 247 if (CollectionUtils.isNotEmpty(orderInfoList)) {
229 orderInfoMap = orderInfoList.stream().collect(Collectors.toMap(PurchaseOrderInfo::getId, Function.identity())); 248 orderInfoMap = orderInfoList.stream().collect(Collectors.toMap(PurchaseOrderInfo::getId, Function.identity()));
@@ -252,6 +271,17 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP @@ -252,6 +271,17 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP
252 if (orderInfo == null) { 271 if (orderInfo == null) {
253 continue; 272 continue;
254 } 273 }
  274 + String type = orderInfo.getType();
  275 + String examineStatus = orderInfo.getExamineStatus();
  276 + String status = orderInfo.getStatus();
  277 + String revokeStatus = orderInfo.getRevokeStatus();
  278 + String specChangeStatus = orderInfo.getSpecChangeStatus();
  279 + // 过滤掉无需发货的数据
  280 + if (!"PRODUCTION".equals(type) || !"PASS".equals(examineStatus)
  281 + || "SHIPPED".equals(status) || "DELIVERED".equals(status) || "CANCEL".equals(status)
  282 + || "UNDOING".equals(revokeStatus) || "IN_PROGRESS".equals(specChangeStatus)) {
  283 + continue;
  284 + }
255 String workshopId = orderInfo.getWorkshopId(); 285 String workshopId = orderInfo.getWorkshopId();
256 if (!workshop.getId().equals(workshopId)) { 286 if (!workshop.getId().equals(workshopId)) {
257 continue; 287 continue;
@@ -21,6 +21,12 @@ public class QueryShipmentsPlanDetailVo extends PageVo implements BaseVo, Serial @@ -21,6 +21,12 @@ public class QueryShipmentsPlanDetailVo extends PageVo implements BaseVo, Serial
21 private List<String> ids; 21 private List<String> ids;
22 22
23 /** 23 /**
  24 + * 厂房ID
  25 + */
  26 + @ApiModelProperty("厂房ID")
  27 + private String workshopId;
  28 +
  29 + /**
24 * 发货计划ID 30 * 发货计划ID
25 */ 31 */
26 @ApiModelProperty("发货计划ID") 32 @ApiModelProperty("发货计划ID")
@@ -106,6 +106,12 @@ @@ -106,6 +106,12 @@
106 #{item} 106 #{item}
107 </foreach> 107 </foreach>
108 </if> 108 </if>
  109 + <if test="vo.orderSpecIds != null and vo.orderSpecIds.size() > 0">
  110 + AND ol.id IN
  111 + <foreach collection="vo.orderSpecIds" open="(" separator="," close=")" item="item">
  112 + #{item}
  113 + </foreach>
  114 + </if>
109 <if test="vo.completed != null"> 115 <if test="vo.completed != null">
110 <choose> 116 <choose>
111 <when test="vo.completed == true"> 117 <when test="vo.completed == true">
@@ -181,9 +187,12 @@ @@ -181,9 +187,12 @@
181 inner join purchase_order_info o on ol.purchase_order_id = o.id 187 inner join purchase_order_info o on ol.purchase_order_id = o.id
182 left join base_data_customer c on o.ordering_unit = c.id 188 left join base_data_customer c on o.ordering_unit = c.id
183 where ol.delivery_date >= #{vo.shipmentDate} and ol.del_flag = false 189 where ol.delivery_date >= #{vo.shipmentDate} and ol.del_flag = false
184 - and o.type = 'PRODUCTION' and o.examine_status = 'PASS' and o.status not in ('SHIPPED', 'DELIVERED') 190 + and o.type = 'PRODUCTION' and o.examine_status = 'PASS' and o.status not in ('SHIPPED', 'DELIVERED', 'CANCEL')
185 and (o.revoke_status != 'UNDOING' or o.revoke_status is null) 191 and (o.revoke_status != 'UNDOING' or o.revoke_status is null)
186 and (o.spec_change_status != 'IN_PROGRESS' or o.spec_change_status is null) 192 and (o.spec_change_status != 'IN_PROGRESS' or o.spec_change_status is null)
  193 + <if test="vo.workshopId != null and vo.workshopId != ''">
  194 + AND o.workshop_id = #{vo.workshopId}
  195 + </if>
187 <if test="vo.orderSpecIds != null and vo.orderSpecIds.size() > 0"> 196 <if test="vo.orderSpecIds != null and vo.orderSpecIds.size() > 0">
188 and ol.id not in 197 and ol.id not in
189 <foreach collection="vo.orderSpecIds" open="(" separator="," close=")" item="item"> 198 <foreach collection="vo.orderSpecIds" open="(" separator="," close=")" item="item">