新增自助平台与UDI管理系统库存校验同步
							parent
							
								
									49f578d505
								
							
						
					
					
						commit
						dc78894221
					
				| @ -0,0 +1,173 @@ | |||||||
|  | package com.glxp.api.task; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.dao.schedule.ScheduledDao; | ||||||
|  | import com.glxp.api.entity.inv.InvPreProductEntity; | ||||||
|  | import com.glxp.api.entity.inv.InvPreinProductEntity; | ||||||
|  | import com.glxp.api.entity.inv.InvProductEntity; | ||||||
|  | import com.glxp.api.entity.system.ScheduledEntity; | ||||||
|  | import com.glxp.api.http.sync.SpGetHttpClient; | ||||||
|  | import com.glxp.api.req.system.ScheduledRequest; | ||||||
|  | import com.glxp.api.res.PageSimpleResponse; | ||||||
|  | import com.glxp.api.res.inv.InvProductResponse; | ||||||
|  | import com.glxp.api.service.inv.InvPreProductService; | ||||||
|  | import com.glxp.api.service.inv.InvPreinProductService; | ||||||
|  | import com.glxp.api.service.inv.InvProductService; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
|  | import org.springframework.scheduling.annotation.SchedulingConfigurer; | ||||||
|  | import org.springframework.scheduling.config.ScheduledTaskRegistrar; | ||||||
|  | import org.springframework.scheduling.support.CronTrigger; | ||||||
|  | import org.springframework.stereotype.Component; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | @Slf4j | ||||||
|  | @Component | ||||||
|  | @Transactional(rollbackFor = Exception.class) | ||||||
|  | public class VailInvTask implements SchedulingConfigurer { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     private ScheduledDao scheduledDao; | ||||||
|  |     @Resource | ||||||
|  |     SpGetHttpClient spGetHttpClient; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { | ||||||
|  |         scheduledTaskRegistrar.addTriggerTask(() -> process(), | ||||||
|  |                 triggerContext -> { | ||||||
|  |                     ScheduledRequest scheduledRequest = new ScheduledRequest(); | ||||||
|  |                     scheduledRequest.setCronName("dlThrSysHeartTask"); | ||||||
|  |                     ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); | ||||||
|  |                     if (scheduledEntity != null) { | ||||||
|  |                         String cron = scheduledEntity.getCron(); | ||||||
|  |                         if (cron.isEmpty()) { | ||||||
|  |                             log.error("cron is null"); | ||||||
|  |                         } | ||||||
|  |                         return new CronTrigger(cron).nextExecutionTime(triggerContext); | ||||||
|  |                     } else | ||||||
|  |                         return null; | ||||||
|  | 
 | ||||||
|  |                 }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void process() { | ||||||
|  | 
 | ||||||
|  |         StringBuffer stringBuffer = new StringBuffer(); | ||||||
|  |         String invStr = downloadInv(); | ||||||
|  |         String invPreStr = downloadPreInv(); | ||||||
|  |         String invPreInStr = downloadPreInInv(); | ||||||
|  |         stringBuffer.append("------------普通库存-----------------------\n"); | ||||||
|  |         stringBuffer.append(invStr); | ||||||
|  |         stringBuffer.append("------------寄售库存-----------------------\n"); | ||||||
|  |         stringBuffer.append(invPreStr); | ||||||
|  |         stringBuffer.append("------------预验收库存-----------------------\n"); | ||||||
|  |         stringBuffer.append(invPreInStr); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     InvProductService invProductService; | ||||||
|  |     @Resource | ||||||
|  |     InvPreinProductService invPreinProductService; | ||||||
|  |     @Resource | ||||||
|  |     InvPreProductService invPreProductService; | ||||||
|  | 
 | ||||||
|  |     public String downloadInv() { | ||||||
|  |         int page = 1; | ||||||
|  |         int limit = 100; | ||||||
|  |         StringBuffer buffer = new StringBuffer(); | ||||||
|  |         while (true) { | ||||||
|  |             BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit); | ||||||
|  |             if (baseResponse.getCode() == 20000) { | ||||||
|  |                 List<InvProductResponse> list = baseResponse.getData().getList(); | ||||||
|  |                 list.forEach(invProductResponse -> { | ||||||
|  |                     InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode()); | ||||||
|  |                     if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) { | ||||||
|  |                         buffer.append(invProductResponse.getCpmctymc() + "," | ||||||
|  |                                 + invProductResponse.getNameCode() + "," | ||||||
|  |                                 + invProductResponse.getBatchNo() + "," | ||||||
|  |                                 + invProductResponse.getSupName() + "," | ||||||
|  |                                 + invProductResponse.getDeptName() + "," | ||||||
|  |                                 + invProductResponse.getInvCode() + "\n"); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|  |                 if (list.size() >= limit) { | ||||||
|  |                     page++; | ||||||
|  |                 } else { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 return buffer.toString(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return buffer.toString(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String downloadPreInv() { | ||||||
|  |         int page = 1; | ||||||
|  |         int limit = 100; | ||||||
|  |         StringBuffer buffer = new StringBuffer(); | ||||||
|  |         while (true) { | ||||||
|  |             BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit); | ||||||
|  |             if (baseResponse.getCode() == 20000) { | ||||||
|  |                 List<InvProductResponse> list = baseResponse.getData().getList(); | ||||||
|  |                 list.forEach(invProductResponse -> { | ||||||
|  |                     InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode()); | ||||||
|  |                     if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) { | ||||||
|  |                         buffer.append(invProductResponse.getCpmctymc() + "," | ||||||
|  |                                 + invProductResponse.getNameCode() + "," | ||||||
|  |                                 + invProductResponse.getBatchNo() + "," | ||||||
|  |                                 + invProductResponse.getSupName() + "," | ||||||
|  |                                 + invProductResponse.getDeptName() + "," | ||||||
|  |                                 + invProductResponse.getInvCode() + "\n"); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|  |                 if (list.size() >= limit) { | ||||||
|  |                     page++; | ||||||
|  |                 } else { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 return buffer.toString(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return buffer.toString(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String downloadPreInInv() { | ||||||
|  |         int page = 1; | ||||||
|  |         int limit = 100; | ||||||
|  |         StringBuffer buffer = new StringBuffer(); | ||||||
|  |         while (true) { | ||||||
|  |             BaseResponse<PageSimpleResponse<InvProductResponse>> baseResponse = spGetHttpClient.getInvData(page, limit); | ||||||
|  |             if (baseResponse.getCode() == 20000) { | ||||||
|  |                 List<InvProductResponse> list = baseResponse.getData().getList(); | ||||||
|  |                 list.forEach(invProductResponse -> { | ||||||
|  |                     InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode()); | ||||||
|  |                     if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) { | ||||||
|  |                         buffer.append(invProductResponse.getCpmctymc() + "," | ||||||
|  |                                 + invProductResponse.getNameCode() + "," | ||||||
|  |                                 + invProductResponse.getBatchNo() + "," | ||||||
|  |                                 + invProductResponse.getSupName() + "," | ||||||
|  |                                 + invProductResponse.getDeptName() + "," | ||||||
|  |                                 + invProductResponse.getInvCode() + "\n"); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|  |                 if (list.size() >= limit) { | ||||||
|  |                     page++; | ||||||
|  |                 } else { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 return buffer.toString(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return buffer.toString(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in New Issue