|  |  | @ -3,12 +3,14 @@ package com.glxp.api.controller.thrsys; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.bean.BeanUtil; |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.ObjectUtil; |  |  |  | import cn.hutool.core.util.ObjectUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.StrUtil; |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.enums.ResultEnum; |  |  |  | import com.glxp.api.common.enums.ResultEnum; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.res.BaseResponse; |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.util.ResultVOUtils; |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.constant.ConstantStatus; |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.UdiEntity; |  |  |  | import com.glxp.api.entity.basic.UdiEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.entity.inout.IoCodeEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; |  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.forthird.ForInvOutScanCodeRequest; |  |  |  | import com.glxp.api.req.forthird.ForInvOutScanCodeRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inv.FilterInvProductRequest; |  |  |  | import com.glxp.api.req.inv.FilterInvProductRequest; | 
			
		
	
	
		
		
			
				
					|  |  | @ -19,6 +21,7 @@ import com.glxp.api.res.inv.InvProductResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.auth.InvWarehouseService; |  |  |  | import com.glxp.api.service.auth.InvWarehouseService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.forthird.impl.ForThirdSysApiService; |  |  |  | import com.glxp.api.service.forthird.impl.ForThirdSysApiService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.service.inout.impl.IoCodeService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inv.InvPreProductDetailService; |  |  |  | import com.glxp.api.service.inv.InvPreProductDetailService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inv.InvPreinProductDetailService; |  |  |  | import com.glxp.api.service.inv.InvPreinProductDetailService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inv.impl.InvProductDetailService; |  |  |  | import com.glxp.api.service.inv.impl.InvProductDetailService; | 
			
		
	
	
		
		
			
				
					|  |  | @ -64,6 +67,9 @@ public class ForThirdSysApiController { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return ResultVOUtils.success(pageSimpleResponse); |  |  |  |         return ResultVOUtils.success(pageSimpleResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoCodeService codeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * B001 查询指定科室高值 |  |  |  |      * B001 查询指定科室高值 | 
			
		
	
		
		
			
				
					
					|  |  |  |      * |  |  |  |      * | 
			
		
	
	
		
		
			
				
					|  |  | @ -77,29 +83,65 @@ public class ForThirdSysApiController { | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         int count = 0; |  |  |  |         int count = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |         UdiEntity udiEntity = FilterUdiUtils.getUdi(filterInvProductRequest.getUdiCode()); |  |  |  |         UdiEntity udiEntity = FilterUdiUtils.getUdi(filterInvProductRequest.getUdiCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<UdiRelevanceResponse> udiRelevanceResponses = null; |  |  |  |         UdiRelevanceResponse checkUdi = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(udiEntity.getUdi(), false); |  |  |  |         if (checkUdi == null) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (udiRelevanceResponses.size() == 0) { |  |  |  |             return ResultVOUtils.error(500, "收费项目未对照!"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             return ResultVOUtils.error("收费项目未对照!"); |  |  |  |         } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         boolean checkSuccess = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String lostMsg = ""; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //校验条码完整性
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if ("是".equals(checkUdi.getScbssfbhph()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             checkSuccess = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lostMsg = lostMsg + ",批次号"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if ("是".equals(checkUdi.getScbssfbhscrq()) && StrUtil.isEmpty(udiEntity.getProduceDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             checkSuccess = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lostMsg = lostMsg + ",生产日期"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if ("是".equals(checkUdi.getScbssfbhsxrq()) && StrUtil.isEmpty(udiEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             checkSuccess = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lostMsg = lostMsg + ",失效日期"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if ("是".equals(checkUdi.getScbssfbhxlh()) && StrUtil.isEmpty(udiEntity.getSerialNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             checkSuccess = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lostMsg = lostMsg + ",序列号"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(504, "序列号超出20位!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (StrUtil.isNotEmpty(udiEntity.getBatchNo()) && udiEntity.getBatchNo().length() > 20) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(504, "批次号超出20位!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (StrUtil.isEmpty(udiEntity.getSerialNo()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             checkSuccess = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (!checkSuccess) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error("UDI码格式错误:缺少" + lostMsg); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCodeEntity codeEntity = codeService.getOne(new QueryWrapper<IoCodeEntity>().likeLeft("code", filterInvProductRequest.getUdiCode()).last("limit 1")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (codeEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error("库存未找到该UDI码,请检查该UDI是否存在错误!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         //1.获取预验收库存
 |  |  |  |         //1.获取预验收库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         InvWarehouseEntity preInInv = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN); |  |  |  |         InvWarehouseEntity preInInv = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (StrUtil.isNotEmpty(udiEntity.getSerialNo())) { |  |  |  |         if (StrUtil.isNotEmpty(udiEntity.getSerialNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             count = invPreinProductDetailService.vailStockCountByCode(null, preInInv.getCode(), null, filterInvProductRequest.getUdiCode()); |  |  |  |             count = invPreinProductDetailService.vailStockCountByCode(null, preInInv.getCode(), null, filterInvProductRequest.getUdiCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else |  |  |  |         } else | 
			
		
	
		
		
			
				
					
					|  |  |  |             count = invPreinProductDetailService.vailStockCount(udiRelevanceResponses.get(0).getRelId(), udiEntity.getBatchNo(), null, null, preInInv.getCode(), null); |  |  |  |             count = invPreinProductDetailService.vailStockCount(checkUdi.getRelId(), udiEntity.getBatchNo(), null, null, preInInv.getCode(), null); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (count == 0) { |  |  |  |         if (count == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             //2.获取寄售库存
 |  |  |  |             //2.获取寄售库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             InvWarehouseEntity preInv = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE); |  |  |  |             InvWarehouseEntity preInv = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE); | 
			
		
	
		
		
			
				
					
					|  |  |  |             count = invPreProductDetailService.vailStockCount(udiRelevanceResponses.get(0).getRelId(), udiEntity.getBatchNo(), null, null, preInv.getCode(), null); |  |  |  |             count = invPreProductDetailService.vailStockCount(checkUdi.getRelId(), udiEntity.getBatchNo(), null, null, preInv.getCode(), null); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (count == 0) { |  |  |  |         if (count == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             //3.获取入账库库存
 |  |  |  |             //3.获取入账库库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             count = invProductDetailService.vailStockCount(udiRelevanceResponses.get(0).getRelId(), udiEntity.getBatchNo(), null, null, filterInvProductRequest.getInvCode(), null, true); |  |  |  |             count = invProductDetailService.vailStockCount(checkUdi.getRelId(), udiEntity.getBatchNo(), null, null, filterInvProductRequest.getInvCode(), null, true); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         InvProductResponse invProductResponse = new InvProductResponse(); |  |  |  |         InvProductResponse invProductResponse = new InvProductResponse(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         BeanUtil.copyProperties(udiRelevanceResponses.get(0), invProductResponse); |  |  |  |         BeanUtil.copyProperties(checkUdi, invProductResponse); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         invProductResponse.setReCount(count); |  |  |  |         invProductResponse.setReCount(count); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         PageSimpleResponse<InvProductResponse> pageSimpleResponse = new PageSimpleResponse<>(); |  |  |  |         PageSimpleResponse<InvProductResponse> pageSimpleResponse = new PageSimpleResponse<>(); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |