事故页面已完成

This commit is contained in:
yuyang 2023-11-04 19:46:54 +08:00
parent 1985cdfc5b
commit f2d2b41223
6 changed files with 465 additions and 0 deletions

View File

@ -0,0 +1,56 @@
package com.xhpc.charging.station.controller;
import com.xhpc.charging.station.service.IXhpcEquipmentAccidentService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.domain.XhpcChargingPile;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/accident")
public class XhpcEquipmentAccidentController extends BaseController {
@Resource
IXhpcEquipmentAccidentService xhpcEquipmentAccidentService;
@GetMapping("/list")
public TableDataInfo list(HttpServletRequest request, String address) {
List<Map<String, Object>> list = xhpcEquipmentAccidentService.getLsit(address);
return getDataTable(list);
}
@PostMapping(value = "/addXhpcEquipmentAccident")
public R addXhpcEquipmentAccident(@RequestBody XhpcEquipmentAccident xhpcEquipmentAccident) {
return xhpcEquipmentAccidentService.insertXhpcEquipmentAccident(xhpcEquipmentAccident);
}
@PostMapping(value = "/updateXhpcEquipmentAccident")
public R updateXhpcEquipmentAccident(@RequestBody XhpcEquipmentAccident xhpcEquipmentAccident) {
return xhpcEquipmentAccidentService.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
}
@GetMapping("/getXhpcEquipmentAccidentById")
public R getXhpcEquipmentAccidentById(Long equipmentAccidentId) {
Map<String, Object> map = xhpcEquipmentAccidentService.getXhpcEquipmentAccidentById(equipmentAccidentId);
return R.ok(map);
}
@Log(title = "删除电站", businessType = BusinessType.DELETE)
@GetMapping("/deleteXhpcEquipmentAccidentById")
public R deleteXhpcEquipmentAccidentById(Long equipmentAccidentId) {
return xhpcEquipmentAccidentService.deleteXhpcEquipmentAccidentById(equipmentAccidentId);
}
}

View File

@ -0,0 +1,21 @@
package com.xhpc.charging.station.mapper;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Map;
public interface XhpcEquipmentAccidentMapper {
List<Map<String,Object>> getLsit(@Param("address")String address);
void insertXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident);
void updateXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident);
Map<String,Object> getXhpcEquipmentAccidentById(@Param("equipmentAccidentId")Long equipmentAccidentId);
void deleteXhpcEquipmentAccidentById(@Param("equipmentAccidentId")Long equipmentAccidentId);
}

View File

@ -0,0 +1,20 @@
package com.xhpc.charging.station.service;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import java.util.List;
import java.util.Map;
public interface IXhpcEquipmentAccidentService {
List<Map<String, Object>> getLsit(String address);
R insertXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident);
R updateXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident);
Map<String, Object> getXhpcEquipmentAccidentById(Long equipmentAccidentId );
R deleteXhpcEquipmentAccidentById(Long equipmentAccidentId);
}

View File

@ -0,0 +1,58 @@
package com.xhpc.charging.station.service;
import com.xhpc.charging.station.mapper.XhpcEquipmentAccidentMapper;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class XhpcEquipmentAccidentImpl extends BaseService implements IXhpcEquipmentAccidentService {
@Resource
XhpcEquipmentAccidentMapper xhpcEquipmentAccidentMapper;
@Autowired
private TokenService tokenService;
@Override
public List<Map<String, Object>> getLsit(String address) {
return xhpcEquipmentAccidentMapper.getLsit(address);
}
@Override
public R insertXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident) {
if(xhpcEquipmentAccident.getEquipmentAccidentId() !=null){
xhpcEquipmentAccidentMapper.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
}else {
xhpcEquipmentAccidentMapper.insertXhpcEquipmentAccident(xhpcEquipmentAccident);
}
return R.ok();
}
@Override
public R updateXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident) {
xhpcEquipmentAccidentMapper.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
return R.ok();
}
@Override
public Map<String, Object> getXhpcEquipmentAccidentById(Long equipmentAccidentId) {
return xhpcEquipmentAccidentMapper.getXhpcEquipmentAccidentById(equipmentAccidentId);
}
@Override
public R deleteXhpcEquipmentAccidentById(Long equipmentAccidentId) {
xhpcEquipmentAccidentMapper.deleteXhpcEquipmentAccidentById(equipmentAccidentId);
return R.ok();
}
}

View File

