|  |  |  | @ -172,14 +172,35 @@ public class SpsSyncDownloadService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * TODO 同步其他模块 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param info 同步设置 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     public void syncOtherData(SyncDataSetResponse info) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Date now = new Date(); | 
			
		
	
		
			
				
					|  |  |  |  |         //是否需要执行
 | 
			
		
	
		
			
				
					|  |  |  |  |         boolean needExec = info.getUdiCodeLost() == 2 || info.getUdiCodeRel() == 2; | 
			
		
	
		
			
				
					|  |  |  |  |         if (!needExec) { | 
			
		
	
		
			
				
					|  |  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             basicExportInfoCreate(BasicExportTypeEnum.OTHER_DATA, now, this.getClass() | 
			
		
	
		
			
				
					|  |  |  |  |                     , x -> x.generateOtherDataFile(info, now, false) | 
			
		
	
		
			
				
					|  |  |  |  |                     , x -> x.generateOtherDataFile(info, now, true)); | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new RuntimeException(e); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 创建一个同步任务 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param exportEnum       任务类型枚举 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param hasDataMethod    判断时候有无数据方法 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param createFileMethod 执行文件生成方法 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |  |      * @throws Exception | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private void basicExportInfoCreate(BasicExportTypeEnum exportEnum, Date now | 
			
		
	
		
			
				
					|  |  |  |  |             , Class<? extends SpsSyncDownloadService> clazz, Function<SpsSyncDownloadService, Boolean> hasDataMethod, Function<SpsSyncDownloadService, Boolean> createFileMethod) throws Exception { | 
			
		
	
	
		
			
				
					|  |  |  | @ -371,6 +392,93 @@ public class SpsSyncDownloadService { | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final IoCodeLostService ioCodeLostService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final IoCodeRelService ioCodeRelService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 读取其他数据,创建文件 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param info       同步设置信息 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param now        当前时间 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param createFile 是否创建文件 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 是否有数据 true/false  有新数据/无新数据 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     protected boolean generateOtherDataFile(SyncDataSetResponse info, Date now, boolean createFile) { | 
			
		
	
		
			
				
					|  |  |  |  |         //文件数据
 | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, List> jsonMap = new WeakHashMap<>(4); | 
			
		
	
		
			
				
					|  |  |  |  |         Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap = new WeakHashMap<>(10); | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             //确认有开启物资字典由外向内同步
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (info.getUdiCodeLost() == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                 Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST, createFile); | 
			
		
	
		
			
				
					|  |  |  |  |                 totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_LOST, map); | 
			
		
	
		
			
				
					|  |  |  |  |                 List<IoCodeLostEntity> ioCodeLostList = ioCodeLostService.list(Wrappers.lambdaQuery(IoCodeLostEntity.class) | 
			
		
	
		
			
				
					|  |  |  |  |                         .le((boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime, now) | 
			
		
	
		
			
				
					|  |  |  |  |                         .between(!(boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime | 
			
		
	
		
			
				
					|  |  |  |  |                                 , map.get("oldDate"), now) | 
			
		
	
		
			
				
					|  |  |  |  |                 ); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (CollectionUtil.isNotEmpty(ioCodeLostList)) { | 
			
		
	
		
			
				
					|  |  |  |  |                     jsonMap.put(BasicExportStatusTimeEntity.class.getSimpleName(), ioCodeLostList); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             //确认有开启udi关联关系同步
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (info.getUdiCodeRel() == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                 Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_REL, createFile); | 
			
		
	
		
			
				
					|  |  |  |  |                 totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_REL, map); | 
			
		
	
		
			
				
					|  |  |  |  |                 List<IoCodeRelEntity> ioCodeRelList = ioCodeRelService.list(Wrappers.lambdaQuery(IoCodeRelEntity.class) | 
			
		
	
		
			
				
					|  |  |  |  |                         .le((boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime, now) | 
			
		
	
		
			
				
					|  |  |  |  |                         .between(!(boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime | 
			
		
	
		
			
				
					|  |  |  |  |                                 , map.get("oldDate"), now) | 
			
		
	
		
			
				
					|  |  |  |  |                 ); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (CollectionUtil.isNotEmpty(ioCodeRelList)) { | 
			
		
	
		
			
				
					|  |  |  |  |                     jsonMap.put(IoCodeRelEntity.class.getSimpleName(), ioCodeRelList); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (jsonMap.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (!createFile) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return true; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |  |                     String fileFullPath = writeFile(filePath, BasicExportTypeEnum.BASIC_DATA.getRemark(), JsonUtils.toJsonString(jsonMap)); | 
			
		
	
		
			
				
					|  |  |  |  |                     //计算总数
 | 
			
		
	
		
			
				
					|  |  |  |  |                     int total = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                     for (List l : jsonMap.values()) { | 
			
		
	
		
			
				
					|  |  |  |  |                         total += l.size(); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     try { | 
			
		
	
		
			
				
					|  |  |  |  |                         //插入一条任务数据
 | 
			
		
	
		
			
				
					|  |  |  |  |                         boolean update = basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .set(BasicExportStatusEntity::getUpdateTime, new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .set(BasicExportStatusEntity::getCacheFilePath, fileFullPath) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .set(BasicExportStatusEntity::getRemark, String.format("%s: %s条", BasicExportTypeEnum.BASIC_DATA.getRemark(), total)) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.BASIC_DATA.getRemark()) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                                 .isNull(BasicExportStatusEntity::getCacheFilePath) | 
			
		
	
		
			
				
					|  |  |  |  |                         ); | 
			
		
	
		
			
				
					|  |  |  |  |                     } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |                         // 异常回滚
 | 
			
		
	
		
			
				
					|  |  |  |  |                         this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.BASIC_DATA, fileFullPath); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     return true; | 
			
		
	
		
			
				
					|  |  |  |  |                 } catch (IOException e) { | 
			
		
	
		
			
				
					|  |  |  |  |                     logger.error(String.format("syncIdcSps----process------------生成[%s]文件及更改库操作异常,异常信息<%s>" | 
			
		
	
		
			
				
					|  |  |  |  |                             , BasicExportTypeEnum.BASIC_DATA.getRemark(), e.getMessage())); | 
			
		
	
		
			
				
					|  |  |  |  |                     // 异常回滚
 | 
			
		
	
		
			
				
					|  |  |  |  |                     this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.BASIC_DATA, null); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |             logger.error(e.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 插入 basicExportStatusTime表 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  |  | 
 |