|  |  |  | @ -3,6 +3,7 @@ package com.glxp.api.service.inout.impl; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.impl.InvProductDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.impl.InvProductService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.RedisUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.lang.UUID; | 
			
		
	
	
		
			
				
					|  |  |  | @ -964,47 +965,59 @@ public class IoOrderServiceImpl implements IoOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |     ThrOrderUploadBustypesService thrOrderUploadBustypesService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     SyncUploadDataSetService syncUploadDataSetService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     RedisUtil redisUtil; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse submitOrderToThrSys(ThrSystemDetailEntity thrSystemDetailEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         //查询可以提交到第三方系统的单据
 | 
			
		
	
		
			
				
					|  |  |  |  |         SyncUploadDataSetEntity syncUploadDataSetEntity = syncUploadDataSetService.selectSet(); | 
			
		
	
		
			
				
					|  |  |  |  |         List<String> billNos = orderDao.selectWaitSubmitOrder(thrSystemDetailEntity.getThirdSysFk(), syncUploadDataSetEntity.getOrderStartTime() + " 00:00:00"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isNotEmpty(billNos)) { | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("开始提交单据到第三方系统,本次提交单据数量:{}", billNos.size()); | 
			
		
	
		
			
				
					|  |  |  |  |             for (String billNo : billNos) { | 
			
		
	
		
			
				
					|  |  |  |  |                 IoOrderEntity orderEntity = findByBillNo(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                 ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesService.findByAction(orderEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (thrOrderUploadBustypesEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     log.error(billNo + ":" + orderEntity.getAction() + "单据类型未设置自动上传"); | 
			
		
	
		
			
				
					|  |  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (!thrOrderUploadBustypesEntity.getOrderSource().contains(orderEntity.getFromType() + "")) { | 
			
		
	
		
			
				
					|  |  |  |  |                     log.error(billNo + ":" + "单据来源不允许自动提交"); | 
			
		
	
		
			
				
					|  |  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_REW) { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(billNo + ":" + "非待审核单据"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Boolean b = redisUtil.getBool(Constant.THIRD_ORDER_SUBMIT); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!IntUtil.value(b)) { | 
			
		
	
		
			
				
					|  |  |  |  |             //查询可以提交到第三方系统的单据
 | 
			
		
	
		
			
				
					|  |  |  |  |             redisUtil.set(Constant.THIRD_ORDER_SUBMIT, true, 3 * 60); | 
			
		
	
		
			
				
					|  |  |  |  |             SyncUploadDataSetEntity syncUploadDataSetEntity = syncUploadDataSetService.selectSet(); | 
			
		
	
		
			
				
					|  |  |  |  |             List<String> billNos = orderDao.selectWaitSubmitOrder(thrSystemDetailEntity.getThirdSysFk(), syncUploadDataSetEntity.getOrderStartTime() + " 00:00:00"); | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollUtil.isNotEmpty(billNos)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 log.info("开始提交单据到第三方系统,本次提交单据数量:{}", billNos.size()); | 
			
		
	
		
			
				
					|  |  |  |  |                 for (String billNo : billNos) { | 
			
		
	
		
			
				
					|  |  |  |  |                     IoOrderEntity orderEntity = findByBillNo(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                     ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesService.findByAction(orderEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (thrOrderUploadBustypesEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(billNo + ":" + orderEntity.getAction() + "单据类型未设置自动上传"); | 
			
		
	
		
			
				
					|  |  |  |  |                         continue; | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_AUDITED) { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(billNo + ":" + "非已审核单据"); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (!thrOrderUploadBustypesEntity.getOrderSource().contains(orderEntity.getFromType() + "")) { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(billNo + ":" + "单据来源不允许自动提交"); | 
			
		
	
		
			
				
					|  |  |  |  |                         continue; | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_CHECK_REW) { | 
			
		
	
		
			
				
					|  |  |  |  |                             log.error(billNo + ":" + "非待审核单据"); | 
			
		
	
		
			
				
					|  |  |  |  |                             continue; | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } else if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (orderEntity.getStatus() != ConstantStatus.ORDER_STATUS_AUDITED) { | 
			
		
	
		
			
				
					|  |  |  |  |                             log.error(billNo + ":" + "非已审核单据"); | 
			
		
	
		
			
				
					|  |  |  |  |                             continue; | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (IntUtil.value(orderEntity.getCheckStatus()) != 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                         log.error(billNo + ":" + "非已确认单据"); | 
			
		
	
		
			
				
					|  |  |  |  |                         continue; | 
			
		
	
		
			
				
					|  |  |  |  |                     } else if (IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (IntUtil.value(orderEntity.getCheckStatus()) != 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                             log.error(billNo + ":" + "非已确认单据"); | 
			
		
	
		
			
				
					|  |  |  |  |                             continue; | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     submitToThrSys(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 submitToThrSys(billNo); | 
			
		
	
		
			
				
					|  |  |  |  |                 log.info("单据提交完成"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("单据提交完成"); | 
			
		
	
		
			
				
					|  |  |  |  |             redisUtil.set(Constant.THIRD_ORDER_SUBMIT, false); | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success("单据提交完成"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success("单据正在提交"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success("单据提交完成"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
	
		
			
				
					|  |  |  | 
 |