23 changed files with 1363 additions and 150 deletions
@ -0,0 +1,10 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
// 调用非机预警设备订阅事件
|
|||
export function eventSubscription(data) { |
|||
return request({ |
|||
url: '/nonAutomaticWarning/eventSubscription', |
|||
method: 'post', |
|||
data: data |
|||
}) |
|||
} |
@ -0,0 +1,82 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<!-- 添加或修改【请填写功能名称】对话框 --> |
|||
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|||
<el-form-item label="用户名称" prop="APPKEY"> |
|||
<el-input v-model="form.APPKEY" placeholder="请输入用户名称"/> |
|||
</el-form-item> |
|||
<el-form-item label="用户密码" prop="APPSECRET"> |
|||
<el-input v-model="form.APPSECRET" placeholder="请输入用户密码"/> |
|||
</el-form-item> |
|||
<el-form-item label="请求路径" prop="URI"> |
|||
<el-input v-model="form.URI" placeholder="请输入请求路径"/> |
|||
</el-form-item> |
|||
<el-form-item label="请求端口" prop="IP"> |
|||
<el-input v-model="form.IP" placeholder="请输入请求端口"/> |
|||
</el-form-item> |
|||
</el-form> |
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button style="float: right" type="primary" @click="submitForm">订阅</el-button> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { eventSubscription } from '@/api/system/NonAutomaticWarning' |
|||
|
|||
export default { |
|||
name: 'NonAutomaticWarning', |
|||
data() { |
|||
return { |
|||
// 表单参数 |
|||
form: { |
|||
APPKEY: '22825659', |
|||
APPSECRET: '7Qcq3fr1gaYws6QhyDqt', |
|||
URI: '/artemis/api/common/v1/event/getTopicInfo', |
|||
IP: '10.0.81.28' |
|||
}, |
|||
// 表单校验 |
|||
rules: { |
|||
APPKEY: [ |
|||
{ required: true, message: '请输入用户名称', trigger: 'blur' } |
|||
], |
|||
APPSECRET: [ |
|||
{ required: true, message: '请输入用户密码', trigger: 'blur' } |
|||
], |
|||
URI: [ |
|||
{ required: true, message: '请输入请求路径', trigger: 'blur' } |
|||
], |
|||
IP: [ |
|||
{ required: true, message: '请输入请求端口', trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
// 表单重置 |
|||
reset() { |
|||
this.form = { |
|||
APPKEY: '22825659', |
|||
APPSECRET: '7Qcq3fr1gaYws6QhyDqt', |
|||
URI: '/artemis/api/common/v1/event/getTopicInfo', |
|||
IP: '10.0.81.28' |
|||
// APPKEY:null, |
|||
// APPSECRET:null, |
|||
// URI:null, |
|||
// IP:null |
|||
} |
|||
this.resetForm('form') |
|||
}, |
|||
/** 提交按钮 */ |
|||
submitForm() { |
|||
this.$refs['form'].validate(valid => { |
|||
if (valid) { |
|||
eventSubscription(this.form).then(response => { |
|||
}) |
|||
this.reset() |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,79 @@ |
|||
package com.zc.business.domain; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 一类交流站和毫米波雷达存储数据实体类 |
|||
*/ |
|||
@Data |
|||
public class DcYzsqbdcHmbldData { |
|||
|
|||
private String id; |
|||
// 物联网设备id
|
|||
private String iotDeviceId; |
|||
// 数据源 1一站式情报调查,2毫米波雷达
|
|||
private String sjy; |
|||
// 设备编号(设备身份识别码)
|
|||
private String sbbh; |
|||
// 上报周期(交通数据处理周期)
|
|||
private String sbzq; |
|||
// 时间序号(一站式情报调查)
|
|||
private String sjxh; |
|||
// 上报时间
|
|||
private String sbsj; |
|||
// 平均车速
|
|||
private Integer pjcs; |
|||
// 车道数
|
|||
private Integer lane; |
|||
// 方向
|
|||
private String direction; |
|||
// 总的车流量
|
|||
private Integer zdcll; |
|||
// 跟车百分比
|
|||
private String gcbfb; |
|||
// 平均车头间距
|
|||
private String pjctjj; |
|||
// 时间占有率
|
|||
private String sjzyl; |
|||
// 中小客车交通量
|
|||
private Integer zxkcjtl; |
|||
// 中小客车平均地点车速
|
|||
private Integer zxkcpjcs; |
|||
// 小型货车交通量
|
|||
private Integer xxhcjtl; |
|||
// 小型货车平均地点车速
|
|||
private Integer xxhcpjcs; |
|||
// 大客车交通量
|
|||
private Integer dkcjtl; |
|||
// 大客车平均地点车速
|
|||
private Integer dkcpjcs; |
|||
// 中型货车交通量
|
|||
private Integer zxhcjtl; |
|||
// 中型货车平均地点车速
|
|||
private Integer zxhcpjcs; |
|||
// 大型货车交通量
|
|||
private Integer dxhcjtl; |
|||
// 大型货车平均地点车速
|
|||
private Integer dxhcpjcs; |
|||
// 特大型货车交通量
|
|||
private Integer tdxhcjtl; |
|||
// 特大型货车平均地点车速
|
|||
private Integer tdxhcpjcs; |
|||
// 集装箱车交通量
|
|||
private Integer jzxcjtl; |
|||
// 集装箱车平均地点车速
|
|||
private Integer jzxcpjcs; |
|||
// 拖拉机交通量
|
|||
private Integer tljjtl; |
|||
// 拖拉机平均地点车速
|
|||
private Integer tljpjcs; |
|||
// 摩托车交通量
|
|||
private Integer mtcjtl; |
|||
// 摩托车平均地点车速
|
|||
private Integer mtcpjcs; |
|||
private Date updateTime; |
|||
private Date createTime; |
|||
|
|||
} |
@ -0,0 +1,311 @@ |
|||
package com.zc.business.domain; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.ruoyi.common.annotation.Excel; |
|||
import com.ruoyi.common.utils.StringUtils; |
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 中间库 设备对象 device |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-02-21 |
|||
*/ |
|||
public class MdDevice |
|||
{ |
|||
|
|||
/** 主键 */ |
|||
private Long id; |
|||
|
|||
/** 设备id */ |
|||
@Excel(name = "设备id") |
|||
private String devNo; |
|||
|
|||
/** 设备名称 */ |
|||
@Excel(name = "设备名称") |
|||
private String devName; |
|||
|
|||
/** 所在桩号 */ |
|||
@Excel(name = "所在桩号") |
|||
private String stakeNum; |
|||
|
|||
/** 方向1-上行,2-中,3-下行 */ |
|||
@Excel(name = "方向1-上行,2-中,3-下行") |
|||
private String direction; |
|||
|
|||
/** 设备类型 |
|||
1 摄像机 |
|||
2 可变信息标志 |
|||
3 气象监测器 |
|||
4 出口诱导灯 |
|||
5 路段语音广播 |
|||
6 护栏碰撞 |
|||
7 毫米波雷达 |
|||
8 合流区预警 |
|||
9 智慧锥桶 |
|||
10 激光疲劳唤醒 |
|||
11 一类交通量调查站 |
|||
12 行车诱导 |
|||
13 智能设备箱 |
|||
14 光线在线监测 |
|||
*/ |
|||
@Excel(name = "设备类型") |
|||
private String typeCode; |
|||
|
|||
/** 设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 */ |
|||
@Excel(name = "设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 ") |
|||
private String facilitiesType; |
|||
|
|||
/** 设备状态:0-异常,1-正常 */ |
|||
@Excel(name = "设备状态:0-异常,1-正常") |
|||
private String devStatus; |
|||
|
|||
/** 所属机构id */ |
|||
@Excel(name = "所属机构id") |
|||
private String opmaManagerId; |
|||
|
|||
/** 所属机构名称 */ |
|||
@Excel(name = "所属机构名称") |
|||
private String opmaManagerName; |
|||
|
|||
/** 所属厂商 */ |
|||
@Excel(name = "所属厂商") |
|||
private String supplierName; |
|||
|
|||
/** 所属路段 */ |
|||
@Excel(name = "所属路段") |
|||
private String sectionId; |
|||
|
|||
/** 创建时间 */ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
|||
private Date creationTime; |
|||
|
|||
/** 创建人 */ |
|||
@Excel(name = "创建人") |
|||
private Long creatorUserId; |
|||
|
|||
/** 最后修改时间 */ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@Excel(name = "最后修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
|||
private Date lastModificationTime; |
|||
|
|||
/** 最后修改人 */ |
|||
@Excel(name = "最后修改人") |
|||
private Long lastModifierUserId; |
|||
|
|||
/** 是否删除 */ |
|||
@Excel(name = "是否删除") |
|||
private Integer isDeleted; |
|||
|
|||
/** 删除人 */ |
|||
@Excel(name = "删除人") |
|||
private Long deleterUserId; |
|||
|
|||
/** 删除时间 */ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
|||
private Date deletionTime; |
|||
|
|||
public void setId(Long id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getId() |
|||
{ |
|||
return id; |
|||
} |
|||
|
|||
public String getDevNo() { |
|||
return devNo; |
|||
} |
|||
|
|||
public void setDevNo(String devNo) { |
|||
this.devNo = devNo; |
|||
} |
|||
|
|||
public String getDevName() { |
|||
return devName; |
|||
} |
|||
|
|||
public void setDevName(String devName) { |
|||
this.devName = devName; |
|||
} |
|||
|
|||
public String getStakeNum() { |
|||
return stakeNum; |
|||
} |
|||
|
|||
public void setStakeNum(String stakeNum) { |
|||
this.stakeNum = stakeNum; |
|||
} |
|||
|
|||
public String getDirection() { |
|||
return direction; |
|||
} |
|||
|
|||
public void setDirection(String direction) { |
|||
this.direction = direction; |
|||
} |
|||
|
|||
public String getTypeCode() { |
|||
return typeCode; |
|||
} |
|||
|
|||
public void setTypeCode(String typeCode) { |
|||
this.typeCode = typeCode; |
|||
} |
|||
|
|||
public String getFacilitiesType() { |
|||
return facilitiesType; |
|||
} |
|||
|
|||
public void setFacilitiesType(String facilitiesType) { |
|||
this.facilitiesType = facilitiesType; |
|||
} |
|||
|
|||
public String getDevStatus() { |
|||
return devStatus; |
|||
} |
|||
|
|||
public void setDevStatus(String devStatus) { |
|||
this.devStatus = devStatus; |
|||
} |
|||
|
|||
public String getOpmaManagerId() { |
|||
return opmaManagerId; |
|||
} |
|||
|
|||
public void setOpmaManagerId(String opmaManagerId) { |
|||
this.opmaManagerId = opmaManagerId; |
|||
} |
|||
|
|||
public String getOpmaManagerName() { |
|||
return opmaManagerName; |
|||
} |
|||
|
|||
public void setOpmaManagerName(String opmaManagerName) { |
|||
this.opmaManagerName = opmaManagerName; |
|||
} |
|||
|
|||
public String getSupplierName() { |
|||
return supplierName; |
|||
} |
|||
|
|||
public void setSupplierName(String supplierName) { |
|||
this.supplierName = supplierName; |
|||
} |
|||
|
|||
public String getSectionId() { |
|||
return sectionId; |
|||
} |
|||
|
|||
public void setSectionId(String sectionId) { |
|||
this.sectionId = sectionId; |
|||
} |
|||
|
|||
public Date getCreationTime() { |
|||
return creationTime; |
|||
} |
|||
|
|||
public void setCreationTime(Date creationTime) { |
|||
this.creationTime = creationTime; |
|||
} |
|||
|
|||
public Long getCreatorUserId() { |
|||
return creatorUserId; |
|||
} |
|||
|
|||
public void setCreatorUserId(Long creatorUserId) { |
|||
this.creatorUserId = creatorUserId; |
|||
} |
|||
|
|||
public Date getLastModificationTime() { |
|||
return lastModificationTime; |
|||
} |
|||
|
|||
public void setLastModificationTime(Date lastModificationTime) { |
|||
this.lastModificationTime = lastModificationTime; |
|||
} |
|||
|
|||
public Long getLastModifierUserId() { |
|||
return lastModifierUserId; |
|||
} |
|||
|
|||
public void setLastModifierUserId(Long lastModifierUserId) { |
|||
this.lastModifierUserId = lastModifierUserId; |
|||
} |
|||
|
|||
public Integer getIsDeleted() { |
|||
return isDeleted; |
|||
} |
|||
|
|||
public void setIsDeleted(Integer isDeleted) { |
|||
this.isDeleted = isDeleted; |
|||
} |
|||
|
|||
public Long getDeleterUserId() { |
|||
return deleterUserId; |
|||
} |
|||
|
|||
public void setDeleterUserId(Long deleterUserId) { |
|||
this.deleterUserId = deleterUserId; |
|||
} |
|||
|
|||
public Date getDeletionTime() { |
|||
return deletionTime; |
|||
} |
|||
|
|||
public void setDeletionTime(Date deletionTime) { |
|||
this.deletionTime = deletionTime; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this) |
|||
.append("id", id) |
|||
.append("devNo", devNo) |
|||
.append("devName", devName) |
|||
.append("stakeNum", stakeNum) |
|||
.append("direction", direction) |
|||
.append("typeCode", typeCode) |
|||
.append("facilitiesType", facilitiesType) |
|||
.append("devStatus", devStatus) |
|||
.append("opmaManagerId", opmaManagerId) |
|||
.append("opmaManagerName", opmaManagerName) |
|||
.append("supplierName", supplierName) |
|||
.append("sectionId", sectionId) |
|||
.append("creationTime", creationTime) |
|||
.append("creatorUserId", creatorUserId) |
|||
.append("lastModificationTime", lastModificationTime) |
|||
.append("lastModifierUserId", lastModifierUserId) |
|||
.append("isDeleted", isDeleted) |
|||
.append("deleterUserId", deleterUserId) |
|||
.append("deletionTime", deletionTime) |
|||
.toString(); |
|||
} |
|||
|
|||
public MdDevice(){} |
|||
|
|||
public MdDevice(DcDevice dcDevice){ |
|||
this.id = dcDevice.getId(); |
|||
this.devNo = dcDevice.getIotDeviceId(); |
|||
this.devName = dcDevice.getDeviceName(); |
|||
this.stakeNum = dcDevice.getStakeMark(); |
|||
this.direction = dcDevice.getDirection(); |
|||
this.typeCode = dcDevice.getDeviceType().toString(); |
|||
if (StringUtils.isNotEmpty(dcDevice.getFacilitiesType())){ |
|||
this.facilitiesType = dcDevice.getFacilitiesType(); |
|||
} |
|||
this.devStatus = dcDevice.getDeviceState(); |
|||
if (dcDevice.getGroupId() != null && dcDevice.getGroupId() > 0){ |
|||
this.opmaManagerId = dcDevice.getGroupId().toString(); |
|||
} |
|||
this.supplierName = dcDevice.getManufacturer(); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.zc.business.domain; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@ApiModel(value = "NonAutomaticWarning", description = "非机预警事件订阅实体类") |
|||
public class NonAutomaticWarning { |
|||
|
|||
@ApiModelProperty("用户名称") |
|||
@JsonProperty |
|||
private String APPKEY; |
|||
@ApiModelProperty("用户密码") |
|||
@JsonProperty |
|||
private String APPSECRET; |
|||
@ApiModelProperty("请求路径") |
|||
@JsonProperty |
|||
private String URI; |
|||
@ApiModelProperty("请求IP") |
|||
@JsonProperty |
|||
private String IP; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.zc.business.mapper; |
|||
|
|||
|
|||
import com.zc.business.domain.DcYzsqbdcHmbldData; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 一类调查站Mapper接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-01-12 |
|||
*/ |
|||
public interface DcYzsqbdcHmbldDataMapper |
|||
{ |
|||
|
|||
/** |
|||
* 批量新增一类调查站数据 |
|||
* |
|||
* @param list 一类调查站数据 |
|||
* @return 结果 |
|||
*/ |
|||
int insertDcEvent(List<DcYzsqbdcHmbldData> list); |
|||
|
|||
} |
|||
|
|||
|
@ -0,0 +1,18 @@ |
|||
package com.zc.business.service; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 一类交通调查站Service接口 |
|||
* |
|||
* @author wangjiabao |
|||
* @date 2024-01-03 |
|||
*/ |
|||
public interface IDcYzsqbdcHmbldDataService |
|||
{ |
|||
|
|||
/** |
|||
* 一类交通调查站数据插入 |
|||
*/ |
|||
boolean addDcYzsqbdcHmbldDataList(Map map); |
|||
} |
@ -0,0 +1,206 @@ |
|||
package com.zc.business.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ruoyi.common.utils.DateUtils; |
|||
import com.ruoyi.common.utils.uuid.UUID; |
|||
import com.zc.business.domain.DcYzsqbdcHmbldData; |
|||
import com.zc.business.mapper.DcYzsqbdcHmbldDataMapper; |
|||
import com.zc.business.service.IDcYzsqbdcHmbldDataService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 一类交通调查站Service业务层处理 |
|||
* |
|||
* @author wangjiabao |
|||
*/ |
|||
@Service |
|||
public class DcYzsqbdcHmbldDataServiceImpl implements IDcYzsqbdcHmbldDataService { |
|||
|
|||
@Resource |
|||
private DcYzsqbdcHmbldDataMapper dcYzsqbdcHmbldDataMapper; |
|||
|
|||
/** |
|||
* 添加一类交流站实时数据到数据库中 |
|||
* |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public boolean addDcYzsqbdcHmbldDataList(Map data) { |
|||
List<DcYzsqbdcHmbldData> list = new ArrayList<>(); |
|||
JSONObject properties = JSONObject.parseObject(data.get("properties").toString()); |
|||
if (properties.get("01") == null) { |
|||
return false; |
|||
} |
|||
JSONObject oneStopIntelligenceInvestigation = JSONObject.parseObject(properties.get("01").toString()); |
|||
// 上行
|
|||
DcYzsqbdcHmbldData upstream = new DcYzsqbdcHmbldData(); |
|||
setCommonDcYzsqbdcHmbldData(upstream, "1", oneStopIntelligenceInvestigation); |
|||
upstream.setIotDeviceId(data.get("deviceId").toString()); |
|||
|
|||
// 下行
|
|||
DcYzsqbdcHmbldData down = new DcYzsqbdcHmbldData(); |
|||
setCommonDcYzsqbdcHmbldData(down, "2", oneStopIntelligenceInvestigation); |
|||
down.setIotDeviceId(data.get("deviceId").toString()); |
|||
|
|||
// 平均车道数
|
|||
int averageNumberOfLanes = Integer.parseInt(oneStopIntelligenceInvestigation.get("numberOfLanes").toString()) / 2; |
|||
|
|||
JSONArray array = JSONArray.parseArray(oneStopIntelligenceInvestigation.get("lanes").toString()); |
|||
for (Object object : array) { |
|||
JSONObject lanesData = JSONObject.parseObject(object.toString()); |
|||
|
|||
if (lanesData.get("laneNumber").toString().equals("11") || |
|||
lanesData.get("laneNumber").toString().equals("12") || |
|||
lanesData.get("laneNumber").toString().equals("13") || |
|||
lanesData.get("laneNumber").toString().equals("14") || |
|||
lanesData.get("laneNumber").toString().equals("01") |
|||
) { |
|||
// 上行数据
|
|||
processingVehicleModelData(upstream, lanesData); |
|||
} else { |
|||
// 下行数据
|
|||
processingVehicleModelData(down, lanesData); |
|||
} |
|||
|
|||
} |
|||
|
|||
averageSpeedOfAllLanesBasedOnType(upstream, averageNumberOfLanes); |
|||
averageSpeedOfAllLanesBasedOnType(down, averageNumberOfLanes); |
|||
|
|||
list.add(upstream); |
|||
list.add(down); |
|||
int number = dcYzsqbdcHmbldDataMapper.insertDcEvent(list); |
|||
if (number > 0) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* 初始化上行和下行数据 |
|||
* |
|||
* @param data |
|||
* @param direction |
|||
* @param oneStopIntelligenceInvestigation |
|||
*/ |
|||
public void setCommonDcYzsqbdcHmbldData(DcYzsqbdcHmbldData data, String direction, JSONObject oneStopIntelligenceInvestigation) { |
|||
data.setId(UUID.randomUUID().toString()); |
|||
// 数据源
|
|||
data.setSjy("1"); |
|||
// 方向
|
|||
data.setDirection(direction); |
|||
// 设备编号
|
|||
data.setSbbh(oneStopIntelligenceInvestigation.get("deviceIdentificationCode").toString()); |
|||
// 上报周期
|
|||
data.setSbzq(oneStopIntelligenceInvestigation.get("trafficDataProcessingCycle").toString()); |
|||
// 时间序号
|
|||
data.setSjxh(oneStopIntelligenceInvestigation.get("timeSequenceNumber").toString()); |
|||
// 上报时间 年月日
|
|||
data.setSbsj(oneStopIntelligenceInvestigation.get("time").toString()); |
|||
// 车道数
|
|||
data.setLane(Integer.parseInt(oneStopIntelligenceInvestigation.get("numberOfLanes").toString())); |
|||
// 创建时间
|
|||
data.setCreateTime(DateUtils.getNowDate()); |
|||
data.setZdcll(0); |
|||
data.setZxkcjtl(0); |
|||
data.setMtcpjcs(0); |
|||
data.setXxhcjtl(0); |
|||
data.setXxhcpjcs(0); |
|||
data.setDkcjtl(0); |
|||
data.setDkcpjcs(0); |
|||
data.setZxhcjtl(0); |
|||
data.setZxhcpjcs(0); |
|||
data.setDxhcjtl(0); |
|||
data.setDxhcpjcs(0); |
|||
data.setTdxhcjtl(0); |
|||
data.setTdxhcpjcs(0); |
|||
data.setJzxcjtl(0); |
|||
data.setJzxcpjcs(0); |
|||
data.setTljjtl(0); |
|||
data.setTljpjcs(0); |
|||
data.setMtcjtl(0); |
|||
data.setMtcpjcs(0); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
/** |
|||
* 计算每个车型所有车道车速的平均值 |
|||
* |
|||
* @param data |
|||
* @param averageNumberOfLanes |
|||
*/ |
|||
public static void averageSpeedOfAllLanesBasedOnType(DcYzsqbdcHmbldData data, int averageNumberOfLanes) { |
|||
data.setMtcpjcs(data.getMtcpjcs() / averageNumberOfLanes); |
|||
data.setXxhcpjcs(data.getXxhcpjcs() / averageNumberOfLanes); |
|||
data.setDkcpjcs(data.getDkcpjcs() / averageNumberOfLanes); |
|||
data.setZxhcpjcs(data.getZxhcpjcs() / averageNumberOfLanes); |
|||
data.setDxhcpjcs(data.getDxhcpjcs() / averageNumberOfLanes); |
|||
data.setTdxhcpjcs(data.getTdxhcpjcs() / averageNumberOfLanes); |
|||
data.setJzxcpjcs(data.getJzxcpjcs() / averageNumberOfLanes); |
|||
data.setTljpjcs(data.getTljpjcs() / averageNumberOfLanes); |
|||
data.setMtcpjcs(data.getMtcpjcs() / averageNumberOfLanes); |
|||
|
|||
int pjcs = data.getMtcpjcs() + data.getXxhcpjcs() + data.getDkcpjcs() + |
|||
data.getZxhcpjcs() + data.getDxhcpjcs() + data.getTdxhcpjcs() + |
|||
data.getJzxcpjcs() + data.getTljpjcs() + data.getMtcpjcs(); |
|||
data.setPjcs(pjcs / 9); |
|||
} |
|||
|
|||
/** |
|||
* 处理车辆类型数据 |
|||
* |
|||
* @param data |
|||
* @param lanesData |
|||
*/ |
|||
public static void processingVehicleModelData(DcYzsqbdcHmbldData data, JSONObject lanesData) { |
|||
// 总的车流量
|
|||
data.setZdcll(data.getZdcll() + Integer.parseInt(lanesData.get("totalTrafficFlow").toString())); |
|||
// 中小客车交通量
|
|||
data.setZxkcjtl(data.getZxkcjtl() + Integer.parseInt(lanesData.get("trafficNumberOfInAndSmall").toString())); |
|||
// 中小客车平均地点车速
|
|||
data.setZxkcpjcs(data.getZxkcpjcs() + Integer.parseInt(lanesData.get("inAndSmallAverageVehicleSpeed").toString())); |
|||
// 小型货车交通量
|
|||
data.setXxhcjtl(data.getXxhcjtl() + Integer.parseInt(lanesData.get("trafficVolumeOfSmallTrucks").toString())); |
|||
// 小型货车平均地点车速
|
|||
data.setXxhcpjcs(data.getXxhcpjcs() + Integer.parseInt(lanesData.get("smallTrucksAverageVehicleSpeed").toString())); |
|||
// 大客车交通量
|
|||
data.setDkcjtl(data.getDkcjtl() + Integer.parseInt(lanesData.get("busTrafficVolume").toString())); |
|||
// 大客车平均地点车速
|
|||
data.setDkcpjcs(data.getDkcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfBus").toString())); |
|||
// 中型货车交通量
|
|||
data.setZxhcjtl(data.getZxhcjtl() + Integer.parseInt(lanesData.get("mediumTruckTrafficVolume").toString())); |
|||
// 中型货车平均地点车速
|
|||
data.setZxhcpjcs(data.getZxhcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfMediumSizeTrucks").toString())); |
|||
// 大型货车交通量
|
|||
data.setDxhcjtl(data.getDxhcjtl() + Integer.parseInt(lanesData.get("largeTruckTrafficVolume").toString())); |
|||
// 大型货车平均地点车速
|
|||
data.setDxhcpjcs(data.getDxhcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfLargeTrucks").toString())); |
|||
// 特大型货车交通量
|
|||
data.setTdxhcjtl(data.getTdxhcjtl() + Integer.parseInt(lanesData.get("extraLargeTrucksTrafficVolume").toString())); |
|||
// 特大型货车平均地点车速
|
|||
data.setTdxhcpjcs(data.getTdxhcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfExtraLargeTrucks").toString())); |
|||
// 集装箱车交通量
|
|||
data.setJzxcjtl(data.getJzxcjtl() + Integer.parseInt(lanesData.get("containerTruckTrafficVolume").toString())); |
|||
// 集装箱车平均地点车速
|
|||
data.setJzxcpjcs(data.getJzxcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfContainerTruck").toString())); |
|||
// 拖拉机交通量
|
|||
data.setTljjtl(data.getTljjtl() + Integer.parseInt(lanesData.get("tractorTrafficVolume").toString())); |
|||
// 拖拉机平均地点车速
|
|||
data.setTljpjcs(data.getTljpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfTractor").toString())); |
|||
// 摩托车交通量
|
|||
data.setMtcjtl(data.getMtcjtl() + Integer.parseInt(lanesData.get("motorcycleTrafficVolume").toString())); |
|||
// 摩托车平均地点车速
|
|||
data.setMtcpjcs(data.getMtcpjcs() + Integer.parseInt(lanesData.get("averageSpeedOfMotorcycle").toString())); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.zc.business.task; |
|||
|
|||
import com.ruoyi.common.constant.HttpStatus; |
|||
import com.ruoyi.common.exception.ServiceException; |
|||
import com.ruoyi.common.utils.DateUtils; |
|||
import com.ruoyi.common.utils.spring.SpringUtils; |
|||
import com.zc.business.domain.DcDevice; |
|||
import com.zc.business.domain.DcProduct; |
|||
import com.zc.business.domain.MdDevice; |
|||
import com.zc.business.service.IDcDeviceService; |
|||
import com.zc.business.service.IDcProductService; |
|||
import com.zc.business.service.IMiddleDatabaseService; |
|||
import com.zc.business.service.impl.StatusService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* 定时任务 |
|||
* |
|||
*/ |
|||
@Component |
|||
public class MiddleDatabaseTask |
|||
{ |
|||
private IDcDeviceService dcDeviceService= SpringUtils.getBean(IDcDeviceService.class); |
|||
|
|||
private IMiddleDatabaseService middleDatabaseService= SpringUtils.getBean(IMiddleDatabaseService.class); |
|||
|
|||
private IDcProductService productService= SpringUtils.getBean(IDcProductService.class); |
|||
|
|||
|
|||
/** |
|||
* @Description 定时同步设备信息到中间库 |
|||
* |
|||
* @author liuwenge |
|||
* @date 2024/2/23 11:57 |
|||
* @param |
|||
* @return void |
|||
*/ |
|||
public void synchronizeMdDevice(){ |
|||
Date startTime = new Date(); |
|||
|
|||
System.out.println("定时同步设备信息到中间库 开始-----------------------------"); |
|||
|
|||
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(null); |
|||
if (dcDeviceList != null){ |
|||
|
|||
List<MdDevice> mdDeviceList = new ArrayList<>(); |
|||
|
|||
dcDeviceList.forEach(item -> { |
|||
|
|||
Long productId = item.getProductId(); |
|||
if (Objects.nonNull(productId)) { |
|||
//设备厂商
|
|||
DcProduct dcProduct = productService.getById(productId); |
|||
if (dcProduct != null) { |
|||
item.setManufacturer(dcProduct.getManufacturer()); |
|||
} |
|||
} |
|||
|
|||
MdDevice mdDevice = new MdDevice(item); |
|||
|
|||
mdDeviceList.add(mdDevice); |
|||
}); |
|||
|
|||
middleDatabaseService.synchronizeMdDevice(mdDeviceList); |
|||
} |
|||
Date endTime = new Date(); |
|||
|
|||
Long diff = (endTime.getTime() - startTime.getTime()) / 1000; |
|||
System.out.println("定时同步设备信息到中间库 结束-----------------------------用时" + diff + "秒"); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.zc.business.mapper.DcYzsqbdcHmbldDataMapper"> |
|||
|
|||
|
|||
|
|||
<insert id="insertDcEvent" parameterType="java.util.List"> |
|||
insert into dc_yzsqbdc_hmbld_data |
|||
|
|||
(id,iot_device_id,sjy, sbbh, sbzq, sjxh, sbsj, lane, direction, zdcll, pjcs, zxkcjtl, zxkcpjcs, |
|||
xxhcjtl, xxhcpjcs, |
|||
dkcjtl, dkcpjcs, zxhcjtl, zxhcpjcs, dxhcjtl, dxhcpjcs, tdxhcjtl, tdxhcpjcs, jzxcjtl, jzxcpjcs, tljjtl, |
|||
tljpjcs, mtcjtl, mtcpjcs,create_time) values |
|||
|
|||
<foreach collection="list" separator="," item="item"> |
|||
( |
|||
#{item.id}, |
|||
#{item.iotDeviceId}, |
|||
#{item.sjy},#{item.sbbh},#{item.sbzq},#{item.sjxh},#{item.sbsj},#{item.lane},#{item.direction},#{item.zdcll}, |
|||
#{item.pjcs},#{item.zxkcjtl},#{item.zxkcpjcs},#{item.xxhcjtl},#{item.xxhcpjcs}, |
|||
#{item.dkcjtl},#{item.dkcpjcs},#{item.zxhcjtl},#{item.zxhcpjcs},#{item.dxhcjtl},#{item.dxhcpjcs},#{item.tdxhcjtl}, |
|||
#{item.tdxhcpjcs},#{item.jzxcjtl},#{item.jzxcpjcs},#{item.tljjtl},#{item.tljpjcs},#{item.mtcjtl},#{item.mtcpjcs}, |
|||
#{item.createTime} |
|||
) |
|||
</foreach> |
|||
|
|||
</insert> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue