Browse Source

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

develop
xiepufeng 11 months ago
parent
commit
df41836029
  1. 33
      zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java
  2. 78
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  3. 15
      zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java
  4. 6
      zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java
  5. 94
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  6. 32
      zc-business/src/main/java/com/zc/business/domain/DcWarning.java
  7. 16
      zc-business/src/main/java/com/zc/business/domain/Status.java
  8. 21
      zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java
  9. 3
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  10. 1
      zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java
  11. 18
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  12. 10
      zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java
  13. 58
      zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java
  14. 44
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  15. 4
      zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java
  16. 4
      zc-business/src/main/java/com/zc/business/service/impl/StatusService.java
  17. 2
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml
  18. 157
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml
  19. 3
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml
  20. 38
      zc-business/src/main/resources/mapper/business/StatusMapper.xml

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

@ -47,13 +47,20 @@ public class DCPerceivedEventsWarningController extends BaseController {
}
return AjaxResult.success(perceivedEventsWarningService.selectWarningById(id));
}
//根据类型和状态查询预计事件
//告警事件列表
@PostMapping("/perceivedEventsList")
public TableDataInfo getPerceivedEventsList(@RequestBody DcWarning dcWarning){
startPage();
List<DcWarning> list = perceivedEventsWarningService.selectPerceivedEventsList(dcWarning);
return getDataTable(list);
}
//非机预警列表
@PostMapping("/nonAutomaticWarningList")
public TableDataInfo nonAutomaticWarningList(@RequestBody DcWarning dcWarning){
startPage();
List<DcWarning> list = perceivedEventsWarningService.selectNonAutomaticWarningList(dcWarning);
return getDataTable(list);
}
//首页感知事件列表
@PostMapping("/warningList")
public AjaxResult getWarningList(@RequestBody DcWarning dcWarning){
@ -209,4 +216,28 @@ public class DCPerceivedEventsWarningController extends BaseController {
return toAjax(perceivedEventsWarningService.updateWarning(dcWarning));
}
//查询非机预警类型,按照时间与类型查询(传入时间类型type与时间warningTime)
@PostMapping("/nonAutomaticWarningType")
public AjaxResult nonAutomaticWarningType(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getType())||dcWarning.getWarningTime()==null){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.selectTypeNonAutomaticWarning(dcWarning));
}
//查询非机预警,按照时间查询(传入时间类型type与时间warningTime)
@PostMapping("/nonAutomaticWarningTimeType")
public AjaxResult nonAutomaticWarningTimeType(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getType())||dcWarning.getWarningTime()==null){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.selectNonAutomaticWarningTimeType(dcWarning));
}
//查询非机预警,按照时间查询收费站分组(传入时间类型type与时间warningTime)
@PostMapping("/nonAutomaticWarningFacility")
public AjaxResult nonAutomaticWarningFacility(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getType())||dcWarning.getWarningTime()==null){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.selectNonAutomaticWarningFacility(dcWarning));
}
}

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

@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
/**
@ -210,6 +211,7 @@ public class DcDeviceController extends BaseController {
/**
* 查询当天设备指定属性列表
*
* @param deviceId 设备id
* @param propertyId 属性id
* @return 属性列表
@ -217,7 +219,7 @@ public class DcDeviceController extends BaseController {
@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 {
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException {
HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
@ -229,8 +231,8 @@ public class DcDeviceController extends BaseController {
// 将日期列表以逗号分隔并设置为查询条件的值
props.put("terms[0].value", String.join(",", dateList));
props.put("paging", false);
props.put("sorts[0].order","asc");
props.put("sorts[0].name","timestamp");
props.put("sorts[0].order", "asc");
props.put("sorts[0].name", "timestamp");
AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props);
if (!ajaxResult.get("code").equals(200)) {
return ajaxResult;
@ -240,12 +242,12 @@ public class DcDeviceController extends BaseController {
JSONArray dataArray = JSON.parseArray(data.toString());
List<Object> list = new ArrayList<>();
dataArray.forEach(o -> {
Map<String,Object> map = new HashMap<>();
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("1", formatValue.get("1"));
map.put("3", formatValue.get("3"));
map.put("timestamp", jsonObject.get("timestamp"));
list.add(map);
});
return AjaxResult.success(list);
@ -430,7 +432,7 @@ public class DcDeviceController extends BaseController {
.data(requestParams)
.post(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
}catch (Exception e){
} catch (Exception e) {
return AjaxResult.error("请求失败");
}
@ -454,21 +456,61 @@ public class DcDeviceController extends BaseController {
JSONObject functionJSONObject = JSONObject.parseObject(String.valueOf(function));
String functionId = functionJSONObject.getString("functionId");
JSONObject jsonObject = functionJSONObject.getJSONObject("params");
HashMap<String, Object> params = jsonObject.toJavaObject(new TypeReference<HashMap<String, Object>>() {
});
JSONObject result = new JSONObject();
result.put("device", device.getId());
if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) {
result.put("result", broadcastController.nearCamListDistance(jsonObject));
} else {
result.put("result", invokedFunction(iotDeviceId, functionId, params));
}
resultArray.add(result);
resultArray.add(getResult(device, iotDeviceId, functionId, jsonObject));
}
}
return AjaxResult.success(resultArray);
}
private JSONObject getResult(DcDevice device, String iotDeviceId, String functionId, JSONObject jsonObject) throws HttpException, IOException {
HashMap<String, Object> params = jsonObject.toJavaObject(new TypeReference<HashMap<String, Object>>() {
});
JSONObject result = new JSONObject();
result.put("device", device.getId());
if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) {
result.put("result", broadcastController.nearCamListDistance(jsonObject));
} else {
result.put("result", invokedFunction(iotDeviceId, functionId, params));
}
return result;
}
/**
* 批量设备功能调用
*
* @param props 调用参数列表
* @return 调用结果
*/
@ApiOperation("批量激光疲劳设备功能调用")
@PostMapping("/batchLaserFatigueInvokedFunction")
public AjaxResult batchLaserFatigueInvokedFunction(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
String deviceId = (String) props.get("deviceId");
String functionId = (String) props.get("functionId");
ArrayList params = (ArrayList) props.get("params");
JSONArray resultArray = new JSONArray();
for (Object param : params) {
resultArray.add(invokedFunction(deviceId, functionId, (HashMap<String, Object>) param));
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("SET", "7");
invokedFunction(deviceId, "SETMD", hashMap);
return AjaxResult.success(resultArray);
}
public HashMap<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
for (Field field : obj.getClass().getDeclaredFields()) {
try {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return (HashMap<String, Object>) map;
}
/**
* 查询物联设备事件数据
*

15
zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java

@ -56,6 +56,21 @@ public class DcEmployeesController extends BaseController
List<DcEmployees> list = dcEmployeesService.selectDcEmployeesList(dcEmployees);
return getDataTable(list);
}
/**
* 查询值班人员信息列表不分页
*/
@ApiOperation("获取人员信息列表")
@PreAuthorize("@ss.hasPermi('business:employees:list')")
@GetMapping("/listAll")
public AjaxResult listAll(DcEmployees dcEmployees)
{
String name = dcEmployees.getName();
if (name != null && !name.isEmpty()) {
name = name.replace(" ", ""); // 去掉空格
dcEmployees.setName(name);
}
return AjaxResult.success(dcEmployeesService.selectDcEmployeesList(dcEmployees));
}
/**
* 导出值班人员信息列表
*/

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

@ -69,14 +69,14 @@ public class DeviceStatus {
boolean reachable = address.isReachable(5000); // Timeout: 5 seconds
status.setLostRate(lostRate);
if (reachable) {
status.setDeviceStatus(1);
status.setDeviceStatus("1");
status.setSuccessRate("100.00%");
} else {
status.setDeviceStatus(0);
status.setDeviceStatus("0");
status.setSuccessRate("0.00%");
}
}else{
status.setDeviceStatus(0);
status.setDeviceStatus("0");
status.setSuccessRate("0.00%");
status.setLostRate("100.00%");
}

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

@ -59,7 +59,7 @@ public class StatusController extends BaseController {
LocalDateTime currentTime = status.getTime().truncatedTo(ChronoUnit.DAYS).plusDays(1);
status.setStartTime(todayStart);
status.setTime(currentTime);
List<Status> listStatus = statusService.list(status);
List<Status> listStatus = statusService.export(status);
ExcelUtil<Status> util = new ExcelUtil<>(Status.class);
util.exportExcel(response, listStatus, "【请填写功能名称】数据");
}
@ -86,7 +86,7 @@ public class StatusController extends BaseController {
Map<String,String> mapSort=new TreeMap<>();
for (Map.Entry<String, List<Status>> entry : mapTime.entrySet()) {
List<Status> groupItems = entry.getValue();
long count = groupItems.stream().filter(iteam -> iteam.getDeviceStatus() == 1).count();
long count = groupItems.stream().filter(iteam -> iteam.getDeviceStatus() == "1").count();
String onlineRate=String.format("%.2f%%", (double) count / groupItems.size() * 100);
mapSort.put(entry.getKey(),onlineRate);
}
@ -244,39 +244,79 @@ public class StatusController extends BaseController {
//根据时间分组
Map<Integer, List<Status>> map = listStatus.stream()
.collect(Collectors.groupingBy(Status -> Status.getTime().getHour()));
if(StringUtils.isEmpty(map)){
if (StringUtils.isEmpty(map)) {
return AjaxResult.success("暂无数据");
}
Map<Integer, List<Status>> ipMap = new TreeMap<>(map);
Integer lastKey = Collections.max(ipMap.keySet());
List<Status> lastEntry = ipMap.get(lastKey);
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType));
Map<String,Map<String,String>> subMap=new HashMap<>();
Map<String, Map<String, String>> subMap = new HashMap<>();
itemTypeMap.forEach((key, value) -> {
for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) {
Map<String, String> maps=new HashMap<>();
List<Status> groupItems = entrys.getValue();
double lostRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
double sucessRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
String failRate=String.format("%.2f", (100-sucessRate))+"%";
//丢包率
maps.put("lostRate",String.format("%.2f", lostRate)+"%");
//在线率
maps.put("sucessRate",String.format("%.2f", sucessRate)+"%");
//离线率
maps.put("failRate",failRate);
//已使用数量
maps.put("sumUseState",String.valueOf(groupItems.size()));
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
if(itemTypeMap.get(entrys.getKey())!=null) {
subMap.put(itemTypeMap.get(entrys.getKey()), maps);
Map<String, String> maps = new HashMap<>();
List<Status> groupItems = typeMap.get(key);
if (groupItems == null) {
//丢包率
maps.put("lostRate", "0%");
//在线率
maps.put("sucessRate", "0%");
//离线率
maps.put("failRate", "0%");
//已使用数量
maps.put("sumUseState", "0");
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
subMap.put(itemTypeMap.get(key), maps);
} else {
double lostRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
double sucessRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
String failRate = String.format("%.2f", (100 - sucessRate)) + "%";
//丢包率
maps.put("lostRate", String.format("%.2f", lostRate) + "%");
//在线率
maps.put("sucessRate", String.format("%.2f", sucessRate) + "%");
//离线率
maps.put("failRate", failRate);
//已使用数量
maps.put("sumUseState", String.valueOf(groupItems.size()));
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
subMap.put(itemTypeMap.get(key), maps);
}
}
});
//for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) {
// Map<String, String> maps=new HashMap<>();
// List<Status> groupItems = entrys.getValue();
// double lostRate = groupItems.stream()
// .mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
// .average().getAsDouble();
// double sucessRate = groupItems.stream()
// .mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
// .average().getAsDouble();
// String failRate=String.format("%.2f", (100-sucessRate))+"%";
// //丢包率
// maps.put("lostRate",String.format("%.2f", lostRate)+"%");
// //在线率
// maps.put("sucessRate",String.format("%.2f", sucessRate)+"%");
// //离线率
// maps.put("failRate",failRate);
// //已使用数量
// maps.put("sumUseState",String.valueOf(groupItems.size()));
// //总数
// maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
// if(itemTypeMap.get(entrys.getKey())!=null) {
// subMap.put(itemTypeMap.get(entrys.getKey()), maps);
//
// }
//}
Map<String, String> maps=new HashMap<>();
double lostRate = lastEntry.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double

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

@ -26,15 +26,14 @@ public class DcWarning extends BaseEntity
private String stakeMark;
/** 方向:1-上行2-中3-下行 */
@Excel(name = "方向: 1-上行 2-中 3-下行")
@Excel(name = "方向",readConverterExp = "1=菏泽方向,3=济南方向,2=双向")
private String direction;
/** 所属部门 */
@Excel(name = "所属部门")
private Long deptId;
/** 警情状态:1-上报2-已完成3-已终止4-自动结束 */
@Excel(name = "警情状态: 1-上报 2-已完成 3-已终止 4-自动结束")
@Excel(name = "警情状态",readConverterExp = "1=上报,2=已完成,3=已终止,4=自动结束")
private Integer warningState;
/** 预警时间 */
@ -43,36 +42,31 @@ public class DcWarning extends BaseEntity
private Date warningTime;
/** 处理人员 */
@Excel(name = "处理人员")
private Long userId;
/** 信息来源:1-视频AI2-雷达识别3-锥桶4-护栏碰撞5-扫码报警6-非机预警 */
@Excel(name = "信息来源: 1-视频AI 2-雷达识别 3-锥桶 4-护栏碰撞 5-扫码报警 6-非机预警")
@Excel(name = "信息来源", readConverterExp = "1=视频AI,2=雷达识别,3=锥桶,4=护栏碰撞,5=扫码报警,6=非机预警")
private Integer warningSource;
/** 预警级别 */
@Excel(name = "预警级别")
private Integer warningLevel;
/** 事件主类:1-交通拥堵2-行人3-非机动车4-停车5-倒车/逆行6-烟火7-撒落物8-异常天气9-护栏碰撞 */
@Excel(name = "事件主类: 1-交通拥堵 2-行人 3-非机动车 4-停车 5-倒车/逆行 6-烟火 7-撒落物 8-异常天气 9-护栏碰撞")
@Excel(name = "事件主类", readConverterExp = "1=交通拥堵,2=行人,3=非机动车,4=停车,5=违规驾驶,6=路障,7=道路施工,8=异常天气,9=护栏碰撞,10=交通事故,11=车辆故障,99=其它")
private Integer warningType;
/** 事件子类:1-1 拥堵1-2 缓行 */
@Excel(name = "事件子类: 1-1 拥堵 1-2 缓行 2-1 普通行人")
@Excel(name = "事件子类", readConverterExp ="1-1-拥堵,1-2=缓行,2-1=普通行人,2-2=工作人员,3-1=摩托车,3-2=自行车,3-3=三轮车,4-1=非工程车,4-2=工程车,4-3=主路有车,4-4=匝道有车,4-5=车辆故障(弃用),4-6=交通事故(弃用),4-7=应急车道被占用,4-8=车离开应急车道,4-9=其他,4-10=未知车辆,5-1=倒车/逆行,5-2=压线,5-3=掉头,5-4=超速,5-5=低速,5-6=违规变道,5-7=未保持安全距离,6-1=烟火,6-2=火灾,6-3=障碍物,6-4=抛洒物,7-1=道路施工,8-1=雨,8-2=冰雹,8-3=风,8-4=雾,8-5=高温,8-6=积水,8-7=路面湿滑,8-8=路面结冰,8-9=道路能见度低,8-10=道路团雾,9-1=只碰撞不倾斜,9-2=只倾斜无碰撞,9-3=碰撞后倾斜,10-1=未知,10-2单车事故,10-3=多车事故,11-1=车辆抛锚,11-2=车辆炸胎(有备胎),11-2=车辆炸胎(无备胎),99-1=其它")
private String warningSubclass;
/** 事件标题 */
@Excel(name = "事件标题")
private String warningTitle;
/** $column.columnComment */
@Excel(name = "其它配置", readConverterExp = "$column.readConverterExp()")
private String otherConfig;
/** 车道0-应急 1-行1 2-行2 3-行3 4-行4 */
@Excel(name = "车道0-应急 1-行1 2-行2 3-行3 4-行4")
@Excel(name = "车道",readConverterExp="0=应急,1=行1,2=行2,3=行3,4=行4")
private String lane;
/** 所属辖区路段名称 */
@ -91,7 +85,6 @@ public class DcWarning extends BaseEntity
//@Excel(name = "车辆类型")
private String vehicleType;
/** 持续时长 */
@Excel(name = "持续时长(秒)")
private int duration;
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
@ -103,10 +96,8 @@ public class DcWarning extends BaseEntity
private String quarter;
//事件原因
@Excel(name = "事件原因")
private String eventCause;
//完结时间
@Excel(name = "完结时间")
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date endTime;
//操作员
@ -120,11 +111,20 @@ public class DcWarning extends BaseEntity
private String startDate;
//结束日期
private String endDate;
//收费站
private String facilityName;
public String getStartStakeMark() {
return startStakeMark;
}
public String getFacilityName() {
return facilityName;
}
public void setFacilityName(String facilityName) {
this.facilityName = facilityName;
}
public void setStartStakeMark(String startStakeMark) {
this.startStakeMark = startStakeMark;
}

16
zc-business/src/main/java/com/zc/business/domain/Status.java

@ -22,7 +22,7 @@ public class Status {
return startTime;
}
public Status(long id, String deviceNo, String deviceName, int deviceStatus, LocalDateTime time, LocalDateTime startTime, String deviceIp, String successRate, String lostRate, String direction, String production, String model, String network, String content, String type) {
public Status(long id, String deviceNo, String deviceName, String deviceStatus, LocalDateTime time, LocalDateTime startTime, String deviceIp, String successRate, String lostRate, String direction, String production, String model, String network, String content, String type) {
this.id = id;
this.deviceNo = deviceNo;
this.deviceName = deviceName;
@ -77,7 +77,7 @@ public class Status {
return deviceNo;
}
public Status(long id, String deviceNo, String deviceName, int deviceStatus) {
public Status(long id, String deviceNo, String deviceName, String deviceStatus) {
this.id = id;
this.deviceNo = deviceNo;
this.deviceName = deviceName;
@ -99,11 +99,11 @@ public class Status {
this.deviceName = deviceName;
}
public int getDeviceStatus() {
public String getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(int deviceStatus) {
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}
@ -116,8 +116,8 @@ public class Status {
private String deviceName;
@Excel(name = "状态")
private int deviceStatus;
@Excel(name = "使用状态")
private String deviceStatus;
//@Excel(name = "使用状态")
private Integer useState;
@ -220,13 +220,13 @@ public class Status {
this.type = type;
}
@Excel(name = "网段")
//@Excel(name = "网段")
private String network;
private String content;
@Excel(name = "类型")
//@Excel(name = "类型")
private String type;

21
zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java

@ -23,6 +23,8 @@ public interface DcPerceivedEventsWarningMapper {
DcWarning selectWarningById(String id);
//根据类型查询预计事件
List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning);
//非机预警
List<DcWarning> selectNonAutomaticWarningList(DcWarning dcWarning);
//首页感知事件列表
List<DcWarning> selectWarningList(DcWarning dcWarning);
//查询感知数量按照路段进行排名
@ -79,4 +81,23 @@ public interface DcPerceivedEventsWarningMapper {
List<HashMap<String,String>> selectWarningMarkDayOptimize(DcWarning dcWarning);
List<HashMap<String,String>> selectWarningMarkQuarterOptimize(DcWarning dcWarning);
//查询非机预警类型,按照天查询
List<HashMap<String,Object>> selectTypeNonAutomaticWarningDay(DcWarning dcWarning);
//查询非机预警类型,按照月查询
List<HashMap<String,Object>> selectTypeNonAutomaticWarningMonth(DcWarning dcWarning);
//查询非机预警类型,按照年查询
List<HashMap<String,Object>> selectTypeNonAutomaticWarningYear(DcWarning dcWarning);
//查询非机预警日类型按照小时分组
List<HashMap<String,Object>> selectNonAutomaticWarningDay(DcWarning dcWarning);
//查询非机预警月类型按照日分组
List<HashMap<String,Object>> selectNonAutomaticWarningMonth(DcWarning dcWarning);
//查询非机预警年类型按照月分组
List<HashMap<String,Object>> selectNonAutomaticWarningYear(DcWarning dcWarning);
//查询非机预警数据按照日和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacilityDay(DcWarning dcWarning);
//查询非机预警数据按照月和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacilityMonth(DcWarning dcWarning);
//查询非机预警数据按照年和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacilityYear(DcWarning dcWarning);
}

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

@ -80,7 +80,8 @@ public interface DcWarningMapper
//查询预警配置信息
public List<DcWaringStrategy> selectDcWaringStrategyList(DcWaringStrategy dcWaringStrategy);
public List<DcWaringStrategy> selectDcWaringStrategyList();
public List<DcWaringStrategy> selectDcWaringStrategyList(@Param("warningSource")String warningSource,@Param
("warningType")String warningType,@Param("warningSubclass")String warningSubclass,@Param("strategy")Integer strategy);
//修改配置
public Integer updateOtherConfig(@Param("id")String id,@Param("otherConfig")String otherConfig);
}

1
zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java

@ -17,6 +17,7 @@ public interface StatusMapper {
int Add(@Param("status")Status status);
List<Status> listStatus(@Param("status")Status status);
List<Status> export(@Param("status")Status status);
List<Status> deviceStatusListById(@Param("status")Status status);
}

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

@ -174,9 +174,22 @@ public class DeviceMessageHandler {
String warningSubclass = data.getString("warningSubclass");
// 子类型
dcWarning.setWarningSubclass(warningSubclass);
//桩号,方向
String stakeMarkDescription = data.getString("stakeMarkDescription");
String title = stakeMarkDescription + WarningSubclassEnum.getDecorateInfo(warningSubclass);
String direction = "";
String[] arr = stakeMarkDescription.split(" ");
//方向
if (arr[2] != null) {
if (arr[2].equals("上行")) {
direction=arr[0]+" "+arr[1]+ " 菏泽方向 ";
}
if (arr[2].equals("下行")) {
direction=arr[0]+" "+arr[1]+ " 济南方向 ";
}
}
String title = direction + WarningSubclassEnum.getDecorateInfo(warningSubclass);
// 标题
dcWarning.setWarningTitle(title);
dcWarning.setRemark(DateUtil.formatDateTime(DateUtil.date(captureTime)) + " " + title);
@ -208,6 +221,7 @@ public class DeviceMessageHandler {
/* JSONObject combinedData = new JSONObject();
combinedData.put("address", otherConfig);*/
dcWarning.setOtherConfig(otherConfig.toString());
dcWarningService.insertDcWarning(dcWarning);
}

10
zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java

@ -21,6 +21,8 @@ public interface IDCPerceivedEventsWarningService {
//根据类型查询预计事件
List<DcWarning> selectPerceivedEventsList(DcWarning dcWarning);
//非机预警
List<DcWarning> selectNonAutomaticWarningList(DcWarning dcWarning);
//首页敢直视事件
List<DcWarning> selectWarningList(DcWarning dcWarning);
//查询感知数量按照路段进行排名
@ -52,7 +54,11 @@ public interface IDCPerceivedEventsWarningService {
//修改感知事件信息
Integer updateWarning(DcWarning dcWarning);
//查询非机预警事件按照类型区分时间查询
List<HashMap<String,Object>> selectTypeNonAutomaticWarning(DcWarning dcWarning);
//查询非机预警按照时间类型查询
List<HashMap<String,Object>> selectNonAutomaticWarningTimeType(DcWarning dcWarning);
//查询非机预警数据按照日和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacility(DcWarning dcWarning);
}

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

@ -10,7 +10,6 @@ import com.zc.business.service.IDCPerceivedEventsWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.sound.midi.Soundbank;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@ -59,6 +58,21 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
}
return perceivedEventsWarningMapper.selectPerceivedEventsList(dcWarning);
}
@Override
public List<DcWarning> selectNonAutomaticWarningList(DcWarning dcWarning) {
if (StringUtils.isNotEmpty(dcWarning.getStartStakeMark())){
String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark());
dcWarning.setStartStakeMark(startStakeMark);
}
if (StringUtils.isNotEmpty(dcWarning.getEndStakeMark())){
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark());
dcWarning.setEndStakeMark(endStakeMark);
}
return perceivedEventsWarningMapper.selectNonAutomaticWarningList(dcWarning);
}
//首页敢直视事件
@Override
public List<DcWarning> selectWarningList(DcWarning dcWarning) {
@ -254,6 +268,48 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
dcWarning.setUpdateTime(DateUtils.getNowDate());
return perceivedEventsWarningMapper.updateWarning(dcWarning);
}
//查询非机预警事件按照类型区分时间查询
@Override
public List<HashMap<String, Object>> selectTypeNonAutomaticWarning(DcWarning dcWarning) {
String type = dcWarning.getType();
switch (type){
case "day":
return perceivedEventsWarningMapper.selectTypeNonAutomaticWarningDay(dcWarning);
case "month":
return perceivedEventsWarningMapper.selectTypeNonAutomaticWarningMonth(dcWarning);
case "year":
return perceivedEventsWarningMapper.selectTypeNonAutomaticWarningYear(dcWarning);
}
return null;
}
//查询非机预警按照时间类型查询
@Override
public List<HashMap<String, Object>> selectNonAutomaticWarningTimeType(DcWarning dcWarning) {
String type = dcWarning.getType();
switch (type){
case "day":
return perceivedEventsWarningMapper.selectNonAutomaticWarningDay(dcWarning);
case "month":
return perceivedEventsWarningMapper.selectNonAutomaticWarningMonth(dcWarning);
case "year":
return perceivedEventsWarningMapper.selectNonAutomaticWarningYear(dcWarning);
}
return null;
}
//查询非机预警数据按照日和收费站分组
@Override
public List<HashMap<String, Object>> selectNonAutomaticWarningFacility(DcWarning dcWarning) {
String type = dcWarning.getType();
switch (type){
case "day":
return perceivedEventsWarningMapper.selectNonAutomaticWarningFacilityDay(dcWarning);
case "month":
return perceivedEventsWarningMapper.selectNonAutomaticWarningFacilityMonth(dcWarning);
case "year":
return perceivedEventsWarningMapper.selectNonAutomaticWarningFacilityYear(dcWarning);
}
return null;
}
}

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

@ -97,8 +97,12 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//优先级策略
//优先级策略(还差优先级策略需要配置)
public int priority(DcWarning dcWarning){
dcWarning.setCreateTime(DateUtils.getNowDate());
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null||
StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){
return 0;
@ -141,6 +145,13 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//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="";
if (map.get("otherConfig")!=null){
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
@ -148,7 +159,8 @@ public class DcWarningServiceImpl implements IDcWarningService
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);
JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json
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){
@ -159,16 +171,25 @@ public class DcWarningServiceImpl implements IDcWarningService
HashMap 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);//加入数据库
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id,30,TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis
redisCache.deleteObject(WARNINGDATA+key);
dcWarningMapper.insertDcWarning(dcWarning);
String id = dcWarning.getId();
redisCache.setCacheObject(WARNINGDATA+key,id,30,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);
@ -182,22 +203,31 @@ public class DcWarningServiceImpl implements IDcWarningService
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 = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
if (insertDcWarning==0){
return 0;
}
String id = dcWarning.getId();//取出加入后的id作为value
redisCache.setCacheObject(WARNINGDATA+key,id);//加入缓存????存在问题会数据累计
return 1;//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置
HashMap<String, Object> map = dcWarningMapper.selectDcWarningById(dataId);
String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息
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);//删除对应的合成事件
redisCache.deleteObject(WARNINGDATA + key);//删除redis存储的数据
if (integer==0){
return 0;
}

4
zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java

@ -102,7 +102,7 @@ public class ExcelExportService {
Map<String, List<Status>> maps = groupItem.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType));
for (Map.Entry<String, List<Status>> entrys : maps.entrySet()) {
List<Status> groupItems = entrys.getValue();
long b = groupItems.stream().filter(iteam -> iteam.getDeviceStatus() == 1).count();
long b = groupItems.stream().filter(iteam -> iteam.getDeviceStatus() == "1").count();
// for (Status ignored : groupItems) {
int a = rowNum++;
Row row = sheet.getRow(a); // 获取指定索引的行
@ -153,7 +153,7 @@ public class ExcelExportService {
rowNum = 1;
for (Map.Entry<String, List<Status>> entry : categoryMap.entrySet()) {
List<Status> groupItems = entry.getValue();
long a=groupItems.stream().filter(iteam->iteam.getDeviceStatus()==1).count();
long a=groupItems.stream().filter(iteam->iteam.getDeviceStatus()=="1").count();
row = sheet.createRow(rowNum++);
HashMap<String, String> itemTypeMap = new HashMap<>();
itemTypeMap.put("1", "高清网络枪型固定摄像机");

4
zc-business/src/main/java/com/zc/business/service/impl/StatusService.java

@ -29,6 +29,10 @@ public class StatusService {
List<Status> list = statusMapper.listStatus(status);
return list;
}
public List<Status> export(Status status) {
List<Status> list = statusMapper.export(status);
return list;
}
public List<Status> deviceStatusListById(Status status) {
return statusMapper.deviceStatusListById(status);

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

@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productionDate != null and productionDate != ''">and t1.production_date = #{productionDate}</if>
<if test="durableYears != null and durableYears != ''">and t1.durable_years = #{durableYears}</if>
<if test="installationSite != null and installationSite != ''">and t1.installation_site = #{installationSite}</if>
<if test="useState != null and useState != ''">and t1.use_state = #{useState}</if>
<if test="useState != null">and t1.use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''">and t1.device_state = #{deviceState}</if>
<if test="otherConfig != null and otherConfig != ''">and json_extract(t1.other_config,'$.childType') = #{otherConfig}</if>
<if test="remark != null and remark != ''">and t1.remark = #{remark}</if>

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

@ -28,7 +28,7 @@
where warning.`id`=#{id}
</select>
<select id="selectPerceivedEventsList" resultType="com.zc.business.domain.DcWarning">
SELECT warning.`id`,warning.`stake_mark`, warning.`direction`,
SELECT facility.facility_name, warning.`id`,warning.`stake_mark`, warning.`direction`,facility.facility_name,
mark.longitude,mark.latitude,warning.lane,duration,
warning.`dept_id`,warning.`warning_state`,warning.`warning_time`,
warning.`user_id`, warning.`warning_source`,warning.`warning_level`,
@ -36,8 +36,9 @@
warning.`warning_type`,warning.`warning_subclass`,warning.`warning_title`,
warning.`other_config` FROM dc_warning AS warning
left JOIN dc_stake_mark AS mark ON mark.stake_mark=warning.stake_mark and mark.direction=warning.direction
left join dc_facility as facility on facility.stake_mark=warning.stake_mark
<where>
<if test="warningSource != null and warningSource != ''"> and warning.warning_source = #{warningSource}</if>
warning.warning_source !=6
<if test="warningState != null and warningState != ''"> and warning.warning_state = #{warningState}</if>
<if test="warningType != null and warningType != ''"> and warning.warning_type = #{warningType}</if>
<if test="warningSubclass != null and warningSubclass != ''"> and warning.warning_subclass = #{warningSubclass}</if>
@ -57,6 +58,37 @@
</where>
order by warning.warning_time desc
</select>
<select id="selectNonAutomaticWarningList" resultType="com.zc.business.domain.DcWarning">
SELECT facility.facility_name, warning.`id`,warning.`stake_mark`, warning.`direction`,facility.facility_name,
mark.longitude,mark.latitude,warning.lane,duration,
warning.`dept_id`,warning.`warning_state`,warning.`warning_time`,
warning.`user_id`, warning.`warning_source`,warning.`warning_level`,
warning.`remark`, warning.`create_time`,warning.`update_time`,
warning.`warning_type`,warning.`warning_subclass`,warning.`warning_title`,
warning.`other_config` FROM dc_warning AS warning
left JOIN dc_stake_mark AS mark ON mark.stake_mark=warning.stake_mark and mark.direction=warning.direction
left join dc_facility as facility on facility.stake_mark=warning.stake_mark
<where>
<if test="warningSource != null and warningSource != ''"> and warning.warning_source = #{warningSource}</if>
<if test="warningState != null and warningState != ''"> and warning.warning_state = #{warningState}</if>
<if test="warningType != null and warningType != ''"> and warning.warning_type = #{warningType}</if>
<if test="warningSubclass != null and warningSubclass != ''"> and warning.warning_subclass = #{warningSubclass}</if>
<if test="direction != null and direction != ''"> and warning.direction = #{direction}</if>
<if test="stakeMark != null and stakeMark != ''"> and warning.stake_mark = #{stakeMark}</if>
<if test="startTime != null and completeTime != null ">
and warning.warning_time between #{startTime} and #{completeTime}</if>
<if test="startStakeMark != null and startStakeMark != ''">
and CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark,'+',1),2)AS UNSIGNED)*1000
+CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&gt;#{startStakeMark}
</if>
<if test=" endStakeMark != null and endStakeMark != '' ">
and CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark,'+',1),2)AS UNSIGNED)*1000
+CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
</if>
</where>
order by warning.warning_time desc
</select>
<select id="selectWarningList" resultType="com.zc.business.domain.DcWarning">
SELECT warning.`id`,warning.`stake_mark`, warning.`direction`,
mark.longitude,mark.latitude,warning.lane,duration,
@ -372,6 +404,127 @@
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="selectTypeNonAutomaticWarningDay" resultType="java.util.HashMap">
SELECT s.subclass,COALESCE(t.count, 0) AS number
FROM (
SELECT '1-1' AS warning_subclass , '拥堵' AS subclass UNION ALL
SELECT '2-1' AS warning_subclass, '行人' AS subclass UNION ALL
SELECT '6-4' AS warning_subclass, '抛洒物' AS subclass UNION ALL
SELECT '5-6' AS warning_subclass, '变道' AS subclass UNION ALL
SELECT '99-1' AS warning_subclass, '机占非' AS subclass UNION ALL
SELECT '6-3' AS warning_subclass, '路障' AS subclass UNION ALL
SELECT '7-1' AS warning_subclass, '施工' AS subclass UNION ALL
SELECT '4-10' AS warning_subclass, '停车' AS subclass UNION ALL
SELECT '5-2' AS warning_subclass, '压线' AS subclass UNION ALL
SELECT '5-3' AS warning_subclass, '掉头' AS subclass UNION ALL
SELECT '5-1' AS warning_subclass, '逆行' AS subclass
) s
LEFT JOIN ( SELECT warning_subclass, COUNT(1) AS count FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
and warning_source=6
GROUP BY warning_subclass) t ON s.warning_subclass = t.warning_subclass
</select>
<select id="selectTypeNonAutomaticWarningMonth" resultType="java.util.HashMap">
SELECT s.subclass,COALESCE(t.count, 0) AS number
FROM (
SELECT '1-1' AS warning_subclass , '拥堵' AS subclass UNION ALL
SELECT '2-1' AS warning_subclass, '行人' AS subclass UNION ALL
SELECT '6-4' AS warning_subclass, '抛洒物' AS subclass UNION ALL
SELECT '5-6' AS warning_subclass, '变道' AS subclass UNION ALL
SELECT '99-1' AS warning_subclass, '机占非' AS subclass UNION ALL
SELECT '6-3' AS warning_subclass, '路障' AS subclass UNION ALL
SELECT '7-1' AS warning_subclass, '施工' AS subclass UNION ALL
SELECT '4-10' AS warning_subclass, '停车' AS subclass UNION ALL
SELECT '5-2' AS warning_subclass, '压线' AS subclass UNION ALL
SELECT '5-3' AS warning_subclass, '掉头' AS subclass UNION ALL
SELECT '5-1' AS warning_subclass, '逆行' AS subclass
) s
LEFT JOIN ( SELECT warning_subclass, COUNT(1) AS count FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m')=DATE_FORMAT(#{warningTime},'%Y-%m')
and warning_source=6
GROUP BY warning_subclass) t ON s.warning_subclass = t.warning_subclass
</select>
<select id="selectTypeNonAutomaticWarningYear" resultType="java.util.HashMap">
SELECT s.subclass,COALESCE(t.count, 0) AS number
FROM (
SELECT '1-1' AS warning_subclass , '拥堵' AS subclass UNION ALL
SELECT '2-1' AS warning_subclass, '行人' AS subclass UNION ALL
SELECT '6-4' AS warning_subclass, '抛洒物' AS subclass UNION ALL
SELECT '5-6' AS warning_subclass, '变道' AS subclass UNION ALL
SELECT '99-1' AS warning_subclass, '机占非' AS subclass UNION ALL
SELECT '6-3' AS warning_subclass, '路障' AS subclass UNION ALL
SELECT '7-1' AS warning_subclass, '施工' AS subclass UNION ALL
SELECT '4-10' AS warning_subclass, '停车' AS subclass UNION ALL
SELECT '5-2' AS warning_subclass, '压线' AS subclass UNION ALL
SELECT '5-3' AS warning_subclass, '掉头' AS subclass UNION ALL
SELECT '5-1' AS warning_subclass, '逆行' AS subclass
) s
LEFT JOIN ( SELECT warning_subclass, COUNT(1) AS count FROM dc_warning
where DATE_FORMAT(warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y')
and warning_source=6
GROUP BY warning_subclass) t ON s.warning_subclass = t.warning_subclass
</select>
<select id="selectNonAutomaticWarningDay" resultType="java.util.HashMap">
select t1.n as time,IFNULL(t2.num,0)as number from
(SELECT 0 AS n UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL
SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL
SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL
SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
) t1
left join
(select HOUR(warning_time) hours,count(*) num from dc_warning
where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d')
and warning_source=6
GROUP BY hours) t2
on t1.n = t2.hours
</select>
<select id="selectNonAutomaticWarningMonth" resultType="java.util.HashMap">
SELECT DATE(warning.warning_time) AS day, COUNT(*) AS number
FROM dc_warning as warning
WHERE DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
and warning_source=6
GROUP BY day
ORDER BY day
</select>
<select id="selectNonAutomaticWarningYear" resultType="java.util.HashMap">
select t1.n as month,IFNULL(t2.num,0)as number from
(SELECT 0 AS n UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL
SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
SELECT 12
) t1 left join
(select month(warning_time) hours,count(*) num from dc_warning t1
where DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and warning_source=6
GROUP BY hours) t2
on t1.n = t2.hours
</select>
<select id="selectNonAutomaticWarningFacilityDay" resultType="java.util.HashMap">
select facility_name as facilityName, COALESCE(w_count.number, 0) AS number
from dc_facility AS s
LEFT JOIN (SELECT w.stake_mark, COUNT(1) AS number FROM dc_warning AS w
WHERE DATE_FORMAT(w.warning_time,'%Y-%m-%d') = DATE_FORMAT(#{warningTime},'%Y-%m-%d')
and w.warning_source=6
GROUP BY w.stake_mark ) AS w_count ON s.stake_mark = w_count.stake_mark
</select>
<select id="selectNonAutomaticWarningFacilityMonth" resultType="java.util.HashMap">
select facility_name as facilityName, COALESCE(w_count.number, 0) AS number
from dc_facility AS s
LEFT JOIN (SELECT w.stake_mark, COUNT(1) AS number FROM dc_warning AS w
WHERE DATE_FORMAT(w.warning_time,'%Y-%m') = DATE_FORMAT(#{warningTime},'%Y-%m')
and w.warning_source=6
GROUP BY w.stake_mark ) AS w_count ON s.stake_mark = w_count.stake_mark
</select>
<select id="selectNonAutomaticWarningFacilityYear" resultType="java.util.HashMap">
select facility_name as facilityName, COALESCE(w_count.number, 0) AS number
from dc_facility AS s
LEFT JOIN (SELECT w.stake_mark, COUNT(1) AS number FROM dc_warning AS w
WHERE DATE_FORMAT(w.warning_time,'%Y') = DATE_FORMAT(#{warningTime},'%Y')
and w.warning_source=6
GROUP BY w.stake_mark ) AS w_count ON s.stake_mark = w_count.stake_mark
</select>
<!-- <select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">-->
<!-- SELECT DISTINCT m.stake_mark stakeMarkId,-->

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

@ -77,6 +77,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
warning.`warning_type`,warning.`warning_subclass`,warning.`warning_title`,
warning.`other_config` FROM dc_warning AS warning
LEFT JOIN dc_stake_mark AS mark ON mark.stake_mark=warning.stake_mark
where warning.warning_source !=6
</select>
<insert id="insertDcWarning" parameterType="DcWarning" useGeneratedKeys="true" keyProperty="id">
@ -208,6 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<if test="strategy != null "> and strategy = #{strategy}</if>
</where>
</select>

38
zc-business/src/main/resources/mapper/business/StatusMapper.xml

@ -85,6 +85,44 @@
select id, device_no, device_name, device_status, time from status
</sql>
<select id="export" parameterType="com.zc.business.domain.Status" resultMap="BaseResultMap">
select s.id, s.device_no, s.device_name,s.time,
d.device_ip,s.success_rate,s.lost_rate,e.manufacturer,e.model,d.facilities_type,d.remark,COALESCE(d.child_type,
d.device_type) AS type,
CASE
WHEN d.direction = 1 THEN '菏泽方向'
WHEN d.direction = 3 THEN '济南方向'
ELSE '双向'
END AS direction,
CASE
WHEN s.device_status = 1 THEN '正常'
WHEN s.device_status = 0 THEN '异常'
ELSE '双向'
END AS device_status
from dc_device d
LEFT JOIN status s on (s.device_id = d.id)
LEFT JOIN dc_product e on e.id = d.product_id
<where>
<if test="status.time != null">
AND s.time BETWEEN #{status.startTime,jdbcType=DATE} AND #{status.time,jdbcType=DATE}
</if>
<if test="status.deviceNo != null">
AND s.device_no = #{status.deviceNo}
</if>
<if test="status.type != null">
AND (d.device_type = #{status.type} or d.child_type=#{status.type})
</if>
<if test="status.deviceId != null">
AND s.device_id = #{status.deviceId}
</if>
<if test="status.useState != null and status.useState != 0">
AND d.use_state = #{status.useState}
</if>
</where>
</select>
<select id="listStatus" parameterType="com.zc.business.domain.Status" resultMap="BaseResultMap">
select s.id, s.device_no, s.device_name, s.device_status,s.time, d.device_ip,s.success_rate,s.lost_rate,d.direction,e.manufacturer,e.model,d.facilities_type,d.remark,COALESCE(d.child_type, d.device_type) AS type
from dc_device d

Loading…
Cancel
Save