@ -0,0 +1,261 @@
<?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.xhpc.charging.station.mapper.XhpcEquipmentAccidentMapper">
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcEquipmentAccident">
<result property="equipmentAccidentId" column="equipment_accident_id"/>
<result property="areaCode" column="area_code"/>
<result property="address" column="address"/>
<result property="accidentEntity" column="accident_entity"/>
<result property="type" column="type"/>
<result property="accidentReason" column="accident_reason"/>
<result property="level" column="level"/>
<result property="accidentTime" column="accident_time"/>
<result property="description" column="description"/>
<result property="pictures" column="pictures"/>
<result property="analysisReport" column="analysis_report"/>
<result property="delFlag" column="del_flag"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="remark" column="remark"/>
<result property="brandModel" column="brand_model"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<select id="getLsit" resultType="map">
select
equipment_accident_id as equipmentAccidentId,
area_code as areaCode,
address as address,
accident_entity as accidentEntity,
type as type,
accident_reason as accidentReason,
level as level,
accident_time as accidentTime,
description as description,
pictures as pictures,
analysis_report as analysisReport,
case when accident_entity=1 then "运营商"
when accident_entity=2 then "车企"
when accident_entity=3 then "设备制造商"
end accidentEntityName,
case when type=1 then "充电设备质量问题"
when type=2 then "电动车电池问题"
when type=3 then "电网故障"
when type=4 then "充电站管路"
when type=99 then "其他"
end typeName,
case when level=1 then "造成经济损失且有人员伤亡"
when level=2 then "造成人员伤亡"
when level=3 then "造成经济损失但未造成人员伤亡"
when level=4 then "未造成经济损失且无人员伤亡"
end levelName
from xhpc_equipment_accident
where del_flag =0
<if test="address !=null and address !=''">
and address like CONCAT('%',#{address},'%')
</if>
<if test="tenantId !=null and tenantId !=''">
and cp.tenant_id=#{tenantId}
</if>
order by create_time desc
</select>
<insert id="insertXhpcEquipmentAccident">
insert into xhpc_equipment_accident
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != areaCode and ''!=areaCode">
area_code,
</if>
<if test="null != address and ''!=address">
address,
</if>
<if test="null != accidentEntity ">
accident_entity,
</if>
<if test="null != type ">
type,
</if>
<if test="null != accidentReason and ''!=accidentReason">
accident_reason,
</if>
<if test="null != level ">
level,
</if>
<if test="null != accidentTime ">
accident_time,
</if>
<if test="null != description and ''!=description">
description,
</if>
<if test="null != pictures and ''!=pictures">
pictures,
</if>
<if test="null != analysisReport and ''!=analysisReport">
analysis_report,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != tenantId ">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != areaCode and ''!=areaCode">
#{areaCode},
</if>
<if test="null != address and ''!=address">
#{address},
</if>
<if test="null != accidentEntity ">
#{accidentEntity},
</if>
<if test="null != type ">
#{type},
</if>
<if test="null != accidentReason and ''!=accidentReason">
#{accidentReason},
</if>
<if test="null != level ">
#{level},
</if>
<if test="null != accidentTime ">
#{accidentTime},
</if>
<if test="null != description and ''!=description">
#{description},
</if>
<if test="null != pictures and ''!=pictures">
#{pictures},
</if>
<if test="null != analysisReport and ''!=analysisReport">
#{analysisReport},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != tenantId ">
#{tenantId},
</if>
</trim>
</insert>
<update id="updateXhpcEquipmentAccident">
update xhpc_equipment_accident
<trim prefix="SET" suffixOverrides=",">
<if test="null != areaCode and ''!=areaCode">
area_code=#{areaCode},
</if>
<if test="null != address and ''!=address">
address=#{address},
</if>
<if test="null != accidentEntity ">
accident_entity=#{accidentEntity},
</if>
<if test="null != type ">
type=#{type},
</if>
<if test="null != accidentReason and ''!=accidentReason">
accident_reason=#{accidentReason},
</if>
<if test="null != level ">
level=#{level},
</if>
<if test="null != accidentTime ">
accident_time=#{accidentTime},
</if>
<if test="null != description and ''!=description">
description=#{description},
</if>
<if test="null != pictures and ''!=pictures">
pictures=#{pictures},
</if>
<if test="null != analysisReport and ''!=analysisReport">
analysis_report=#{analysisReport},
</if>
<if test="null != delFlag ">
del_flag = #{delFlag},
</if>
<if test="null != createTime ">
create_time = #{createTime},
</if>
<if test="null != createBy and '' != createBy">
create_by = #{createBy},
</if>
<if test="null != updateTime ">
update_time = #{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
update_by =#{updateBy},
</if>
<if test="null != remark and '' != remark">
remark =#{remark},
</if>
<if test="null != tenantId ">
tenant_id =#{tenantId},
</if>
</trim>
where equipment_accident_id = #{equipmentAccidentId}
</update>
<select id="getXhpcEquipmentAccidentById" resultType="map">
select
equipment_accident_id as equipmentAccidentId,
area_code as areaCode,
address as address,
accident_entity as accidentEntity,
type as type,
accident_reason as accidentReason,
level as level,
accident_time as accidentTime,
description as description,
pictures as pictures,
analysis_report as analysisReport
from xhpc_equipment_accident
where equipment_accident_id = #{equipmentAccidentId}
</select>
<update id="deleteXhpcEquipmentAccidentById">
update xhpc_equipment_accident set del_flag =1 where equipment_accident_id = #{equipmentAccidentId}
</update>
</mapper>

View File

@ -0,0 +1,49 @@
package com.xhpc.common.domain;
import com.xhpc.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
@Data
public class XhpcEquipmentAccident extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 充电事故id */
private Long equipmentAccidentId;
/** 区域代码 */
private String areaCode;
/** 事故地点 */
private String address;
/** 事故主题 1.运营商 2车企 3.设备制造商 */
private Integer accidentEntity;
/** 事故类型 1.充电设备质量问题 2.电动车电池问题 3.电网故障 4.充电站管路 99.其他 */
private Integer type;
/** 事故原因 */
private String accidentReason;
/** 事故分级 1.造成经济损失且有人员伤亡 2.造成人员伤亡 3.造成经济损失但未造成人员伤亡 4.未造成经济损失且无人员伤亡 */
private Integer level;
/** 发生时间 */
private Date accidentTime;
/** 事故文字描述 */
private String description;
/** 现场图片 */
private String pictures;
/** 事故分析报告 */
private String analysisReport;
private Integer delFlag;
}