| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -37,6 +37,7 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.feign.OssFeignClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.IcVaccineService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.UserService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.utils.ImportTaskUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.github.pagehelper.PageHelper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.github.pagehelper.PageInfo; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -45,6 +46,7 @@ import org.apache.commons.fileupload.FileItem; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.fileupload.FileItemFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.fileupload.disk.DiskFileItemFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.http.entity.ContentType; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.poi.util.IOUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.scheduling.annotation.Async; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -177,7 +179,6 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            EasyExcel.read(filePath.toFile(), IcVaccineImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Path errorDescFile = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String errorDesFileUrl = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<IcVaccineImportExcelData.RowRemarkMessage> errorRows = listener.getErrorRows(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -189,16 +190,17 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            errorRows.addAll(otherRows); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 生成并上传描述文件
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            OutputStream os = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            FileItem fileItem = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (errorRows.size() > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // 文件生成
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import", "error_des"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    String fileName = UUID.randomUUID().toString().concat(".xlsx"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    errorDescFile = errorDescDir.resolve(fileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    OutputStream os = fileItem.getOutputStream(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    fileItem = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, errorDescDir.toFile()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            .createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), false, fileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    os = fileItem.getOutputStream(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    EasyExcel.write(os, IcNatImportExcelData.RowRemarkMessage.class).sheet("信息列表").doWrite(errorRows); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // 文件上传oss
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -208,20 +210,21 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (Files.exists(errorDescFile)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        Files.delete(errorDescFile); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    IOUtils.closeQuietly(os); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        fileItem.delete(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        log.error("【疫苗接种导入】删除错误描述临时文件失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setTaskId(importTaskId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setOperatorId(userId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setResultDesc(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Result result = ImportTaskUtils.finishImportTask( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    importTaskId, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    errorDesFileUrl, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.error("【疫苗接种导入】finishImportTask失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |