Browse Source

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

develop
xiepufeng 8 months ago
parent
commit
56fb46b470
  1. 10
      ruoyi-admin/src/main/resources/application-druid.yml
  2. 12
      ruoyi-admin/src/main/resources/application.yml
  3. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  4. 18
      zc-business/src/main/java/com/zc/business/controller/DcBoardReleaseLogController.java
  5. 18
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  6. 28
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  7. 21
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  8. 123
      zc-business/src/main/java/com/zc/business/controller/WordController.java
  9. 37
      zc-business/src/main/java/com/zc/business/domain/DcBoardReleaseLog.java
  10. 44
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  11. 2
      zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java
  12. 142
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  13. 2
      zc-business/src/main/resources/mapper/business/DcBoardReleaseLogMapper.xml

10
ruoyi-admin/src/main/resources/application-druid.yml

@ -8,10 +8,12 @@ spring:
master:
# 公司数据库地址
# url: jdbc:mysql://10.168.3.169:3306/athena?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
url: jdbc:mysql://10.168.56.204:3306/jihe-dc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: root
# password: Platform123!@#
password: Platform123!@#
# url: jdbc:mysql://127.0.0.1:3308/event_iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
# url: jdbc:mysql://127.0.0.1:3308/jihe-dc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
url: jdbc:mysql://10.168.56.204:3306/jihe-dc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: root
# password: root
password: Platform123!@#
# 从库数据源
slave:
# 从数据源开关/默认关闭

12
ruoyi-admin/src/main/resources/application.yml

@ -67,9 +67,9 @@ spring:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
database: 1
# 密码
password: Redis123!@#
password:
# 连接超时时间
timeout: 10s
lettuce:
@ -156,7 +156,7 @@ aj:
iot:
# 物联平台地址
address: http://127.0.0.1:8080
address: https://10.0.81.202:8081
# redis 配置
redis:
# 地址
@ -164,9 +164,9 @@ iot:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 10
database: 0
# 密码
password: Redis123!@#
password:
# 连接超时时间
timeout: 10s
lettuce:
@ -183,4 +183,4 @@ iot:
# 允许访问的ip地址
allowed:
ips: 10.0.81.202,10.168.73.54,10.168.71.194
ips: 10.0.81.202,10.168.73.54,10.168.71.194,

2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@ -126,7 +126,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/**/*.js",
"/profile/**"
).permitAll()
// .antMatchers("/swagger-ui.html").anonymous()
// .antMatchers("/swagger-ui.html").anonymous()
// .antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous()

18
zc-business/src/main/java/com/zc/business/controller/DcBoardReleaseLogController.java

@ -1,8 +1,11 @@
package com.zc.business.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -62,6 +65,21 @@ public class DcBoardReleaseLogController extends BaseController
public void export(HttpServletResponse response, DcBoardReleaseLog dcBoardReleaseLog)
{
List<DcBoardReleaseLog> list = dcBoardReleaseLogService.selectDcBoardReleaseLogList(dcBoardReleaseLog);
for (DcBoardReleaseLog releaseLog : list) {
String content = releaseLog.getReleaseContent();
List<Map<String,Object>> contentList = JSONArray.parseObject(content,List.class);
if (contentList != null){
StringBuilder contentText = new StringBuilder();
for (int i = 0; i < contentList.size(); i++) {
String contentItem = contentList.get(i+1).get("CONTENT").toString().replace("\\\\n"," ");
contentText.append(i).append(".").append(contentItem).append("\n");
}
releaseLog.setReleaseContent(contentText.toString());
} else {
releaseLog.setReleaseContent("");
}
}
ExcelUtil<DcBoardReleaseLog> util = new ExcelUtil<>(DcBoardReleaseLog.class);
util.exportExcel(response, list, "情报板内容发布日志数据");
}

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

@ -31,6 +31,7 @@ import javax.validation.Valid;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
/**
* 设备Controller
@ -240,17 +241,26 @@ public class DcDeviceController extends BaseController {
Object data = JSON.parseObject(queryDeviceProperties(deviceId, propertyId, props).get("data").toString()).get("data");
JSONArray dataArray = JSON.parseArray(data.toString());
List<Object> list = new ArrayList<>();
List<Map<String, 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"));
map.put("timestamp", formatValue.get("equipmentReportingTime") == null? "":Long.valueOf(formatValue.get("equipmentReportingTime").toString()));
list.add(map);
});
return AjaxResult.success(list);
List<Map<String, Object>> newList = list.stream()
.filter(map-> !map.get("timestamp").equals(""))
.collect(Collectors.toList());
Collections.sort(newList, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
return map1.get("timestamp").toString().compareTo(map2.get("timestamp").toString());
}
});
return AjaxResult.success(newList);
}
/**
@ -459,7 +469,7 @@ public class DcDeviceController extends BaseController {
JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function);
//JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ;
String functionId = functionJSONObject.getString("functionId");
JSONObject jsonObject = functionJSONObject.getJSONObject("params") == null?functionJSONObject.getJSONObject("params"):new JSONObject();
JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null?functionJSONObject.getJSONObject("params"):new JSONObject();
resultArray.add(getResult(device, iotDeviceId, functionId, jsonObject));
}
}

28
zc-business/src/main/java/com/zc/business/controller/StatusController.java

@ -107,7 +107,7 @@ public class StatusController extends BaseController {
@GetMapping ("/rule")
public AjaxResult setRule(String rule)
{
redisCache.setCacheSetValue(ORDERRULE,rule);
redisCache.setCacheObject(ORDERRULE,rule);
return AjaxResult.success();
}
@ -354,19 +354,19 @@ public class StatusController extends BaseController {
//总数
maps.put("sum",String.valueOf(list.size()));
subMap.put("全部设备",maps);
// Map<Object, Object> ruleMap=new HashMap<>();
// String orderRule=redisCache.getCacheObject(ORDERRULE);
// if(StringUtil.isNotEmpty(orderRule)){
// ruleMap.put("rule",orderRule);
// subMap.put("排序规则",ruleMap);
// }else{
// String[] rules = {"全部设备","高清网络枪型固定摄像机","高清网络球形摄像机","桥下高清网络球形摄像机","360°全景摄像机","180°全景摄像机",
// "门架式可变信息标志","雨棚可变信息标志","站前悬臂式可变信息标志","气象检测器","路段语音广播系统","护栏碰撞预警系统","毫米波雷达",
// "合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统"};
// orderRule= Arrays.toString(rules);
// ruleMap.put("rule",orderRule);
// subMap.put("排序规则",ruleMap);
// }
Map<Object, Object> ruleMap=new HashMap<>();
String orderRule=redisCache.getCacheObject(ORDERRULE);
if(StringUtil.isNotEmpty(orderRule)){
ruleMap.put("rule",orderRule);
subMap.put("排序规则",ruleMap);
}else{
String[] rules = {"全部设备","高清网络枪型固定摄像机","高清网络球形摄像机","桥下高清网络球形摄像机","360°全景摄像机","180°全景摄像机",
"门架式可变信息标志","雨棚可变信息标志","站前悬臂式可变信息标志","气象检测器","路段语音广播系统","护栏碰撞预警系统","毫米波雷达",
"合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统"};
orderRule= Arrays.toString(rules);
ruleMap.put("rule",orderRule);
subMap.put("排序规则",ruleMap);
}
return AjaxResult.success(subMap);
}

21
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -412,35 +412,30 @@ public class VideoController extends BaseController {
Integer pileNumDistance = pileNumTransformMetre(pileNum);
Map<String,Object> result = new HashMap<>();
//上行列表
//上行列表(包含双向)
List<Map<String,Object>> upCameraList = datalist.stream()
.filter(item -> "0".equals(item.get("camOrientation")))
.map(item->{
item.put("distance",Math.abs(pileNumTransformMetre(item.get("pileNum").toString()) - pileNumDistance));
return item;
})
.filter(item ->
("0".equals(item.get("camOrientation")) || "2".equals(item.get("camOrientation")))
&& Integer.parseInt(item.get("distance").toString()) < 2000)
.sorted(comparing(item -> Integer.parseInt(item.get("distance").toString())))
.collect(Collectors.toList());
if (upCameraList.size() > 0 && Integer.parseInt(upCameraList.get(0).get("distance").toString()) < 2000){
result.put("upCamera",upCameraList.get(0));
} else {
result.put("upCamera",new HashMap<>());
}
result.put("upCamera",upCameraList);
//下行列表
List<Map<String,Object>> downCameraList = datalist.stream()
.filter(item -> "1".equals(item.get("camOrientation")))
.map(item->{
item.put("distance",Math.abs(pileNumTransformMetre(item.get("pileNum").toString()) - pileNumDistance));
return item;
})
.filter(item -> "1".equals(item.get("camOrientation")) && Integer.parseInt(item.get("distance").toString()) < 2000)
.sorted(comparing(item -> Integer.parseInt(item.get("distance").toString())))
.collect(Collectors.toList());
if (downCameraList.size() > 0 && Integer.parseInt(downCameraList.get(0).get("distance").toString()) < 2000){
result.put("downCamera",downCameraList.get(0));
} else {
result.put("downCamera",new HashMap<>());
}
result.put("downCamera",downCameraList);
return AjaxResult.success(result);

123
zc-business/src/main/java/com/zc/business/controller/WordController.java

@ -128,68 +128,75 @@ public class WordController {
PoiUtil.createHeading2(doc,"天气情况统计");
XWPFTable table = doc.createTable(9, 25);
//列宽自动分割
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA);
infoTableWidth.setW(BigInteger.valueOf(9072));
AjaxResult ajaxResult = weatherForecastController.hourlyWeather();
if (ajaxResult.get("code").equals(200)) {
Map<String,List<Map<String,Object>>> data = (Map<String, List<Map<String,Object>>>) ajaxResult.get("data");
data.keySet().forEach(key ->{
if ("hourlyWeather1".equals(key)){
setTableFonts(table.getRow(1).getCell(0), "长清区");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
OffsetDateTime offsetDateTime = OffsetDateTime.parse(weatherList.get(i).get("fxTime").toString());
setTableFonts(table.getRow(0).getCell(i+1),offsetDateTime.format(DateTimeFormatter.ofPattern("dd日HH时")));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather2".equals(key)){
setTableFonts(table.getRow(2).getCell(0), "平阴县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather3".equals(key)){
setTableFonts(table.getRow(3).getCell(0), "东平县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather4".equals(key)){
setTableFonts(table.getRow(4).getCell(0), "汶上县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather5".equals(key)){
setTableFonts(table.getRow(5).getCell(0), "梁山县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("text").toString());
if (data != null && data.size() != 0){
XWPFTable table = doc.createTable(9, 25);
//列宽自动分割
CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA);
infoTableWidth.setW(BigInteger.valueOf(9072));
data.keySet().forEach(key ->{
if ("hourlyWeather1".equals(key)){
setTableFonts(table.getRow(1).getCell(0), "长清区");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
OffsetDateTime offsetDateTime = OffsetDateTime.parse(weatherList.get(i).get("fxTime").toString());
setTableFonts(table.getRow(0).getCell(i+1),offsetDateTime.format(DateTimeFormatter.ofPattern("dd日HH时")));
setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather2".equals(key)){
setTableFonts(table.getRow(2).getCell(0), "平阴县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather3".equals(key)){
setTableFonts(table.getRow(3).getCell(0), "东平县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather4".equals(key)){
setTableFonts(table.getRow(4).getCell(0), "汶上县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather5".equals(key)){
setTableFonts(table.getRow(5).getCell(0), "梁山县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather6".equals(key)){
setTableFonts(table.getRow(6).getCell(0), "嘉祥县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather7".equals(key)){
setTableFonts(table.getRow(7).getCell(0), "巨野县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather8".equals(key)){
setTableFonts(table.getRow(8).getCell(0), "郓城县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("text").toString());
}
}
} else if ("hourlyWeather6".equals(key)){
setTableFonts(table.getRow(6).getCell(0), "嘉祥县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather7".equals(key)){
setTableFonts(table.getRow(7).getCell(0), "巨野县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("text").toString());
}
} else if ("hourlyWeather8".equals(key)){
setTableFonts(table.getRow(8).getCell(0), "郓城县");
List<Map<String,Object>> weatherList = data.get(key);
for (int i = 0; i < weatherList.size(); i++) {
setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("text").toString());
}
}
});
});
} else {
addDescription(doc,"暂无数据");
}
}
//换行

37
zc-business/src/main/java/com/zc/business/domain/DcBoardReleaseLog.java

@ -40,7 +40,7 @@ public class DcBoardReleaseLog extends BaseEntity
private String stakeMark;
/** 方向1-上行,2-中,3-下行 */
@Excel(name = "方向1-上行,2-中,3-下行")
@Excel(name = "方向",readConverterExp = "1=上行,2=中,3=下行")
@ApiModelProperty(value="方向1-上行,2-中,3-下行")
private String direction;
@ -49,9 +49,9 @@ public class DcBoardReleaseLog extends BaseEntity
@ApiModelProperty(value="发布内容")
private String releaseContent;
/** 发布状态(0:成功;1:失败) */
@Excel(name = "发布状态", readConverterExp = "0=:成功;1:失败")
@ApiModelProperty(value="发布状态0=:成功;1:失败")
/** 发布状态(0:失败;1:成功) */
@Excel(name = "发布状态", readConverterExp = "0=失败,1成功")
@ApiModelProperty(value="发布状态0=:失败;1:成功")
private String releaseStatus;
/** 发布时间 */
@ -60,6 +60,14 @@ public class DcBoardReleaseLog extends BaseEntity
@Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date releaseTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value="范围查询-开始时间")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value="范围查询-结束时间")
private Date endTime;
/** 发布机构 */
@Excel(name = "发布机构")
@ApiModelProperty(value="发布机构")
@ -81,7 +89,7 @@ public class DcBoardReleaseLog extends BaseEntity
private String releaseUserId;
/** 发布端 */
@Excel(name = "发布端")
@Excel(name = "发布端", readConverterExp = "00=系统用户,01=智慧大脑,02=GIS+BIM")
@ApiModelProperty(value="发布端(00=系统用户,01=智慧大脑,02=GIS+BIM")
private String platform;
@ -161,7 +169,24 @@ public class DcBoardReleaseLog extends BaseEntity
{
return releaseTime;
}
public void setReleaseDeptName(String releaseDeptName)
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public void setReleaseDeptName(String releaseDeptName)
{
this.releaseDeptName = releaseDeptName;
}

44
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -37,6 +37,7 @@ public class DeviceMessageHandler {
private final int EVENT_AI = 1;
private final int EVENT_STATE = 1;
private final int EVENTEND_STATE = 4;
private final int VISIBILITY_LEVEL = 8;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
@ -113,7 +114,7 @@ public class DeviceMessageHandler {
// 气象检测器
if (IotProductEnum.WEATHER_DETECTOR.value().equals(productId)) {
weatherDetectorMessageHandle(data);
return;
return;
}
// 护栏碰撞
@ -168,8 +169,13 @@ public class DeviceMessageHandler {
dcWarning.setWarningTime(new Date(captureTime));
// 信息来源
dcWarning.setWarningSource(WarningSourceEnum.VIDEO_AI.getCode());
// 事件主类型
dcWarning.setWarningType(data.getInteger("warningType"));
//异常天气等级
if (data.getInteger("warningType") == VISIBILITY_LEVEL) {
dcWarning.setWarningLevel(data.getInteger("visibilityLevel"));
}
String warningSubclass = data.getString("warningSubclass");
// 子类型
@ -181,10 +187,10 @@ public class DeviceMessageHandler {
//方向
if (arr[2] != null) {
if (arr[2].equals("上行")) {
direction=arr[0]+" "+arr[1]+ " 菏泽方向 ";
direction = arr[0] + " " + arr[1] + " 菏泽方向 ";
}
if (arr[2].equals("下行")) {
direction=arr[0]+" "+arr[1]+ " 济南方向 ";
direction = arr[0] + " " + arr[1] + " 济南方向 ";
}
}
@ -349,7 +355,7 @@ public class DeviceMessageHandler {
* @param msg 设备消息
*/
private void oneStopDeviceMessageHandle(JSONObject msg) {
dcTrafficSectionDataService.processRealtimeOneStopMessage(msg);
dcTrafficSectionDataService.processRealtimeOneStopMessage(msg);
}
@ -445,12 +451,12 @@ public class DeviceMessageHandler {
*/
private void weatherDetectorMessageHandle(JSONObject msg) {
// DcMeteorologicalDetectorData meteorologicalDetectorData = (DcMeteorologicalDetectorData) msg.get("properties");
// DcMeteorologicalDetectorData meteorologicalDetectorData = (DcMeteorologicalDetectorData) msg.get("properties");
JSONObject jsonObject = (JSONObject) msg.get("properties");
DcMeteorologicalDetectorData meteorologicalDetectorData = jsonObject.toJavaObject(DcMeteorologicalDetectorData.class);
JSONObject jsonObjectHeaders = (JSONObject)msg.get("headers");
JSONObject jsonObjectHeaders = (JSONObject) msg.get("headers");
String parts = jsonObjectHeaders.getString("deviceName");
String[] strings = parts.split("-");
String deviceName = strings[0];
@ -474,19 +480,19 @@ public class DeviceMessageHandler {
mdDeviceData.setTimeStamp(new Date());
mdDeviceData.setCreatorUserId("自动存储");
Map<String,Object> expands = new HashMap<>();
expands.put("rainFall",meteorologicalDetectorData.getRainfall()); //雨量
expands.put("windDirection",meteorologicalDetectorData.getWindDirection()); //风向
expands.put("windSpeed",meteorologicalDetectorData.getWindSpeed()); //风速
expands.put("temperature",meteorologicalDetectorData.getTemperature()); //大气温度
expands.put("humidity",meteorologicalDetectorData.getHumidity()); //大气湿度
expands.put("airPressure",meteorologicalDetectorData.getAtmosphericPressure()); //气压
expands.put("waterThick",meteorologicalDetectorData.getWaterFilmIceSnowValue()); //水膜厚度
expands.put("wet",meteorologicalDetectorData.getWetSlipperyCoefficient()); //湿滑
expands.put("rainXingTai",meteorologicalDetectorData.getPrecipitationType()); //雨量降水形态
expands.put("visibility",meteorologicalDetectorData.getVisibility()); //能见度
expands.put("remoteRoadSurfaceTemperature",meteorologicalDetectorData.getRemoteRoadSurfaceTemperature()); //路面温度
expands.put("pathContactZhuang",meteorologicalDetectorData.getRemoteRoadSurfaceStatus()); //路面状况
Map<String, Object> expands = new HashMap<>();
expands.put("rainFall", meteorologicalDetectorData.getRainfall()); //雨量
expands.put("windDirection", meteorologicalDetectorData.getWindDirection()); //风向
expands.put("windSpeed", meteorologicalDetectorData.getWindSpeed()); //风速
expands.put("temperature", meteorologicalDetectorData.getTemperature()); //大气温度
expands.put("humidity", meteorologicalDetectorData.getHumidity()); //大气湿度
expands.put("airPressure", meteorologicalDetectorData.getAtmosphericPressure()); //气压
expands.put("waterThick", meteorologicalDetectorData.getWaterFilmIceSnowValue()); //水膜厚度
expands.put("wet", meteorologicalDetectorData.getWetSlipperyCoefficient()); //湿滑
expands.put("rainXingTai", meteorologicalDetectorData.getPrecipitationType()); //雨量降水形态
expands.put("visibility", meteorologicalDetectorData.getVisibility()); //能见度
expands.put("remoteRoadSurfaceTemperature", meteorologicalDetectorData.getRemoteRoadSurfaceTemperature()); //路面温度
expands.put("pathContactZhuang", meteorologicalDetectorData.getRemoteRoadSurfaceStatus()); //路面状况
mdDeviceData.setExpands(JSONObject.toJSONString(expands));

2
zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java

@ -260,7 +260,7 @@ public class DcBoardServiceImpl implements IDcBoardService {
result.add(map);
}else {
status = "0";
map.put("code",status);
map.put("code",status);
map.put("msg",ajaxResult13.get("msg").toString());
result.add(map);
}

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

@ -117,12 +117,8 @@ public class DcWarningServiceImpl implements IDcWarningService
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的值)
HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略)
if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发)
return dcWarningMapper.insertDcWarning(dcWarning);//未定义直接走新增;
}
HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
if (redisValueTwo!=null){ //执行策略2,
String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
@ -135,97 +131,39 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据那就删除这条redis数据,新数据加入到数据库,并加入到redis
if (map==null||(map.get("warningState")!=null&&!map.get("warningState").toString().equals("1"))){//redis中有id但是数据库中没有这条数据,或则数据库中有数据但是状态不为上报,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
return 1;
return dcWarningMapper.insertDcWarning(dcWarning);
}
String otherConfig="";
if (map.get("otherConfig")!=null){
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
}
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectOne = new JSONObject(otherConfig);//原始数据库数据
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
if (integer==0){
return 0;
}
return 1;
}
HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略)
if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
int picturesLength = jsonObjectOne.getJSONArray("pictures").length();//已经存在数据库的图片的长度
if (picturesLength>=10&&jsonObjectTwo.get("pictures")!=null){//如果数据长度大于等于10,对第十位进行替换
JSONArray pictures = jsonObjectOne.getJSONArray("pictures");//获取图片数组
pictures.put(picturesLength-1,jsonObjectTwo.getJSONArray("pictures").getString(0)); //替换第十个元素
jsonObjectOne.put("pictures", pictures);//更新 jsonObjectOne中的pictures 数组
int videoListLength = jsonObjectOne.getJSONArray("pictures").length();//已经存在数据库的视频的长度
if (videoListLength>=10&&jsonObjectTwo.get("videoList")!=null){
JSONArray videoList = jsonObjectOne.getJSONArray("videoList");
videoList.put(videoListLength-1,jsonObjectTwo.getJSONArray("videoList").getString(0));
jsonObjectOne.put("videoList",videoList);
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
return 1;
}
String otherConfig="";
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;
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId,jsonObjectOne.toString());//修改数据库配置
}
return 1;
}
HashMap 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 = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,24,TimeUnit.HOURS);//加入缓存,防止redis数据累计,这里也要设置过期时间,设置为24小时
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id);
return 1;
}
String otherConfig="";
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);//删除redis存储的数据
if (integer==0){
return 0;
}
return 1;
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成工具类
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
}
return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
}
//优先级策略(还差优先级策略需要配置)
@ -260,10 +198,40 @@ public class DcWarningServiceImpl implements IDcWarningService
String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值)
HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略)
if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发)
String priority = redisValueOne.get("priority").toString();//全部的优先等级
String[] split = priority.split(",");
for (int i = 0; i < split.length; i++){
String priorityValue=split[i];//取出当前循环的优先级类型
String keys=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
toString()+dcWarning.getWarningType().toString()+priorityValue;//redis存储事件的key
String dataIds = redisCache.getCacheObject(WARNINGDATA + keys);//查看redis是否存在数据(id的值)
if (dataIds==null){ //没有对应的优先级类型的id值,结束当前循环
continue;
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
if (map==null){//redis中有id但是数据库中没有这条数据,那就直接新增这个事件
return dcWarningMapper.insertDcWarning(dcWarning);
}
String warningState = map.get("warningState").toString();//事件上报状态
if ("1".equals(warningState)==false){ //状态不为上报,不用合成事件,删除之前的redis数据
redisCache.deleteObject(WARNINGDATA+keys);
continue;
}
String otherConfig="";
if (map.get("otherConfig")!=null){
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
}
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置
}
}
HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略)
if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
if (redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件
String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
@ -300,7 +268,7 @@ public class DcWarningServiceImpl implements IDcWarningService
return 1;
}
HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略)
if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
if (redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件
String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长
if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
@ -333,14 +301,14 @@ public class DcWarningServiceImpl implements IDcWarningService
return 1;
}
HashMap redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略)
if (redisValueOne==null&&redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件
if (redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件
if (dataId==null){//如果不存在直接加入数据库,加入缓存
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id);//加入缓存????存在问题会数据累计
redisCache.setCacheObject(WARNINGDATA+key,id,24,TimeUnit.HOURS);//加入缓存,防止redis数据累计,这里也要设置过期时间,设置为24小时
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置

2
zc-business/src/main/resources/mapper/business/DcBoardReleaseLogMapper.xml

@ -36,6 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="releaseContent != null and releaseContent != ''"> and t1.release_content = #{releaseContent}</if>
<if test="releaseStatus != null and releaseStatus != ''"> and t1.release_status = #{releaseStatus}</if>
<if test="releaseTime != null "> and t1.release_time = #{releaseTime}</if>
<if test="startTime != null"> and date_format(t1.release_time,'%Y-%m-%d %H:%i:%s') >= date_format(#{startTime},'%Y-%m-%d %H:%i:%s')</if>
<if test="endTime != null"> and date_format(t1.release_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')</if>
<if test="releaseDeptName != null and releaseDeptName != ''"> and t1.release_dept_name like concat('%', #{releaseDeptName}, '%')</if>
<if test="releaseDeptId != null and releaseDeptId != ''"> and t1.release_dept_id = #{releaseDeptId}</if>
<if test="releaseUserName != null and releaseUserName != ''"> and t1.release_user_name like concat('%', #{releaseUserName}, '%')</if>

Loading…
Cancel
Save