|  |  | @ -1,9 +1,16 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.glxp.api.service.inout.impl; |  |  |  | package com.glxp.api.service.inout.impl; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.collection.CollUtil; |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.constant.ConstantType; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.entity.basic.UdiEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.entity.inout.*; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.inout.*; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.res.inout.*; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.service.basic.UdiProductService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.service.inout.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.purchase.SupCertService; |  |  |  | import com.glxp.api.service.purchase.SupCertService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.purchase.SupProductService; |  |  |  | import com.glxp.api.service.purchase.SupProductService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.DateUtil; |  |  |  | import com.glxp.api.util.*; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.IdUtil; |  |  |  | import cn.hutool.core.util.IdUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.StrUtil; |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
	
		
		
			
				
					|  |  | @ -19,47 +26,29 @@ import com.glxp.api.entity.auth.AuthAdmin; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; |  |  |  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.UdiProductEntity; |  |  |  | import com.glxp.api.entity.basic.UdiProductEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderDetailBizEntity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderDetailCodeEntity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderEntity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderInvoiceEntity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.purchase.SupCertEntity; |  |  |  | import com.glxp.api.entity.purchase.SupCertEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.purchase.SupProductEntity; |  |  |  | import com.glxp.api.entity.purchase.SupProductEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.system.SystemParamConfigEntity; |  |  |  | import com.glxp.api.entity.system.SystemParamConfigEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.exception.JsonException; |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; |  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.AddBizProductReqeust; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.AddWarlockBagProductReqeust; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.FilterOrderDetailBizRequest; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.FilterOrderDetailCodeRequest; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inout.IoOrderDetailBizResponse; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inout.IoOrderDetailCodeResponse; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inout.IoOrderDetailResultResponse; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inout.IoOrderInvoiceResponse; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.auth.CustomerService; |  |  |  | import com.glxp.api.service.auth.CustomerService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.auth.InvWarehouseService; |  |  |  | import com.glxp.api.service.auth.InvWarehouseService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.BasicSkProjectService; |  |  |  | import com.glxp.api.service.basic.BasicSkProjectService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; |  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inout.IoCheckInoutService; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inout.IoOrderDetailBizService; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inout.IoOrderDetailCodeService; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inout.IoOrderService; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.system.SystemParamConfigService; |  |  |  | import com.glxp.api.service.system.SystemParamConfigService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.GennerOrderUtils; |  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.IntUtil; |  |  |  | import com.glxp.api.util.udi.UdiCalCountUtil; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.OrderNoTypeBean; |  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.beans.BeanUtils; |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.context.annotation.Lazy; |  |  |  | import org.springframework.context.annotation.Lazy; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.transaction.annotation.Transactional; |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Collections; |  |  |  | import java.util.stream.Collectors; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Date; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | @Service |  |  |  | @Service | 
			
		
	
		
		
			
				
					
					|  |  |  | @Transactional(rollbackFor = Exception.class) |  |  |  | @Transactional(rollbackFor = Exception.class) | 
			
		
	
	
		
		
			
				
					|  |  | @ -664,4 +653,386 @@ public class IoOrderDetailBizServiceImpl implements IoOrderDetailBizService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return ioOrderDetailBizDao.updateById(ioOrderDetailBizEntity) > 0; |  |  |  |         return ioOrderDetailBizDao.updateById(ioOrderDetailBizEntity) > 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoSplitFifoCodeService fifoCodeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private IoCodeTempService codeTempService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoAddInoutService transInoutService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     UdiProductService udiProductService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     UdiCalCountUtil udiCalCountUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoCodeLostService codeLostService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoAddInoutService ioAddInoutService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoOrderDetailCodeService ioOrderDetailCodeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoSplitFifoCodeService splitFifoCodeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse adddDrugOrder(AddOrderRequest addOrderRequest, UdiEntity udiEntity, String code) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         AddCodeResult addCodeResult = new AddCodeResult(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(addOrderRequest.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //批次号校验
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //判断此产品是否开启允许无批次号
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         UdiProductEntity udiInfoEntity = udiProductService.findByNameCode(udiEntity.getUdi()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (udiInfoEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(500, "药品字典不存在此产品!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (StrUtil.isEmpty(udiEntity.getBatchNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             IoCodeLostEntity codeLostEntity = codeLostService.findByCode(addOrderRequest.getCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (codeLostEntity != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiEntity.setBatchNo(codeLostEntity.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiEntity.setProduceDate(codeLostEntity.getProduceDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiEntity.setExpireDate(codeLostEntity.getExpireDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String orderId = addOrderRequest.getBillNo(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //过期提醒:
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (IntUtil.value(bussinessTypeEntity.getCheckExpire()) == 1 && !addOrderRequest.isIgnoreExpire()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String expireDate = "20" + udiEntity.getExpireDate(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long expireTime = MsDateUtil.parseDateExpire(expireDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (expireTime - System.currentTimeMillis() < 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(504, "当前产品已过期,是否确定继续添加?"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (IntUtil.value(bussinessTypeEntity.getCheckExpire()) == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String expireDate = "20" + udiEntity.getExpireDate(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long expireTime = MsDateUtil.parseDateExpire(expireDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (expireTime - System.currentTimeMillis() < 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(604, "当前产品已过期,无法添加!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //近效期提醒
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         long recent = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (udiRelevanceResponse.getRecentDateTime() != null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             recent = udiRelevanceResponse.getRecentDateTime().longValue(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (IntUtil.value(bussinessTypeEntity.getCheckVailDate()) == 1 && recent > 0 && !addOrderRequest.isIgnoreRecentExpire() && udiRelevanceResponse.getIsDateBy() == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String expireDate = "20" + udiEntity.getExpireDate(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long expireTime = MsDateUtil.parseDateExpire(expireDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long recentTieme = Math.abs(recent * 24 * 60 * 60 * 1000); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long resultTime = expireTime - System.currentTimeMillis(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (resultTime > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     long time = resultTime / (60 * 60 * 1000); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (resultTime < recentTieme) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         return ResultVOUtils.error(505, "当前产品临近过期,距过期还剩" + time + "时,是否确定继续添加?"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (IntUtil.value(bussinessTypeEntity.getCheckVailDate()) == 1 && recent > 0 && !addOrderRequest.isIgnoreRecentExpire() && udiRelevanceResponse.getIsDateBy() == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String expireDate = "20" + udiEntity.getExpireDate(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long expireTime = MsDateUtil.parseDateExpire(expireDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long recentTieme = Math.abs(recent * 24 * 60 * 60 * 1000); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 long resultTime = expireTime - System.currentTimeMillis(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (resultTime > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     long time = resultTime / (24 * 60 * 60 * 1000); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (resultTime < recentTieme) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         return ResultVOUtils.error(505, "当前产品临近过期,距过期还剩" + time + "天,是否确定继续添加?"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //校验工位存量是否存在
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (bussinessTypeEntity.getAction().equals(ConstantType.SPLIT_OUT)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             IoSplitFifoCodeEntity fifoCodeEntity = fifoCodeService.findByCode(code, null); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (fifoCodeEntity != null && StrUtil.isNotEmpty(fifoCodeEntity.getSerialNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 return ResultVOUtils.error(500, "当前追溯码已存在!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (addOrderRequest.getFromCorp() == null || StrUtil.isNotEmpty(addOrderRequest.getSickerAdNum())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String fromCorp = ioAddInoutService.updateCorp(bussinessTypeEntity, addOrderRequest.getFromCorp(), addOrderRequest.getSickerAdNum()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             addOrderRequest.setFromCorp(fromCorp); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //先生成扫码单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoOrderEntity orderEntity = orderService.findByBillNo(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String inBatch = ""; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (org.apache.commons.lang3.StringUtils.isBlank(orderId) || orderEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             orderId = orderNo; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         inBatch = orderId.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeTempEntity> codeEnttitys = codeTempService.findByOrderId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCodeTempEntity exitLocalEntity = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCodeTempEntity genDetaiEntity = new IoCodeTempEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<UdiRelevanceResponse> udiRelevanceResponses = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (codeEnttitys.size() > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             exitLocalEntity = isExitLocal(code, codeEnttitys); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (exitLocalEntity != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (StrUtil.isEmpty(exitLocalEntity.getSupId()) || exitLocalEntity.getRelId() == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "当前药品追溯码已存在,且存在异常未处理!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(exitLocalEntity.getNameCode(), null); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 BeanUtils.copyProperties(exitLocalEntity, genDetaiEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 genDetaiEntity.setCount(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 exitLocalEntity.setCount(exitLocalEntity.getMyCount() + 1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (!StringUtils.isBlank(exitLocalEntity.getSerialNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "重复扫码!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (exitLocalEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             IoCodeTempEntity codeEnttity = new IoCodeTempEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setCode(code); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setOrderId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setCorpOrderId(addOrderRequest.getCorpOrderId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setMainAction(bussinessTypeEntity.getMainAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setAction(bussinessTypeEntity.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setNameCode(udiEntity.getUdi()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setBatchNo(udiEntity.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setProduceDate(udiEntity.getProduceDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setExpireDate(udiEntity.getExpireDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setSerialNo(udiEntity.getSerialNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setDeptCode(invWarehouseEntity.getParentId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setInvCode(addOrderRequest.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setWarehouseCode(addOrderRequest.getCurSpaceCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setPreSpaceCode(addOrderRequest.getPreCurSpaceCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setPreInSpaceCode(addOrderRequest.getCheckPreInSpaceCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setRelId(addOrderRequest.getRelId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setFifoSplit(addOrderRequest.getFifoSplit()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setProductType(2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setCount(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String unitFk = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 unitFk = addOrderRequest.getFromCorp(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else if (StrUtil.isNotEmpty(addOrderRequest.getSelectSupId())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 unitFk = addOrderRequest.getSelectSupId(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //产品是否禁用
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(codeEnttity.getNameCode(), false); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (udiRelevanceResponses.size() >= 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (udiRelevanceResponse == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "该产品信息未维护!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } else if (!udiRelevanceResponse.getUseDy() && udiRelevanceResponse.getDiType() == ConstantStatus.DITYPE_SYDY) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "该产品不允许以使用单元入库!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (bussinessTypeEntity.isVailDispatch() && !udiRelevanceResponse.isDispatch()) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return ResultVOUtils.error(500, "该产品不可配送,请联系院方!");
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (bussinessTypeEntity.getVailGroupBuy() == 1 && !udiRelevanceResponse.isGroupBuy()) {       //只采集集采产品
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return ResultVOUtils.error(500, bussinessTypeEntity.getName() + "单只允许录入集采产品!");
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (bussinessTypeEntity.getVailGroupBuy() == 2 && udiRelevanceResponse.isGroupBuy()) {        //只采集非集采产品
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return ResultVOUtils.error(500, bussinessTypeEntity.getName() + "单只允许录入非集采产品!");
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (IntUtil.value(addOrderRequest.getFifoSplit()) == 2 && IntUtil.value(udiRelevanceResponse.getSplitEnable())) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return ResultVOUtils.error(500, "当前上货只允许录入整取产品!");
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (IntUtil.value(addOrderRequest.getFifoSplit()) == 1 && !IntUtil.value(udiRelevanceResponse.getSplitEnable())) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return ResultVOUtils.error(500, "当前上货只允许录入拆零产品!");
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //计算实际数量
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else if (udiRelevanceResponses.size() == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (unitFk == null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "耗材字典不存在此产品!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return ResultVOUtils.error(500, "当前供应商不存在此配送产品!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            //校验供应商是否配送此产品
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            BaseResponse corpResponse = checkCorp(codeEnttity, bussinessTypeEntity, unitFk);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            if (corpResponse != null) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                return corpResponse;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             IoOrderEntity isExit = orderService.findByBillNo(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (isExit == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity = new IoOrderEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setBillNo(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setCorpOrderId(addOrderRequest.getCorpOrderId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setMainAction(bussinessTypeEntity.getMainAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setAction(bussinessTypeEntity.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setFromCorp(addOrderRequest.getFromCorp()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (StrUtil.isNotEmpty(addOrderRequest.getFromInvCode())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvWarehouseEntity invWarehouseEntity1 = invWarehouseService.findByInvSubByCode(addOrderRequest.getFromInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     orderEntity.setFromDeptCode(invWarehouseEntity1.getParentId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setFromInvCode(addOrderRequest.getFromInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setFromType(ConstantStatus.FROM_WEBNEW); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 AuthAdmin authAdmin = customerService.getUserBean(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setCreateUser(authAdmin.getId() + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setUpdateUser(authAdmin.getId() + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setCustomerId(authAdmin.getCustomerId() + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setDeptCode(invWarehouseEntity.getParentId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setCheckPreInOrders(addOrderRequest.getCheckPreInOrders()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setInvCode(addOrderRequest.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setOrderType(addOrderRequest.getOrderType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setBusType(bussinessTypeEntity.getBusType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setSickerAdNum(addOrderRequest.getSickerAdNum()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setWorkPlaceCode(addOrderRequest.getWorkPlaceCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setSplitBusType(addOrderRequest.getSplitBusType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setFifoSplit(addOrderRequest.getFifoSplit()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setSplitBusType(addOrderRequest.getSplitBusType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderEntity.setProductType(2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 orderService.insertOrder(orderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             BaseResponse baseResponse = checkDrugRelId(codeEnttity, unitFk); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (baseResponse != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 deleteEmptyBillNo(orderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             genDetaiEntity = codeEnttity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            if (baseResponse == null) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                baseResponse = checkSupId(bussinessTypeEntity, codeEnttity, unitFk);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (baseResponse != null)
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return baseResponse;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            } else {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                if (baseResponse.getCode() == 501) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return baseResponse;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                } else if (baseResponse.getCode() == 502) {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    return baseResponse;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                checkSupId(bussinessTypeEntity, codeEnttity, unitFk);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                return baseResponse;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            }
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeTempService.insert(codeEnttity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         addCodeResult.setOrderId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return ResultVOUtils.success(addCodeResult); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 判断本单是否存在 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param code | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param codeEnttityList | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public IoCodeTempEntity isExitLocal(String code, List<IoCodeTempEntity> codeEnttityList) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeTempEntity> codeTempEntities = isExitLocalList(code, codeEnttityList); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (CollUtil.isNotEmpty(codeTempEntities)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return codeTempEntities.get(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse checkDrugRelId(IoCodeTempEntity codeEnttity, String unitFk) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.selectDrugsByNameCode(codeEnttity, unitFk); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 1 && codeEnttity.getRelId() == null) {//同一个DI绑定多个产品西信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            codeEnttity.setRelId(null);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            codeEnttity.setStatus(ConstantStatus.ORDER_DETAIL_DI_MUTI);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            codeTempService.insert(codeEnttity);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //            codeEnttity = codeTempService.findByUnique(codeEnttity.getOrderId(), codeEnttity.getCode());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             BaseResponse baseResponse = ResultVOUtils.error(502, "DI绑定多个产品ID,请指定对应产品"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             baseResponse.setData(codeEnttity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return baseResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else if (udiRelevanceEntities == null || udiRelevanceEntities.size() == 0) {//未找到产品信息,一般不会出现
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setRelId(null); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setStatus(2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(501, "耗材字典不存在此产品!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             codeEnttity.setStatus(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (codeEnttity.getRelId() == null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 codeEnttity.setRelId(udiRelevanceEntities.get(0).getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public void deleteEmptyBillNo(IoOrderEntity orderEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         boolean r1 = orderDetailBizService.isExit(orderEntity.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         boolean r2 = ioOrderDetailCodeService.isExit(orderEntity.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         boolean r3 = codeTempService.isExit(orderEntity.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (!r1 && !r2 && !r3) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             orderService.deleteByBillNo(orderEntity.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public List<IoCodeTempEntity> isExitLocalList(String code, List<IoCodeTempEntity> codeEnttityList) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         UdiEntity udiEntity = FilterUdiUtils.getUdi(code); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeTempEntity> codeTempEntities = codeEnttityList.stream() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .filter(item -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (item.getCode().equals(code)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (StrUtil.emptyIfNull(item.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (!StrUtil.emptyIfNull(item.getNameCode()).equals(StrUtil.emptyIfNull(udiEntity.getUdi()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (!StrUtil.emptyIfNull(item.getBatchNo()).toUpperCase(Locale.ROOT).equals(StrUtil.emptyIfNull(udiEntity.getBatchNo()).toUpperCase(Locale.ROOT))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (!StrUtil.emptyIfNull(item.getProduceDate()).equals(StrUtil.emptyIfNull(udiEntity.getProduceDate()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (!StrUtil.emptyIfNull(item.getExpireDate()).equals(StrUtil.emptyIfNull(udiEntity.getExpireDate()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (!StrUtil.emptyIfNull(item.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 }).sorted(Comparator.comparing(IoCodeTempEntity::getInBatchNo)).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Collections.reverse(codeTempEntities); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return codeTempEntities; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |