| | |
| | | public R export (@RequestParam("file") MultipartFile file) { |
| | | List<TTitleMajor> tTechnicalTitles = new ArrayList<>(); |
| | | |
| | | |
| | | |
| | | int errorLines = 0; |
| | | int successLines = 0; |
| | | ImportParams params = new ImportParams(); |
| | |
| | | List<MahorImportExcel> techImportExcels = ExcelImportUtil.importExcel(inputStream, MahorImportExcel.class, params); |
| | | for (MahorImportExcel techImportExcel : techImportExcels) { |
| | | |
| | | List<Integer> regionIds; |
| | | if (techImportExcel.getAddress() == null || StringUtils.isEmpty(techImportExcel.getAddress())) { |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel) + "行,地区不能为空"; |
| | | failMsg.add(msg); |
| | | continue; |
| | | } else { |
| | | String[] split = techImportExcel.getAddress().split(";"); |
| | | regionIds = new ArrayList<>(); |
| | | for (String s : split) { |
| | | TRegion region = regionService.lambdaQuery().like(TRegion::getName, s).one(); |
| | | if (region == null) { |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel) + "行,地区不存在"; |
| | | failMsg.add(msg); |
| | | } else { |
| | | regionIds.add(region.getId()); |
| | | } |
| | | } |
| | | if (regionIds.size() != split.length) { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | // List<Integer> regionIds; |
| | | // if (techImportExcel.getAddress() == null || StringUtils.isEmpty(techImportExcel.getAddress())) { |
| | | // msg = "第" + techImportExcels.indexOf(techImportExcel)+1 + "行,地区不能为空"; |
| | | // failMsg.add(msg); |
| | | // continue; |
| | | // } else { |
| | | // String[] split = techImportExcel.getAddress().split(";"); |
| | | // regionIds = new ArrayList<>(); |
| | | // for (String s : split) { |
| | | // TRegion region = regionService.lambdaQuery().like(TRegion::getName, s).one(); |
| | | // if (region == null) { |
| | | // msg = "第" + techImportExcels.indexOf(techImportExcel)+1 + "行,地区不存在"; |
| | | // failMsg.add(msg); |
| | | // } else { |
| | | // regionIds.add(region.getId()); |
| | | // } |
| | | // } |
| | | // if (regionIds.size() != split.length) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // } |
| | | TTitleMajor tTechnicalTitle = new TTitleMajor(); |
| | | if (techImportExcel.getTitileName()==null||StringUtils.isEmpty(techImportExcel.getTitileName())){ |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel) + "行,职称名称不能为空"; |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel)+1 + "行,职称名称不能为空"; |
| | | failMsg.add(msg); |
| | | continue; |
| | | }else { |
| | | TTechnicalTitle one = tTechnicalTitleService.lambdaQuery().eq(TTechnicalTitle::getTitileName, techImportExcel.getTitileName()).last("limit 1").one(); |
| | | if (one!=null){ |
| | | tTechnicalTitle.setTechnicalId(one.getId()); |
| | | tTechnicalTitle.setRegionIds(one.getRegionIds()); |
| | | }else { |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel) + "行,职称名称不存在"; |
| | | msg = "第" + techImportExcels.indexOf(techImportExcel)+1 + "行,职称名称不存在"; |
| | | failMsg.add(msg); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | tTechnicalTitle.setRegionIds(StringUtils.join(regionIds, ",")); |
| | | tTechnicalTitle.setMajorName(techImportExcel.getMajorName()); |
| | | tTechnicalTitles.add(tTechnicalTitle); |
| | | } |