|  |  |  | @ -1,24 +1,15 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.glxp.sale.admin.thread.didl; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.constant.FileConstant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.entity.sync.UdiCompanyEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.service.param.SystemParamConfigService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.service.sync.BasicExportService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.util.FileUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.sale.admin.util.RedisUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.slf4j.Logger; | 
			
		
	
		
			
				
					|  |  |  |  | import org.slf4j.LoggerFactory; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.factory.annotation.Value; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.scheduling.annotation.Async; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  |  | public class AsyncCompanyDlService { | 
			
		
	
	
		
			
				
					|  |  |  | @ -41,41 +32,41 @@ public class AsyncCompanyDlService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Async | 
			
		
	
		
			
				
					|  |  |  |  |     public void asyncDiByTime(String updateTime) { | 
			
		
	
		
			
				
					|  |  |  |  |         SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (systemParamConfigEntity.getParamValue().equals("1")) { | 
			
		
	
		
			
				
					|  |  |  |  |             List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             int page = 1; | 
			
		
	
		
			
				
					|  |  |  |  |             int limit = 300; | 
			
		
	
		
			
				
					|  |  |  |  |             while (true) { | 
			
		
	
		
			
				
					|  |  |  |  |                 logger.info("更新时间:" + updateTime + "----" + page + "----" + limit); | 
			
		
	
		
			
				
					|  |  |  |  |                 List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     mUdiCompanyEntities.addAll(udiCompanyEntities); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (udiCompanyEntities.size() < limit) { | 
			
		
	
		
			
				
					|  |  |  |  |                         break; | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         page++; | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     break; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             logger.info("更新时间:" + updateTime + "----" + "下载结束"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); | 
			
		
	
		
			
				
					|  |  |  |  |             String key = "UdiCompanys" + System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |  |             String datas = JSON.toJSON(mUdiCompanyEntities).toString(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (downstream.getParamValue().equals("1")) { | 
			
		
	
		
			
				
					|  |  |  |  |                 redisUtil.set(key, datas); | 
			
		
	
		
			
				
					|  |  |  |  |                 BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                 myEntity.setId(key); | 
			
		
	
		
			
				
					|  |  |  |  |                 basicExportService.insertExportStatus(myEntity); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 String path = getPath(); | 
			
		
	
		
			
				
					|  |  |  |  |                 String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn"; | 
			
		
	
		
			
				
					|  |  |  |  |                 FileUtils.SaveFileAs(datas, fileName); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | //        SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
 | 
			
		
	
		
			
				
					|  |  |  |  | //        if (systemParamConfigEntity.getParamValue().equals("1")) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            int page = 1;
 | 
			
		
	
		
			
				
					|  |  |  |  | //            int limit = 300;
 | 
			
		
	
		
			
				
					|  |  |  |  | //            while (true) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    mUdiCompanyEntities.addAll(udiCompanyEntities);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    if (udiCompanyEntities.size() < limit) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        break;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        page++;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    break;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            logger.info("更新时间:" + updateTime + "----" + "下载结束");
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
 | 
			
		
	
		
			
				
					|  |  |  |  | //            String key = "UdiCompanys" + System.currentTimeMillis();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            String datas = JSON.toJSON(mUdiCompanyEntities).toString();
 | 
			
		
	
		
			
				
					|  |  |  |  | //            if (downstream.getParamValue().equals("1")) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                redisUtil.set(key, datas);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                myEntity.setId(key);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                basicExportService.insertExportStatus(myEntity);
 | 
			
		
	
		
			
				
					|  |  |  |  | //            } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                String path = getPath();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn";
 | 
			
		
	
		
			
				
					|  |  |  |  | //                FileUtils.SaveFileAs(datas, fileName);
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //        }
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |