|  |  |  | @ -70,7 +70,7 @@ import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  |  | @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |  | //@Transactional(rollbackFor = Exception.class)
 | 
			
		
	
		
			
				
					|  |  |  |  | public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
	
		
			
				
					|  |  |  | @ -855,7 +855,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (CollectionUtil.isEmpty(thrInvOrderDetails)) continue; | 
			
		
	
		
			
				
					|  |  |  |  |                 log.info("扫描处理第三方收费明细生成单据定时任务==orderIdFk==:[" + thrInvOrder.getBillNo() + "]"); | 
			
		
	
		
			
				
					|  |  |  |  |                 //新单号
 | 
			
		
	
		
			
				
					|  |  |  |  |                 String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //通过单号获取单据信息
 | 
			
		
	
		
			
				
					|  |  |  |  |                 QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>(); | 
			
		
	
	
		
			
				
					|  |  |  | @ -884,7 +884,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                                     thrInvOrderDetail.setRelId(sk.getRelId()); | 
			
		
	
		
			
				
					|  |  |  |  |                                     thrInvOrderDetail.setSupId(sk.getSupId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |                                     thrInvOrderDetail.setHandleStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |                                     thrInvOrderDetail.setToBillNo(newBillNo); | 
			
		
	
		
			
				
					|  |  |  |  |                                     thrInvOrderDetail.setToBillNo(null); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                                     Integer skCount = sk.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                     if (skCount != null && skCount > 0) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -921,7 +921,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                                 if (ObjectUtil.isNotNull(relId)) { | 
			
		
	
		
			
				
					|  |  |  |  |                                     item.setRelId(relId); | 
			
		
	
		
			
				
					|  |  |  |  |                                     item.setHandleStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |                                     item.setToBillNo(newBillNo); | 
			
		
	
		
			
				
					|  |  |  |  |                                     item.setToBillNo(null); | 
			
		
	
		
			
				
					|  |  |  |  |                                     updateThrInvOrderDetails.add(item); | 
			
		
	
		
			
				
					|  |  |  |  |                                     //校验产品是否被供应商关联
 | 
			
		
	
		
			
				
					|  |  |  |  |                                     CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId); | 
			
		
	
	
		
			
				
					|  |  |  | @ -949,14 +949,14 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) { | 
			
		
	
		
			
				
					|  |  |  |  |                     thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 genOrder(newBillNo, thrInvOrder, bussinessTypeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 genOrder(thrInvOrder, bussinessTypeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 log.info("扫描处理第三方收费明细生成单据定时任务结束"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public boolean genOrder(String newBillNo, | 
			
		
	
		
			
				
					|  |  |  |  |     public boolean genOrder( | 
			
		
	
		
			
				
					|  |  |  |  |             ThrInvOrder thrInvOrder, BasicBussinessTypeEntity bussinessTypeEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<ThrInvOrderDetail> qwd = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         qwd.eq("orderIdFk", thrInvOrder.getBillNo()); | 
			
		
	
	
		
			
				
					|  |  |  | @ -973,6 +973,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |             grouped.put(thrInvOrder.getFromCorp(), thrInvOrderDetails); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isEmpty(entry.getValue())) | 
			
		
	
		
			
				
					|  |  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |  |             String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); | 
			
		
	
		
			
				
					|  |  |  |  |             IoOrderEntity ioOrderEntity = new IoOrderEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setBillNo(newBillNo); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); | 
			
		
	
	
		
			
				
					|  |  |  | @ -995,18 +998,18 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setCustomerId("110"); | 
			
		
	
		
			
				
					|  |  |  |  |             Long userId = 1l; | 
			
		
	
		
			
				
					|  |  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |  |                 userId = customerService.getUserId(); | 
			
		
	
		
			
				
					|  |  |  |  |             } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |                 e.printStackTrace(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | //            try {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                userId = customerService.getUserId();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            } catch (Exception e) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                e.printStackTrace();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setCreateUser(userId + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setUpdateUser(userId + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
 | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (entry.getValue().size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (!copyOrderDetailBiz(entry.getValue(), newOrderDetailBiz, newBillNo)) { | 
			
		
	
		
			
				
					|  |  |  |  |                     throw new JsonException("第三方收费明细自动转化单据异常"); | 
			
		
	
		
			
				
					|  |  |  |  |                   continue; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1016,7 +1019,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                 toBillNo = toBillNo.substring(1); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             thrInvOrder.setToBillNo(toBillNo); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             thrInvOrderMapper.updateById(thrInvOrder); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderService.insertOrder(ioOrderEntity); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1314,10 +1316,16 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |             newBillNo) { | 
			
		
	
		
			
				
					|  |  |  |  |         List<Long> relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId())) | 
			
		
	
		
			
				
					|  |  |  |  |                 .map(ThrInvOrderDetail::getRelId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isEmpty(relIds)) | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isEmpty(relIds)) { | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("第三方高耗明细没有关联产品" + relIds); | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<BasicProductsEntity> basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollectionUtil.isEmpty(basicProductsEntities)) return false; | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollectionUtil.isEmpty(basicProductsEntities)) { | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("第三方高耗明细没有关联产品" + relIds); | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         Map<Long, BasicProductsEntity> relIdBasicProductsEntityMap = basicProductsEntities.stream().collect(Collectors.toMap(BasicProductsEntity::getId, x -> x)); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         for (int i = 0; i < thrInvOrderDetails.size(); i++) { | 
			
		
	
	
		
			
				
					|  |  |  | 
 |