|
@@ -3,6 +3,7 @@ package com.sooka.sponest.data.housingconstruction.handler;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.security.utils.DictUtils;
|
|
|
import com.ruoyi.system.api.RemoteConfigService;
|
|
@@ -57,19 +58,13 @@ public class TaskHandler {
|
|
|
* 企业生产报告运行预警
|
|
|
*/
|
|
|
@GetMapping("/enterpriseProductionReportTask")
|
|
|
- // 每天午夜 12 点执行
|
|
|
-// @Scheduled(cron = "0 0 0 * * ?")
|
|
|
public void enterpriseProductionReportTask() {
|
|
|
//字典列表
|
|
|
List<SysDictData> reportCacheList = DictUtils.getDictCache("enterprise_production_report");
|
|
|
-
|
|
|
//企业列表
|
|
|
List<CenterdataTHousingconstructionEnterprise> enterpriseList = enterpriseService.selectCenterdataTHousingconstructionEnterpriseList(new CenterdataTHousingconstructionEnterprise());
|
|
|
-
|
|
|
//获取每个企业每种报告的最新记录
|
|
|
List<CenterdataTHousingconstructionEnterpriseproductionreport> dataList = reportService.getNewReport(new CenterdataTHousingconstructionEnterpriseproductionreport());
|
|
|
-
|
|
|
-
|
|
|
//遍历企业列表,获取企业信息
|
|
|
for (CenterdataTHousingconstructionEnterprise enterprise : enterpriseList) {
|
|
|
StringBuilder enterpriseStr = new StringBuilder();//事故隐患排查治理制度,安全事故应急救援预案,
|
|
@@ -119,64 +114,16 @@ public class TaskHandler {
|
|
|
sendEvent.sendEvent(enterpriseStr.toString(), StaticEntity.ENTERPRISE_NAME, "", "", sensorEventVo, StaticEntity.ENTERPRISE_CODE);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 每个企业每种类型的文件单独上报代码
|
|
|
- /*//获取报告类型
|
|
|
- reportCacheList.forEach(sysDictData -> {
|
|
|
- //获取企业信息
|
|
|
- enterpriseList.forEach(enterprise -> {
|
|
|
- //设置事件标识, 当标识为true时, 发送事件
|
|
|
- boolean flag = true;
|
|
|
- for (CenterdataTHousingconstructionEnterpriseproductionreport data : dataList) {
|
|
|
- if (sysDictData.getDictValue().equals(data.getReportType()) && enterprise.getId().equals(data.getEnterpriseId())) {
|
|
|
- //获取数据的上传时间
|
|
|
- Date createTime = data.getCreateTime();
|
|
|
- // 将 Date 转换为 LocalDateTime
|
|
|
- LocalDateTime localDateTime = convertToLocalDateTime(createTime);
|
|
|
- // 在 LocalDateTime 上加上 30 天
|
|
|
- LocalDateTime increaseBy30Days = localDateTime.plus(30, ChronoUnit.DAYS);
|
|
|
- // 获取当前日期和时间
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- // 比较日期
|
|
|
- if (increaseBy30Days.isAfter(now)) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //发送事件
|
|
|
- if (flag) {
|
|
|
- //创建事件实体类
|
|
|
- SensorEventVo sensorEventVo = new SensorEventVo(
|
|
|
- enterprise.getLongitude(),
|
|
|
- enterprise.getLatitude(),
|
|
|
- enterprise.getId(),
|
|
|
- enterprise.getEnterpriseName(),
|
|
|
- new Date(),
|
|
|
- enterprise.getRegisteredAddress()
|
|
|
- );
|
|
|
- //设置基础模板
|
|
|
- StringBuilder template = new StringBuilder();
|
|
|
- template.append(enterprise.getEnterpriseName()).append("的").append(sysDictData.getDictLabel()).append("发生%s, 超过30天未上传, 请及时处理!%s%s");
|
|
|
- //发送事件
|
|
|
- sendEvent.sendEvent(template.toString(), StaticEntity.ENTERPRISE_NAME, "", "", sensorEventVo, StaticEntity.ENTERPRISE_CODE);
|
|
|
- }
|
|
|
- });
|
|
|
- });*/
|
|
|
}
|
|
|
|
|
|
// 将 Date 转换为 LocalDateTime
|
|
|
public static LocalDateTime convertToLocalDateTime(Date date) {
|
|
|
- return date.toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDateTime();
|
|
|
+ return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 1207 气瓶存疑预警
|
|
|
*/
|
|
|
- // 每天午夜 12 点执行
|
|
|
-// @Scheduled(cron = "0 0 0 * * ?")
|
|
|
@GetMapping("/performDailyTask")
|
|
|
public void performDailyTask() {
|
|
|
//获取告警数据
|
|
@@ -198,7 +145,6 @@ public class TaskHandler {
|
|
|
//发送事件
|
|
|
sendEvent.sendEvent(template.toString(), StaticEntity.INSPECT_NAME, data.getThreshold(), "", sensorEventVo, StaticEntity.INSPECT_CODE);
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@PostMapping("/sendGpsEvent")
|
|
@@ -213,39 +159,39 @@ public class TaskHandler {
|
|
|
logger.info("设定的阈值{}", speedThreshold);
|
|
|
|
|
|
String address = getAddressMap(jsonObject, speedThreshold);
|
|
|
- logger.info("事件发生地点信息{}",address);
|
|
|
-
|
|
|
- Map<String, Object> carInfo = carService.getCarInfoByDeviceId(jsonObject.getString("deviceid"));
|
|
|
- logger.info("车辆信息{}",carInfo);
|
|
|
-
|
|
|
- String eventSlatSlon = getEventSlatSlon(jsonObject);
|
|
|
- logger.info("事件起点经纬度{}",eventSlatSlon);
|
|
|
-
|
|
|
- //创建事件实体
|
|
|
- SensorEventVo sensorEventVo = new SensorEventVo();
|
|
|
- sensorEventVo.setEventType("8");
|
|
|
- sensorEventVo.setLongitude("false".equals(eventSlatSlon)?"":eventSlatSlon.split("_")[0]);
|
|
|
- sensorEventVo.setLatitude("false".equals(eventSlatSlon)?"":eventSlatSlon.split("_")[1]);
|
|
|
- //上报人为设备id
|
|
|
+ logger.info("事件发生地点信息{}", address);
|
|
|
+ if (StringUtils.isNotBlank(address)) {
|
|
|
+ Map<String, Object> carInfo = carService.getCarInfoByDeviceId(jsonObject.getString("deviceid"));
|
|
|
+ logger.info("车辆信息{}", carInfo);
|
|
|
+
|
|
|
+ String eventSlatSlon = getEventSlatSlon(jsonObject);
|
|
|
+ logger.info("事件起点经纬度{}", eventSlatSlon);
|
|
|
+
|
|
|
+ //创建事件实体
|
|
|
+ SensorEventVo sensorEventVo = new SensorEventVo();
|
|
|
+ sensorEventVo.setEventType("8");
|
|
|
+ sensorEventVo.setLatitude("false".equals(eventSlatSlon) ? "" : eventSlatSlon.split("_")[0]);
|
|
|
+ sensorEventVo.setLongitude("false".equals(eventSlatSlon) ? "" : eventSlatSlon.split("_")[1]);
|
|
|
+ //上报人为设备id
|
|
|
// sensorEventVo.setSensorId(jsonObject.getString("deviceid"));
|
|
|
- //上报人为企业id
|
|
|
- sensorEventVo.setSensorId(MapUtils.getString(carInfo, "enterpriseId"));
|
|
|
- sensorEventVo.setReportTime(new Date());
|
|
|
- sensorEventVo.setAddress(getAddress(eventSlatSlon, jsonObject.getJSONObject("addressmap")));
|
|
|
- //上报人名称为车号
|
|
|
+ //上报人为企业id
|
|
|
+ sensorEventVo.setSensorId(MapUtils.getString(carInfo, "enterpriseId"));
|
|
|
+ sensorEventVo.setReportTime(new Date());
|
|
|
+ sensorEventVo.setAddress(getAddress(eventSlatSlon, jsonObject.getJSONObject("addressmap")));
|
|
|
+ //上报人名称为车号
|
|
|
// sensorEventVo.setReportor(MapUtils.getString(carInfo, "carNumber"));
|
|
|
- //上报人为企业名称
|
|
|
- sensorEventVo.setReportor(MapUtils.getString(carInfo, "enterpriseName"));
|
|
|
- StringBuilder template = new StringBuilder();
|
|
|
- template.append(MapUtils.getString(carInfo, "enterpriseName"))
|
|
|
- .append("的").append(MapUtils.getString(carInfo, "driverName"))
|
|
|
- .append("驾驶").append(MapUtils.getString(carInfo, "carNumber"))
|
|
|
- .append("车辆【").append(address).append("】发生%s")
|
|
|
- .append(",设定的阈值为%skm/h");
|
|
|
- System.out.println("事件推送实体 =》 " + sensorEventVo);
|
|
|
- //发送事件
|
|
|
- sendEvent.sendEvent(template.toString(), StaticEntity.SPEED_NAME, String.valueOf(speedThreshold), "", sensorEventVo, StaticEntity.SPEED_CODE);
|
|
|
-
|
|
|
+ //上报人为企业名称
|
|
|
+ sensorEventVo.setReportor(MapUtils.getString(carInfo, "enterpriseName"));
|
|
|
+ StringBuilder template = new StringBuilder();
|
|
|
+ template.append(MapUtils.getString(carInfo, "enterpriseName"))
|
|
|
+ .append("的").append(MapUtils.getString(carInfo, "driverName"))
|
|
|
+ .append("驾驶").append(MapUtils.getString(carInfo, "carNumber"))
|
|
|
+ .append("车辆【").append(address).append("】发生%s")
|
|
|
+ .append(",设定的阈值为%skm/h");
|
|
|
+ System.out.println("事件推送实体 =》 " + sensorEventVo);
|
|
|
+ //发送事件
|
|
|
+ sendEvent.sendEvent(template.toString(), StaticEntity.SPEED_NAME, String.valueOf(speedThreshold), "", sensorEventVo, StaticEntity.SPEED_CODE);
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -265,7 +211,7 @@ public class TaskHandler {
|
|
|
String mapKeyStart = getStr(gps.getSlat()) + "_" + getStr(gps.getSlon());
|
|
|
//超速结束
|
|
|
String mapKeyEnd = getStr(gps.getElat()) + "_" + getStr(gps.getElon());
|
|
|
- String addressStr = "{" + addressmap.getString(mapKeyStart) + ">>>" + addressmap.getString(mapKeyEnd) + "}区间最高时速为" + v + "km/h";
|
|
|
+ String addressStr = "”" + addressmap.getString(mapKeyStart) + "”-->”" + addressmap.getString(mapKeyEnd) + "”区间最高时速为" + v + "km/h";
|
|
|
String address = addressStr.replace("null", "未知位置");
|
|
|
addressResult.append("在").append(address).append(";");
|
|
|
}
|
|
@@ -310,7 +256,7 @@ public class TaskHandler {
|
|
|
/**
|
|
|
* 获取事件集合中时间最早的一个经纬度信息
|
|
|
*/
|
|
|
- private String getEventSlatSlon(JSONObject jsonObject){
|
|
|
+ private String getEventSlatSlon(JSONObject jsonObject) {
|
|
|
JSONArray totaltrips = jsonObject.getJSONArray("totaltrips");
|
|
|
List<GpsEntity> gpsEntities = JSONArray.parseArray(totaltrips.toJSONString(), GpsEntity.class);
|
|
|
// 找到 startTime 最小的 GpsEntity
|
|
@@ -328,11 +274,12 @@ public class TaskHandler {
|
|
|
|
|
|
/**
|
|
|
* 根据最早的经纬度信息获取位置信息
|
|
|
- * @param latAndLon 最早的经纬度信息
|
|
|
+ *
|
|
|
+ * @param latAndLon 最早的经纬度信息
|
|
|
* @param addressmap 地点结合
|
|
|
* @return 事件位置
|
|
|
*/
|
|
|
- private String getAddress(String latAndLon, JSONObject addressmap){
|
|
|
+ private String getAddress(String latAndLon, JSONObject addressmap) {
|
|
|
String[] split = latAndLon.split("_");
|
|
|
return addressmap.getString(getStr(split[0]) + "_" + getStr(split[1]));
|
|
|
}
|