Browse Source

感知事件季度问题

develop
wangsixiang 9 months ago
parent
commit
01f925e9c5
  1. 42
      zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java
  2. 10
      zc-business/src/main/java/com/zc/business/domain/DcWarning.java
  3. 1
      zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java
  4. 41
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

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

@ -100,12 +100,22 @@ public class DCPerceivedEventsWarningController extends BaseController {
public AjaxResult getWarningTrend(@RequestBody DcWarning dcWarning){
String type = dcWarning.getType();//类型
String sectionId = dcWarning.getSectionId();//路段辖区id
Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00
String direction = dcWarning.getDirection();//方向
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null||StringUtils.isBlank(direction)){
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||StringUtils.isBlank(direction)){
return AjaxResult.error("参数数据异常");
}
dcWarning.setWarningTime(createTime);
if (!"day".equals(type) && !"month".equals(type) && !"year".equals(type) && !"quarter".equals(type)) {
return AjaxResult.error("参数错误");
}
if (type.equals("quarter")&&dcWarning.getQuarter()==null){
return AjaxResult.error("参数错误");
}
if (!"quarter".equals(type)&&dcWarning.getCreateTime()==null){
return AjaxResult.error("参数错误");
}
if (dcWarning.getCreateTime()!=null){
dcWarning.setWarningTime(dcWarning.getCreateTime());
}
return AjaxResult.success(perceivedEventsWarningService.selectWarningTrend(dcWarning));
}
//某一路段某一时间段的感知事件类型占比
@ -114,12 +124,22 @@ public class DCPerceivedEventsWarningController extends BaseController {
HashMap<String, Object> map = new HashMap<>();
String type = dcWarning.getType();//类型
String sectionId = dcWarning.getSectionId();//路段辖区id
Date createTime = dcWarning.getCreateTime();//时间参数,参数根据类型配置,比如2022年,传值2022-00-00 00:00:00
String direction = dcWarning.getDirection();//方向
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||createTime==null||StringUtils.isBlank(direction)){
if (StringUtils.isBlank(type)||StringUtils.isBlank(sectionId)||StringUtils.isBlank(direction)){
return AjaxResult.error("参数数据异常");
}
dcWarning.setWarningTime(createTime);
if (!"day".equals(type) && !"month".equals(type) && !"year".equals(type) && !"quarter".equals(type)) {
return AjaxResult.error("参数错误");
}
if (type.equals("quarter")&&dcWarning.getQuarter()==null){
return AjaxResult.error("参数错误");
}
if (!"quarter".equals(type)&&dcWarning.getCreateTime()==null){
return AjaxResult.error("参数错误");
}
if (dcWarning.getCreateTime()!=null){
dcWarning.setWarningTime(dcWarning.getCreateTime());
}
if (type.equals("quarter")) {
String total = perceivedEventsWarningService.selectWarningSectionTypeCountQuarter(dcWarning);
map.put("total",total);
@ -145,6 +165,16 @@ public class DCPerceivedEventsWarningController extends BaseController {
if (dcWarning.getCreateTime()!=null){
dcWarning.setWarningTime(dcWarning.getCreateTime());
}
String type = dcWarning.getType();
if (!"day".equals(type) && !"month".equals(type) && !"year".equals(type) && !"quarter".equals(type)) {
return AjaxResult.error("参数错误");
}
if (!"quarter".equals(type)&&dcWarning.getCreateTime()==null){
return AjaxResult.error("参数错误");
}
if (type.equals("quarter")&&dcWarning.getQuarter()==null){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.selectSectionMarkOptimize(dcWarning));
}
//查询某个路段下的全部桩号

10
zc-business/src/main/java/com/zc/business/domain/DcWarning.java

@ -98,6 +98,16 @@ public class DcWarning extends BaseEntity
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date endTime;
//月度参数
private String quarter;
public String getQuarter() {
return quarter;
}
public void setQuarter(String quarter) {
this.quarter = quarter;
}
public Date getStartTime() {
return startTime;

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

@ -212,6 +212,7 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
if (dcWarning.getType().equals("quarter")){
return perceivedEventsWarningMapper.selectWarningMarkQuarterOptimize(dcWarning);
}else {
return perceivedEventsWarningMapper.selectWarningMarkDayOptimize(dcWarning);
}
}

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

@ -39,7 +39,7 @@
<if test="warningSubclass != null and warningSubclass != ''"> and warning.warning_subclass = #{warningSubclass}</if>
<if test="warningSource != null and warningSource != ''"> and warning.warning_source = #{warningSource}</if>
<if test="direction != null and direction != ''"> and warning.direction = #{direction}</if>
<if test="stakeMark != null and direction != ''"> and warning.stake_mark = #{stakeMark}</if>
<if test="stakeMark != null and stakeMark != ''"> and warning.stake_mark = #{stakeMark}</if>
<if test="startTime != null and endTime != null ">
and warning.warning_time between #{startTime} and #{endTime}</if>
</where>
@ -130,21 +130,15 @@
</select>
<select id="selectWarningTrendQuarter" resultType="java.util.HashMap">
SELECT
CASE
WHEN MONTH(warning.warning_time) BETWEEN 1 AND 3 THEN '第一季度'
WHEN MONTH(warning.warning_time) BETWEEN 4 AND 6 THEN '第二季度'
WHEN MONTH(warning.warning_time) BETWEEN 7 AND 9 THEN '第三季度'
ELSE '第四季度'
END AS QUARTER,
MONTH(warning.warning_time) AS month,
COUNT(*) AS number
FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE YEAR(warning.warning_time) =DATE_FORMAT(#{warningTime},'%Y')
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
GROUP BY QUARTER, MONTH
ORDER BY QUARTER, MONTH;
GROUP BY MONTH
ORDER BY MONTH;
</select>
<select id="selectWarningTrendYear" resultType="java.util.HashMap">
@ -195,27 +189,21 @@
COUNT(*) AS number
FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE YEAR(warning.warning_time) =DATE_FORMAT(#{warningTime},'%Y')
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
</select>
<select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap">
SELECT
CASE
WHEN MONTH(warning.warning_time) BETWEEN 1 AND 3 THEN '第一季度'
WHEN MONTH(warning.warning_time) BETWEEN 4 AND 6 THEN '第二季度'
WHEN MONTH(warning.warning_time) BETWEEN 7 AND 9 THEN '第三季度'
ELSE '第四季度'
END AS QUARTER,
warning.warning_type warningType,
COUNT(*) AS number
FROM dc_warning as warning
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE YEAR(warning.warning_time) =DATE_FORMAT(#{warningTime},'%Y')
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
GROUP BY QUARTER, warningType
ORDER BY QUARTER;
GROUP BY warningType
</select>
<select id="selectWarningSectionTypeYearCount" resultType="java.lang.String">
SELECT COUNT(*) AS number FROM dc_warning as warning
@ -303,19 +291,12 @@
</select>
<select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap">
SELECT count( 1 ) sectionNumber,
CASE
WHEN MONTH ( w.warning_time ) BETWEEN 1 AND 3 THEN '第一季度'
WHEN MONTH ( w.warning_time ) BETWEEN 4 AND 6 THEN '第二季度'
WHEN MONTH ( w.warning_time ) BETWEEN 7 AND 9 THEN '第三季度'
ELSE '第四季度'
END AS QUARTER
SELECT count( 1 ) sectionNumber,m.stake_mark stakeMarkId
FROM dc_warning w
LEFT JOIN dc_stake_mark m ON w.stake_mark = m.stake_mark and m.direction=w.direction
WHERE m.stake_mark IS NOT null and w.direction=#{direction}
and YEAR(w.warning_time) =DATE_FORMAT(#{warningTime},'%Y')
GROUP BY QUARTER
ORDER BY QUARTER;
and QUARTER(w.warning_time)=#{quarter} and m.`section_id`=#{sectionId}
GROUP BY stakeMarkId
</select>
<select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">
SELECT DISTINCT m.stake_mark stakeMarkId,

Loading…
Cancel
Save