From 178e429c07d5e9c57afb4e81952c360ef48508b5 Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Fri, 8 Mar 2024 15:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=9F=E4=BC=8D=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E6=97=B6=E8=A6=81=E8=83=BD=E8=87=AA=E8=A1=8C=E8=BE=93?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ehs/EhsRescueTeamController.java | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java index af9dc4d..d6b587c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java @@ -1,38 +1,31 @@ package com.ruoyi.web.controller.ehs; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Arrays; -import javax.servlet.http.HttpServletResponse; - -import com.ruoyi.common.core.domain.ExcelExp; -import com.ruoyi.common.utils.ExcelExportUtil; -import com.ruoyi.ehsRescueTeam.domain.RescueTeamImportTemplate; -import com.ruoyi.ehsRescueTeamWorker.service.IEhsRescueTeamWorkerService; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.DictUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.ehsRescueTeam.domain.EhsRescueTeam; import com.ruoyi.ehsRescueTeam.service.IEhsRescueTeamService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.ehsRescueTeamWorker.service.IEhsRescueTeamWorkerService; +import com.ruoyi.system.service.ISysDictDataService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + /** * 应急救援队伍管理Controller * @@ -49,6 +42,9 @@ public class EhsRescueTeamController extends BaseController { @Autowired private IEhsRescueTeamWorkerService ehsRescueTeamWorkerService; + @Autowired + private ISysDictDataService dictDataService; + /** * 查询应急救援队伍管理列表 */ @@ -68,7 +64,7 @@ public class EhsRescueTeamController extends BaseController { @PostMapping("/export") public void export(HttpServletResponse response, EhsRescueTeam ehsRescueTeam) { List list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam); - ExcelUtil util = new ExcelUtil(EhsRescueTeam.class); + ExcelUtil util = new ExcelUtil<>(EhsRescueTeam.class); util.exportExcel(response, list, "应急救援队伍管理数据"); } @@ -77,7 +73,7 @@ public class EhsRescueTeamController extends BaseController { */ @PostMapping("/importTemplate") public void importTemplate(HttpServletResponse response) throws Exception { - ExcelUtil util = new ExcelUtil(EhsRescueTeam.class); + ExcelUtil util = new ExcelUtil<>(EhsRescueTeam.class); util.importComboTemplateExcel(response, "应急救援队伍信息数据"); } @@ -108,7 +104,21 @@ public class EhsRescueTeamController extends BaseController { @PreAuthorize("@ss.hasPermi('ehs:ehsRescueTeam:add')") @Log(title = "应急救援队伍管理", businessType = BusinessType.INSERT) @PostMapping + @Transactional public AjaxResult add(@RequestBody EhsRescueTeam ehsRescueTeam) { + String teamLevel = DictUtils.getDictLabel("team_level", ehsRescueTeam.getTeamLevel()); + if (StringUtils.isBlank(teamLevel)) { + // 字典表中不存在该队伍级别就创建 + SysDictData dictData = new SysDictData(); + dictData.setDictLabel(ehsRescueTeam.getTeamLevel()); + dictData.setDictValue(ehsRescueTeam.getTeamLevel()); + dictData.setDictType("team_level"); + dictData.setListClass("default"); + dictData.setCreateTime(new Date()); + dictData.setCreateBy(getUsername()); + dictDataService.insertDictData(dictData); + } + return toAjax(ehsRescueTeamService.save(ehsRescueTeam)); }