| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private TTitleMajorService majorService; |
| | | @Resource |
| | | private TLevelService levelService; |
| | | @Resource |
| | | private TUserChangeDetailService userChangeDetailService; |
| | | @Resource |
| | | private TConsultationService consultationService; |
| | | @Resource |
| | | private TDeclareNoticeService declareNoticeService; |
| | | @Resource |
| | | private TCommitteeTechnicalService committeeTechnicalService; |
| | | @Resource |
| | | private TCommitteeService committeeService; |
| | | @Resource |
| | | private TInformationService informationService; |
| | | @Resource |
| | | private TCourseService courseService; |
| | | //添加接口 |
| | | @ApiOperation(value = "添加",tags = "后台-系统设置-职称系列") |
| | | @PostMapping(value = "/add") |
| | |
| | | @ApiOperation(value = "树状图",tags = "web-下拉框") |
| | | @PostMapping(value = "/tree") |
| | | public R<List<TTechnicalTitle>> tree(){ |
| | | List<TLevel> list2 = levelService.list(); |
| | | |
| | | List<TTitleMajor> tTitleMajorList = majorService.lambdaQuery().list(); |
| | | List<TTechnicalTitle> list = tTechnicalTitleService.list(); |
| | | for (TTechnicalTitle tTechnicalTitle : list) { |
| | | tTechnicalTitle.setName(tTechnicalTitle.getTitileName()); |
| | | List<TTitleMajor> list1 = majorService.lambdaQuery().eq(TTitleMajor::getTechnicalId, tTechnicalTitle.getId()).list(); |
| | | for (TTitleMajor tTitleMajor : list1) { |
| | | List<TTitleMajor> tTitleMajors = tTitleMajorList.stream().filter(e -> e.getTechnicalId().equals(tTechnicalTitle.getId())).collect(Collectors.toList()); |
| | | for (TTitleMajor tTitleMajor : tTitleMajors) { |
| | | tTitleMajor.setName(tTitleMajor.getMajorName()); |
| | | tTitleMajor.setMajors(list2); |
| | | // tTitleMajor.setMajors(list2); |
| | | } |
| | | tTechnicalTitle.setMajors(list1); |
| | | tTechnicalTitle.setMajors(tTitleMajors); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | |
| | | @PostMapping(value = "/edit") |
| | | public R edit(@RequestBody TTechnicalTitle tTechnicalTitle){ |
| | | tTechnicalTitleService.updateById(tTechnicalTitle); |
| | | |
| | | // 修改专业的地区 |
| | | majorService.lambdaUpdate().eq(TTitleMajor::getTechnicalId, tTechnicalTitle.getId()).set(TTitleMajor::getRegionIds, tTechnicalTitle.getRegionIds()).update(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Resource |
| | | private TUserChangeDetailService userChangeDetailService; |
| | | @Resource |
| | | private TConsultationService consultationService; |
| | | @Resource |
| | | private TDeclareNoticeService declareNoticeService; |
| | | @Resource |
| | | private TCommitteeTechnicalService committeeTechnicalService; |
| | | @Resource |
| | | private TCommitteeService committeeService; |
| | | @Resource |
| | | private TInformationService informationService; |
| | | @Resource |
| | | private TCourseService courseService; |
| | | //批量删除接口 |
| | | @ApiOperation(value = "删除",tags = "后台-系统设置-职称系列") |
| | | @PostMapping(value = "/deleteByIds") |
| | |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | for (String s : list) { |
| | | //判断是否有关联数据 |
| | | Long count = userChangeDetailService.lambdaQuery().eq(TUserChangeDetail::getTitleId, s).count(); |
| | | if (count>0){ |
| | | Long userChange = userChangeDetailService.lambdaQuery().eq(TUserChangeDetail::getTitleId, s).count(); |
| | | if (userChange>0){ |
| | | return R.fail("当前职称已有用户设为偏好,无法删除"); |
| | | } |
| | | Long count1 = consultationService.lambdaQuery().eq(TConsultation::getTitleId, s).count(); |
| | | if (count1>0){ |
| | | Long consultation = consultationService.lambdaQuery().eq(TConsultation::getTitleId, s).count(); |
| | | if (consultation>0){ |
| | | return R.fail("当前职称已设置咨询,无法删除"); |
| | | } |
| | | Long count2 = declareNoticeService.lambdaQuery().eq(TDeclareNotice::getTechnicalId, s).count(); |
| | | if (count2>0){ |
| | | Long declareNotice = declareNoticeService.lambdaQuery().eq(TDeclareNotice::getTechnicalId, s).count(); |
| | | if (declareNotice>0){ |
| | | return R.fail("当前职称已设置申报通知,无法删除"); |
| | | } |
| | | Long count3 = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getTechnicalId, s).count(); |
| | | if (count3>0){ |
| | | Long committeeTechnical = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getTechnicalId, s).count(); |
| | | if (committeeTechnical>0){ |
| | | return R.fail("当前职称已设置委员会可评审职称,无法删除"); |
| | | } |
| | | Long count4 = committeeService.lambdaQuery().eq(TCommittee::getTechnicalId, s).count(); |
| | | if (count4>0){ |
| | | Long committee = committeeService.lambdaQuery().eq(TCommittee::getTechnicalId, s).count(); |
| | | if (committee>0){ |
| | | return R.fail("当前职称已设置评审委员会,无法删除"); |
| | | } |
| | | Long count5 = informationService.lambdaQuery().eq(TInformation::getTechnicalId, s).count(); |
| | | if (count5>0){ |
| | | Long infomation = informationService.lambdaQuery().eq(TInformation::getTechnicalId, s).count(); |
| | | if (infomation>0){ |
| | | return R.fail("当前职称已设置资料,无法删除"); |
| | | } |
| | | Long count6 = majorService.lambdaQuery().eq(TTitleMajor::getTechnicalId, s).count(); |
| | | if (count6>0){ |
| | | Long major = majorService.lambdaQuery().eq(TTitleMajor::getTechnicalId, s).count(); |
| | | if (major>0){ |
| | | return R.fail("当前职称已设置专业,无法删除"); |
| | | } |
| | | Long count7 = courseService.lambdaQuery().eq(TCourse::getTechnicalId, s).count(); |
| | | if (count7>0){ |
| | | Long course = courseService.lambdaQuery().eq(TCourse::getTechnicalId, s).count(); |
| | | if (course>0){ |
| | | return R.fail("当前职称已设置课程,无法删除"); |
| | | } |
| | | } |
| | |
| | | @PostMapping("/export") |
| | | public R export (@RequestParam("file") MultipartFile file) { |
| | | List<TTechnicalTitle> tTechnicalTitles = new ArrayList<>(); |
| | | |
| | | |
| | | |
| | | int errorLines = 0; |
| | | int successLines = 0; |
| | | ImportParams params = new ImportParams(); |
| | | // params.setTitleRows(1);//标题行数 |
| | | params.setHeadRows(1); //表头行数 |
| | | String msg = null; |
| | | InputStream inputStream = null; |
| | | |
| | | List<String> failMsg = new ArrayList<>(); |
| | | |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | List<TechImportExcel> techImportExcels = ExcelImportUtil.importExcel(inputStream, TechImportExcel.class, params); |
| | | List<TRegion> list = regionService.lambdaQuery().list(); |
| | | |
| | | for (TechImportExcel techImportExcel : techImportExcels) { |
| | | |
| | | List<Integer> regionIds; |
| | |
| | | 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("全部".equals(techImportExcel.getAddress())){ |
| | | regionIds = list.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | }else { |
| | | String[] split = techImportExcel.getAddress().split(";"); |
| | | regionIds = new ArrayList<>(); |
| | | for (String s : split) { |
| | | TRegion region = list.stream().filter(e -> e.getName().contains(s)).findFirst().orElse(null); |
| | | // 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; |
| | | } |
| | | } |
| | | if (regionIds.size() != split.length) { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | TTechnicalTitle tTechnicalTitle = new TTechnicalTitle(); |
| | | tTechnicalTitle.setTitileName(techImportExcel.getTitileName()); |
| | |
| | | e.printStackTrace(); |
| | | // logger.error("批量购入导入失败:{}",e.getMessage()); |
| | | // importRecordService.removeById(tImportRecord.getId()); |
| | | return R.fail("批量购入导入失败!"); |
| | | return R.fail("批量导入失败!"); |
| | | }finally { |
| | | try { |
| | | inputStream.close(); |