|  |  | @ -27,6 +27,7 @@ import com.glxp.api.http.ErpInvClient; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inv.FilterInvProductRequest; |  |  |  | import com.glxp.api.req.inv.FilterInvProductRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.thrsys.FilterThrInvOrderRequest; |  |  |  | import com.glxp.api.req.thrsys.FilterThrInvOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.thrsys.GenerateOrderRequest; |  |  |  | import com.glxp.api.req.thrsys.GenerateOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.thrsys.RefreshOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.PageSimpleResponse; |  |  |  | import com.glxp.api.res.PageSimpleResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.MainIdRelIdAndProductResponse; |  |  |  | import com.glxp.api.res.basic.MainIdRelIdAndProductResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inv.ThrInvResultResponse; |  |  |  | import com.glxp.api.res.inv.ThrInvResultResponse; | 
			
		
	
	
		
		
			
				
					|  |  | @ -88,20 +89,45 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |     SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |  |  |  |     SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void handleExternalThrInvOrder(FilterInvProductRequest filterInvProductRequest) { |  |  |  |     public void handleExternalThrInvOrderSf(FilterInvProductRequest filterInvProductRequest) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResult(filterInvProductRequest); |  |  |  |         BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResultSf(filterInvProductRequest); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if (baseResponse.getCode() == 20000) { |  |  |  |         if (baseResponse.getCode() == 20000) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             List<ThrInvResultResponse> list = baseResponse.getData().getList(); |  |  |  |             List<ThrInvResultResponse> list = baseResponse.getData().getList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (CollectionUtil.isNotEmpty(list)) { |  |  |  |             if (CollectionUtil.isNotEmpty(list)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 String billNo = generateBillNo(filterInvProductRequest);//单据号
 |  |  |  |                 String billNo = generateBillNo(filterInvProductRequest);//单据号
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //处理 返回实体 转换成 单据 和 单据明细
 |  |  |  |                 //处理 返回实体 转换成 单据 和 单据明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 ThrInvOrder thrInvOrder = new ThrInvOrder(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 List<ThrInvOrderDetail> thrInvOrderDetails = new ArrayList<>(); |  |  |  |                 List<ThrInvOrderDetail> thrInvOrderDetails = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 String thirdSys = filterInvProductRequest.getThirdSys(); |  |  |  |                 String thirdSys = filterInvProductRequest.getThirdSys(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 handleExternalConvertThrInvOrderDetail(list, thrInvOrderDetails, billNo, thirdSys); |  |  |  |                 handleExternalConvertThrInvOrderDetail(list, thrInvOrderDetails, billNo, thirdSys,thrInvOrder); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (CollectionUtil.isNotEmpty(thrInvOrderDetails)) { |  |  |  |                 if (CollectionUtil.isNotEmpty(thrInvOrderDetails)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0),Constant.THR_INV_SF_ORDER_TYPE); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //保存数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     thrInvOrderMapper.insert(thrInvOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     thrInvOrderDetailMapper.insertBatch(thrInvOrderDetails); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public void handleExternalThrInvOrderPh(FilterInvProductRequest filterInvProductRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResultPh(filterInvProductRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (baseResponse.getCode() == 20000) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<ThrInvResultResponse> list = baseResponse.getData().getList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (CollectionUtil.isNotEmpty(list)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String billNo = generateBillNo(filterInvProductRequest);//单据号
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //处理 返回实体 转换成 单据 和 单据明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ThrInvOrder thrInvOrder = new ThrInvOrder(); |  |  |  |                 ThrInvOrder thrInvOrder = new ThrInvOrder(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0)); |  |  |  |                 List<ThrInvOrderDetail> thrInvOrderDetails = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String thirdSys = filterInvProductRequest.getThirdSys(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 handleExternalConvertThrInvOrderDetail(list, thrInvOrderDetails, billNo, thirdSys,thrInvOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (CollectionUtil.isNotEmpty(thrInvOrderDetails)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0),Constant.THR_INV_PH_ORDER_TYPE); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //保存数据
 |  |  |  |                     //保存数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     thrInvOrderMapper.insert(thrInvOrder); |  |  |  |                     thrInvOrderMapper.insert(thrInvOrder); | 
			
		
	
	
		
		
			
				
					|  |  | @ -113,7 +139,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void downloadInvOrder(ThrSystemDetailEntity thrSystemDetailEntity) { |  |  |  |     public void downloadInvOrder(ThrSystemDetailEntity thrSystemDetailEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         log.info("自动抓取第三方出入库明细生成单据定时任务开始"); |  |  |  |         log.info("自动抓取第三方收费出入库明细生成单据定时任务开始"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); |  |  |  |         FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         filterInvProductRequest.setThirdSys(thrSystemDetailEntity.getThirdSysFk()); |  |  |  |         filterInvProductRequest.setThirdSys(thrSystemDetailEntity.getThirdSysFk()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         filterInvProductRequest.setThirdSysUrlValue(thrSystemDetailEntity.getValue()); |  |  |  |         filterInvProductRequest.setThirdSysUrlValue(thrSystemDetailEntity.getValue()); | 
			
		
	
	
		
		
			
				
					|  |  | @ -121,8 +147,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         filterInvProductRequest.setStartDate(stringToDate(days + " 00:00:00")); |  |  |  |         filterInvProductRequest.setStartDate(stringToDate(days + " 00:00:00")); | 
			
		
	
		
		
			
				
					
					|  |  |  |         filterInvProductRequest.setEndDate(stringToDate(days + " 23:59:59")); |  |  |  |         filterInvProductRequest.setEndDate(stringToDate(days + " 23:59:59")); | 
			
		
	
		
		
			
				
					
					|  |  |  |         handleExternalThrInvOrder(filterInvProductRequest); |  |  |  |         handleExternalThrInvOrderSf(filterInvProductRequest); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         log.info("自动抓取第三方出入库明细生成单据定时任务结束"); |  |  |  |         log.info("自动抓取第三方收费出入库明细生成单据定时任务结束"); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -205,6 +231,116 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return true; |  |  |  |         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public boolean refreshOrder(RefreshOrderRequest refreshOrderRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String billNo = refreshOrderRequest.getBillNo(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //通过单号获取单据信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         qw.eq("billNo", billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (Objects.isNull(thrInvOrder)) return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //通过单号获取单据明细信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         QueryWrapper<ThrInvOrderDetail> qwd = new QueryWrapper<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         qwd.eq("orderIdFk", billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList(qwd); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollectionUtil.isEmpty(thrInvOrderDetails)) return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<ThrInvOrderDetail> addThrInvOrderDetails = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<Long> delThrInvOrderDetailIds = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<String> delThrCodes = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         StringBuilder exmsg = new StringBuilder(""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer skProject = thrInvOrder.getSkProject(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (skProject == 1){//走组套
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetails.forEach(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 Long relId = item.getRelId(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (ObjectUtil.isNull(relId)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //通过thrCode获取到项目组套
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     String thrCode = item.getThrCode(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     Integer count = Integer.valueOf(item.getReCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         delThrInvOrderDetailIds.add(item.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         skProjectDetailEntityList.forEach(sk -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             BeanUtils.copyProperties(item, thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             thrInvOrderDetail.setOrderIdFk(billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             thrInvOrderDetail.setRelId(sk.getRelId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             Integer skCount = sk.getCount(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             if (skCount != null && skCount > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 thrInvOrderDetail.setReCount(String.valueOf(skCount * count)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             addThrInvOrderDetails.add(thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             delThrCodes.add(thrCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             exmsg.append(thrCode+","); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (exmsg.length() > 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.deleteCharAt(exmsg.length()-1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.insert(0,"以下第三方项目编码未匹配成功:"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(String.valueOf(exmsg)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }else {//不走组套
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String thirdSysFk = thrInvOrder.getThirdSysFk(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<String> thrCodes = thrInvOrderDetails.stream().filter(x->ObjectUtil.isNull(x.getRelId())) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Map<String, Long> mainIdRelIdMap = map.getMainIdRelIdMap(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetails.forEach(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (ObjectUtil.isNull(item.getRelId())){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     String thrCode = item.getThrCode(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     Long relId = mainIdRelIdMap.get(thrCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (ObjectUtil.isNotNull(relId)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         item.setRelId(relId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         updateThrInvOrderDetails.add(item); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         exmsg.append(thrCode+","); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (exmsg.length() > 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.deleteCharAt(exmsg.length()-1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.insert(0,"以下第三方耗材字典未匹配成功:"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(String.valueOf(exmsg)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //更新单据信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         thrInvOrderMapper.updateById(thrInvOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //删除原来的明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //删除原来的明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollectionUtil.isNotEmpty(delThrCodes)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //新增明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //更新明细
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * 校验relId字段有空返回false |  |  |  |      * 校验relId字段有空返回false | 
			
		
	
		
		
			
				
					
					|  |  |  |      * |  |  |  |      * | 
			
		
	
	
		
		
			
				
					|  |  | @ -290,7 +426,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param thrInvOrder |  |  |  |      * @param thrInvOrder | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param thrInvResultResponse |  |  |  |      * @param thrInvResultResponse | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void handleExternalConvertThrInvOrder(String billNo, FilterInvProductRequest filterInvProductRequest, ThrInvOrder thrInvOrder, ThrInvResultResponse thrInvResultResponse) { |  |  |  |     private void handleExternalConvertThrInvOrder(String billNo, FilterInvProductRequest filterInvProductRequest, ThrInvOrder thrInvOrder, ThrInvResultResponse thrInvResultResponse,Integer SourceType) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         Date newDate = new Date(); |  |  |  |         Date newDate = new Date(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setBillNo(billNo);//单据号
 |  |  |  |         thrInvOrder.setBillNo(billNo);//单据号
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -304,6 +440,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setInvCode(thrInvResultResponse.getInvCode());//仓库代码
 |  |  |  |         thrInvOrder.setInvCode(thrInvResultResponse.getInvCode());//仓库代码
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setSpaceCode(thrInvResultResponse.getSpaceCode());//货位编码
 |  |  |  |         thrInvOrder.setSpaceCode(thrInvResultResponse.getSpaceCode());//货位编码
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setStatus(ConstantStatus.SFIO_DRAFT);//单据状态 草稿
 |  |  |  |         thrInvOrder.setStatus(ConstantStatus.SFIO_DRAFT);//单据状态 草稿
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         thrInvOrder.setSourceType(SourceType);//来源类型
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setCreateTime(newDate); |  |  |  |         thrInvOrder.setCreateTime(newDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrder.setCreateUser("外部系统下载"); |  |  |  |         thrInvOrder.setCreateUser("外部系统下载"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -316,13 +453,14 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param thrInvOrderDetails |  |  |  |      * @param thrInvOrderDetails | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param billNo |  |  |  |      * @param billNo | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void handleExternalConvertThrInvOrderDetail(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String thirdSys) { |  |  |  |     private void handleExternalConvertThrInvOrderDetail(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String thirdSys,ThrInvOrder thrInvOrder) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         Integer inv_set_enable = Integer.valueOf(systemParamConfigService.selectValueByParamKey("inv_set_enable")); |  |  |  |         Integer inv_set_enable = Integer.valueOf(systemParamConfigService.selectValueByParamKey("inv_set_enable")); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (inv_set_enable == null || inv_set_enable == 0) {//直接明细 不走项目组套
 |  |  |  |         if (inv_set_enable == null || inv_set_enable == 0) {//直接明细 不走项目组套
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |             thrInvOrder.setSkProject(0); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             List<String> thrCodes = list.stream().map(ThrInvResultResponse::getThrCode).collect(Collectors.toList()); |  |  |  |             List<String> thrCodes = list.stream().map(ThrInvResultResponse::getThrCode).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSys); |  |  |  |             MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSys); | 
			
		
	
		
		
			
				
					
					|  |  |  |             Map<String, Long> mainIdRelIdMap = map.getMainIdRelIdMap(); |  |  |  |             Map<String, Long> mainIdRelIdMap = map.getMainIdRelIdMap(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             StringBuilder exmsg = new StringBuilder(""); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             list.forEach(item -> { |  |  |  |             list.forEach(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 String mainAction = item.getMainAction(); |  |  |  |                 String mainAction = item.getMainAction(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -341,8 +479,19 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 thrInvOrderDetail.setThrCode(thrCode); |  |  |  |                 thrInvOrderDetail.setThrCode(thrCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 thrInvOrderDetail.setReCount(String.valueOf(count)); |  |  |  |                 thrInvOrderDetail.setReCount(String.valueOf(count)); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 thrInvOrderDetails.add(thrInvOrderDetail); |  |  |  |                 thrInvOrderDetails.add(thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (ObjectUtil.isNull(relId)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     exmsg.append(thrCode+","); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             }); |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (exmsg.length() > 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.deleteCharAt(exmsg.length()-1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.insert(0,"以下第三方耗材字典未匹配成功:"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(String.valueOf(exmsg)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else {//走项目组套
 |  |  |  |         } else {//走项目组套
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             thrInvOrder.setSkProject(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             StringBuilder exmsg = new StringBuilder(""); | 
			
		
	
		
		
			
				
					
					|  |  |  |             list.forEach(item -> { |  |  |  |             list.forEach(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 String thrCode = item.getThrCode(); |  |  |  |                 String thrCode = item.getThrCode(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 String mainAction = item.getMainAction(); |  |  |  |                 String mainAction = item.getMainAction(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -367,8 +516,21 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |                         thrInvOrderDetails.add(thrInvOrderDetail); |  |  |  |                         thrInvOrderDetails.add(thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     }); |  |  |  |                     }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     exmsg.append(thrCode+","); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     BeanUtils.copyProperties(item, thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     thrInvOrderDetail.setOrderIdFk(billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     thrInvOrderDetail.setReCount(String.valueOf(count)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     thrInvOrderDetails.add(thrInvOrderDetail); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             }); |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (exmsg.length() > 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.deleteCharAt(exmsg.length()-1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exmsg.insert(0,"以下第三方项目编码未匹配成功:"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 thrInvOrder.setExMsg(String.valueOf(exmsg)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |