|  |  |  | @ -1,31 +1,32 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.glxp.api.service.inv.impl; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.IdUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.enums.ResultEnum; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.auth.InvSpaceDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.auth.InvWarehouseDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.InvPreInProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.InvPreProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.InvProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.InvSpace; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPreInProductDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPreProductDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvProductDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.AddInvPlaceOrderRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvPlaceRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inout.IoOrderResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.BindInvSpaceRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPlaceDetailResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPlaceOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPlaceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.BeanCopyUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.OrderNoTypeBean; | 
			
		
	
		
			
				
					|  |  |  |  | import io.swagger.models.auth.In; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
	
		
			
				
					|  |  |  | @ -34,6 +35,7 @@ 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.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -54,6 +56,14 @@ public class InvPlaceServiceImpl implements InvPlaceService { | 
			
		
	
		
			
				
					|  |  |  |  |     private InvSpaceDao invSpaceDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvPlaceOrderService invPlaceOrderService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvPlaceOrderDao invPlaceOrderDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvPlaceOrderDetailDao invPlaceOrderDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private UdiRelevanceService udiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public List<InvPlaceDetailResponse> getPlaceDetailList(FilterInvPlaceRequest filterInvPlaceRequest) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -75,67 +85,160 @@ public class InvPlaceServiceImpl implements InvPlaceService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<InvProductDetailEntity> list = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) { | 
			
		
	
		
			
				
					|  |  |  |  |             List<InvPreInProductDetailEntity> invPreInProductDetailEntities = invPreInProductDetailDao.selectList(new QueryWrapper<InvPreInProductDetailEntity>() | 
			
		
	
		
			
				
					|  |  |  |  |                     .select("id", "code", "relId", "batchNo") | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("deptCode", deptCode) | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("invCode", bindInvSpaceRequest.getInvCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .in("code", bindInvSpaceRequest.getCodeArray()) | 
			
		
	
		
			
				
					|  |  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |  |             for (InvPreInProductDetailEntity invPreInProductDetailEntity : invPreInProductDetailEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |                 InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                 BeanCopyUtils.copy(invPreInProductDetailEntity, invProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 list.add(invProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |             List<InvPlaceOrderDetailEntity> invPlaceOrderDetailEntityList=invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId",bindInvSpaceRequest.getOrderId())); | 
			
		
	
		
			
				
					|  |  |  |  |             for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                     //拆解库存表
 | 
			
		
	
		
			
				
					|  |  |  |  |                     QueryWrapper<InvPreInProductDetailEntity> ew=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.and(o-> o.isNull("invSpaceCode").or().eq("invSpaceCode","")); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.gt("inCount",0); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |                     InvPreInProductDetailEntity invPreInProductDetailEntity=invPreInProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                     if(invPreInProductDetailEntity.getInCount()>0){ | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setInCount(invPreInProductDetailEntity.getInCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setCount(invPreInProductDetailEntity.getCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  | //                        invPreInProductDetailEntity.setReCount(invPreInProductDetailEntity.getReCount()-getActCount(invPlaceOrderDetailEntity.get));
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailDao.updateById(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.clear(); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("invSpaceCode",invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         InvPreInProductDetailEntity invPreInProductDetailEntity1=invPreInProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                         if(invPreInProductDetailEntity1!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setCount(invPreInProductDetailEntity1.getCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setInCount(invPreInProductDetailEntity1.getInCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailDao.updateById(invPreInProductDetailEntity1); | 
			
		
	
		
			
				
					|  |  |  |  |                         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setId(null); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setOutCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInvSpaceCode(invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailDao.insert(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             List<InvPreProductDetailEntity> invPreProductDetailEntities = invPreProductDetailDao.selectList(new QueryWrapper<InvPreProductDetailEntity>() | 
			
		
	
		
			
				
					|  |  |  |  |                     .select("id", "code", "relId", "batchNo") | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("deptCode", deptCode) | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("invCode", bindInvSpaceRequest.getInvCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .in("code", bindInvSpaceRequest.getCodeArray()) | 
			
		
	
		
			
				
					|  |  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |  |             for (InvPreProductDetailEntity invPreInProductDetailEntity : invPreProductDetailEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |                 InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                 BeanCopyUtils.copy(invPreInProductDetailEntity, invProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 list.add(invProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             list = invProductDetailDao.selectList(new QueryWrapper<InvProductDetailEntity>() | 
			
		
	
		
			
				
					|  |  |  |  |                     .select("id", "code", "relId", "batchNo") | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("deptCode", deptCode) | 
			
		
	
		
			
				
					|  |  |  |  |                     .eq("invCode", bindInvSpaceRequest.getInvCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .in("code", bindInvSpaceRequest.getCodeArray()) | 
			
		
	
		
			
				
					|  |  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isNotEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |  |             List<Integer> ids = list.stream().map(InvProductDetailEntity::getId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("本次绑定货位的库存详情数量为:{} 条", ids.size()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) { | 
			
		
	
		
			
				
					|  |  |  |  |                 invPreInProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) { | 
			
		
	
		
			
				
					|  |  |  |  |                 invPreProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 invProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             List<InvPlaceOrderDetailEntity> invPlaceOrderDetailEntityList=invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId",bindInvSpaceRequest.getOrderId())); | 
			
		
	
		
			
				
					|  |  |  |  |             for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                     //拆解库存表
 | 
			
		
	
		
			
				
					|  |  |  |  |                     QueryWrapper<InvPreProductDetailEntity> ew=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.and(o-> o.isNull("invSpaceCode").or().eq("invSpaceCode","")); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.gt("inCount",0); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |                     InvPreProductDetailEntity invPreInProductDetailEntity=invPreProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                     if(invPreInProductDetailEntity.getInCount()>0){ | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setInCount(invPreInProductDetailEntity.getInCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setCount(invPreInProductDetailEntity.getCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  | //                        invPreInProductDetailEntity.setReCount(invPreInProductDetailEntity.getReCount()-getActCount(invPlaceOrderDetailEntity.get));
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreProductDetailDao.updateById(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.clear(); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("invSpaceCode",invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         InvPreProductDetailEntity invPreInProductDetailEntity1=invPreProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                         if(invPreInProductDetailEntity1!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setCount(invPreInProductDetailEntity1.getCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setInCount(invPreInProductDetailEntity1.getInCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreProductDetailDao.updateById(invPreInProductDetailEntity1); | 
			
		
	
		
			
				
					|  |  |  |  |                         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setId(null); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setOutCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInvSpaceCode(invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreProductDetailDao.insert(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             //添加物资上架记录
 | 
			
		
	
		
			
				
					|  |  |  |  |             AddInvPlaceOrderRequest addInvPlaceOrderRequest = new AddInvPlaceOrderRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |             addInvPlaceOrderRequest.setType(bindInvSpaceRequest.getType()); | 
			
		
	
		
			
				
					|  |  |  |  |             addInvPlaceOrderRequest.setOrderId(bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |             addInvPlaceOrderRequest.setCodeList(list); | 
			
		
	
		
			
				
					|  |  |  |  |             addInvPlaceOrderRequest.setInvCode(bindInvSpaceRequest.getInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             addInvPlaceOrderRequest.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderService.addInvPlaceOrder(addInvPlaceOrderRequest); | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success("绑定成功!本次绑定货位的库存详情数量为:" + ids.size() + "条"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("绑定货位列表查询无数据"); | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "绑定货位列表查询无数据"); | 
			
		
	
		
			
				
					|  |  |  |  |             List<InvPlaceOrderDetailEntity> invPlaceOrderDetailEntityList=invPlaceOrderDetailDao.selectList(new QueryWrapper<InvPlaceOrderDetailEntity>().eq("recordId",bindInvSpaceRequest.getOrderId())); | 
			
		
	
		
			
				
					|  |  |  |  |             for (InvPlaceOrderDetailEntity invPlaceOrderDetailEntity : invPlaceOrderDetailEntityList) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 for (Integer i = 0; i < invPlaceOrderDetailEntity.getCount(); i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                     //拆解库存表
 | 
			
		
	
		
			
				
					|  |  |  |  |                     QueryWrapper<InvProductDetailEntity> ew=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.and(o-> o.isNull("invSpaceCode").or().eq("invSpaceCode","")); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.gt("inCount",0); | 
			
		
	
		
			
				
					|  |  |  |  |                     ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |                     InvProductDetailEntity invPreInProductDetailEntity=invProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                     if(invPreInProductDetailEntity.getInCount()>0){ | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setInCount(invPreInProductDetailEntity.getInCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailEntity.setCount(invPreInProductDetailEntity.getCount()-1); | 
			
		
	
		
			
				
					|  |  |  |  | //                        invPreInProductDetailEntity.setReCount(invPreInProductDetailEntity.getReCount()-getActCount(invPlaceOrderDetailEntity.get));
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invProductDetailDao.updateById(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.clear(); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("code",invPlaceOrderDetailEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                         ew.eq("invSpaceCode",invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         InvProductDetailEntity invPreInProductDetailEntity1=invProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                         if(invPreInProductDetailEntity1!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setCount(invPreInProductDetailEntity1.getCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity1.setInCount(invPreInProductDetailEntity1.getInCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invProductDetailDao.updateById(invPreInProductDetailEntity1); | 
			
		
	
		
			
				
					|  |  |  |  |                         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setId(null); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setOutCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductDetailEntity.setInvSpaceCode(invPlaceOrderDetailEntity.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             invProductDetailDao.insert(invPreInProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //        if (CollUtil.isNotEmpty(list)) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            List<Integer> ids = list.stream().map(InvProductDetailEntity::getId).collect(Collectors.toList());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            log.info("本次绑定货位的库存详情数量为:{} 条", ids.size());
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                invPreInProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                invPreProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                invProductDetailDao.batchBindSpace(ids, bindInvSpaceRequest.getInvSpaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            //添加物资上架记录
 | 
			
		
	
		
			
				
					|  |  |  |  | //            AddInvPlaceOrderRequest addInvPlaceOrderRequest = new AddInvPlaceOrderRequest();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            addInvPlaceOrderRequest.setType(bindInvSpaceRequest.getType());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            addInvPlaceOrderRequest.setOrderId(bindInvSpaceRequest.getOrderId());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            addInvPlaceOrderRequest.setCodeList(list);
 | 
			
		
	
		
			
				
					|  |  |  |  | //            addInvPlaceOrderRequest.setInvCode(bindInvSpaceRequest.getInvCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            addInvPlaceOrderRequest.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            invPlaceOrderService.addInvPlaceOrder(addInvPlaceOrderRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  | //            return ResultVOUtils.success("绑定成功!本次绑定货位的库存详情数量为:" + ids.size() + "条");
 | 
			
		
	
		
			
				
					|  |  |  |  | //        } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            log.info("绑定货位列表查询无数据");
 | 
			
		
	
		
			
				
					|  |  |  |  | //            return ResultVOUtils.error(500, "绑定货位列表查询无数据");
 | 
			
		
	
		
			
				
					|  |  |  |  | //        }
 | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
	
		
			
				
					|  |  |  | @ -229,16 +332,16 @@ public class InvPlaceServiceImpl implements InvPlaceService { | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public List<InvPlaceDetailResponse> getInvProductInfo(FilterInvPlaceRequest filterInvPlaceRequest) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOne(new QueryWrapper<InvWarehouseEntity>().eq("code", filterInvPlaceRequest.getInvCode())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) { | 
			
		
	
		
			
				
					|  |  |  |  |             return invPreInProductDetailDao.getInvProductInfo(filterInvPlaceRequest); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) { | 
			
		
	
		
			
				
					|  |  |  |  |             return invPreProductDetailDao.getInvProductInfo(filterInvPlaceRequest); | 
			
		
	
		
			
				
					|  |  |  |  |         } else | 
			
		
	
		
			
				
					|  |  |  |  |             return invProductDetailDao.getInvProductInfo(filterInvPlaceRequest); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public List<InvPlaceDetailResponse> getInvProductInfo(BindInvSpaceRequest bindInvSpaceRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //        InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOne(new QueryWrapper<InvWarehouseEntity>().eq("code", filterInvPlaceRequest.getInvCode()));
 | 
			
		
	
		
			
				
					|  |  |  |  | //        if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            return invPreInProductDetailDao.getInvProductInfo(filterInvPlaceRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  | //        } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            return invPreProductDetailDao.getInvProductInfo(filterInvPlaceRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  | //        } else
 | 
			
		
	
		
			
				
					|  |  |  |  | //            return invProductDetailDao.getInvProductInfo(filterInvPlaceRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
	
		
			
				
					|  |  |  | @ -261,4 +364,79 @@ public class InvPlaceServiceImpl implements InvPlaceService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public String checkCount(BindInvSpaceRequest bindInvSpaceRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOne(new QueryWrapper<InvWarehouseEntity>().eq("code", bindInvSpaceRequest.getInvCode())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) { | 
			
		
	
		
			
				
					|  |  |  |  |             Integer count  = invPreInProductDetailDao.getInventoryQuantity(bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if(count==null || count<=0){ | 
			
		
	
		
			
				
					|  |  |  |  |                 return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())){ | 
			
		
	
		
			
				
					|  |  |  |  |                 QueryWrapper ew=new QueryWrapper(); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("recordId",bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("code",bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 InvPlaceOrderDetailEntity invPlaceOrderDetailEntity =invPlaceOrderDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                 if(invPlaceOrderDetailEntity.getCount()>=count){ | 
			
		
	
		
			
				
					|  |  |  |  |                     return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) { | 
			
		
	
		
			
				
					|  |  |  |  |             Integer count  = invPreProductDetailDao.getInventoryQuantity(bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if(count==null || count<=0){ | 
			
		
	
		
			
				
					|  |  |  |  |                 return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())){ | 
			
		
	
		
			
				
					|  |  |  |  |                 QueryWrapper ew=new QueryWrapper(); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("recordId",bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("code",bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 InvPlaceOrderDetailEntity invPlaceOrderDetailEntity =invPlaceOrderDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                 if(invPlaceOrderDetailEntity.getCount()>=count){ | 
			
		
	
		
			
				
					|  |  |  |  |                     return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_NORMAL){ | 
			
		
	
		
			
				
					|  |  |  |  |             Integer count  = invProductDetailDao.getInventoryQuantity(bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if(count==null || count<=0){ | 
			
		
	
		
			
				
					|  |  |  |  |                 return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(StrUtil.isNotBlank(bindInvSpaceRequest.getOrderId())){ | 
			
		
	
		
			
				
					|  |  |  |  |                 QueryWrapper ew=new QueryWrapper(); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("recordId",bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("code",bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 InvPlaceOrderDetailEntity invPlaceOrderDetailEntity =invPlaceOrderDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                 if(invPlaceOrderDetailEntity.getCount()>=count){ | 
			
		
	
		
			
				
					|  |  |  |  |                     return "该产品库存不足!"; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ""; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public int getActCount(String nameCode) { | 
			
		
	
		
			
				
					|  |  |  |  |         UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(nameCode); | 
			
		
	
		
			
				
					|  |  |  |  |         int count = getActCount(udiRelevanceResponse); | 
			
		
	
		
			
				
					|  |  |  |  |         return count; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |     public int getActCount(UdiRelevanceResponse udiRelevanceResponse) { | 
			
		
	
		
			
				
					|  |  |  |  |         int actCount; | 
			
		
	
		
			
				
					|  |  |  |  |         if (!udiRelevanceResponse.getUseDy() && (udiRelevanceResponse.getDiType() == null || udiRelevanceResponse.getDiType() != 2)) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (udiRelevanceResponse.getBhzxxsbzsl() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 actCount = udiRelevanceResponse.getZxxsbzbhsydysl(); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udiRelevanceResponse.getBhzxxsbzsl() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     udiRelevanceResponse.setBhzxxsbzsl(1); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udiRelevanceResponse.getZxxsbzbhsydysl() == null || udiRelevanceResponse.getZxxsbzbhsydysl() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     udiRelevanceResponse.setZxxsbzbhsydysl(1); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 actCount = udiRelevanceResponse.getBhzxxsbzsl() * udiRelevanceResponse.getZxxsbzbhsydysl(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             actCount = udiRelevanceResponse.getBhzxxsbzsl(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return actCount; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |