|  |  | @ -34,6 +34,7 @@ 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; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.auth.CustomerService; |  |  |  | import com.glxp.api.service.auth.CustomerService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.ProductInfoService; |  |  |  | import com.glxp.api.service.basic.ProductInfoService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.UdiRlSupService; |  |  |  | import com.glxp.api.service.basic.UdiRlSupService; | 
			
		
	
	
		
		
			
				
					|  |  | @ -310,6 +311,11 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return thrInvOrderMapper.delete(uw); |  |  |  |         return thrInvOrderMapper.delete(uw); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IBasicBussinessTypeService bussinessTypeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoAddInoutService addInoutService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public boolean generateOrder(GenerateOrderRequest generateOrderRequest) { |  |  |  |     public boolean generateOrder(GenerateOrderRequest generateOrderRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         String billNo = generateOrderRequest.getBillNo(); |  |  |  |         String billNo = generateOrderRequest.getBillNo(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -329,17 +335,32 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         //校验单据的relId有null不生成单据
 |  |  |  |         //校验单据的relId有null不生成单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (!inspectionDocuments(thrInvOrderDetails)) return false; |  |  |  |         if (!inspectionDocuments(thrInvOrderDetails)) return false; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //todo 如果是患者收费明细需要根据患者进行分组拆单而且往来单位为患者信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(generateOrderRequest.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<String> fromCorpList = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Map<String, List<ThrInvOrderDetail>> grouped = new HashMap<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //往来类型为患者,则需要根据患者进行拆单
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             grouped = thrInvOrderDetails.stream() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .collect(Collectors.groupingBy(ThrInvOrderDetail::getSickerCode)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             grouped.put(generateOrderRequest.getFromCorp(), thrInvOrderDetails); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             //新单号
 |  |  |  |             //新单号
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); |  |  |  |             String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             IoOrderEntity ioOrderEntity = new IoOrderEntity(); |  |  |  |             IoOrderEntity ioOrderEntity = new IoOrderEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setBillNo(newBillNo); |  |  |  |             ioOrderEntity.setBillNo(newBillNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); |  |  |  |             ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         ioOrderEntity.setFromCorp(generateOrderRequest.getFromCorp()); |  |  |  |             String fromCorp = addInoutService.updateCorp(bussinessTypeEntity, entry.getValue().get(0).getSickerName(), entry.getKey()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioOrderEntity.setFromCorp(fromCorp); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setInvCode(thrInvOrder.getInvCode()); |  |  |  |             ioOrderEntity.setInvCode(thrInvOrder.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode()); |  |  |  |             ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setAction(generateOrderRequest.getAction()); |  |  |  |             ioOrderEntity.setAction(generateOrderRequest.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
 |  |  |  |             ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
 |  |  |  |             ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
 |  |  |  |             ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -351,8 +372,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setUpdateUser(userId + ""); |  |  |  |             ioOrderEntity.setUpdateUser(userId + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
 |  |  |  |             ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(thrInvOrderDetails.size()); |  |  |  |             List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(grouped.values().size()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (!copyOrderDetailBiz(thrInvOrderDetails, newOrderDetailBiz, newBillNo)) { |  |  |  |             if (!copyOrderDetailBiz(entry.getValue(), newOrderDetailBiz, newBillNo)) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 return false; |  |  |  |                 return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -363,6 +384,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |             thrInvOrderMapper.updateByPrimaryKey(thrInvOrder); |  |  |  |             thrInvOrderMapper.updateByPrimaryKey(thrInvOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); |  |  |  |             ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //        ioAddInoutService.stockGenScan(ioOrderEntity);
 |  |  |  | //        ioAddInoutService.stockGenScan(ioOrderEntity);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         return true; |  |  |  |         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -636,7 +660,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param newOrderDetailBiz |  |  |  |      * @param newOrderDetailBiz | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @return |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private boolean copyOrderDetailBiz(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoOrderDetailBizEntity> newOrderDetailBiz, String newBillNo) { |  |  |  |     private boolean copyOrderDetailBiz | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     (List<ThrInvOrderDetail> thrInvOrderDetails, List<IoOrderDetailBizEntity> newOrderDetailBiz, String | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             newBillNo) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<Long> relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId())) |  |  |  |         List<Long> relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId())) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 .map(ThrInvOrderDetail::getRelId).collect(Collectors.toList()); |  |  |  |                 .map(ThrInvOrderDetail::getRelId).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<BasicProductsEntity> basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds); |  |  |  |         List<BasicProductsEntity> basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds); | 
			
		
	
	
		
		
			
				
					|  |  | @ -661,7 +687,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param newBillNo |  |  |  |      * @param newBillNo | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @return |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private boolean copyIoCodeTemps(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoCodeTempEntity> newIoCodeTemps, String newBillNo, GenerateOrderRequest generateOrderRequest) { |  |  |  |     private boolean copyIoCodeTemps | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     (List<ThrInvOrderDetail> thrInvOrderDetails, List<IoCodeTempEntity> newIoCodeTemps, String | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             newBillNo, GenerateOrderRequest generateOrderRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         thrInvOrderDetails.forEach(item -> { |  |  |  |         thrInvOrderDetails.forEach(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |             IoCodeTempEntity ioCodeTempEntity = new IoCodeTempEntity(); |  |  |  |             IoCodeTempEntity ioCodeTempEntity = new IoCodeTempEntity(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -685,7 +713,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param basicProductsEntity |  |  |  |      * @param basicProductsEntity | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param ioOrderDetailBizEntity |  |  |  |      * @param ioOrderDetailBizEntity | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void parameterPackag(BasicProductsEntity basicProductsEntity, IoOrderDetailBizEntity ioOrderDetailBizEntity, ThrInvOrderDetail thrInvOrderDetail) { |  |  |  |     private void parameterPackag(BasicProductsEntity basicProductsEntity, IoOrderDetailBizEntity | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioOrderDetailBizEntity, ThrInvOrderDetail thrInvOrderDetail) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         ioOrderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); |  |  |  |         ioOrderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (ObjectUtil.isNotNull(basicProductsEntity)) { |  |  |  |         if (ObjectUtil.isNotNull(basicProductsEntity)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             BeanUtils.copyProperties(basicProductsEntity, ioOrderDetailBizEntity); |  |  |  |             BeanUtils.copyProperties(basicProductsEntity, ioOrderDetailBizEntity); | 
			
		
	
	
		
		
			
				
					|  |  | @ -724,7 +753,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param thrInvOrder |  |  |  |      * @param thrInvOrder | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param thrInvResultResponse |  |  |  |      * @param thrInvResultResponse | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void handleExternalConvertThrInvOrder(String billNo, FilterInvProductRequest filterInvProductRequest, ThrInvOrder thrInvOrder, ThrInvResultResponse thrInvResultResponse, Integer SourceType) { |  |  |  |     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);//单据号
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -751,7 +781,9 @@ 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, ThrInvOrder thrInvOrder) { |  |  |  |     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); |  |  |  |             thrInvOrder.setSkProject(0); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |