Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-dc into develop

develop
xiepufeng 11 months ago
parent
commit
f74ccc399e
  1. 6
      zc-business/pom.xml
  2. 42
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  3. 6
      zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java
  4. 123
      zc-business/src/main/java/com/zc/business/domain/DcWaringStrategy.java
  5. 2
      zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java
  6. 4
      zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java
  7. 12
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  8. 1
      zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java
  9. 2
      zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
  10. 5
      zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java
  11. 5
      zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java
  12. 319
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  13. 41
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml
  14. 8
      zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml
  15. 3
      zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml
  16. 15
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

6
zc-business/pom.xml

@ -21,7 +21,11 @@
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>

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

@ -1,5 +1,6 @@
package com.zc.business.controller;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -207,6 +208,47 @@ public class DcDeviceController extends BaseController {
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
/**
* 查询当天设备指定属性列表
* @param deviceId 设备id
* @param propertyId 属性id
* @return 属性列表
*/
@ApiOperation("查询当天设备指定属性列表")
@GetMapping("/properties/history/day/{deviceId}/{propertyId}")
public AjaxResult queryDevicePropertiesOneDay(@PathVariable @Parameter(description = "设备ID") String deviceId,
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException {
HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
props.put("terms[0].column", "timestamp$BTW");
ArrayList<String> dateList = new ArrayList<>();
// 添加当前日期的开始和结束时间到列表,用于设定时间范围
dateList.add(DateUtil.beginOfDay(new Date()).toString());
dateList.add(DateUtil.endOfDay(new Date()).toString());
// 将日期列表以逗号分隔并设置为查询条件的值
props.put("terms[0].value", String.join(",", dateList));
props.put("paging", false);
AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props);
if (!ajaxResult.get("code").equals(200)) {
return ajaxResult;
}
Object data = JSON.parseObject(queryDeviceProperties(deviceId, propertyId, props).get("data").toString()).get("data");
JSONArray dataArray = JSON.parseArray(data.toString());
List<Object> list = new ArrayList<>();
dataArray.forEach(o -> {
Map<String,Object> map = new HashMap<>();
JSONObject jsonObject = JSON.parseObject(o.toString());
JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString());
map.put("1",formatValue.get("1"));
map.put("3",formatValue.get("3"));
map.put("timestamp",jsonObject.get("timestamp"));
list.add(map);
});
return AjaxResult.success(list);
}
/**
* 查询设备指定属性列表
*

6
zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java

@ -50,6 +50,12 @@ public class DcRoadSectionController extends BaseController
List<DcRoadSection> list = dcRoadSectionService.selectDcRoadSectionList(dcRoadSection);
return getDataTable(list);
}
//查询全路段名称与id
@GetMapping("/listName")
public AjaxResult listRoadName()
{
return AjaxResult.success(dcRoadSectionService.selectName());
}
/**
* 查询辖区路段列表(不分页)
*/

123
zc-business/src/main/java/com/zc/business/domain/DcWaringStrategy.java

@ -0,0 +1,123 @@
package com.zc.business.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 预警事件配置对象 dc_waring_strategy
*
* @author ruoyi
* @date 2024-03-19
*/
public class DcWaringStrategy extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 事件源 */
@Excel(name = "事件源")
private Integer warningSource;
/** 事件主类 */
@Excel(name = "事件主类")
private Integer warningType;
/** 事件子类 */
@Excel(name = "事件子类")
private String warningSubclass;
/** 过期策略 */
@Excel(name = "过期策略")
private Integer strategy;
/** 策略时间 */
@Excel(name = "策略时间", width = 30, dateFormat = "yyyy-MM-dd")
private Integer strategyTime;
//优先级
private String priority;
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setWarningSource(Integer warningSource)
{
this.warningSource = warningSource;
}
public Integer getWarningSource()
{
return warningSource;
}
public void setWarningType(Integer warningType)
{
this.warningType = warningType;
}
public Integer getWarningType()
{
return warningType;
}
public void setWarningSubclass(String warningSubclass)
{
this.warningSubclass = warningSubclass;
}
public String getWarningSubclass()
{
return warningSubclass;
}
public void setStrategy(Integer strategy)
{
this.strategy = strategy;
}
public Integer getStrategy()
{
return strategy;
}
public Integer getStrategyTime() {
return strategyTime;
}
public void setStrategyTime(Integer strategyTime) {
this.strategyTime = strategyTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("warningSource", getWarningSource())
.append("warningType", getWarningType())
.append("warningSubclass", getWarningSubclass())
.append("strategy", getStrategy())
.append("strategyTime", getStrategyTime())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

2
zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java

@ -28,7 +28,7 @@ public interface DcRoadSectionMapper
* @return 辖区路段集合
*/
List<DcRoadSection> selectDcRoadSectionList(DcRoadSection dcRoadSection);
List<DcRoadSection> selectName();
/**
* 新增辖区路段
*

4
zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java

@ -70,9 +70,11 @@ public interface DcShiftsMapper
HashMap<String,Object> contactNumber(String contactNumber);
//路管驻点名称查询路管驻点id
HashMap<String,Object> selectStationId(@Param("stationName") String stationName);
//查询人员与驻点的信息
List<HashMap<String,Object>> selectEmp(@Param("organizationId")Long organizationId,@Param("name") String name);
//根据创建时间获取信息
public DcShifts selectDcShiftsByCreateTime(Long id);
//
/**
* 查询值班
*

12
zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java

@ -2,6 +2,9 @@ package com.zc.business.mapper;
import java.util.HashMap;
import java.util.List;
import cn.hutool.core.lang.hash.Hash;
import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning;
import org.apache.ibatis.annotations.Param;
@ -19,7 +22,7 @@ public interface DcWarningMapper
* @param id 预警信息主键
* @return 预警信息
*/
public DcWarning selectDcWarningById(String id);
public HashMap<String,Object> selectDcWarningById(String id);
/**
* 查询预警信息列表
@ -73,4 +76,11 @@ public interface DcWarningMapper
boolean batchUpdateState(@Param("userId") Long userId,@Param("dcWarningList") List<DcWarning> dcWarningList);
boolean batchDelete(@Param("dcWarningList") List<DcWarning> dcWarningList);
//查询预警配置信息
public List<DcWaringStrategy> selectDcWaringStrategyList(DcWaringStrategy dcWaringStrategy);
public List<DcWaringStrategy> selectDcWaringStrategyList();
//修改配置
public Integer updateOtherConfig(@Param("id")String id,@Param("otherConfig")String otherConfig);
}

1
zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java

@ -28,6 +28,7 @@ public interface IDcRoadSectionService
*/
List<DcRoadSection> selectDcRoadSectionList(DcRoadSection dcRoadSection);
List<DcRoadSection> selectDcRoadSectionListAll(DcRoadSection dcRoadSection);
List<DcRoadSection> selectName();
/**
* 新增辖区路段
*

2
zc-business/src/main/java/com/zc/business/service/IDcWarningService.java

@ -22,7 +22,7 @@ public interface IDcWarningService
* @param id 预警信息主键
* @return 预警信息
*/
public DcWarning selectDcWarningById(String id);
public HashMap<String, Object> selectDcWarningById(String id);
/**
* 查询预警信息列表

5
zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java

@ -93,6 +93,11 @@ public class DcRoadSectionServiceImpl implements IDcRoadSectionService
return dcRoadSectionMapper.selectDcRoadSectionList(dcRoadSection);
}
@Override
public List<DcRoadSection> selectName() {
return dcRoadSectionMapper.selectName();
}
/**
* 新增辖区路段
*

5
zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java

@ -326,6 +326,11 @@ public class DcShiftsServiceImpl implements IDcShiftsService
throw new ServiceException(msg);
}
Long stationId =(Long) stationIdMap.get("id");
List<HashMap<String, Object>> mapList = dcShiftsMapper.selectEmp(stationId, name);//查询人员配置中是否有此人员配置的对应机构信息
if (mapList==null||mapList.size()==0){
msg = "没有查询到" + name + "对应的"+organizationName+"驻点信息,请查看输入是否正确以及人员信息中是否配置正确";
throw new ServiceException(msg);
}
dcShifts.setStation(stationId);//驻点id
Long id = (Long) map.get("id");
dcShifts.setEmployeesId(id);

319
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -1,11 +1,16 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.*;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.enums.ValueConverter;
import com.zc.business.mapper.DcEventMapper;
import com.zc.business.mapper.DcWarningMapper;
@ -16,11 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.json.JSONObject;
import org.json.JSONArray;
/**
* 预警信息Service业务层处理
*
@ -37,6 +45,12 @@ public class DcWarningServiceImpl implements IDcWarningService
private DcEventMapper dcEventMapper;
@Autowired
private IDcEventService dcEventService;
@Resource
private RedisCache redisCache;
private static final String WARNINGSTRATEGY = "warningStrategy";//redis策略缓存的key
private static final String WARNINGDATA = "warningData:";//redis事件缓存的key
private static String JUDGE = "1"; //自定义判断参数,1为满足0为不满足
/**
* 查询预警信息
*
@ -44,7 +58,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息
*/
@Override
public DcWarning selectDcWarningById(String id)
public HashMap<String, Object> selectDcWarningById(String id)
{
return dcWarningMapper.selectDcWarningById(id);
}
@ -75,15 +89,149 @@ public class DcWarningServiceImpl implements IDcWarningService
@Override
public int insertDcWarning(DcWarning dcWarning)
{
dcWarning.setCreateTime(DateUtils.getNowDate());
if (dcWarning.getId()==null) {
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
int priority = new DcWarningServiceImpl().priority(dcWarning);
if (priority==0){
return 0;
}
return dcWarningMapper.insertDcWarning(dcWarning);
}
//优先级策略
public int priority(DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null||
StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){
return 0;
}
String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略
Map<String, JSONObject> redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据
if (redisWarningStrategy==null){//如果缓存为空,查询数据重新加入缓存
Map<String, JSONObject> redisMap = new HashMap<>();
List<DcWaringStrategy> dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据
for (DcWaringStrategy waringStrategy : dcWaringStrategies) {
String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString()
+ waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key
JSONObject jsonObject = new JSONObject();
jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式
jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟
jsonObject.put("priority", waringStrategy.getPriority());//策略模式
redisMap.put(key, jsonObject);
}
redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中
redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置
}
String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型)
String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值)
JSONObject redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略)
if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发)
}
JSONObject redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
String strategyTime = redisValueTwo.getString("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
if (integer==0){
return 0;
}
return 1;
}
JSONObject redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略)
if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间(30分钟)
int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,30,TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
if (integer==0){
return 0;
}
return 1;
}
JSONObject redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略)
if (redisValueOne==null&&redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件
if (dataId==null){//如果不存在直接加入数据库,加入缓存
int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id);//加入缓存????存在问题会数据累计
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
redisCache.deleteObject(WARNINGDATA + key);//删除对应的合成事件
if (integer==0){
return 0;
}
return 1;
}
return 1;
}
private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo){
// 合并videoList
if (jsonObjectTwo.has("videoList")) {
JSONArray videoListTwo = jsonObjectTwo.getJSONArray("videoList");
JSONArray videoListOne = jsonObjectOne.optJSONArray("videoList");
if (videoListOne == null) {
videoListOne = new JSONArray();
}
for (int i = 0; i < videoListTwo.length(); i++) {
videoListOne.put(videoListTwo.get(i));
}
jsonObjectOne.put("videoList", videoListOne);
}
// 合并pictures
if (jsonObjectTwo.has("pictures")) {
JSONArray picturesTwo = jsonObjectTwo.getJSONArray("pictures");
JSONArray picturesOne = jsonObjectOne.optJSONArray("pictures");
if (picturesOne == null) {
picturesOne = new JSONArray();
}
for (int i = 0; i < picturesTwo.length(); i++) {
picturesOne.put(picturesTwo.get(i));
}
jsonObjectOne.put("pictures", picturesOne);
}
return jsonObjectOne;
}
/**
* 修改预警信息
*
@ -203,7 +351,7 @@ public class DcWarningServiceImpl implements IDcWarningService
if ("0".equals(dcWarningBatchConvert.getType())){
dcWarningMapper.batchDelete(dcWarningList);
} else {
//确认,批量转换为事件
//确认,批量转换为事件
List<DcEvent> dcEventList = new ArrayList<>();
for (DcWarning dcWarning : dcWarningList) {
if (dcWarning == null || dcWarning.getId() == null || StringUtils.isBlank(dcWarning.getStakeMark()) ||
@ -238,156 +386,6 @@ public class DcWarningServiceImpl implements IDcWarningService
dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间
dcEvent.setUserId(SecurityUtils.getUserId());//处置人员
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR,3);
dcEvent.setEstimatedEndTime(cal.getTime()); //预计解除时间
dcEvent.setRoadId(1L); //道路id
dcEvent.setRoadName("济菏高速"); //道路id
dcEvent.setInTunnel(0); //是否处在隧道
Integer warningType = dcWarning.getWarningType();
if (warningType == 1){
//交通拥堵
DcEventTrafficCongestion dcEventTrafficCongestion = new DcEventTrafficCongestion();
dcEventTrafficCongestion.setId(dcWarning.getId());
dcEventTrafficCongestion.setCongestionCause(5L);
dcEventTrafficCongestion.setCongestionMileage(0F);
dcEventTrafficCongestion.setMaxCongestionMileage(0F);
dcEvent.setDcEventTrafficCongestion(dcEventTrafficCongestion);
} else if (warningType == 4) {
//停车
DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident();
dcEventVehicleAccident.setId(dcWarning.getId());
if (dcWarning.getWarningSource() == 1) {
dcEventVehicleAccident.setReporterName("视频AI");
} else if (dcWarning.getWarningSource() == 2) {
dcEventVehicleAccident.setReporterName("雷达识别");
} else if (dcWarning.getWarningSource() == 3) {
dcEventVehicleAccident.setReporterName("智慧锥桶");
} else if (dcWarning.getWarningSource() == 4) {
dcEventVehicleAccident.setReporterName("护栏碰撞");
} else if (dcWarning.getWarningSource() == 6) {
dcEventVehicleAccident.setReporterName("非机预警");
}
dcEventVehicleAccident.setReporterPhoneNumber("96659");
dcEventVehicleAccident.setLocationType(1L);
dcEventVehicleAccident.setTrafficJam(0L);
dcEventVehicleAccident.setWeatherCondition(1L);
dcEventVehicleAccident.setCongestionAhead(1);
dcEventVehicleAccident.setAtIntersection(1);
dcEventVehicleAccident.setOnCurve(1);
dcEventVehicleAccident.setSmallCar(0L);
dcEventVehicleAccident.setTrucks(0L);
dcEventVehicleAccident.setBuses(0L);
dcEventVehicleAccident.setTankers(0L);
dcEventVehicleAccident.setMinorInjuries(0L);
dcEventVehicleAccident.setSeriousInjuries(0L);
dcEventVehicleAccident.setFatalities(0L);
dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident);
} else if (warningType == 7){
//道路施工
} else if (warningType == 8) {
//异常天气
DcEventAbnormalWeather dcEventAbnormalWeather = new DcEventAbnormalWeather();
dcEventAbnormalWeather.setId(dcWarning.getId());
dcEventAbnormalWeather.setEmergencyLevel(1L);
dcEvent.setDcEventAbnormalWeather(dcEventAbnormalWeather);
} else if (warningType == 9) {
//护栏碰撞
DcEventAccident dcEventAccident = new DcEventAccident();
dcEventAccident.setId(dcWarning.getId());
if (dcWarning.getWarningSource() == 1) {
dcEventAccident.setReporterName("视频AI");
dcEventAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 2) {
dcEventAccident.setReporterName("雷达识别");
dcEventAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 3) {
dcEventAccident.setReporterName("智慧锥桶");
dcEventAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 4) {
dcEventAccident.setReporterName("护栏碰撞");
dcEventAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 5) {
dcEventAccident.setReporterName("扫码报警");
JSONObject otherConfig = JSONObject.parseObject(dcWarning.getOtherConfig());
if (otherConfig != null && otherConfig.containsKey("phone")) {
dcEventAccident.setReporterPhoneNumber(otherConfig.getString("phone"));
dcEventAccident.setVehicleOwnerPhone(otherConfig.getString("phone"));
}
} else if (dcWarning.getWarningSource() == 6) {
dcEventAccident.setReporterName("非机预警");
dcEventAccident.setReporterPhoneNumber("96659");
}
dcEventAccident.setLocationType(1L);
dcEventAccident.setTrafficJam(0f);
dcEventAccident.setWeatherCondition(1L);
dcEventAccident.setImpactLevel(1L);
dcEventAccident.setIsReverseCargo(0);
dcEventAccident.setIsMaintenance(0);
dcEventAccident.setCongestionAhead(0);
dcEventAccident.setOnCurve(0);
dcEventAccident.setSmallCar(0L);
dcEventAccident.setTrucks(0L);
dcEventAccident.setBuses(0L);
dcEventAccident.setTankers(0L);
dcEventAccident.setMinorInjuries(0L);
dcEventAccident.setSeriousInjuries(0L);
dcEventAccident.setFatalities(0L);
dcEvent.setDcEventAccident(dcEventAccident);
} else if (warningType == 10) {
//交通事故
DcEventAccident dcEventAccident = new DcEventAccident();
} else if (warningType == 11) {
//车辆故障
DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident();
dcEventVehicleAccident.setId(dcWarning.getId());
if (dcWarning.getWarningSource() == 1) {
dcEventVehicleAccident.setReporterName("视频AI");
dcEventVehicleAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 2) {
dcEventVehicleAccident.setReporterName("雷达识别");
dcEventVehicleAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 3) {
dcEventVehicleAccident.setReporterName("智慧锥桶");
dcEventVehicleAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 4) {
dcEventVehicleAccident.setReporterName("护栏碰撞");
dcEventVehicleAccident.setReporterPhoneNumber("96659");
} else if (dcWarning.getWarningSource() == 5) {
dcEventVehicleAccident.setReporterName("扫码报警");
JSONObject otherConfig = JSONObject.parseObject(dcWarning.getOtherConfig());
if (otherConfig != null && otherConfig.containsKey("phone")) {
dcEventVehicleAccident.setReporterPhoneNumber(otherConfig.getString("phone"));
}
} else if (dcWarning.getWarningSource() == 6) {
dcEventVehicleAccident.setReporterName("非机预警");
dcEventVehicleAccident.setReporterPhoneNumber("96659");
}
dcEventVehicleAccident.setLocationType(1L);
dcEventVehicleAccident.setTrafficJam(0L);
dcEventVehicleAccident.setWeatherCondition(1L);
dcEventVehicleAccident.setCongestionAhead(1);
dcEventVehicleAccident.setAtIntersection(1);
dcEventVehicleAccident.setOnCurve(1);
dcEventVehicleAccident.setSmallCar(0L);
dcEventVehicleAccident.setTrucks(0L);
dcEventVehicleAccident.setBuses(0L);
dcEventVehicleAccident.setTankers(0L);
dcEventVehicleAccident.setMinorInjuries(0L);
dcEventVehicleAccident.setSeriousInjuries(0L);
dcEventVehicleAccident.setFatalities(0L);
dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident);
}
dcEventList.add(dcEvent);
}
@ -395,7 +393,6 @@ public class DcWarningServiceImpl implements IDcWarningService
dcWarningMapper.batchUpdateState(SecurityUtils.getUserId(),dcWarningList);
//批量插入事件表
dcEventService.batchInsertDcEventWarning(dcEventList);
}

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

@ -100,7 +100,8 @@
FROM dc_road_section AS s
LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN
dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction
WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d')
WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d')
and w.warning_source!=6
GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id
</select>
<select id="selectDailyCumulative" resultType="java.util.HashMap">
@ -119,7 +120,7 @@
UNION ALL SELECT 22 UNION ALL SELECT 23
) AS a
LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H')
= DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H')
= DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H') and dw.warning_source!=6
GROUP BY time
ORDER BY time;
</select>
@ -127,18 +128,18 @@
SELECT HOUR(warning_time) AS time, COUNT(*) AS number
FROM dc_warning
WHERE MONTH(warning_time) = MONTH(CURDATE())
AND YEAR(warning_time) = YEAR(CURDATE())
AND YEAR(warning_time) = YEAR(CURDATE()) and warning_source!=6
GROUP BY HOUR(warning_time)
ORDER BY HOUR(warning_time);
</select>
<select id="selectWarningSourceGroup" resultType="java.util.HashMap">
SELECT warning_source warningSource,COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') and warning_source!=6
GROUP BY warning_source
</select>
<select id="selectWarningSourceGroupCount" resultType="java.lang.String">
SELECT COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') and warning_source!=6
</select>
<select id="selectWarningStateDay" resultType="java.util.HashMap">
select t1.warningState,t1.warningStateName,IFNULL(t2.num,0)number from
@ -149,12 +150,13 @@
LEFT JOIN
(SELECT warning_state warningState,count(*) num
from dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')
where warning_source!=6 and DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')
GROUP BY warning_state)t2
on t1.warningState=t2.warningState
</select>
<select id="selectWarningTypeDay" resultType="java.util.HashMap">
SELECT warning_type warningType,COUNT(*) AS number FROM dc_warning
where warning_source!=6
GROUP BY warning_type
ORDER BY number DESC
</select>
@ -169,7 +171,7 @@
) t1
left join
(select HOUR(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.warning_source!=6
and t1.direction = t2.direction where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d')
and t2.section_id = #{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction}
@ -182,7 +184,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY day
ORDER BY day
</select>
@ -194,7 +196,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY MONTH
ORDER BY MONTH;
@ -209,7 +211,7 @@
(select month(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where
DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and t2.section_id =#{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction} GROUP BY hours) t2
and t1.direction=#{direction} and t1.warning_source!=6 and t2.direction=#{direction} GROUP BY hours) t2
on t1.n = t2.hours
</select>
<select id="selectWarningSectionTypeDayCount" resultType="java.lang.String">
@ -217,7 +219,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select>
<select id="selectWarningSectionTypeDay" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,
@ -226,7 +228,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warning_type
ORDER BY number DESC
</select>
@ -235,7 +237,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select>
<select id="selectWarningSectionTypeMonth" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,COUNT(*) AS number
@ -243,7 +245,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warning_type
ORDER BY number DESC
</select>
@ -254,7 +256,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select>
<select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap">
SELECT
@ -264,7 +266,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId}
and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warningType
</select>
@ -273,7 +275,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction}
and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y')
and warning.warning_source!=6
</select>
<select id="selectWarningSectionTypeYear" resultType="java.util.HashMap">
SELECT warning.warning_type warningType, COUNT(*) AS number
@ -281,6 +283,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction}
and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y')
and warning.warning_source!=6
GROUP BY warningType
</select>
@ -356,7 +359,7 @@
<select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap">
SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber
FROM dc_stake_mark AS m LEFT JOIN ( SELECT stake_mark, COUNT(0) AS count FROM dc_warning WHERE
QUARTER(warning_time) =#{quarter} AND direction = #{direction} GROUP BY stake_mark ) AS wc
QUARTER(warning_time) =#{quarter} AND direction = #{direction} and warning_source!=6 GROUP BY stake_mark ) AS wc
ON m.stake_mark = wc.stake_mark WHERE m.section_id = #{sectionId}
</select>
<select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">
@ -366,7 +369,7 @@
<if test = 'type == "day"' > DATE(warning_time)= DATE_FORMAT(#{warningTime},'%Y-%m-%d')</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{warningTime},'%Y')</if>
AND direction = #{direction} GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark
AND direction = #{direction} and warning_source!=6 GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark
WHERE m.section_id = #{sectionId}
</select>

8
zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml

@ -31,7 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcRoadSectionList" parameterType="DcRoadSection" resultMap="DcRoadSectionResult">
<include refid="selectDcRoadSectionVo"/>
<where>
<where>
<if test="id != null "> and section.id = #{id}</if>
<if test="deptId != null "> and section.dept_id = #{deptId}</if>
<if test="roadId != null "> and section.road_id = #{roadId}</if>
<if test="startStakeMark != null and startStakeMark != ''
@ -56,7 +57,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roadCode != null and roadCode != ''"> and section.road_code = #{roadCode}</if>
</where>
</select>
<select id="selectName" resultType="com.zc.business.domain.DcRoadSection">
select id,section_name from dc_road_section
</select>
<select id="selectDcRoadSectionById" parameterType="Long" resultMap="DcRoadSectionResult">
<include refid="selectDcRoadSectionVo"/>
where section.id = #{id}
@ -77,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+CAST(SUBSTRING_INDEX(stake_mark, '+', -1) AS UNSIGNED) stakeMark from dc_stake_mark where stake_mark!='222'
</select>
<update id="updateStakeMarkRecord">
update dc_stake_mark set section_id=#{sectionId} where stake_mark=#{stakeMark}
</update>

3
zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml

@ -109,6 +109,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcShiftsDeleteList" resultType="com.zc.business.domain.DcShifts">
select id from dc_shifts where date=#{date} and station=#{station}
</select>
<select id="selectEmp" resultType="java.util.HashMap">
select id from dc_employees where organization_id=#{organizationId} and name=#{name}
</select>
<insert id="insertDcShifts" parameterType="DcShifts" useGeneratedKeys="true" keyProperty="id">

15
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectDcWarningById" parameterType="string" resultType="com.zc.business.domain.DcWarning">
<select id="selectDcWarningById" parameterType="string" resultType="hashmap">
<include refid="selectDcWarningVo"/>
where id = #{id}
</select>
@ -159,6 +159,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<update id="updateOtherConfig">
update dc_warning set other_config=#{otherConfig} where id=#{id}
</update>
<delete id="deleteDcWarningById" parameterType="Integer">
delete from dc_warning where id = #{id}
@ -197,5 +200,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warningSubclass != null and warningSubclass != ''"> and warning_subclass = #{warningSubclass}</if>
</where>
</select>
<select id="selectDcWaringStrategyList" resultType="com.zc.business.domain.DcWaringStrategy">
select id, warning_source, warning_type, warning_subclass, strategy,priority,
strategy_time, create_by, create_time,
update_by, update_time from dc_waring_strategy
<where>
<if test="warningSource != null "> and warning_source = #{warningSource}</if>
<if test="warningType != null "> and warning_type = #{warningType}</if>
<if test="warningSubclass != null and warningSubclass != ''"> and warning_subclass = #{warningSubclass}</if>
</where>
</select>
</mapper>

Loading…
Cancel
Save