|  |  |  | @ -5,7 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableField; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
			
		
	
		
			
				
					|  |  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.collect.IoCollectOrderMapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.SysWorkplace; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicCollectBustypeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity; | 
			
		
	
	
		
			
				
					|  |  |  | @ -13,6 +15,7 @@ import com.glxp.api.entity.collect.IoCollectOrder; | 
			
		
	
		
			
				
					|  |  |  |  | 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.IoOrderEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.collect.CollectOrderRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inout.DeleteTageCodeRequest; | 
			
		
	
	
		
			
				
					|  |  |  | @ -20,22 +23,22 @@ import com.glxp.api.req.inout.FilterOrderRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.collect.IoCollectOrderResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inout.IoOrderResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.auth.SysWorkplaceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.BasicCollectBustypeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.BasicSkPrescirbeDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.BasicSkPrescribeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inout.IoCodeTempService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inout.IoOrderDetailBizService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inout.IoOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inout.impl.IoCodeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.IntUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.MsDateUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Collections; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Date; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  |  | public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoCollectOrder> { | 
			
		
	
	
		
			
				
					|  |  |  | @ -85,15 +88,49 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |         importPrescribe(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoOrderDetailBizService orderDetailCodeService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCodeTempService codeTempService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCodeService codeService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void clearOrder() { | 
			
		
	
		
			
				
					|  |  |  |  |         collectOrderMapper.clearOrder(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderEntity> orderEntities = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderEntity> orderEntities1 = orderService.findAllByAction("SC72197936495755"); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderEntity> orderEntities2 = orderService.findAllByAction("SC72249388338364"); | 
			
		
	
		
			
				
					|  |  |  |  |         orderEntities.addAll(orderEntities1); | 
			
		
	
		
			
				
					|  |  |  |  |         orderEntities.addAll(orderEntities2); | 
			
		
	
		
			
				
					|  |  |  |  |         orderEntities.parallelStream().forEach(item -> | 
			
		
	
		
			
				
					|  |  |  |  |                 { | 
			
		
	
		
			
				
					|  |  |  |  |                     List<String> delBillNos = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     delBillNos.add(item.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                     orderService.deleteInvByBillNo(delBillNos); | 
			
		
	
		
			
				
					|  |  |  |  |                     for (String billNo : delBillNos) { | 
			
		
	
		
			
				
					|  |  |  |  |                         orderService.deleteByBillNo(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                         orderDetailBizService.deleteByOrderId(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                         orderDetailCodeService.deleteByOrderId(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                         codeTempService.deleteByBillNo(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                         codeService.deleteCodeByOrderId(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |         ); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     SysWorkplaceService sysWorkplaceService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void importUdi() { | 
			
		
	
		
			
				
					|  |  |  |  |         //下载UDI内部单据
 | 
			
		
	
		
			
				
					|  |  |  |  |         FilterOrderRequest filterOrderRequest = new FilterOrderRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |         filterOrderRequest.setPage(1); | 
			
		
	
		
			
				
					|  |  |  |  |         filterOrderRequest.setLimit(1000); | 
			
		
	
		
			
				
					|  |  |  |  | //        filterOrderRequest.setPage(1);
 | 
			
		
	
		
			
				
					|  |  |  |  | //        filterOrderRequest.setLimit(1000);
 | 
			
		
	
		
			
				
					|  |  |  |  |         filterOrderRequest.setStatus(7); | 
			
		
	
		
			
				
					|  |  |  |  |         filterOrderRequest.setProductType(null); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderResponse> list = orderService.filterList(filterOrderRequest); | 
			
		
	
	
		
			
				
					|  |  |  | @ -105,11 +142,39 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |             if (collectOrderMapper.exists(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, ioOrderEntity.getBillNo()))) { | 
			
		
	
		
			
				
					|  |  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             //自动分配工位
 | 
			
		
	
		
			
				
					|  |  |  |  |             final Long[] defaultWorkplace = {null}; | 
			
		
	
		
			
				
					|  |  |  |  |             List<SysWorkplace> sysWorkplaces = sysWorkplaceService.getAllByBusType(collectBustypeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isNotEmpty(sysWorkplaces)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (sysWorkplaces.size() == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     defaultWorkplace[0] = sysWorkplaces.get(0).getWorkplaceId(); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     List<SysWorkplace> addWorkplace = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     for (SysWorkplace sysWorkplace : sysWorkplaces) { | 
			
		
	
		
			
				
					|  |  |  |  |                         //获取是否有正在处理的工位
 | 
			
		
	
		
			
				
					|  |  |  |  |                         List<IoCollectOrder> collectOrderList1 = collectOrderMapper.selectList(new LambdaQueryWrapper<IoCollectOrder>() | 
			
		
	
		
			
				
					|  |  |  |  |                                 .eq(IoCollectOrder::getWorkPlaceCode, sysWorkplace.getWorkplaceId()).in(IoCollectOrder::getTagStatus, -1, 1, 2)); | 
			
		
	
		
			
				
					|  |  |  |  |                         sysWorkplace.setOrderCount(collectOrderList1.size()); | 
			
		
	
		
			
				
					|  |  |  |  |                         if (IntUtil.value(sysWorkplace.getOrderCount()) > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                             addWorkplace.add(sysWorkplace); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (addWorkplace.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         Optional<SysWorkplace> minCountObject = addWorkplace.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                                 .min((o1, o2) -> Integer.compare(o1.getOrderCount(), o2.getOrderCount())); | 
			
		
	
		
			
				
					|  |  |  |  |                         minCountObject.ifPresent(sysWorkplace -> defaultWorkplace[0] = sysWorkplace.getWorkplaceId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         defaultWorkplace[0] = sysWorkplaces.get(0).getWorkplaceId(); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             IoCollectOrder collectOrder = IoCollectOrder.builder() | 
			
		
	
		
			
				
					|  |  |  |  |                     .billNo(ioOrderEntity.getBillNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .busType(collectBustypeEntity.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .fromType(collectBustypeEntity.getFromType()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .fromCorp(ioOrderEntity.getFromName()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .workPlaceCode(defaultWorkplace[0]) | 
			
		
	
		
			
				
					|  |  |  |  |                     .billTime(ioOrderEntity.getCreateTime()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .createTime(ioOrderEntity.getCreateTime()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .createUser(ioOrderEntity.getCreateUser()) | 
			
		
	
	
		
			
				
					|  |  |  | @ -117,6 +182,9 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |                     .splitStatus(0) | 
			
		
	
		
			
				
					|  |  |  |  |                     .tagStatus(0) | 
			
		
	
		
			
				
					|  |  |  |  |                     .build(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (collectOrder.getWorkPlaceCode() != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrder.setTagStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderList.add(collectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(ioOrderEntity.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -162,16 +230,47 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrder> collectOrderList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         for (BasicSkPrescribeEntity basicSkPrescribeEntity : basicSkPrescribeEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |             BasicCollectBustypeEntity collectBustypeEntity = collectBustypeService.findByAddr(String.valueOf(basicSkPrescribeEntity.getAddr())); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (collectBustypeEntity == null) | 
			
		
	
		
			
				
					|  |  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |  |             if (collectOrderMapper.exists(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, basicSkPrescribeEntity.getCode()))) { | 
			
		
	
		
			
				
					|  |  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             //自动分配工位
 | 
			
		
	
		
			
				
					|  |  |  |  |             final Long[] defaultWorkplace = {null}; | 
			
		
	
		
			
				
					|  |  |  |  |             List<SysWorkplace> sysWorkplaces = sysWorkplaceService.getAllByBusType(collectBustypeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isNotEmpty(sysWorkplaces)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (sysWorkplaces.size() == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     defaultWorkplace[0] = sysWorkplaces.get(0).getWorkplaceId(); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     List<SysWorkplace> addWorkplace = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     for (SysWorkplace sysWorkplace : sysWorkplaces) { | 
			
		
	
		
			
				
					|  |  |  |  |                         //获取是否有正在处理的工位
 | 
			
		
	
		
			
				
					|  |  |  |  |                         List<IoCollectOrder> collectOrderList1 = collectOrderMapper.selectList(new LambdaQueryWrapper<IoCollectOrder>() | 
			
		
	
		
			
				
					|  |  |  |  |                                 .eq(IoCollectOrder::getWorkPlaceCode, sysWorkplace.getWorkplaceId()).in(IoCollectOrder::getTagStatus, -1, 1, 2)); | 
			
		
	
		
			
				
					|  |  |  |  |                         sysWorkplace.setOrderCount(collectOrderList1.size()); | 
			
		
	
		
			
				
					|  |  |  |  |                         if (IntUtil.value(sysWorkplace.getOrderCount()) > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                             addWorkplace.add(sysWorkplace); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (addWorkplace.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         Optional<SysWorkplace> minCountObject = addWorkplace.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                                 .min((o1, o2) -> Integer.compare(o1.getOrderCount(), o2.getOrderCount())); | 
			
		
	
		
			
				
					|  |  |  |  |                         minCountObject.ifPresent(sysWorkplace -> defaultWorkplace[0] = sysWorkplace.getWorkplaceId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         defaultWorkplace[0] = sysWorkplaces.get(0).getWorkplaceId(); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             IoCollectOrder collectOrder = IoCollectOrder.builder() | 
			
		
	
		
			
				
					|  |  |  |  |                     .billNo(basicSkPrescribeEntity.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .busType(collectBustypeEntity.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .fromType(collectBustypeEntity.getFromType()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .fromCorp(basicSkPrescribeEntity.getSickerCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .workPlaceCode(defaultWorkplace[0]) | 
			
		
	
		
			
				
					|  |  |  |  |                     .billTime(MsDateUtil.localToDate(basicSkPrescribeEntity.getCreateTime())) | 
			
		
	
		
			
				
					|  |  |  |  |                     .createTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .createUser(basicSkPrescribeEntity.getCreateUser()) | 
			
		
	
	
		
			
				
					|  |  |  | @ -179,6 +278,9 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |                     .splitStatus(0) | 
			
		
	
		
			
				
					|  |  |  |  |                     .tagStatus(0) | 
			
		
	
		
			
				
					|  |  |  |  |                     .build(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (collectOrder.getWorkPlaceCode() != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrder.setTagStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderList.add(collectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |             List<BasicSkPrescribeItemEntity> basicSkPrescribeItemEntities = basicSkPrescirbeDetailService.findByPrescribeNum(basicSkPrescribeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -199,10 +301,10 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |                         .tagStatus(1) | 
			
		
	
		
			
				
					|  |  |  |  |                         .unTagCount(bizEntity.getCount()).build(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //                if (IntUtil.value(udiRelevanceResponse.getProductsType()) == 2) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    collectOrderBiz.setGgxh(udiRelevanceResponse.getBzgg());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    collectOrderBiz.setMeasureUnit(udiRelevanceResponse.getPrepnUnit());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (IntUtil.value(udiRelevanceResponse.getProductsType()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setGgxh(udiRelevanceResponse.getBzgg()); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setMeasureUnit(udiRelevanceResponse.getPrepnUnit()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBizs.add(collectOrderBiz); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isNotEmpty(collectOrderBizs)) | 
			
		
	
	
		
			
				
					|  |  |  | @ -218,34 +320,34 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC | 
			
		
	
		
			
				
					|  |  |  |  |         Integer delType = deleteTageCodeRequest.getDelType(); | 
			
		
	
		
			
				
					|  |  |  |  |         Long codeManId = deleteTageCodeRequest.getCodeManId(); | 
			
		
	
		
			
				
					|  |  |  |  |         IoCollectOrderCodeMan ioCollectOrderCodeMan = ioCollectOrderCodeManService.getById(codeManId); | 
			
		
	
		
			
				
					|  |  |  |  |         if (ioCollectOrderCodeMan == null) throw  new JsonException("码明细id有误"); | 
			
		
	
		
			
				
					|  |  |  |  |         String bizIdFk = ioCollectOrderCodeMan.getBizIdFk(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (ioCollectOrderCodeMan == null) throw new JsonException("码明细id有误"); | 
			
		
	
		
			
				
					|  |  |  |  |         Long bizIdFk = ioCollectOrderCodeMan.getBizIdFk(); | 
			
		
	
		
			
				
					|  |  |  |  |         Integer scanCount = ioCollectOrderCodeMan.getScanCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         Integer delCount = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         if (delType == 1){//1.减一,,,IoCollectOrderCodeMan-1    IoCollectOrderBiz-1
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (delType == 1) {//1.减一,,,IoCollectOrderCodeMan-1    IoCollectOrderBiz-1
 | 
			
		
	
		
			
				
					|  |  |  |  |             Integer newCount = scanCount - 1; | 
			
		
	
		
			
				
					|  |  |  |  |             delCount = 1; | 
			
		
	
		
			
				
					|  |  |  |  |             if (newCount == 0){ | 
			
		
	
		
			
				
					|  |  |  |  |             if (newCount == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 ioCollectOrderCodeManService.removeById(codeManId); | 
			
		
	
		
			
				
					|  |  |  |  |             }else { | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 ioCollectOrderCodeMan.setScanCount(newCount); | 
			
		
	
		
			
				
					|  |  |  |  |                 ioCollectOrderCodeManService.updateById(ioCollectOrderCodeMan); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         }else if (delType == 2){//2.删除     IoCollectOrderCodeMan-删除    IoCollectOrderBiz-数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (delType == 2) {//2.删除     IoCollectOrderCodeMan-删除    IoCollectOrderBiz-数量
 | 
			
		
	
		
			
				
					|  |  |  |  |             delCount = scanCount; | 
			
		
	
		
			
				
					|  |  |  |  |             ioCollectOrderCodeManService.removeById(codeManId); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (delCount >0){ | 
			
		
	
		
			
				
					|  |  |  |  |         if (delCount > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             IoCollectOrderBiz bizServiceOne = collectOrderBizService.getOne(new LambdaQueryWrapper<IoCollectOrderBiz>() | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq(IoCollectOrderBiz::getId, bizIdFk)); | 
			
		
	
		
			
				
					|  |  |  |  |             if (bizServiceOne == null)  throw  new JsonException("扫码详情未查找到"); | 
			
		
	
		
			
				
					|  |  |  |  |             if (bizServiceOne == null) throw new JsonException("扫码详情未查找到"); | 
			
		
	
		
			
				
					|  |  |  |  |             Integer count = bizServiceOne.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |             Integer newCount = count - delCount; | 
			
		
	
		
			
				
					|  |  |  |  |             if (newCount > 0){ | 
			
		
	
		
			
				
					|  |  |  |  |             if (newCount > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 bizServiceOne.setCount(newCount); | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBizService.updateById(bizServiceOne); | 
			
		
	
		
			
				
					|  |  |  |  |             }else { | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBizService.removeById(bizServiceOne.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |