|  | @@ -25,11 +25,17 @@ import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrder;
 | 
											
												
													
														|  |  import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
 |  |  import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
 | 
											
												
													
														|  |  import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderItemVO;
 |  |  import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderItemVO;
 | 
											
												
													
														|  |  import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderVO;
 |  |  import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderVO;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqSyShippingDetailsItemVO;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqSyShippingDetailsVO;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.syShippingOrder.mapper.SyShippingOrderItemMapper;
 | 
											
												
													
														|  |  import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderItemService;
 |  |  import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderItemService;
 | 
											
												
													
														|  |  import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderService;
 |  |  import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderService;
 | 
											
												
													
														|  |  import org.jeecg.modules.openApi.entity.DxpDataPlan;
 |  |  import org.jeecg.modules.openApi.entity.DxpDataPlan;
 | 
											
												
													
														|  |  import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 |  |  import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.openApi.service.ISenYuDataSourceThree;
 | 
											
												
													
														|  |  import org.jeecg.modules.splfi.entity.SyPackingListFabric;
 |  |  import org.jeecg.modules.splfi.entity.SyPackingListFabric;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.splfi.entity.SyPackingListFabricItem;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.splfi.service.ISyPackingListFabricItemService;
 | 
											
												
													
														|  |  import org.jeecg.modules.splfi.service.ISyPackingListFabricService;
 |  |  import org.jeecg.modules.splfi.service.ISyPackingListFabricService;
 | 
											
												
													
														|  |  import org.jeecg.modules.system.util.HttpHelper;
 |  |  import org.jeecg.modules.system.util.HttpHelper;
 | 
											
												
													
														|  |  import org.jeecg.modules.system.util.InterfaceConnUtils;
 |  |  import org.jeecg.modules.system.util.InterfaceConnUtils;
 | 
											
										
											
												
													
														|  | @@ -41,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Value;
 |  |  import org.springframework.beans.factory.annotation.Value;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Component;
 |  |  import org.springframework.stereotype.Component;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import javax.annotation.Resource;
 | 
											
												
													
														|  |  import java.util.ArrayList;
 |  |  import java.util.ArrayList;
 | 
											
												
													
														|  |  import java.util.Arrays;
 |  |  import java.util.Arrays;
 | 
											
												
													
														|  |  import java.util.List;
 |  |  import java.util.List;
 | 
											
										
											
												
													
														|  | @@ -69,6 +76,12 @@ public class PushShippingDetailsJob implements Job {
 | 
											
												
													
														|  |      private ISyShippingOrderService syShippingOrderService;
 |  |      private ISyShippingOrderService syShippingOrderService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private ISyPackingListFabricService syPackingListFabricService;
 |  |      private ISyPackingListFabricService syPackingListFabricService;
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private ISenYuDataSourceThree senYuDataSourceThree;
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private ISyPackingListFabricItemService syPackingListFabricItemService;
 | 
											
												
													
														|  | 
 |  | +    @Resource
 | 
											
												
													
														|  | 
 |  | +    private SyShippingOrderItemMapper syShippingOrderItemMapper;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      // srm调用校验码
 |  |      // srm调用校验码
 | 
											
												
													
														|  |      @Value("${srm.access-token}")
 |  |      @Value("${srm.access-token}")
 | 
											
										
											
												
													
														|  | @@ -176,7 +189,9 @@ public class PushShippingDetailsJob implements Job {
 | 
											
												
													
														|  |                      LambdaQueryWrapper<SyShippingOrder> mQueryWrapper = new LambdaQueryWrapper<>();
 |  |                      LambdaQueryWrapper<SyShippingOrder> mQueryWrapper = new LambdaQueryWrapper<>();
 | 
											
												
													
														|  |                      mQueryWrapper.in(SyShippingOrder::getId, itemList.stream().map(SyShippingOrderItem::getSyShippingOrderItemId).distinct().collect(Collectors.toList()));
 |  |                      mQueryWrapper.in(SyShippingOrder::getId, itemList.stream().map(SyShippingOrderItem::getSyShippingOrderItemId).distinct().collect(Collectors.toList()));
 | 
											
												
													
														|  |                      List<SyShippingOrder> orderList = syShippingOrderService.list(mQueryWrapper);
 |  |                      List<SyShippingOrder> orderList = syShippingOrderService.list(mQueryWrapper);
 | 
											
												
													
														|  | -                    List<ReqShippingOrderItemVO> reqVoList = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    List<ReqShippingOrderItemVO> reqVoList = new ArrayList<>(); // 回写托书信息
 | 
											
												
													
														|  | 
 |  | +                    List<ReqSyShippingDetailsItemVO> reqQuantityList = new ArrayList<>(); // 回写可以对账数量
 | 
											
												
													
														|  | 
 |  | +                    List<RespUpdateVO> errList = new ArrayList<>();
 | 
											
												
													
														|  |                      List<SyPackingListFabric> packingListFabricList = new ArrayList<>();
 |  |                      List<SyPackingListFabric> packingListFabricList = new ArrayList<>();
 | 
											
												
													
														|  |                      for (SyShippingOrderItem item : itemList){
 |  |                      for (SyShippingOrderItem item : itemList){
 | 
											
												
													
														|  |                          SyShippingOrder findOrder = orderList.stream().filter(x -> x.getId().equals(item.getSyShippingOrderItemId())).findFirst().orElse(null);
 |  |                          SyShippingOrder findOrder = orderList.stream().filter(x -> x.getId().equals(item.getSyShippingOrderItemId())).findFirst().orElse(null);
 | 
											
										
											
												
													
														|  | @@ -187,17 +202,37 @@ public class PushShippingDetailsJob implements Job {
 | 
											
												
													
														|  |                              ReqShippingOrderItemVO reqVo = new ReqShippingOrderItemVO();
 |  |                              ReqShippingOrderItemVO reqVo = new ReqShippingOrderItemVO();
 | 
											
												
													
														|  |                              reqVo.fromShippingOrder(item, findOrder);
 |  |                              reqVo.fromShippingOrder(item, findOrder);
 | 
											
												
													
														|  |                              if (!"成衣".equals(findOrder.getReadyFabric())){
 |  |                              if (!"成衣".equals(findOrder.getReadyFabric())){
 | 
											
												
													
														|  | -                                // 拉取装箱单表头外销发票号
 |  | 
 | 
											
												
													
														|  | -                                SyPackingListFabric syPackingListFabric = packingListFabricList.stream().filter(e->e.getId().equals(item.getTailoringFabricId())).findFirst().orElse(null);
 |  | 
 | 
											
												
													
														|  | -                                if (syPackingListFabric == null){
 |  | 
 | 
											
												
													
														|  | -                                    syPackingListFabric = syPackingListFabricService.getById(item.getTailoringFabricId());
 |  | 
 | 
											
												
													
														|  | -                                    packingListFabricList.add(syPackingListFabric);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                                boolean isReqQuantity = "采购".equals(getOrderType(item));
 | 
											
												
													
														|  | 
 |  | +                                if (isReqQuantity){
 | 
											
												
													
														|  | 
 |  | +                                    ReqSyShippingDetailsItemVO itemVO = syShippingOrderItemMapper.queryPackingQuantity(item.getId());
 | 
											
												
													
														|  | 
 |  | +                                    if (itemVO == null){
 | 
											
												
													
														|  | 
 |  | +                                        RespUpdateVO respUpdateVO = new RespUpdateVO();
 | 
											
												
													
														|  | 
 |  | +                                        respUpdateVO.setExtraInfo(item.getId());
 | 
											
												
													
														|  | 
 |  | +                                        respUpdateVO.setSuccess(false);
 | 
											
												
													
														|  | 
 |  | +                                        respUpdateVO.setMessage("获取出运明细装箱记录失败");
 | 
											
												
													
														|  | 
 |  | +                                        errList.add(respUpdateVO);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                                    }else {
 | 
											
												
													
														|  | 
 |  | +                                        reqQuantityList.add(itemVO);
 | 
											
												
													
														|  | 
 |  | +                                    }
 | 
											
												
													
														|  | 
 |  | +                                }else {
 | 
											
												
													
														|  | 
 |  | +                                    // 拉取装箱单表头外销发票号
 | 
											
												
													
														|  | 
 |  | +                                    SyPackingListFabric syPackingListFabric = packingListFabricList.stream().filter(e -> e.getId().equals(item.getTailoringFabricId())).findFirst().orElse(null);
 | 
											
												
													
														|  | 
 |  | +                                    if (syPackingListFabric == null) {
 | 
											
												
													
														|  | 
 |  | +                                        syPackingListFabric = syPackingListFabricService.getById(item.getTailoringFabricId());
 | 
											
												
													
														|  | 
 |  | +                                        packingListFabricList.add(syPackingListFabric);
 | 
											
												
													
														|  | 
 |  | +                                    }
 | 
											
												
													
														|  | 
 |  | +                                    reqVo.setExportInvoiceNo(syPackingListFabric.getExportInvoiceNo());
 | 
											
												
													
														|  | 
 |  | +                                    reqVoList.add(reqVo);
 | 
											
												
													
														|  |                                  }
 |  |                                  }
 | 
											
												
													
														|  | -                                reqVo.setExportInvoiceNo(syPackingListFabric.getExportInvoiceNo());
 |  | 
 | 
											
												
													
														|  | 
 |  | +                            }else {
 | 
											
												
													
														|  | 
 |  | +                                reqVoList.add(reqVo);
 | 
											
												
													
														|  |                              }
 |  |                              }
 | 
											
												
													
														|  | -                            reqVoList.add(reqVo);
 |  | 
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  | 
 |  | +                    if (errList.size()>0){
 | 
											
												
													
														|  | 
 |  | +                        syShippingOrderItemService.updateSrmPushState(errList);
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  |                      if (reqVoList.size()>0){
 |  |                      if (reqVoList.size()>0){
 | 
											
												
													
														|  |                          ReqShippingOrderVO reqVo = new ReqShippingOrderVO();
 |  |                          ReqShippingOrderVO reqVo = new ReqShippingOrderVO();
 | 
											
												
													
														|  |                          reqVo.setVerifyToken(srmAccessToken);
 |  |                          reqVo.setVerifyToken(srmAccessToken);
 | 
											
										
											
												
													
														|  | @@ -206,6 +241,14 @@ public class PushShippingDetailsJob implements Job {
 | 
											
												
													
														|  |                                  RespUpdateVO.class);
 |  |                                  RespUpdateVO.class);
 | 
											
												
													
														|  |                          syShippingOrderItemService.updateSrmPushState(respUpdateVOList);
 |  |                          syShippingOrderItemService.updateSrmPushState(respUpdateVOList);
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  | 
 |  | +                    if (reqQuantityList.size()>0){
 | 
											
												
													
														|  | 
 |  | +                        ReqSyShippingDetailsVO reqVo = new ReqSyShippingDetailsVO();
 | 
											
												
													
														|  | 
 |  | +                        reqVo.setVerifyToken(srmAccessToken);
 | 
											
												
													
														|  | 
 |  | +                        reqVo.setItemList(reqQuantityList);
 | 
											
												
													
														|  | 
 |  | +                        List<RespUpdateVO> respUpdateVOList = JSONArray.parseArray(HttpHelper.httpJsonPost(dxpDataPlan.getItemIp().replace("/purchaseDeliver/dzSaveTs","/purchaseReceive/dzSaveReceiveSum"), JSONObject.toJSONString(reqVo), null),
 | 
											
												
													
														|  | 
 |  | +                                RespUpdateVO.class);
 | 
											
												
													
														|  | 
 |  | +                        syShippingOrderItemService.updateSrmPushState(respUpdateVOList);
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -270,4 +313,15 @@ public class PushShippingDetailsJob implements Job {
 | 
											
												
													
														|  |              e.printStackTrace();
 |  |              e.printStackTrace();
 | 
											
												
													
														|  |          }*/
 |  |          }*/
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private String getOrderType(SyShippingOrderItem syShippingOrderItem){
 | 
											
												
													
														|  | 
 |  | +        QueryWrapper<SyPackingListFabricItem> queryWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +        queryWrapper.lambda().eq(SyPackingListFabricItem::getId,syShippingOrderItem.getTailoringFabricItemId());
 | 
											
												
													
														|  | 
 |  | +        List<SyPackingListFabricItem> syPackingListFabricItems = syPackingListFabricItemService.list(queryWrapper);
 | 
											
												
													
														|  | 
 |  | +        if (syPackingListFabricItems.size() == 0){
 | 
											
												
													
														|  | 
 |  | +            return "";
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        SyPackingListFabricItem item = syPackingListFabricItems.get(0);
 | 
											
												
													
														|  | 
 |  | +        return senYuDataSourceThree.getOrderType(item.getAccount(), item.getOmpoId(), item.getPurOrSubOrder());
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  }
 |  |  }
 |