|  |  | @ -1,5 +1,6 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.glxp.api.controller.inout; |  |  |  | package com.glxp.api.controller.inout; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.collection.CollUtil; |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.StrUtil; |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.github.pagehelper.PageInfo; |  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
	
		
		
			
				
					|  |  | @ -7,6 +8,7 @@ import com.glxp.api.annotation.AuthRuleAnnotation; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.enums.ResultEnum; |  |  |  | import com.glxp.api.common.enums.ResultEnum; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.res.BaseResponse; |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.util.ResultVOUtils; |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.constant.ConstantStatus; |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.controller.BaseController; |  |  |  | import com.glxp.api.controller.BaseController; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.auth.InvBusUserEntity; |  |  |  | import com.glxp.api.entity.auth.InvBusUserEntity; | 
			
		
	
	
		
		
			
				
					|  |  | @ -25,6 +27,9 @@ import com.glxp.api.service.auth.InvBusUserService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.EntrustReceService; |  |  |  | import com.glxp.api.service.basic.EntrustReceService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; |  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.inout.*; |  |  |  | import com.glxp.api.service.inout.*; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.util.CustomUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.util.GennerOrderUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.util.OrderNoTypeBean; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lombok.extern.slf4j.Slf4j; |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.apache.commons.lang3.StringUtils; |  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.beans.BeanUtils; |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
	
		
		
			
				
					|  |  | @ -35,6 +40,7 @@ import org.springframework.web.bind.annotation.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.ArrayList; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Arrays; |  |  |  | import java.util.Arrays; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.Date; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -466,4 +472,70 @@ public class IoOrderController extends BaseController { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return orderService.submitToThrSys(billNo); |  |  |  |         return orderService.submitToThrSys(billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     GennerOrderUtils gennerOrderUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @AuthRuleAnnotation("") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @PostMapping("/udiwms/stock/order/change") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse stockOrderChange(@RequestBody AddStockOrderChangeRequest addStockOrderChangeRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoOrderEntity originOrder = orderService.findByBillNo(addStockOrderChangeRequest.getOrderId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoOrderEntity newOrder = new IoOrderEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeEntity> originCodes = codeService.findByOrderId(originOrder.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setFromCorp(addStockOrderChangeRequest.getFromCorp()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setFromInvCode(addStockOrderChangeRequest.getFromInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setFromDeptCode(addStockOrderChangeRequest.getFromDeptCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setInvCode(addStockOrderChangeRequest.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setDeptCode(addStockOrderChangeRequest.getDeptCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setCorpOrderId(CustomUtil.getId() + "x"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setMainAction(addStockOrderChangeRequest.getMainAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setAction(addStockOrderChangeRequest.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setExportStatus(0);  //设置导出状态为未导出
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//设置单据未草稿状态
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); //设置验收状态为未验收
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setFromType(ConstantStatus.FROM_COPY); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addStockOrderChangeRequest.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String supplementOrderNo = orderNo; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setBillNo(supplementOrderNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setReplicateNo(null); //新单据的复制单号置空
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         originOrder.setReplicateNo(orderNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeTempEntity> supplementCodes = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<IoCodeEntity> products = addStockOrderChangeRequest.getProducts(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         originCodes.forEach( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 code -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //复制选中的产品
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     for (IoCodeEntity product : products) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (product.getRelId().equals(code.getRelId())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             if ((StrUtil.isNotBlank(product.getBatchNo()) && StrUtil.isNotBlank(code.getBatchNo()) && product.getBatchNo().equals(code.getBatchNo())) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                     || (StrUtil.isBlank(product.getBatchNo()) && StrUtil.isBlank(code.getBatchNo()))) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 IoCodeTempEntity supplementCode = new IoCodeTempEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 BeanUtil.copyProperties(code, supplementCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setCode(product.getCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setInvCode(newOrder.getInvCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setDeptCode(newOrder.getDeptCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setOrderId(newOrder.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setCorpOrderId(newOrder.getCorpOrderId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 //查询补单设置
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setAction(newOrder.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setMainAction(newOrder.getMainAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCode.setId(null); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 supplementCodes.add(supplementCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                 break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         newOrder.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         orderService.insertOrder(newOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         codeTempService.insertBatch(supplementCodes); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         orderService.update(originOrder); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |