|  |  |  | @ -1,24 +1,33 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.glxp.api.controller.inv; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.annotation.AuthRuleAnnotation; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.controller.BaseController; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.UdiEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.IoCodeTempEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPreInProductDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPreinDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvProductDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvPreinDetailRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvPreinRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvProductDetailRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.system.DeleteRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPlaceDetailResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPreinDetailResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPreinOrderResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.auth.InvWarehouseService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPreProductDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPreinDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPreinOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPreinProductDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.apache.regexp.RE; | 
			
		
	
	
		
			
				
					|  |  |  | @ -34,7 +43,12 @@ import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | @RestController | 
			
		
	
		
			
				
					|  |  |  |  | public class InvPreinOrderController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     InvWarehouseService invWarehouseService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     InvPreinProductDetailService invPreinProductDetailService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IBasicBussinessTypeService basicBussinessTypeService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     InvPreinOrderService invPreinOrderService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
	
		
			
				
					|  |  |  | @ -72,34 +86,54 @@ public class InvPreinOrderController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @AuthRuleAnnotation("") | 
			
		
	
		
			
				
					|  |  |  |  |     @GetMapping("spms/prein/inv/products/getDetaiByCode") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse getDetaiByCode(FilterInvProductDetailRequest filterInvProductDetailRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         InvPreinDetailEntity invProductDetailEntity = invPreinDetailService.findUseOneByCode(filterInvProductDetailRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (invProductDetailEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "预验收库存未存在此产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotEmpty(invProductDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(filterInvProductDetailRequest.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     && !invProductDetailEntity.getBatchNo().equals(filterInvProductDetailRequest.getBatchNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(500, "当前批次号与预验收录入批次号不匹配!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             UdiEntity udiEntity = FilterUdiUtils.getUdi(filterInvProductDetailRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isEmpty(udiEntity.getSerialNo())) {//该单据已有该产品
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //无序列号,则可能存在多个预验收入库单
 | 
			
		
	
		
			
				
					|  |  |  |  |                 List<InvPreinDetailEntity> invPreinDetailEntities = invPreinDetailService.findUseByCode(filterInvProductDetailRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 int count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                 for (InvPreinDetailEntity temp : invPreinDetailEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |                     count = count + temp.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("spms/prein/inv/products/getDetaiByCode") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse getDetaiByCode(@RequestBody IoCodeTempEntity codeTempEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN); | 
			
		
	
		
			
				
					|  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(codeTempEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |         int count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 count = invPreinProductDetailService.vailStockCountByCode(null, invWarehouseEntity.getCode(), null, codeTempEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             } else | 
			
		
	
		
			
				
					|  |  |  |  |                 count = invPreinProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), null, invWarehouseEntity.getCode(), null); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_SET) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 count = invPreinProductDetailService.vailStockCountByCode(null, invWarehouseEntity.getCode(), codeTempEntity.getPreInSpaceCode(), codeTempEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             } else | 
			
		
	
		
			
				
					|  |  |  |  |                 count = invPreinProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), null, invWarehouseEntity.getCode(), codeTempEntity.getPreInSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_CODE) { | 
			
		
	
		
			
				
					|  |  |  |  |             //按指定货位出库
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isEmpty(codeTempEntity.getPreSpaceCode())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 List<InvPlaceDetailResponse> invProductDetailEntities = invPreinProductDetailService.findByGroupCode(invWarehouseEntity.getCode(), codeTempEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (CollUtil.isNotEmpty(invProductDetailEntities) && invProductDetailEntities.size() > 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     BaseResponse baseResponse = ResultVOUtils.error(511, "存在多个货位,请指定当前货位!"); | 
			
		
	
		
			
				
					|  |  |  |  |                     baseResponse.setData(invProductDetailEntities); | 
			
		
	
		
			
				
					|  |  |  |  |                     return baseResponse; | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (invProductDetailEntities.size() == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     InvPlaceDetailResponse invPlaceDetailResponse = invProductDetailEntities.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |                     count = invPlaceDetailResponse.getReCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                     codeTempEntity.setPreSpaceCode(invPlaceDetailResponse.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "添加失败,该产品未上架货位!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 invPreinDetailEntities.get(0).setCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.success(invPreinDetailEntities.get(0)); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (invProductDetailEntity.getCount() < 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "超出预验收库存数量"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                     count = invPreinProductDetailService.vailStockCountByCode(null, codeTempEntity.getInvCode(), codeTempEntity.getPreInSpaceCode(), codeTempEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else | 
			
		
	
		
			
				
					|  |  |  |  |                     count = invPreinProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), null, codeTempEntity.getInvCode(), codeTempEntity.getPreInSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(invProductDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         InvPreInProductDetailEntity invPreinDetailEntity = invPreinProductDetailService.findUseOneByCode(codeTempEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count <= 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "预验收库存数量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotEmpty(invPreinDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(codeTempEntity.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     && !invPreinDetailEntity.getBatchNo().equals(codeTempEntity.getBatchNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(500, "当前批次号与预验收录入批次号不匹配!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(count); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |