From b6373daa40c3dc17ca107f3666fd252f3b6b0778 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 03 一月 2025 18:34:52 +0800 Subject: [PATCH] 代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTitleMajorController.java | 74 +++++++++++------------------------- 1 files changed, 23 insertions(+), 51 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTitleMajorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTitleMajorController.java index 53a8f8c..0422256 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTitleMajorController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTitleMajorController.java @@ -81,33 +81,33 @@ public R deleteById(Long id){ String s = id.toString(); //判断是否有关联数据 - Long count = userChangeDetailService.lambdaQuery().eq(TUserChangeDetail::getMajorId, s).count(); - if (count>0){ + Long userChange = userChangeDetailService.lambdaQuery().eq(TUserChangeDetail::getMajorId, s).count(); + if (userChange>0){ return R.fail("当前专业已有用户设为偏好,无法删除"); } - Long count1 = consultationService.lambdaQuery().eq(TConsultation::getMajorId, s).count(); - if (count1>0){ + Long consultation = consultationService.lambdaQuery().eq(TConsultation::getMajorId, s).count(); + if (consultation>0){ return R.fail("当前专业已设置咨询,无法删除"); } - Long count2 = declareNoticeService.lambdaQuery().eq(TDeclareNotice::getMajorId, s).count(); - if (count2>0){ + Long declareNotice = declareNoticeService.lambdaQuery().eq(TDeclareNotice::getMajorId, s).count(); + if (declareNotice>0){ return R.fail("当前专业已设置申报通知,无法删除"); } - Long count3 = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getMajorId, s).count(); - if (count3>0){ + Long committeeTechnical = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getMajorId, s).count(); + if (committeeTechnical>0){ return R.fail("当前专业已设置委员会可评审职称,无法删除"); } - Long count4 = committeeService.lambdaQuery().eq(TCommittee::getMajorId, s).count(); - if (count4>0){ + Long committee = committeeService.lambdaQuery().eq(TCommittee::getMajorId, s).count(); + if (committee>0){ return R.fail("当前专业已设置评审委员会,无法删除"); } - Long count5 = informationService.lambdaQuery().eq(TInformation::getMajorId, s).count(); - if (count5>0){ + Long infomation = informationService.lambdaQuery().eq(TInformation::getMajorId, s).count(); + if (infomation>0){ return R.fail("当前专业已设置资料,无法删除"); } - Long count7 = courseService.lambdaQuery().eq(TCourse::getMajorId, s).count(); - if (count7>0){ + Long course = courseService.lambdaQuery().eq(TCourse::getMajorId, s).count(); + if (course>0){ return R.fail("当前专业已设置课程,无法删除"); } @@ -128,11 +128,6 @@ @PostMapping("/export") public R export (@RequestParam("file") MultipartFile file) { List<TTitleMajor> tTechnicalTitles = new ArrayList<>(); - - - - int errorLines = 0; - int successLines = 0; ImportParams params = new ImportParams(); // params.setTitleRows(1);//标题行数 params.setHeadRows(1); //表头行数 @@ -144,49 +139,26 @@ try { inputStream = file.getInputStream(); List<MahorImportExcel> techImportExcels = ExcelImportUtil.importExcel(inputStream, MahorImportExcel.class, params); + List<TTechnicalTitle> tTechnicalTitleList = tTechnicalTitleService.lambdaQuery().list(); + 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; - } - - } 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 technicalTitle = tTechnicalTitleList.stream() + .filter(e -> e.getTitileName().equals(techImportExcel.getTitileName())).findFirst().orElse(null); + if (technicalTitle!=null){ + tTechnicalTitle.setTechnicalId(technicalTitle.getId()); + tTechnicalTitle.setRegionIds(technicalTitle.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); } -- Gitblit v1.7.1