From 01f925e9c5ec2d6b5b9f66c52be35b815a06c12f Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Mon, 19 Feb 2024 15:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=84=9F=E7=9F=A5=E4=BA=8B=E4=BB=B6=E5=AD=A3?= =?UTF-8?q?=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DCPerceivedEventsWarningController.java | 42 ++++++++++++++++--- .../com/zc/business/domain/DcWarning.java | 10 +++++ .../DcPerceivedEventsWarningServiceImpl.java | 1 + .../DcPerceivedEventsWarningMapper.xml | 41 +++++------------- 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java index 15b9f658..968b7e82 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java +++ b/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 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)); } //查询某个路段下的全部桩号 diff --git a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java index 3d935316..1ac24f4c 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java +++ b/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; diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java index 3f23fb6a..90838bf0 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java +++ b/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); } } diff --git a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml index 98627d4d..39edf1da 100644 --- a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml @@ -39,7 +39,7 @@ and warning.warning_subclass = #{warningSubclass} and warning.warning_source = #{warningSource} and warning.direction = #{direction} - and warning.stake_mark = #{stakeMark} + and warning.stake_mark = #{stakeMark} and warning.warning_time between #{startTime} and #{endTime} @@ -130,21 +130,15 @@