|  |  | @ -58,6 +58,7 @@ import javax.servlet.http.HttpServletResponse; | 
			
		
	
		
			
				
					|  |  |  | import java.io.IOException; | 
			
		
	
		
			
				
					|  |  |  | import java.io.InputStream; | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.ExecutorService; | 
			
		
	
		
			
				
					|  |  |  | import java.util.function.Function; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -95,6 +96,8 @@ public class BuildingServiceImpl implements BuildingService { | 
			
		
	
		
			
				
					|  |  |  |     private IcNeighborHoodService neighborHoodService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private ExecutorService executorService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
	
		
			
				
					|  |  | @ -403,33 +406,34 @@ public class BuildingServiceImpl implements BuildingService { | 
			
		
	
		
			
				
					|  |  |  |      * @date 2022/2/13 10:15 上午 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     @Async | 
			
		
	
		
			
				
					|  |  |  |     public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException { | 
			
		
	
		
			
				
					|  |  |  |         ExcelReader excelReader = null; | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             InputStream inputStream = null; | 
			
		
	
		
			
				
					|  |  |  |         executorService.submit(() -> { | 
			
		
	
		
			
				
					|  |  |  |             ExcelReader excelReader = null; | 
			
		
	
		
			
				
					|  |  |  |             try { | 
			
		
	
		
			
				
					|  |  |  |                 inputStream = file.getInputStream(); | 
			
		
	
		
			
				
					|  |  |  |             } catch (IOException e) { | 
			
		
	
		
			
				
					|  |  |  |                 return new Result<String>().error("读取文件失败"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             excelReader = EasyExcel.read(inputStream).build(); | 
			
		
	
		
			
				
					|  |  |  |             // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
 | 
			
		
	
		
			
				
					|  |  |  |             ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) | 
			
		
	
		
			
				
					|  |  |  |                     .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) | 
			
		
	
		
			
				
					|  |  |  |                     .build(); | 
			
		
	
		
			
				
					|  |  |  |             excelReader.read(readSheet); | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |             ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |             input.setOperatorId(formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |             input.setTaskId(importTask.getData().getTaskId()); | 
			
		
	
		
			
				
					|  |  |  |             input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); | 
			
		
	
		
			
				
					|  |  |  |             epmetCommonServiceOpenFeignClient.finishImportTask(input); | 
			
		
	
		
			
				
					|  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |             if (excelReader != null) { | 
			
		
	
		
			
				
					|  |  |  |                 excelReader.finish(); | 
			
		
	
		
			
				
					|  |  |  |                 InputStream inputStream = null; | 
			
		
	
		
			
				
					|  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |                     inputStream = file.getInputStream(); | 
			
		
	
		
			
				
					|  |  |  |                 } catch (IOException e) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("读取文件失败"); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 excelReader = EasyExcel.read(inputStream).build(); | 
			
		
	
		
			
				
					|  |  |  |                 // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
 | 
			
		
	
		
			
				
					|  |  |  |                 ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) | 
			
		
	
		
			
				
					|  |  |  |                         .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) | 
			
		
	
		
			
				
					|  |  |  |                         .build(); | 
			
		
	
		
			
				
					|  |  |  |                 excelReader.read(readSheet); | 
			
		
	
		
			
				
					|  |  |  |             } catch (Exception e){ | 
			
		
	
		
			
				
					|  |  |  |                 ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |                 input.setOperatorId(formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |                 input.setTaskId(importTask.getData().getTaskId()); | 
			
		
	
		
			
				
					|  |  |  |                 input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); | 
			
		
	
		
			
				
					|  |  |  |                 epmetCommonServiceOpenFeignClient.finishImportTask(input); | 
			
		
	
		
			
				
					|  |  |  |             } finally { | 
			
		
	
		
			
				
					|  |  |  |                 if (excelReader != null) { | 
			
		
	
		
			
				
					|  |  |  |                     excelReader.finish(); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         return new Result<>(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 |