|
@@ -418,70 +418,73 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
|
|
|
String invccode = deliverDetailVoList.get(0).getInvccode();
|
|
|
// 判断是否成衣
|
|
|
boolean isCloth = invccode.startsWith("19");
|
|
|
- // 如果是成衣,根据已提交的group_id单个提交
|
|
|
- // 如果是面辅料,判断同一订单、同一发货日期、同一物料、是否有不同尺码的还未提交;如果有,先不推送
|
|
|
- if (isCloth){
|
|
|
- List<String> groupIdList = deliverDetailVoList.stream().filter(e->"1".equals(e.getSubmitStatus())).map(PurchasePreDeliverDetailVo::getSyShippingDetailGroupId).distinct().collect(Collectors.toList());
|
|
|
- for (String groupId : groupIdList){
|
|
|
- List<PurchasePreDeliverDetailVo> findDetailVoList = deliverDetailVoList.stream().filter(p->p.getSyShippingDetailGroupId().equals(groupId)).collect(Collectors.toList());
|
|
|
- PurchasePreDeliverDetailVo findDetailVo = findDetailVoList.get(0);
|
|
|
- PurchasePreDeliverVo deliverVo = new PurchasePreDeliverVo();
|
|
|
- deliverVo.setSyShippingId(shippingDetails.getId());
|
|
|
- deliverVo.setVbilldate(DateUtils.date2Str(shippingDetails.getDocumentDate(), DateUtils.date_sdf.get()));
|
|
|
- deliverVo.setSendDate(findDetailVo.getArriveDate());
|
|
|
- deliverVo.setQuantity(findDetailVo.getQuantity());
|
|
|
- deliverVo.setPurchasePreDeliverDetailList(findDetailVoList);
|
|
|
- deliverVo.setSysOrgCode(findDetailVo.getSysOrgCode());
|
|
|
- List<PurchasePreDeliverDetailSizeVo> findDetailSizeVoList = deliverDetailSizeVoList.stream().filter(p1->p1.getSyShippingDetailGroupId().equals(findDetailVo.getSyShippingDetailGroupId())).collect(Collectors.toList());
|
|
|
- findDetailVo.setPurchasePreDeliverDetailSizeList(findDetailSizeVoList);
|
|
|
- deliverVoList.add(deliverVo);
|
|
|
- }
|
|
|
- }else{
|
|
|
+ // 如果是面辅料,去掉同一采购委外订单、同一发货日期、同一物料、有不同尺码的还未提交的。先不推送
|
|
|
+ if (!isCloth){
|
|
|
// 排除的订单id+存货编码
|
|
|
List<String> excludeList = new ArrayList<>();
|
|
|
deliverDetailVoList.forEach(e->{
|
|
|
- if ("0".equals(e.getSubmitStatus())){
|
|
|
+ if ("0".equals(e.getSubmitStatus()) && e.fabricNeedMerge()){
|
|
|
excludeList.add(e.toFabricUnicId());
|
|
|
}
|
|
|
});
|
|
|
- List<PurchasePreDeliverDetailVo> includeDetailVoList = deliverDetailVoList.stream().filter(e->!excludeList.contains(e.toFabricUnicId())).collect(Collectors.toList());
|
|
|
- List<String> includeUnicIdList = new ArrayList<>();
|
|
|
- includeDetailVoList.forEach(e->{
|
|
|
- if (!includeUnicIdList.contains(e.toFabricUnicId())){
|
|
|
- includeUnicIdList.add(e.toFabricUnicId());
|
|
|
+ deliverDetailVoList = deliverDetailVoList.stream().filter(e->!e.fabricNeedMerge() || !excludeList.contains(e.toFabricUnicId())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ // 去掉未提交的明细
|
|
|
+ deliverDetailVoList = deliverDetailVoList.stream().filter(e->"1".equals(e.getSubmitStatus())).collect(Collectors.toList());
|
|
|
+ // 如果是面辅料,如果尺码不为空给就需要合并。根据同一采购委外订单、同一发货日期、同一物料合并不同尺码
|
|
|
+ // 1)如果分组已经包含当前分组,略过;
|
|
|
+ // 2)如果尺码为空不需要合并的,直接加分组编号;
|
|
|
+ // 3)如果尺码不为空的,根据标识,吧多个分组逗号分割加入;
|
|
|
+ // 4) 对每个分组id轮询分组
|
|
|
+ if (!isCloth){
|
|
|
+ List<String> groupIdList = new ArrayList<>();
|
|
|
+ for (PurchasePreDeliverDetailVo purchasePreDeliverDetailVo : deliverDetailVoList){
|
|
|
+ long count = groupIdList.stream().filter(p->p.indexOf(purchasePreDeliverDetailVo.getSyShippingDetailGroupId())>-1).count();
|
|
|
+ if (count>0){
|
|
|
+ continue;
|
|
|
}
|
|
|
- });
|
|
|
- for (String unicId : includeUnicIdList){
|
|
|
-
|
|
|
- List<PurchasePreDeliverDetailVo> findDetailVoList = deliverDetailVoList.stream().filter(p->p.toFabricUnicId().equals(unicId)).collect(Collectors.toList());
|
|
|
- // 多个分组号逗号分隔
|
|
|
- List<String> groupIdList = findDetailVoList.stream().map(PurchasePreDeliverDetailVo::getSyShippingDetailGroupId).distinct().collect(Collectors.toList());
|
|
|
- String strGroupIds = String.join(",",groupIdList);
|
|
|
- // 查找匹配的尺码
|
|
|
- List<PurchasePreDeliverDetailSizeVo> findDetailSizeVoList = deliverDetailSizeVoList.stream().filter(p1->groupIdList.contains(p1.getSyShippingDetailGroupId())).collect(Collectors.toList());
|
|
|
+ if (!purchasePreDeliverDetailVo.fabricNeedMerge()){
|
|
|
+ groupIdList.add(purchasePreDeliverDetailVo.getSyShippingDetailGroupId());
|
|
|
+ }else{
|
|
|
+ List<String> findGroupidList = deliverDetailVoList.stream().filter(e->e.toFabricUnicId().equals(purchasePreDeliverDetailVo.toFabricUnicId())).map(PurchasePreDeliverDetailVo::getSyShippingDetailGroupId).distinct().collect(Collectors.toList());
|
|
|
+ String strGroupIds = String.join(",",findGroupidList);
|
|
|
+ groupIdList.add(strGroupIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PurchasePreDeliverDetailVo> groupDetailVoList = new ArrayList<>();
|
|
|
+ for (String groupId : groupIdList){
|
|
|
+
|
|
|
+ List<PurchasePreDeliverDetailVo> findDetailVoList = deliverDetailVoList.stream().filter(p->groupId.indexOf(p.getSyShippingDetailGroupId())>-1).collect(Collectors.toList());
|
|
|
// 多个尺码数量相加
|
|
|
PurchasePreDeliverDetailVo findDetailVo = findDetailVoList.get(0);
|
|
|
for (int i=1; i<findDetailVoList.size(); i++){
|
|
|
findDetailVo.setQuantity(findDetailVo.getQuantity().add(findDetailVoList.get(i).getQuantity()));
|
|
|
}
|
|
|
// 设置分组id
|
|
|
- findDetailVo.setSyShippingDetailGroupId(strGroupIds);
|
|
|
- // 设置尺码
|
|
|
- findDetailVo.setPurchasePreDeliverDetailSizeList(findDetailSizeVoList);
|
|
|
- // 清空集合,只保留一个
|
|
|
- findDetailVoList.clear();
|
|
|
- findDetailVoList.add(findDetailVo);
|
|
|
-
|
|
|
- PurchasePreDeliverVo deliverVo = new PurchasePreDeliverVo();
|
|
|
- deliverVo.setSyShippingId(shippingDetails.getId());
|
|
|
- deliverVo.setVbilldate(DateUtils.date2Str(shippingDetails.getDocumentDate(), DateUtils.date_sdf.get()));
|
|
|
- deliverVo.setSendDate(findDetailVo.getArriveDate());
|
|
|
- deliverVo.setPurchasePreDeliverDetailList(findDetailVoList);
|
|
|
- deliverVo.setQuantity(findDetailVo.getQuantity());
|
|
|
- deliverVo.setSysOrgCode(findDetailVo.getSysOrgCode());
|
|
|
- deliverVoList.add(deliverVo);
|
|
|
-
|
|
|
+ findDetailVo.setSyShippingDetailGroupId(groupId);
|
|
|
+ groupDetailVoList.add(findDetailVo);
|
|
|
}
|
|
|
+ deliverDetailVoList = groupDetailVoList;
|
|
|
+ }
|
|
|
+ // 单据拆分
|
|
|
+ List<String> billIdList = deliverDetailVoList.stream().map(PurchasePreDeliverDetailVo::toBillId).distinct().collect(Collectors.toList());
|
|
|
+ for (String billId : billIdList){
|
|
|
+ List<PurchasePreDeliverDetailVo> findDetailVoList = deliverDetailVoList.stream().filter(p->p.toBillId().equals(billId)).collect(Collectors.toList());
|
|
|
+ PurchasePreDeliverDetailVo findDetailVo = findDetailVoList.get(0);
|
|
|
+ PurchasePreDeliverVo deliverVo = new PurchasePreDeliverVo();
|
|
|
+ deliverVo.setSyShippingId(shippingDetails.getId());
|
|
|
+ deliverVo.setVbilldate(DateUtils.date2Str(shippingDetails.getDocumentDate(), DateUtils.date_sdf.get()));
|
|
|
+ deliverVo.setSendDate(findDetailVo.getArriveDate());
|
|
|
+ deliverVo.setPurchasePreDeliverDetailList(findDetailVoList);
|
|
|
+ deliverVo.setSysOrgCode(findDetailVo.getSysOrgCode());
|
|
|
+ deliverVo.setQuantity(BigDecimal.ZERO);
|
|
|
+ findDetailVoList.forEach(d->{
|
|
|
+ deliverVo.setQuantity(deliverVo.getQuantity().add(d.getQuantity()));
|
|
|
+ List<PurchasePreDeliverDetailSizeVo> findDetailSizeVoList = deliverDetailSizeVoList.stream().
|
|
|
+ filter(p1->d.getSyShippingDetailGroupId().indexOf(p1.getSyShippingDetailGroupId())>-1).collect(Collectors.toList());
|
|
|
+ d.setPurchasePreDeliverDetailSizeList(findDetailSizeVoList);
|
|
|
+ });
|
|
|
+ deliverVoList.add(deliverVo);
|
|
|
}
|
|
|
return deliverVoList;
|
|
|
}
|