|  |  | @ -1,6 +1,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.glxp.api.service.collect; |  |  |  | package com.glxp.api.service.collect; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.collection.CollUtil; |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.github.pagehelper.PageHelper; |  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
	
		
		
			
				
					|  |  | @ -10,8 +11,11 @@ import com.glxp.api.entity.basic.BasicSkPrescribeEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity; |  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.collect.IoCollectOrder; |  |  |  | import com.glxp.api.entity.collect.IoCollectOrder; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.collect.IoCollectOrderBiz; |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderBiz; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderCodeMan; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.inout.IoOrderDetailBizEntity; |  |  |  | import com.glxp.api.entity.inout.IoOrderDetailBizEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.collect.CollectOrderRequest; |  |  |  | import com.glxp.api.req.collect.CollectOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.inout.DeleteTageCodeRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.FilterOrderRequest; |  |  |  | import com.glxp.api.req.inout.FilterOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.collect.IoCollectOrderResponse; |  |  |  | import com.glxp.api.res.collect.IoCollectOrderResponse; | 
			
		
	
	
		
		
			
				
					|  |  | @ -25,6 +29,7 @@ import com.glxp.api.service.inout.IoOrderService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.IntUtil; |  |  |  | import com.glxp.api.util.IntUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.MsDateUtil; |  |  |  | import com.glxp.api.util.MsDateUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.ArrayList; | 
			
		
	
	
		
		
			
				
					|  |  | @ -37,6 +42,8 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Resource |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |     IoCollectOrderMapper collectOrderMapper; |  |  |  |     IoCollectOrderMapper collectOrderMapper; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoCollectOrderCodeManService ioCollectOrderCodeManService; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public IoCollectOrder getByBillNo(String billNo) { |  |  |  |     public IoCollectOrder getByBillNo(String billNo) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return collectOrderMapper.selectOne(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, billNo).last("limit 1")); |  |  |  |         return collectOrderMapper.selectOne(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, billNo).last("limit 1")); | 
			
		
	
	
		
		
			
				
					|  |  | @ -206,4 +213,42 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public void removeCode(DeleteTageCodeRequest deleteTageCodeRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer delType = deleteTageCodeRequest.getDelType(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Long codeManId = deleteTageCodeRequest.getCodeManId(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCollectOrderCodeMan ioCollectOrderCodeMan = ioCollectOrderCodeManService.getById(codeManId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (ioCollectOrderCodeMan == null) throw  new JsonException("码明细id有误"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String bizIdFk = ioCollectOrderCodeMan.getBizIdFk(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer scanCount = ioCollectOrderCodeMan.getScanCount(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer delCount = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (delType == 1){//1.减一,,,IoCollectOrderCodeMan-1    IoCollectOrderBiz-1
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer newCount = scanCount - 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             delCount = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (newCount == 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 ioCollectOrderCodeManService.removeById(codeManId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 ioCollectOrderCodeMan.setScanCount(newCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 ioCollectOrderCodeManService.updateById(ioCollectOrderCodeMan); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }else if (delType == 2){//2.删除     IoCollectOrderCodeMan-删除    IoCollectOrderBiz-数量
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             delCount = scanCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ioCollectOrderCodeManService.removeById(codeManId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (delCount >0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             IoCollectOrderBiz bizServiceOne = collectOrderBizService.getOne(new LambdaQueryWrapper<IoCollectOrderBiz>() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .eq(IoCollectOrderBiz::getId, bizIdFk)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (bizServiceOne == null)  throw  new JsonException("扫码详情未查找到"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer count = bizServiceOne.getCount(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer newCount = count - delCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (newCount > 0){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 bizServiceOne.setCount(newCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 collectOrderBizService.updateById(bizServiceOne); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 collectOrderBizService.removeById(bizServiceOne.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |