package com.ruoyi.plan.controller;
|
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
import javax.servlet.http.HttpServletResponse;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.system.service.ISysUserService;
|
import io.swagger.annotations.Api;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
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 com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.plan.domain.ArdEplan;
|
import com.ruoyi.plan.service.IArdEplanService;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
/**
|
* 应急预案Controller
|
*
|
* @author ard
|
* @date 2023-10-05
|
*/
|
@RestController
|
@RequestMapping("/plan/eplan")
|
@Api(tags = "应急预案")
|
public class ArdEplanController extends BaseController
|
{
|
@Autowired
|
private IArdEplanService ardEplanService;
|
|
@Autowired
|
private ISysUserService userService;
|
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
/**
|
* 查询应急预案列表
|
*/
|
/*@PreAuthorize("@ss.hasPermi('plan:eplan:list')")
|
@GetMapping("/list")
|
public TableDataInfo list(ArdEplan ardEplan)
|
{
|
startPage();
|
List<ArdEplan> list = ardEplanService.selectArdEplanList(ardEplan);
|
return getDataTable(list);
|
}*/
|
@PreAuthorize("@ss.hasPermi('plan:eplan:list')")
|
@GetMapping("/list")
|
public TableDataInfo list(ArdEplan ardEplan)
|
{
|
startPage();
|
List<ArdEplan> list = ardEplanService.selectArdEplanList(ardEplan);
|
List<Map<String,Object>> result = new ArrayList();
|
for(ArdEplan para : list){
|
Map<String,Object> map = new HashMap();
|
map.put("id",para.getId());
|
map.put("name",para.getName());
|
map.put("time",para.getTime());
|
String info = para.getInfo();
|
String[] infoArr = info.split(";");
|
List<Map<String,String>> infoList = new ArrayList();
|
for(String str : infoArr){
|
Map<String,String> infoMap = new HashMap();
|
infoMap.put("longitude",str.split(",")[0]);
|
infoMap.put("latitude",str.split(",")[1]);
|
infoMap.put("altitude",str.split(",")[2]);
|
infoMap.put("text",str.split(",")[3]);
|
infoList.add(infoMap);
|
}
|
map.put("obj",infoList);
|
map.put("userId",para.getUserId());
|
map.put("deptId",para.getDeptId());
|
map.put("createBy",para.getCreateBy());
|
result.add(map);
|
}
|
return getDataTable(result);
|
}
|
|
|
/**
|
* 导出应急预案列表
|
*/
|
@PreAuthorize("@ss.hasPermi('plan:eplan:export')")
|
@Log(title = "应急预案", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, ArdEplan ardEplan)
|
{
|
List<ArdEplan> list = ardEplanService.selectArdEplanList(ardEplan);
|
ExcelUtil<ArdEplan> util = new ExcelUtil<ArdEplan>(ArdEplan.class);
|
util.exportExcel(response, list, "应急预案数据");
|
}
|
|
/**
|
* 获取应急预案详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('plan:eplan:query')")
|
@GetMapping(value = "/{id}")
|
public AjaxResult getInfo(@PathVariable("id") String id)
|
{
|
return success(ardEplanService.selectArdEplanById(id));
|
}
|
|
/**
|
* 新增应急预案
|
*/
|
/*@PreAuthorize("@ss.hasPermi('plan:eplan:add')")
|
@Log(title = "应急预案", businessType = BusinessType.INSERT)
|
@PostMapping
|
public AjaxResult add(@RequestBody ArdEplan ardEplan)
|
{
|
return toAjax(ardEplanService.insertArdEplan(ardEplan));
|
}*/
|
|
@PreAuthorize("@ss.hasPermi('plan:eplan:add')")
|
@Log(title = "应急预案", businessType = BusinessType.INSERT)
|
@PostMapping
|
public AjaxResult add(@RequestBody Map<String,Object> para)
|
{
|
ArdEplan ardEplan = new ArdEplan();
|
String id = IdUtils.simpleUUID();
|
ardEplan.setId(id);
|
ardEplan.setName((String) para.get("name"));
|
Date date = new Date();
|
ardEplan.setTime(sdf.format(date));
|
String info = "";
|
if(para.get("obj") == null){
|
return toAjax(0);
|
}else{
|
if(((List<Map<String,String>>)para.get("obj")).size() == 0){
|
return toAjax(0);
|
}
|
}
|
for(Map<String,String> map : (List<Map<String,String>>)para.get("obj")){
|
info = info+map.get("longitude")+","+map.get("latitude")+","+map.get("altitude")+","+map.get("text")+";";
|
}
|
info = info.substring(0,info.length() - 1);
|
ardEplan.setInfo(info);
|
String userId = SecurityUtils.getUserId();
|
ardEplan.setUserId(userId);
|
ardEplan.setDeptId(String.valueOf((Integer) para.get("deptId")));
|
SysUser sysUser = userService.selectUserById(userId);
|
ardEplan.setCreateBy(sysUser.getUserName());
|
ardEplan.setCreateTime(date);
|
return toAjax(ardEplanService.insertArdEplan(ardEplan));
|
}
|
|
/**
|
* 修改应急预案
|
*/
|
/*@PreAuthorize("@ss.hasPermi('plan:eplan:edit')")
|
@Log(title = "应急预案", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public AjaxResult edit(@RequestBody ArdEplan ardEplan)
|
{
|
return toAjax(ardEplanService.updateArdEplan(ardEplan));
|
}*/
|
|
@PreAuthorize("@ss.hasPermi('plan:eplan:edit')")
|
@Log(title = "应急预案", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public AjaxResult edit(@RequestBody Map<String,Object> para)
|
{
|
ArdEplan ardEplan = new ArdEplan();
|
ardEplan.setId((String) para.get("id"));
|
ardEplan.setName((String) para.get("name"));
|
Date date = new Date();
|
ardEplan.setTime(sdf.format(date));
|
String info = "";
|
if(para.get("obj") == null){
|
return toAjax(0);
|
}else{
|
if(((List<Map<String,String>>)para.get("obj")).size() == 0){
|
return toAjax(0);
|
}
|
}
|
for(Map<String,String> map : (List<Map<String,String>>)para.get("obj")){
|
info = info+map.get("longitude")+","+map.get("latitude")+","+map.get("altitude")+","+map.get("text")+";";
|
}
|
info = info.substring(0,info.length() - 1);
|
ardEplan.setInfo(info);
|
String userId = SecurityUtils.getUserId();
|
ardEplan.setUserId(userId);
|
ardEplan.setDeptId(String.valueOf((Integer) para.get("deptId")));
|
SysUser sysUser = userService.selectUserById(userId);
|
ardEplan.setCreateBy(sysUser.getUserName());
|
ardEplan.setCreateTime(date);
|
return toAjax(ardEplanService.updateArdEplan(ardEplan));
|
}
|
|
/**
|
* 删除应急预案
|
*/
|
@PreAuthorize("@ss.hasPermi('plan:eplan:remove')")
|
@Log(title = "应急预案", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public AjaxResult remove(@PathVariable String[] ids)
|
{
|
return toAjax(ardEplanService.deleteArdEplanByIds(ids));
|
}
|
}
|