Browse Source

感知统计相关接口

develop
zhao-meiyu 1 year ago
parent
commit
ee8cd8ce60
  1. 32
      zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java
  2. 8
      zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java
  3. 6
      zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java
  4. 32
      zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java
  5. 75
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

32
zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java

@ -2,6 +2,7 @@ package com.zc.business.controller;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDCPerceivedEventsWarningService; import com.zc.business.service.IDCPerceivedEventsWarningService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
/** /**
* @author 王思祥 * @author 王思祥
@ -36,19 +38,16 @@ public class DCPerceivedEventsWarningController extends BaseController {
return AjaxResult.success(perceivedEventsWarningService.selectEventTypeList()); return AjaxResult.success(perceivedEventsWarningService.selectEventTypeList());
} }
//查询预警感知事件类型 //根据类型和状态查询预计事件
@PostMapping("/warningType")
public AjaxResult getWarningTypeList(){
return AjaxResult.success(perceivedEventsWarningService.selectWarningTypeList());
}
//根据类型查询预计事件
@PostMapping("/perceivedEventsList") @PostMapping("/perceivedEventsList")
public AjaxResult getPerceivedEventsList(@RequestBody DcWarning dcWarning){ public TableDataInfo getPerceivedEventsList(@RequestBody DcWarning dcWarning){
return AjaxResult.success(perceivedEventsWarningService.selectPerceivedEventsList(dcWarning)); startPage();
List<DcWarning> list = perceivedEventsWarningService.selectPerceivedEventsList(dcWarning);
return getDataTable(list);
} }
//查询感知数量按照路段数量进行排名 //查询感知数量按照路段数量进行排名
@PostMapping("/sectionPerceivedList") @PostMapping("/sectionPerceivedList")
public AjaxResult getSectionPerceivedEventsList( ){ public AjaxResult getSectionPerceivedEventsList(){
return AjaxResult.success(perceivedEventsWarningService.selectSectionPerceivedEventsList()); return AjaxResult.success(perceivedEventsWarningService.selectSectionPerceivedEventsList());
} }
//查询感知数量按照路段进行区分 //查询感知数量按照路段进行区分
@ -86,7 +85,7 @@ public class DCPerceivedEventsWarningController extends BaseController {
@PostMapping("/warningTrend") @PostMapping("/warningTrend")
public AjaxResult getWarningTrend(@RequestBody DcWarning dcWarning){ public AjaxResult getWarningTrend(@RequestBody DcWarning dcWarning){
String type = dcWarning.getType();//类型 String type = dcWarning.getType();//类型
String sectionId = dcWarning.getSectionId();//桩号id String sectionId = dcWarning.getSectionId();//路段辖区id
Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00 Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null){ if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null){
return AjaxResult.error("参数数据异常"); return AjaxResult.error("参数数据异常");
@ -97,7 +96,7 @@ public class DCPerceivedEventsWarningController extends BaseController {
@PostMapping("/warningSectionType") @PostMapping("/warningSectionType")
public AjaxResult getWarningSectionType(@RequestBody DcWarning dcWarning){ public AjaxResult getWarningSectionType(@RequestBody DcWarning dcWarning){
String type = dcWarning.getType();//类型 String type = dcWarning.getType();//类型
String sectionId = dcWarning.getSectionId();//路段所属桩号id String sectionId = dcWarning.getSectionId();//路段辖区id
Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00 Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null){ if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null){
return AjaxResult.error("参数数据异常"); return AjaxResult.error("参数数据异常");
@ -114,11 +113,12 @@ public class DCPerceivedEventsWarningController extends BaseController {
return AjaxResult.success(perceivedEventsWarningService.selectSectionMark(dcWarning)); return AjaxResult.success(perceivedEventsWarningService.selectSectionMark(dcWarning));
} }
//感知事件类型占比 //预警事件,事件列表 查询状态为上报的感知事件
@PostMapping("/selectMarkId") @PostMapping("/warningEscalation")
public AjaxResult selectMarkId(){ public TableDataInfo getWarningEscalation(@RequestBody DcWarning dcWarning){
return AjaxResult.success(perceivedEventsWarningService.selectMarkId()); startPage();
List<HashMap<String, Object>> list = perceivedEventsWarningService.selectWarningEscalation(dcWarning);
return getDataTable(list);
} }
} }

8
zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java

@ -20,8 +20,7 @@ public interface DcPerceivedEventsWarningMapper {
//感知事件类型 //感知事件类型
List<DcEventType> selectEventTypeList(); List<DcEventType> selectEventTypeList();
//查询预警感知事件类型
List<HashMap<String,Object>> selectWarningTypeList();
//根据类型查询预计事件 //根据类型查询预计事件
List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning); List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning);
//查询感知数量按照路段进行排名 //查询感知数量按照路段进行排名
@ -58,9 +57,10 @@ public interface DcPerceivedEventsWarningMapper {
List<HashMap<String,Object>> selectSectionMark(DcWarning dcWarning); List<HashMap<String,Object>> selectSectionMark(DcWarning dcWarning);
//根据桩号查询条数 //根据桩号查询条数
String selectSectionNumber(@Param("stakeMarkId") String markId); String selectSectionNumber(@Param("stakeMarkId") String markId);
//预警事件,事件列表 查询状态为上报的感知事件
List<HashMap<String,Object>> selectWarningEscalation(DcWarning dcWarning);
List<HashMap<String,String>> selectMarkId();
int updateMarkId(@Param("id")String id,@Param("markIdTail")String markIdTail);
} }

6
zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java

@ -16,8 +16,7 @@ public interface IDCPerceivedEventsWarningService {
HashMap<String,Object> perceivedEventsWarningNum(); HashMap<String,Object> perceivedEventsWarningNum();
//感知事件类型 //感知事件类型
List<DcEventType> selectEventTypeList(); List<DcEventType> selectEventTypeList();
//查询预警感知事件类型
List<HashMap<String,Object>> selectWarningTypeList();
//根据类型查询预计事件 //根据类型查询预计事件
List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning); List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning);
//查询感知数量按照路段进行排名 //查询感知数量按照路段进行排名
@ -40,9 +39,10 @@ public interface IDCPerceivedEventsWarningService {
List<HashMap<String,Object>> selectWarningSectionType(DcWarning dcWarning); List<HashMap<String,Object>> selectWarningSectionType(DcWarning dcWarning);
//查询某个路段下的全部桩号 //查询某个路段下的全部桩号
List<HashMap<String,Object>> selectSectionMark(DcWarning dcWarning); List<HashMap<String,Object>> selectSectionMark(DcWarning dcWarning);
//预警事件,事件列表 查询状态为上报的感知事件
List<HashMap<String,Object>> selectWarningEscalation(DcWarning dcWarning);
int selectMarkId();
} }

32
zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java

@ -45,11 +45,7 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
public List<DcEventType> selectEventTypeList() { public List<DcEventType> selectEventTypeList() {
return perceivedEventsWarningMapper.selectEventTypeList(); return perceivedEventsWarningMapper.selectEventTypeList();
} }
//查询预警感知事件类型
@Override
public List<HashMap<String, Object>> selectWarningTypeList() {
return perceivedEventsWarningMapper.selectWarningTypeList();
}
//根据类型查询预计事件 //根据类型查询预计事件
@Override @Override
public List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning) { public List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning) {
@ -157,30 +153,10 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
} }
return numList; return numList;
} }
//预警事件,事件列表 查询状态为上报的感知事件
@Override @Override
public int selectMarkId() { public List<HashMap<String, Object>> selectWarningEscalation(DcWarning dcWarning) {
List<HashMap<String, String>> mapList = perceivedEventsWarningMapper.selectMarkId(); return perceivedEventsWarningMapper.selectWarningEscalation(dcWarning);
for (HashMap<String,String>map:mapList){
String id = map.get("id");
String[] split = id.split("\\+");
String markIdHead=split[0];
String markIdTail=split[1];
if (markIdTail.length()<3){
int i=3-markIdTail.length();
for (int i1 = 0; i1 < i; i1++) {
markIdTail = "0" + markIdTail;
}
String markIdValue=markIdHead+"+"+markIdTail;
perceivedEventsWarningMapper.updateMarkId(id,markIdValue);
}
}
return 1;
} }

75
zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

@ -13,9 +13,7 @@
<select id="selectEventTypeList" resultType="com.zc.business.domain.DcEventType"> <select id="selectEventTypeList" resultType="com.zc.business.domain.DcEventType">
select event_type, event_name from dc_event_type select event_type, event_name from dc_event_type
</select> </select>
<select id="selectWarningTypeList" resultType="java.util.HashMap">
select event_type eventType,event_subclass eventSubclass from dc_event
</select>
<select id="selectPerceivedEventsList" resultType="com.zc.business.domain.DcWarning"> <select id="selectPerceivedEventsList" resultType="com.zc.business.domain.DcWarning">
select `id`,`stake_mark_id`, `direction`,`dept_id`, `warning_state`,`warning_time`,`user_id`, select `id`,`stake_mark_id`, `direction`,`dept_id`, `warning_state`,`warning_time`,`user_id`,
`warning_source`,`warning_level`, `remark`, `create_time`,`update_time`,`warning_type`, `warning_source`,`warning_level`, `remark`, `create_time`,`update_time`,`warning_type`,
@ -41,44 +39,44 @@
group by section.section_name group by section.section_name
</select> </select>
<select id="selectDailyCumulative" resultType="java.util.HashMap"> <select id="selectDailyCumulative" resultType="java.util.HashMap">
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H') AS HOUR, COUNT(*) AS COUNT SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H') AS time, COUNT(*) AS number
FROM dc_warning FROM dc_warning
WHERE create_time >= CURDATE() AND create_time <![CDATA[<]]> CURDATE() + INTERVAL 1 DAY WHERE create_time >= CURDATE() AND create_time <![CDATA[<]]> CURDATE() + INTERVAL 1 DAY
GROUP BY HOUR GROUP BY time
ORDER BY HOUR ORDER BY time
</select> </select>
<select id="selectDailyCumulativeMonth" resultType="java.util.HashMap"> <select id="selectDailyCumulativeMonth" resultType="java.util.HashMap">
SELECT DATE_FORMAT(create_time, '%H') AS HOUR, COUNT(*) AS COUNT SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H') AS time, COUNT(*) AS number
FROM dc_warning FROM dc_warning
WHERE MONTH(create_time) = MONTH(CURDATE()) AND YEAR(create_time) = YEAR(CURDATE()) WHERE MONTH(create_time) = MONTH(CURDATE()) AND YEAR(create_time) = YEAR(CURDATE())
GROUP BY HOUR GROUP BY time
ORDER BY HOUR; ORDER BY time;
</select> </select>
<select id="selectWarningSourceGroup" resultType="java.util.HashMap"> <select id="selectWarningSourceGroup" resultType="java.util.HashMap">
SELECT warning_source warningSource,COUNT(*) AS COUNT FROM dc_warning SELECT warning_source warningSource,COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d') where DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d')
GROUP BY warning_source GROUP BY warning_source
</select> </select>
<select id="selectWarningStateDay" resultType="java.util.HashMap"> <select id="selectWarningStateDay" resultType="java.util.HashMap">
SELECT warning_state warningState,COUNT(*) AS COUNT FROM dc_warning SELECT warning_state warningState,COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d') where DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d')
GROUP BY warning_state GROUP BY warning_state
</select> </select>
<select id="selectWarningTypeDay" resultType="java.util.HashMap"> <select id="selectWarningTypeDay" resultType="java.util.HashMap">
SELECT warning_type warningType,COUNT(*) AS COUNT FROM dc_warning SELECT warning_type warningType,COUNT(*) AS number FROM dc_warning
GROUP BY warning_type GROUP BY warning_type
ORDER BY COUNT DESC ORDER BY number DESC
</select> </select>
<select id="selectWarningTrendDay" resultType="java.util.HashMap"> <select id="selectWarningTrendDay" resultType="java.util.HashMap">
SELECT DATE_FORMAT(warning.create_time, '%Y-%m-%d %H') AS HOUR, COUNT(*) AS COUNT SELECT DATE_FORMAT(warning.create_time, '%Y-%m-%d %H') AS time, COUNT(*) AS number
FROM dc_warning AS warning FROM dc_warning AS warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
WHERE DATE_FORMAT(warning.create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d') WHERE DATE_FORMAT(warning.create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d')
AND mark.`section_id`=#{sectionId} AND mark.`section_id`=#{sectionId}
GROUP BY HOUR GROUP BY time
</select> </select>
<select id="selectWarningTrendMonth" resultType="java.util.HashMap"> <select id="selectWarningTrendMonth" resultType="java.util.HashMap">
SELECT DATE(warning.create_time) AS DAY, COUNT(*) AS COUNT SELECT DATE(warning.create_time) AS DAY, COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
WHERE DATE_FORMAT(warning.create_time,'%Y-%m') =DATE_FORMAT(#{createTime},'%Y-%m') WHERE DATE_FORMAT(warning.create_time,'%Y-%m') =DATE_FORMAT(#{createTime},'%Y-%m')
@ -95,7 +93,7 @@
ELSE '第四季度' ELSE '第四季度'
END AS QUARTER, END AS QUARTER,
MONTH(warning.create_time) AS MONTH, MONTH(warning.create_time) AS MONTH,
COUNT(*) AS COUNT COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
WHERE YEAR(warning.create_time) =DATE_FORMAT(#{createTime},'%Y') WHERE YEAR(warning.create_time) =DATE_FORMAT(#{createTime},'%Y')
@ -105,51 +103,49 @@
</select> </select>
<select id="selectWarningTrendYear" resultType="java.util.HashMap"> <select id="selectWarningTrendYear" resultType="java.util.HashMap">
SELECT YEAR(warning.create_time) AS YEAR, COUNT(*) AS COUNT SELECT YEAR(warning.create_time) AS YEAR, COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
where mark.`section_id`=#{sectionId} where mark.`section_id`=#{sectionId}
GROUP BY YEAR GROUP BY YEAR
</select> </select>
<select id="selectWarningSectionTypeDay" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeDay" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,COUNT(*) AS COUNT SELECT warning.warning_type warningType,COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark as mark on warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark as mark on warning.stake_mark_id=mark.id
where DATE_FORMAT(warning.create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d') where DATE_FORMAT(warning.create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime},'%Y-%m-%d')
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId}
GROUP BY warning_type GROUP BY warning_type
ORDER BY COUNT DESC ORDER BY number DESC
</select> </select>
<select id="selectWarningSectionTypeMonth" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeMonth" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,COUNT(*) AS COUNT SELECT warning.warning_type warningType,COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark as mark on warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark as mark on warning.stake_mark_id=mark.id
where DATE_FORMAT(warning.create_time,'%Y-%m') =DATE_FORMAT(#{createTime},'%Y-%m') where DATE_FORMAT(warning.create_time,'%Y-%m') =DATE_FORMAT(#{createTime},'%Y-%m')
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId}
GROUP BY warning_type GROUP BY warning_type
ORDER BY COUNT DESC ORDER BY number DESC
</select> </select>
<select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap">
SELECT SELECT
CASE CASE
WHEN MONTH(warning.create_time) BETWEEN 3 AND 5 THEN '春季' WHEN MONTH(warning.create_time) BETWEEN 1 AND 3 THEN '第一季度'
WHEN MONTH(warning.create_time) BETWEEN 6 AND 8 THEN '夏季' WHEN MONTH(warning.create_time) BETWEEN 4 AND 6 THEN '第二季度'
WHEN MONTH(warning.create_time) BETWEEN 9 AND 11 THEN '秋季' WHEN MONTH(warning.create_time) BETWEEN 7 AND 9 THEN '第三季度'
ELSE '冬季' ELSE '第四季度'
END AS QUARTER, END AS QUARTER,
MONTH(warning.create_time) AS MONTH,
warning.warning_type warningType, warning.warning_type warningType,
COUNT(*) AS COUNT COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
WHERE YEAR(warning.create_time) =DATE_FORMAT(#{createTime},'%Y') WHERE YEAR(warning.create_time) =DATE_FORMAT(#{createTime},'%Y')
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId}
GROUP BY QUARTER, warningType GROUP BY QUARTER, warningType
ORDER BY QUARTER, MONTH; ORDER BY QUARTER;
</select> </select>
<select id="selectWarningSectionTypeYear" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeYear" resultType="java.util.HashMap">
SELECT warning.warning_type warningType, COUNT(*) AS COUNT, SELECT warning.warning_type warningType, COUNT(*) AS number,
DATE_FORMAT(warning.create_time, '%Y') as createTime DATE_FORMAT(warning.create_time, '%Y') as createTime
FROM dc_warning as warning FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark_id=mark.id
@ -163,13 +159,16 @@
<select id="selectSectionNumber" resultType="java.lang.String"> <select id="selectSectionNumber" resultType="java.lang.String">
select count(1) from dc_warning where stake_mark_id=#{stakeMarkId} select count(1) from dc_warning where stake_mark_id=#{stakeMarkId}
</select> </select>
<select id="selectWarningEscalation" resultType="java.util.HashMap">
select org.organization_name,warning.warning_type,warning.warning_subclass,
<select id="selectMarkId" resultType="java.util.HashMap"> warning_title,warning.warning_state,warning.
select id from dc_stake_mark where id!='222' and section_id='0' warning_source,DATE_FORMAT(warning.create_time,'%Y-%m-%d %H:%m:%s') createTime from dc_warning as warning
LEFT JOIN dc_stake_mark as mark on warning.stake_mark_id=mark.id
LEFT JOIN dc_organization as org on mark.id=org.stake_mark_id AND mark.direction=org.direction
<where>
<if test="warningState != null and warningState != ''"> and warning.warning_state = #{warningState}</if>
</where>
</select> </select>
<update id="updateMarkId">
update dc_stake_mark set id=#{markIdTail} where id=#{id}
</update>
</mapper> </mapper>
Loading…
Cancel
Save