diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 17eb160a64..1d6193834f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -129,7 +129,7 @@ public interface IcNeighborHoodService extends BaseService * @author zxc * @date 2022/2/12 11:11 上午 */ - void neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; /** * 获取导入小区,楼栋,单元ID diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 107fb203b2..32e84af348 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -234,8 +234,36 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) throws IOException { - importNeighbor(formDTO,file,importTask); + public Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException { +// importNeighbor(formDTO,file,importTask); + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + return new Result().error("读取文件失败"); + } + + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,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<>(); } /**