添加队伍其他时要能自行输入

main
15036302109 9 months ago
parent 9fb2245f1c
commit 178e429c07

@ -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<EhsRescueTeam> list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam);
ExcelUtil<EhsRescueTeam> util = new ExcelUtil<EhsRescueTeam>(EhsRescueTeam.class);
ExcelUtil<EhsRescueTeam> 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<EhsRescueTeam> util = new ExcelUtil<EhsRescueTeam>(EhsRescueTeam.class);
ExcelUtil<EhsRescueTeam> 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));
}

Loading…
Cancel
Save