From b8bb71260434558a94a61b7e24c6a0895949d102 Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期四, 05 十月 2023 18:53:26 +0800 Subject: [PATCH] 应急预案提交 --- ard-work/src/main/java/com/ruoyi/plan/controller/ArdEplanController.java | 214 +++++++++++++++++++ ard-work/src/main/java/com/ruoyi/plan/service/impl/ArdEplanServiceImpl.java | 98 ++++++++ ard-work/src/main/java/com/ruoyi/plan/mapper/ArdEplanMapper.java | 61 +++++ ard-work/src/main/java/com/ruoyi/plan/domain/ArdEplan.java | 124 +++++++++++ ard-work/src/main/java/com/ruoyi/plan/service/IArdEplanService.java | 61 +++++ ard-work/src/main/resources/mapper/plan/ArdEplanMapper.xml | 98 ++++++++ 6 files changed, 656 insertions(+), 0 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/plan/controller/ArdEplanController.java b/ard-work/src/main/java/com/ruoyi/plan/controller/ArdEplanController.java new file mode 100644 index 0000000..2d4feae --- /dev/null +++ b/ard-work/src/main/java/com/ruoyi/plan/controller/ArdEplanController.java @@ -0,0 +1,214 @@ +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; + +/** + * 搴旀�ラ妗圕ontroller + * + * @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)); + } +} diff --git a/ard-work/src/main/java/com/ruoyi/plan/domain/ArdEplan.java b/ard-work/src/main/java/com/ruoyi/plan/domain/ArdEplan.java new file mode 100644 index 0000000..d59a3a2 --- /dev/null +++ b/ard-work/src/main/java/com/ruoyi/plan/domain/ArdEplan.java @@ -0,0 +1,124 @@ +package com.ruoyi.plan.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 搴旀�ラ妗堝璞� ard_eplan + * + * @author ard + * @date 2023-10-05 + */ +public class ArdEplan extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 涓婚敭 */ + private String id; + + /** 棰勬鍚嶇О */ + @Excel(name = "棰勬鍚嶇О") + private String name; + + /** 鍒涘缓鏃堕棿 */ + @Excel(name = "鍒涘缓鏃堕棿") + private String time; + + /** 棰勬璇︽儏 */ + @Excel(name = "棰勬璇︽儏") + private String info; + + /** 鍒涘缓浜� */ + @Excel(name = "鍒涘缓浜�") + private String userId; + + /** 閮ㄩ棬涓婚敭 */ + @Excel(name = "閮ㄩ棬涓婚敭") + private String deptId; + + /** 鍒犻櫎鏍囪 */ + private String delFlag; + + public void setId(String id) + { + this.id = id; + } + + public String getId() + { + return id; + } + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setTime(String time) + { + this.time = time; + } + + public String getTime() + { + return time; + } + public void setInfo(String info) + { + this.info = info; + } + + public String getInfo() + { + return info; + } + public void setUserId(String userId) + { + this.userId = userId; + } + + public String getUserId() + { + return userId; + } + public void setDeptId(String deptId) + { + this.deptId = deptId; + } + + public String getDeptId() + { + return deptId; + } + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getDelFlag() + { + return delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("time", getTime()) + .append("info", getInfo()) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("delFlag", getDelFlag()) + .toString(); + } +} diff --git a/ard-work/src/main/java/com/ruoyi/plan/mapper/ArdEplanMapper.java b/ard-work/src/main/java/com/ruoyi/plan/mapper/ArdEplanMapper.java new file mode 100644 index 0000000..61bf3e3 --- /dev/null +++ b/ard-work/src/main/java/com/ruoyi/plan/mapper/ArdEplanMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.plan.mapper; + +import java.util.List; +import com.ruoyi.plan.domain.ArdEplan; + +/** + * 搴旀�ラ妗圡apper鎺ュ彛 + * + * @author ard + * @date 2023-10-05 + */ +public interface ArdEplanMapper +{ + /** + * 鏌ヨ搴旀�ラ妗� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 搴旀�ラ妗� + */ + public ArdEplan selectArdEplanById(String id); + + /** + * 鏌ヨ搴旀�ラ妗堝垪琛� + * + * @param ardEplan 搴旀�ラ妗� + * @return 搴旀�ラ妗堥泦鍚� + */ + public List<ArdEplan> selectArdEplanList(ArdEplan ardEplan); + + /** + * 鏂板搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + public int insertArdEplan(ArdEplan ardEplan); + + /** + * 淇敼搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + public int updateArdEplan(ArdEplan ardEplan); + + /** + * 鍒犻櫎搴旀�ラ妗� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 缁撴灉 + */ + public int deleteArdEplanById(String id); + + /** + * 鎵归噺鍒犻櫎搴旀�ラ妗� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteArdEplanByIds(String[] ids); +} diff --git a/ard-work/src/main/java/com/ruoyi/plan/service/IArdEplanService.java b/ard-work/src/main/java/com/ruoyi/plan/service/IArdEplanService.java new file mode 100644 index 0000000..19520da --- /dev/null +++ b/ard-work/src/main/java/com/ruoyi/plan/service/IArdEplanService.java @@ -0,0 +1,61 @@ +package com.ruoyi.plan.service; + +import java.util.List; +import com.ruoyi.plan.domain.ArdEplan; + +/** + * 搴旀�ラ妗圫ervice鎺ュ彛 + * + * @author ard + * @date 2023-10-05 + */ +public interface IArdEplanService +{ + /** + * 鏌ヨ搴旀�ラ妗� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 搴旀�ラ妗� + */ + public ArdEplan selectArdEplanById(String id); + + /** + * 鏌ヨ搴旀�ラ妗堝垪琛� + * + * @param ardEplan 搴旀�ラ妗� + * @return 搴旀�ラ妗堥泦鍚� + */ + public List<ArdEplan> selectArdEplanList(ArdEplan ardEplan); + + /** + * 鏂板搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + public int insertArdEplan(ArdEplan ardEplan); + + /** + * 淇敼搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + public int updateArdEplan(ArdEplan ardEplan); + + /** + * 鎵归噺鍒犻櫎搴旀�ラ妗� + * + * @param ids 闇�瑕佸垹闄ょ殑搴旀�ラ妗堜富閿泦鍚� + * @return 缁撴灉 + */ + public int deleteArdEplanByIds(String[] ids); + + /** + * 鍒犻櫎搴旀�ラ妗堜俊鎭� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 缁撴灉 + */ + public int deleteArdEplanById(String id); +} diff --git a/ard-work/src/main/java/com/ruoyi/plan/service/impl/ArdEplanServiceImpl.java b/ard-work/src/main/java/com/ruoyi/plan/service/impl/ArdEplanServiceImpl.java new file mode 100644 index 0000000..e8751c4 --- /dev/null +++ b/ard-work/src/main/java/com/ruoyi/plan/service/impl/ArdEplanServiceImpl.java @@ -0,0 +1,98 @@ +package com.ruoyi.plan.service.impl; + +import java.util.List; + import com.ruoyi.common.utils.DateUtils; + +import com.ruoyi.common.utils.uuid.IdUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.ArrayList; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.plan.mapper.ArdEplanMapper; +import com.ruoyi.plan.domain.ArdEplan; +import com.ruoyi.plan.service.IArdEplanService; + +/** + * 搴旀�ラ妗圫ervice涓氬姟灞傚鐞� + * + * @author ard + * @date 2023-10-05 + */ +@Service +public class ArdEplanServiceImpl implements IArdEplanService { + @Autowired + private ArdEplanMapper ardEplanMapper; + + /** + * 鏌ヨ搴旀�ラ妗� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 搴旀�ラ妗� + */ + @Override + public ArdEplan selectArdEplanById(String id) { + return ardEplanMapper.selectArdEplanById(id); + } + + /** + * 鏌ヨ搴旀�ラ妗堝垪琛� + * + * @param ardEplan 搴旀�ラ妗� + * @return 搴旀�ラ妗� + */ + @Override + public List<ArdEplan> selectArdEplanList(ArdEplan ardEplan) { + return ardEplanMapper.selectArdEplanList(ardEplan); + } + + /** + * 鏂板搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + @Override + public int insertArdEplan(ArdEplan ardEplan) { + ardEplan.setId(IdUtils.simpleUUID()); + ardEplan.setUserId(SecurityUtils.getUserId()); + ardEplan.setCreateBy(SecurityUtils.getUsername()); + ardEplan.setCreateTime(DateUtils.getNowDate()); + return ardEplanMapper.insertArdEplan(ardEplan); + } + + /** + * 淇敼搴旀�ラ妗� + * + * @param ardEplan 搴旀�ラ妗� + * @return 缁撴灉 + */ + @Override + public int updateArdEplan(ArdEplan ardEplan) { + ardEplan.setUpdateBy(SecurityUtils.getUsername()); + ardEplan.setUpdateTime(DateUtils.getNowDate()); + return ardEplanMapper.updateArdEplan(ardEplan); + } + + /** + * 鎵归噺鍒犻櫎搴旀�ラ妗� + * + * @param ids 闇�瑕佸垹闄ょ殑搴旀�ラ妗堜富閿� + * @return 缁撴灉 + */ + @Override + public int deleteArdEplanByIds(String[] ids) { + return ardEplanMapper.deleteArdEplanByIds(ids); + } + + /** + * 鍒犻櫎搴旀�ラ妗堜俊鎭� + * + * @param id 搴旀�ラ妗堜富閿� + * @return 缁撴灉 + */ + @Override + public int deleteArdEplanById(String id) { + return ardEplanMapper.deleteArdEplanById(id); + } +} diff --git a/ard-work/src/main/resources/mapper/plan/ArdEplanMapper.xml b/ard-work/src/main/resources/mapper/plan/ArdEplanMapper.xml new file mode 100644 index 0000000..0b3b611 --- /dev/null +++ b/ard-work/src/main/resources/mapper/plan/ArdEplanMapper.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.plan.mapper.ArdEplanMapper"> + + <resultMap type="ArdEplan" id="ArdEplanResult"> + <result property="id" column="id" /> + <result property="name" column="name" /> + <result property="time" column="time" /> + <result property="info" column="info" /> + <result property="userId" column="user_id" /> + <result property="deptId" column="dept_id" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="delFlag" column="del_flag" /> + </resultMap> + + <sql id="selectArdEplanVo"> + select id, name, time, info, user_id, dept_id, create_by, create_time, update_by, update_time, del_flag from ard_eplan + </sql> + + <select id="selectArdEplanList" parameterType="ArdEplan" resultMap="ArdEplanResult"> + <include refid="selectArdEplanVo"/> + <where> + <if test="name != null and name != ''"> and name like '%'||#{name}||'%'</if> + <if test="time != null and time != ''"> and time = #{time}</if> + <if test="info != null and info != ''"> and info = #{info}</if> + <if test="userId != null and userId != ''"> and user_id = #{userId}</if> + <if test="deptId != null and deptId != ''"> and dept_id = #{deptId}</if> + </where> + </select> + + <select id="selectArdEplanById" parameterType="String" resultMap="ArdEplanResult"> + <include refid="selectArdEplanVo"/> + where id = #{id} + </select> + + <insert id="insertArdEplan" parameterType="ArdEplan"> + insert into ard_eplan + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">id,</if> + <if test="name != null">name,</if> + <if test="time != null">time,</if> + <if test="info != null">info,</if> + <if test="userId != null">user_id,</if> + <if test="deptId != null">dept_id,</if> + <if test="createBy != null">create_by,</if> + <if test="createTime != null">create_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="delFlag != null">del_flag,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null">#{id},</if> + <if test="name != null">#{name},</if> + <if test="time != null">#{time},</if> + <if test="info != null">#{info},</if> + <if test="userId != null">#{userId},</if> + <if test="deptId != null">#{deptId},</if> + <if test="createBy != null">#{createBy},</if> + <if test="createTime != null">#{createTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="delFlag != null">#{delFlag},</if> + </trim> + </insert> + + <update id="updateArdEplan" parameterType="ArdEplan"> + update ard_eplan + <trim prefix="SET" suffixOverrides=","> + <if test="name != null">name = #{name},</if> + <if test="time != null">time = #{time},</if> + <if test="info != null">info = #{info},</if> + <if test="userId != null">user_id = #{userId},</if> + <if test="deptId != null">dept_id = #{deptId},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="delFlag != null">del_flag = #{delFlag},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteArdEplanById" parameterType="String"> + delete from ard_eplan where id = #{id} + </delete> + + <delete id="deleteArdEplanByIds" parameterType="String"> + delete from ard_eplan where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> +</mapper> \ No newline at end of file -- Gitblit v1.9.3