forked from xxhjsb/wit-park-backend
parent
f0d66f8110
commit
7c74ad3d93
|
@ -4,18 +4,19 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import com.hbt.safety.supervision.pojo.HiddenDanger;
|
||||
import com.hbt.safety.supervision.pojo.vo.TrendVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 隐患Mapper接口
|
||||
*
|
||||
*
|
||||
* @author hbt
|
||||
*/
|
||||
public interface HiddenDangerMapper
|
||||
public interface HiddenDangerMapper
|
||||
{
|
||||
/**
|
||||
* 查询隐患
|
||||
*
|
||||
*
|
||||
* @param id 隐患主键
|
||||
* @return 隐患
|
||||
*/
|
||||
|
@ -30,7 +31,7 @@ public interface HiddenDangerMapper
|
|||
|
||||
/**
|
||||
* 新增隐患
|
||||
*
|
||||
*
|
||||
* @param hiddenDanger 隐患
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -38,7 +39,7 @@ public interface HiddenDangerMapper
|
|||
|
||||
/**
|
||||
* 修改隐患
|
||||
*
|
||||
*
|
||||
* @param hiddenDanger 隐患
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -46,7 +47,7 @@ public interface HiddenDangerMapper
|
|||
|
||||
/**
|
||||
* 删除隐患
|
||||
*
|
||||
*
|
||||
* @param id 隐患主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -54,7 +55,7 @@ public interface HiddenDangerMapper
|
|||
|
||||
/**
|
||||
* 批量删除隐患
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -82,5 +83,5 @@ public interface HiddenDangerMapper
|
|||
* @param endTime 结束时间
|
||||
* @return 返回值
|
||||
*/
|
||||
List<String> selectHiddenDangerSubmitDat(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
List<TrendVo> selectHiddenDangerSubmitDat(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
}
|
||||
|
|
|
@ -5,20 +5,21 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.hbt.safety.supervision.pojo.Risk;
|
||||
import com.hbt.safety.supervision.pojo.vo.TrendVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 风险Mapper接口
|
||||
*
|
||||
*
|
||||
* @author 张雨
|
||||
*/
|
||||
@Mapper
|
||||
public interface RiskMapper
|
||||
public interface RiskMapper
|
||||
{
|
||||
/**
|
||||
* 查询风险
|
||||
*
|
||||
*
|
||||
* @param id 风险主键
|
||||
* @return 风险
|
||||
*/
|
||||
|
@ -33,7 +34,7 @@ public interface RiskMapper
|
|||
|
||||
/**
|
||||
* 新增风险
|
||||
*
|
||||
*
|
||||
* @param risk 风险
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -41,7 +42,7 @@ public interface RiskMapper
|
|||
|
||||
/**
|
||||
* 修改风险
|
||||
*
|
||||
*
|
||||
* @param risk 风险
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -49,7 +50,7 @@ public interface RiskMapper
|
|||
|
||||
/**
|
||||
* 删除风险
|
||||
*
|
||||
*
|
||||
* @param id 风险主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -57,7 +58,7 @@ public interface RiskMapper
|
|||
|
||||
/**
|
||||
* 批量删除风险
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -93,5 +94,5 @@ public interface RiskMapper
|
|||
* @param endTime 结束时间
|
||||
* @return 返回值
|
||||
*/
|
||||
List<String> selectRiskSubmitDat(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
List<TrendVo> selectRiskSubmitDat(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.hbt.safety.supervision.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 趋势图vo
|
||||
*/
|
||||
@Data
|
||||
public class TrendVo {
|
||||
|
||||
private String date;
|
||||
|
||||
private int type;
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.hbt.safety.supervision.pojo.vo;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 周统计数据实体类
|
||||
*
|
||||
|
@ -14,5 +16,5 @@ public class WeekDateVo {
|
|||
private String date;
|
||||
|
||||
/** 数量 */
|
||||
private int count;
|
||||
private List<StatisticsVo> list;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.github.pagehelper.PageInfo;
|
|||
import com.hbt.safety.supervision.mapper.HiddenDangerMapper;
|
||||
import com.hbt.safety.supervision.pojo.HiddenDanger;
|
||||
import com.hbt.safety.supervision.pojo.vo.DateVo;
|
||||
import com.hbt.safety.supervision.pojo.vo.TrendVo;
|
||||
import com.hbt.safety.supervision.service.IHiddenDangerService;
|
||||
import com.hbt.safety.supervision.util.StatisticsResultUtil;
|
||||
import com.hbt.safety.supervision.util.YearWeeksUtil;
|
||||
|
@ -19,7 +20,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
/**
|
||||
* 隐患Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author hbt
|
||||
*/
|
||||
@Service
|
||||
|
@ -32,7 +33,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
|
||||
/**
|
||||
* 查询隐患
|
||||
*
|
||||
*
|
||||
* @param id 隐患主键
|
||||
* @return 隐患
|
||||
*/
|
||||
|
@ -73,7 +74,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
|
||||
/**
|
||||
* 新增隐患
|
||||
*
|
||||
*
|
||||
* @param hiddenDanger 隐患
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -85,7 +86,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
|
||||
/**
|
||||
* 修改隐患
|
||||
*
|
||||
*
|
||||
* @param hiddenDanger 隐患
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -97,7 +98,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
|
||||
/**
|
||||
* 批量删除隐患
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的隐患主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -109,7 +110,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
|
||||
/**
|
||||
* 删除隐患信息
|
||||
*
|
||||
*
|
||||
* @param id 隐患主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -169,7 +170,7 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
|
|||
String endTime = statisticsList.get(statisticsList.size()-1).get("endTime");
|
||||
|
||||
// 查询时间范围内隐患数据
|
||||
List<String> list = hiddenDangerMapper.selectHiddenDangerSubmitDat(startTime, endTime);
|
||||
return YearWeeksUtil.getResultData(statisticsList, list, date);
|
||||
List<TrendVo> list = hiddenDangerMapper.selectHiddenDangerSubmitDat(startTime, endTime);
|
||||
return YearWeeksUtil.getResultData(statisticsList, list, date, HIDDENDANGER_STATUS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.hbt.safety.supervision.service.impl;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hbt.safety.supervision.mapper.RiskMapper;
|
||||
import com.hbt.safety.supervision.pojo.Risk;
|
||||
import com.hbt.safety.supervision.pojo.vo.DateVo;
|
||||
import com.hbt.safety.supervision.pojo.vo.TrendVo;
|
||||
import com.hbt.safety.supervision.service.IRiskService;
|
||||
import com.hbt.safety.supervision.util.StatisticsResultUtil;
|
||||
import com.hbt.safety.supervision.util.YearWeeksUtil;
|
||||
|
@ -17,7 +16,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
/**
|
||||
* 风险Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author 张雨
|
||||
*/
|
||||
@Service
|
||||
|
@ -30,7 +29,7 @@ public class RiskServiceImpl implements IRiskService
|
|||
|
||||
/**
|
||||
* 查询风险
|
||||
*
|
||||
*
|
||||
* @param id 风险主键
|
||||
* @return 风险
|
||||
*/
|
||||
|
@ -53,7 +52,7 @@ public class RiskServiceImpl implements IRiskService
|
|||
|
||||
/**
|
||||
* 新增风险
|
||||
*
|
||||
*
|
||||
* @param risk 风险
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -65,7 +64,7 @@ public class RiskServiceImpl implements IRiskService
|
|||
|
||||
/**
|
||||
* 修改风险
|
||||
*
|
||||
*
|
||||
* @param risk 风险
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -77,7 +76,7 @@ public class RiskServiceImpl implements IRiskService
|
|||
|
||||
/**
|
||||
* 批量删除风险
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的风险主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -89,7 +88,7 @@ public class RiskServiceImpl implements IRiskService
|
|||
|
||||
/**
|
||||
* 删除风险信息
|
||||
*
|
||||
*
|
||||
* @param id 风险主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -140,8 +139,8 @@ public class RiskServiceImpl implements IRiskService
|
|||
String endTime = statisticsList.get(statisticsList.size()-1).get("endTime");
|
||||
|
||||
// 查询时间范围内隐患数据
|
||||
List<String> list = riskMapper.selectRiskSubmitDat(startTime, endTime);
|
||||
List<TrendVo> list = riskMapper.selectRiskSubmitDat(startTime, endTime);
|
||||
|
||||
return YearWeeksUtil.getResultData(statisticsList, list, date);
|
||||
return YearWeeksUtil.getResultData(statisticsList, list, date, RISK_LEVEL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,26 @@ import java.util.Map;
|
|||
public class StatisticsResultUtil {
|
||||
|
||||
public static String defaultResultStatistics(int count) {
|
||||
List<StatisticsVo> list = defaultResultStatisticsList(count);
|
||||
return JSONObject.toJSONString(list);
|
||||
}
|
||||
|
||||
public static String resultStatistics(int count, Map<Integer, Long> map) {
|
||||
List<StatisticsVo> list = resultStatisticsList(count, map);
|
||||
return JSONObject.toJSONString(list);
|
||||
}
|
||||
|
||||
|
||||
public static List<StatisticsVo> defaultResultStatisticsList(int count) {
|
||||
List<StatisticsVo> list = new ArrayList<>();
|
||||
for (int i = 1; i <= count; i++) {
|
||||
StatisticsVo statisticsVo = new StatisticsVo(i, 0);
|
||||
list.add(statisticsVo);
|
||||
}
|
||||
return JSONObject.toJSONString(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String resultStatistics(int count, Map<Integer, Long> map) {
|
||||
public static List<StatisticsVo> resultStatisticsList(int count, Map<Integer, Long> map) {
|
||||
List<StatisticsVo> list = new ArrayList<>();
|
||||
// 组装数据数据
|
||||
for (int i =1; i <= count; i ++) {
|
||||
|
@ -27,6 +38,6 @@ public class StatisticsResultUtil {
|
|||
statisticsVo.setCount(map.getOrDefault(i, 0L).intValue());
|
||||
list.add(statisticsVo);
|
||||
}
|
||||
return JSONObject.toJSONString(list);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.hbt.safety.supervision.util;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hbt.common.core.utils.DateUtils;
|
||||
import com.hbt.safety.supervision.pojo.vo.DateVo;
|
||||
import com.hbt.safety.supervision.pojo.vo.TrendVo;
|
||||
import com.hbt.safety.supervision.pojo.vo.WeekDateVo;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
@ -132,39 +133,6 @@ public class YearWeeksUtil {
|
|||
return week;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
*
|
||||
* @param list 数据
|
||||
* @return 返回值
|
||||
*/
|
||||
public static String dealWeekDate(List<Date> list) {
|
||||
List<Integer> weekList = new ArrayList<>();
|
||||
// 遍历风险时间,计算每个时间的周数
|
||||
for (Date date : list) {
|
||||
// 计算上报风险时间,与一年前时间间的周数
|
||||
int week = weekBetweenYearAgoDate(date);
|
||||
weekList.add(week);
|
||||
}
|
||||
|
||||
// 获取当前时间和往前推一年间的周数
|
||||
int weeks = getYearWeekConut();
|
||||
|
||||
List<WeekDateVo> weekDates = new ArrayList<>();
|
||||
// 筛选数据
|
||||
for (int i = 1; i <= weeks; i++) {
|
||||
WeekDateVo weekDateVo = new WeekDateVo();
|
||||
int finalI = i;
|
||||
int count = (int) weekList.stream().filter(s -> s == finalI).count();
|
||||
weekDateVo.setDate(i+"");
|
||||
weekDateVo.setCount(count);
|
||||
weekDates.add(weekDateVo);
|
||||
}
|
||||
// 处理数据
|
||||
return JSONObject.toJSONString(weekDates);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取某年某周的时间跨度
|
||||
*
|
||||
|
@ -339,17 +307,25 @@ public class YearWeeksUtil {
|
|||
return dateVo;
|
||||
}
|
||||
|
||||
public static String getResultData(List<Map<String, String>> statisticsList, List<String> list, List<String> date) {
|
||||
public static String getResultData(List<Map<String, String>> statisticsList, List<TrendVo> list, List<String> date, int count) {
|
||||
List<WeekDateVo> weekDateVos = new ArrayList<>();
|
||||
// 组装数据
|
||||
for (int i = 0; i < statisticsList.size(); i++) {
|
||||
int finalI = i;
|
||||
int hiddenDangerCount = (int) list.stream()
|
||||
.filter(s -> YearWeeksUtil.belongCalendar(s, statisticsList.get(finalI).get("startTime"),
|
||||
statisticsList.get(finalI).get("endTime"))).count();
|
||||
|
||||
List<TrendVo> trendVos = list.stream()
|
||||
.filter(s -> YearWeeksUtil.belongCalendar(s.getDate(), statisticsList.get(finalI).get("startTime"),
|
||||
statisticsList.get(finalI).get("endTime"))).collect(Collectors.toList());
|
||||
WeekDateVo weekDateVo = new WeekDateVo();
|
||||
weekDateVo.setDate(date.get(i));
|
||||
weekDateVo.setCount(hiddenDangerCount);
|
||||
|
||||
if(CollectionUtils.isEmpty(list)) {
|
||||
weekDateVo.setList(StatisticsResultUtil.defaultResultStatisticsList(count));
|
||||
} else {
|
||||
Map<Integer, Long> map = trendVos.stream()
|
||||
.collect(Collectors.groupingBy(TrendVo::getType, Collectors.counting()));
|
||||
weekDateVo.setList(StatisticsResultUtil.resultStatisticsList(count, map));
|
||||
}
|
||||
weekDateVos.add(weekDateVo);
|
||||
}
|
||||
return JSONObject.toJSONString(weekDateVos);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hbt.safety.supervision.mapper.HiddenDangerMapper">
|
||||
|
||||
|
||||
<resultMap type="com.hbt.safety.supervision.pojo.HiddenDanger" id="HiddenDangerResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
|
@ -27,29 +27,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectHiddenDangerList" parameterType="com.hbt.safety.supervision.pojo.HiddenDanger" resultType="HiddenDanger">
|
||||
<include refid="selectHiddenDangerVo"/>
|
||||
<where>
|
||||
<where>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<sql id="selectHiddenDanger">
|
||||
select distinct(a.id) id, a.name, a.details, a.risk_id riskId, DATE_FORMAT(a.submit_date,'%Y-%m-%d %H:%i:%S') submitDate, a.reform_measures reformMeasures, a.reform_status reformStatus, a.exceed_time_limit_status exceedTimeLimitStatus, a.enterprise_id enterpriseId, a.person_id personId, a.remarks remarks, a.rectification_period rectificationPeriod,
|
||||
b.name as enterprise,
|
||||
p.name as person,
|
||||
r.name as riskName,
|
||||
a.investigator_id investigatorId,
|
||||
n.name investigator
|
||||
b.name as enterprise,
|
||||
p.name as person,
|
||||
r.name as riskName,
|
||||
a.investigator_id investigatorId,
|
||||
n.name investigator
|
||||
from hidden_danger as a
|
||||
left join enterprise_information as b on a.enterprise_id = b.id
|
||||
left join person as p on a.person_id = p.id
|
||||
left join risk as r on a.risk_id = r.id
|
||||
left join person as n on a.investigator_id = n.id
|
||||
left join enterprise_information as b on a.enterprise_id = b.id
|
||||
left join person as p on a.person_id = p.id
|
||||
left join risk as r on a.risk_id = r.id
|
||||
left join person as n on a.investigator_id = n.id
|
||||
</sql>
|
||||
|
||||
<select id="selectHiddenDangerById" parameterType="String" resultType="HiddenDanger">
|
||||
<include refid="selectHiddenDanger"/>
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertHiddenDanger" parameterType="com.hbt.safety.supervision.pojo.HiddenDanger">
|
||||
insert into hidden_danger
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="personId != null">person_id,</if>
|
||||
<if test="remarks != null">remarks,</if>
|
||||
<if test="rectificationPeriod != null">rectification_period,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
|
@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="personId != null">#{personId},</if>
|
||||
<if test="remarks != null">#{remarks},</if>
|
||||
<if test="rectificationPeriod != null">#{rectificationPeriod},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateHiddenDanger" parameterType="com.hbt.safety.supervision.pojo.HiddenDanger">
|
||||
|
@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteHiddenDangerByIds" parameterType="String">
|
||||
delete from hidden_danger where id in
|
||||
delete from hidden_danger where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
@ -121,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select id, name, reform_status reformStatus from hidden_danger where exceed_time_limit_status = 0
|
||||
</select>
|
||||
|
||||
<select id="selectHiddenDangerSubmitDat" resultType="String">
|
||||
select DATE_FORMAT(submit_date,'%Y-%m-%d') submit_date from hidden_danger where DATE_FORMAT(submit_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(submit_date,'%Y-%m-%d') <= #{endTime}
|
||||
<select id="selectHiddenDangerSubmitDat" resultType="com.hbt.safety.supervision.pojo.vo.TrendVo">
|
||||
select DATE_FORMAT(submit_date,'%Y-%m-%d') date , reform_status type from hidden_danger where DATE_FORMAT(submit_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(submit_date,'%Y-%m-%d') <= #{endTime}
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,9 +1,9 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hbt.safety.supervision.mapper.RiskMapper">
|
||||
|
||||
|
||||
<resultMap type="com.hbt.safety.supervision.pojo.Risk" id="RiskResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
|
@ -24,27 +24,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectRiskList" parameterType="com.hbt.safety.supervision.pojo.Risk" resultMap="RiskResult">
|
||||
<include refid="selectRiskVo"/>
|
||||
<where>
|
||||
<where>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="selectRisk">
|
||||
select distinct(a.id) id, a.name name, a.risk_probability riskProbability, a.risk_factor riskFactor, a.affect_consequences affectConsequences, a.level level, a.enterprise_id enterpriseId, a.responsible_person_id responsiblePersonId, a.risk_control_measures riskControlMeasures, DATE_FORMAT(a.last_review_date,'%Y-%m-%d %H:%i:%S') lastReviewDate, a.major_hazard_sources_id majorHazardSourcesId,
|
||||
b.name as enterprise,
|
||||
p.name as responsiblePerson,
|
||||
m.name as majorHazardSourcesName,
|
||||
a.major_hazard_sources_id as majorHazardSourcesId
|
||||
b.name as enterprise,
|
||||
p.name as responsiblePerson,
|
||||
m.name as majorHazardSourcesName,
|
||||
a.major_hazard_sources_id as majorHazardSourcesId
|
||||
from risk as a
|
||||
left join enterprise_information as b on a.enterprise_id = b.id
|
||||
left join person as p on a.responsible_person_id = p.id
|
||||
left join major_hazard_sources as m on m.id = a.major_hazard_sources_id
|
||||
left join enterprise_information as b on a.enterprise_id = b.id
|
||||
left join person as p on a.responsible_person_id = p.id
|
||||
left join major_hazard_sources as m on m.id = a.major_hazard_sources_id
|
||||
</sql>
|
||||
<select id="selectRiskById" parameterType="String" resultType="Risk">
|
||||
<include refid="selectRisk"/>
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertRisk" parameterType="com.hbt.safety.supervision.pojo.Risk">
|
||||
insert into risk
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="riskControlMeasures != null">risk_control_measures,</if>
|
||||
<if test="lastReviewDate != null">last_review_date,</if>
|
||||
<if test="majorHazardSourcesId != null">major_hazard_sources_id,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
|
@ -72,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="riskControlMeasures != null">#{riskControlMeasures},</if>
|
||||
<if test="lastReviewDate != null">#{lastReviewDate},</if>
|
||||
<if test="majorHazardSourcesId != null">#{majorHazardSourcesId},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRisk" parameterType="com.hbt.safety.supervision.pojo.Risk">
|
||||
|
@ -97,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteRiskByIds" parameterType="String">
|
||||
delete from risk where id in
|
||||
delete from risk where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
@ -115,7 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select DATE_FORMAT(submit_date,'%Y-%m-%d %H:%i:%S') as submit_date from risk where DATE_FORMAT(submit_date,'%Y-%m-%d') >= DATE_FORMAT(#{yearAgo},'%Y-%m-%d')
|
||||
</select>
|
||||
|
||||
<select id="selectRiskSubmitDat" resultType="String">
|
||||
select DATE_FORMAT(submit_date,'%Y-%m-%d') as submit_date from risk where DATE_FORMAT(submit_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(submit_date,'%Y-%m-%d') <= #{endTime}
|
||||
<select id="selectRiskSubmitDat" resultType="TrendVo">
|
||||
select DATE_FORMAT(submit_date,'%Y-%m-%d') as date , level as type from risk where DATE_FORMAT(submit_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(submit_date,'%Y-%m-%d') <= #{endTime}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue