Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
wangsixiang 1 year ago
parent
commit
a945f68c44
  1. 10
      ruoyi-ui/src/api/system/NonAutomaticWarning.js
  2. 16
      ruoyi-ui/src/views/system/device/index.vue
  3. 82
      ruoyi-ui/src/views/system/non-automatic-warning/index.vue
  4. 37
      zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java
  5. 5
      zc-business/src/main/java/com/zc/business/domain/DcDevice.java
  6. 5
      zc-business/src/main/java/com/zc/business/domain/DcEvent.java
  7. 79
      zc-business/src/main/java/com/zc/business/domain/DcYzsqbdcHmbldData.java
  8. 311
      zc-business/src/main/java/com/zc/business/domain/MdDevice.java
  9. 24
      zc-business/src/main/java/com/zc/business/domain/NonAutomaticWarning.java
  10. 28
      zc-business/src/main/java/com/zc/business/mapper/DcYzsqbdcHmbldDataMapper.java
  11. 39
      zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java
  12. 6
      zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java
  13. 18
      zc-business/src/main/java/com/zc/business/service/IDcYzsqbdcHmbldDataService.java
  14. 41
      zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java
  15. 30
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  16. 102
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  17. 206
      zc-business/src/main/java/com/zc/business/service/impl/DcYzsqbdcHmbldDataServiceImpl.java
  18. 58
      zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java
  19. 78
      zc-business/src/main/java/com/zc/business/task/MiddleDatabaseTask.java
  20. 2
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml
  21. 10
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml
  22. 31
      zc-business/src/main/resources/mapper/business/DcYzsqbdcHmbldDataMapper.xml
  23. 149
      zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

10
ruoyi-ui/src/api/system/NonAutomaticWarning.js

@ -0,0 +1,10 @@
import request from '@/utils/request'
// 调用非机预警设备订阅事件
export function eventSubscription(data) {
return request({
url: '/nonAutomaticWarning/eventSubscription',
method: 'post',
data: data
})
}

16
ruoyi-ui/src/views/system/device/index.vue

@ -174,7 +174,12 @@
<el-input v-model="form.network" placeholder="请输入网段" />
</el-form-item>
<el-form-item label="备注">
<editor v-model="form.content" :min-height="192"/>
<!-- 脚本 -->
<json-editor
v-model="form.content"
:mode="editorOptions.mode"
:lang="editorOptions.lang"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -187,11 +192,20 @@
<script>
import { listDevice, getDevice, delDevice, addDevice, updateDevice } from "@/api/system/device";
import JsonEditor from '@/components/JsonEditor'
export default {
name: "Device",
components: {
JsonEditor
},
data() {
return {
//
editorOptions: {
mode: 'text', // tree,code,form,text,view
lang: 'zh' // zh(),en()
},
//
loading: true,
//

82
ruoyi-ui/src/views/system/non-automatic-warning/index.vue

@ -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>

37
zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java

@ -8,15 +8,15 @@ import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.NonAutomaticWarning;
import com.zc.business.service.IDcWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
@ -51,13 +51,24 @@ public class NonAutomaticWarningController extends BaseController {
* */
@ApiOperation("事件订阅")
@PostMapping(value = "/eventSubscription")
public AjaxResult eventSubscription() throws Exception {
public AjaxResult eventSubscription(@RequestBody NonAutomaticWarning parameter) throws Exception {
if (parameter.getAPPKEY() == null || parameter.getAPPSECRET() == null || parameter.getURI() == null || parameter.getIP() == null) {
return AjaxResult.error();
}
return getAjaxResult(parameter);
}
private AjaxResult getAjaxResult(NonAutomaticWarning parameter) throws Exception {
String appKey = parameter.getAPPKEY();
String appSecret = parameter.getAPPSECRET();
String uri = parameter.getURI();
String ip = parameter.getIP();
ArtemisConfig config = new ArtemisConfig();
config.setHost(IP); // 代理API网关nginx服务器ip端口
config.setAppKey(APPKEY); // 秘钥appkey
config.setAppSecret(APPSECRET);// 秘钥appSecret
final String getCamsApi = URI;
config.setHost(ip); // 代理API网关nginx服务器ip端口
config.setAppKey(appKey); // 秘钥appkey
config.setAppSecret(appSecret);// 秘钥appSecret
final String getCamsApi = uri;
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
ArrayList<Long> longs = new ArrayList<>();
longs.add(6274879489L);
@ -244,4 +255,14 @@ public class NonAutomaticWarningController extends BaseController {
}
return AjaxResult.error();
}
@PostConstruct
public AjaxResult eventSubscriptionPostConstruct() throws Exception {
NonAutomaticWarning stringStringHashMap = new NonAutomaticWarning();
stringStringHashMap.setAPPKEY(APPKEY);
stringStringHashMap.setAPPSECRET(APPSECRET);
stringStringHashMap.setURI(URI);
stringStringHashMap.setIP(IP);
return getAjaxResult(stringStringHashMap);
}
}

5
zc-business/src/main/java/com/zc/business/domain/DcDevice.java

@ -53,6 +53,8 @@ public class DcDevice {
private String otherConfig;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等")
private String facilitiesType;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
@ -61,4 +63,7 @@ public class DcDevice {
private String longitude;
@TableField(exist = false)
private String latitude;
//设备厂商
@TableField(exist = false)
private String manufacturer;
}

5
zc-business/src/main/java/com/zc/business/domain/DcEvent.java

@ -61,10 +61,11 @@ public class DcEvent extends BaseEntity {
* 2-
* 3-
*/
@Excel(name = "方向", readConverterExp = "1=上行,3=下行")
@Excel(name = "方向", readConverterExp = "1=菏泽方向,3=济南方向")
//@Excel(name = "方向")
@ApiModelProperty("方向")
private String direction;
/**
* 处理人员
*/
@ -135,7 +136,7 @@ public class DcEvent extends BaseEntity {
* 3-3 立交封闭和限行
* 3-4 服务区封闭和限行
*/
@Excel(name = "设备编号")
@Excel(name = "事件类型")
@ApiModelProperty("事件子类 例:事件子类:* 1-1 追尾* 1-2 侧翻* 1-3 撞护栏* 1-4 自然* 1-5 其他事故* 2-1 车辆故障")
private String eventSubclass;

79
zc-business/src/main/java/com/zc/business/domain/DcYzsqbdcHmbldData.java

@ -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;
}

311
zc-business/src/main/java/com/zc/business/domain/MdDevice.java

@ -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();
}
}

24
zc-business/src/main/java/com/zc/business/domain/NonAutomaticWarning.java

@ -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;
}

28
zc-business/src/main/java/com/zc/business/mapper/DcYzsqbdcHmbldDataMapper.java

@ -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);
}

39
zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java

@ -3,10 +3,7 @@ package com.zc.business.mapper;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.zc.business.domain.DcBoardReleaseLog;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import com.zc.business.domain.*;
import java.util.List;
@ -27,6 +24,40 @@ public interface MiddleDatabaseMapper
*/
Boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData);
/**
* 新增中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice);
/**
* 修改中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice);
/**
* 删除中间库设备
* 假删
*
* @param ids 设备ids
* @return 结果
*/
boolean deleteMiddleDatabaseDeviceInfoByIds(List<String> ids);
/**
* 批量更新中间库设备
* 有则修改,无则新增
*
* @param mdDeviceList 设备列表
* @return 结果
*/
boolean synchronizeMdDevice(List<MdDevice> mdDeviceList);
/**
* 更新中间库设备
*

6
zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java

@ -9,6 +9,7 @@ import com.zc.business.domain.MdDeviceData;
import com.zc.business.enums.IotProductEnum;
import com.zc.business.service.IDcMeteorologicalDetectorDataService;
import com.zc.business.service.IMiddleDatabaseService;
import com.zc.business.service.IDcYzsqbdcHmbldDataService;
import com.zc.common.core.redis.stream.RedisStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,7 +23,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -43,6 +43,9 @@ public class DevicePropertyReportListener implements StreamListener<String, Obje
@Autowired
private IMiddleDatabaseService middleDatabaseService;
@Autowired
private IDcYzsqbdcHmbldDataService dcYzsqbdcHmbldDataService;
@Override
public void onMessage(ObjectRecord<String, String> message) {
String streamKay = message.getStream();
@ -86,6 +89,7 @@ public class DevicePropertyReportListener implements StreamListener<String, Obje
middleDatabaseService.insertMiddleDatabaseDeviceData(mdDeviceData);
} else if (IotProductEnum.ONE_STOP_PRODUCT.value().equals(productId)){
//交调
dcYzsqbdcHmbldDataService.addDcYzsqbdcHmbldDataList(data);
}
}

18
zc-business/src/main/java/com/zc/business/service/IDcYzsqbdcHmbldDataService.java

@ -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);
}

41
zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java

@ -2,10 +2,7 @@ package com.zc.business.service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcBoardPublish;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import com.zc.business.domain.*;
import java.util.List;
@ -35,7 +32,41 @@ public interface IMiddleDatabaseService
boolean updateMiddleDatabaseDeviceByList(List<DcDevice> listDevice);
/**
* 更新中间库设备
* 添加中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice);
/**
* 修改中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice);
/**
* 批量删除中间库设备
* 假删
*
* @param ids ids
* @return 结果
*/
boolean deleteMiddleDatabaseDeviceInfoByIds(List<String> ids);
/**
* 批量更新中间库设备
* 有则修改,无则新增
*
* @param mdDeviceList 设备列表
* @return 结果
*/
boolean synchronizeMdDevice(List<MdDevice> mdDeviceList);
/**
* 更新中间库设备状态
*
* @param device 设备
* @return 结果

30
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -10,10 +10,12 @@ import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcProduct;
import com.zc.business.domain.DcStakeMark;
import com.zc.business.domain.MdDevice;
import com.zc.business.mapper.DcDeviceMapper;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcProductService;
import com.zc.business.service.IDcStakeMarkService;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -37,6 +39,8 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
private IDcStakeMarkService dcStakeMarkService;
@Resource
private DcDeviceMapper dcDeviceMapper;
@Resource
private IMiddleDatabaseService middleDataBaseService;
@Resource
private RedisCache redisCache;
@ -211,6 +215,8 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
if (Objects.isNull(dcProduct)) {
throw new ServiceException("所属产品[" + productId + "]不存在", HttpStatus.BAD_REQUEST);
}
//设备厂商
dcDevice.setManufacturer(dcProduct.getManufacturer());
}
dcDevice.setCreateTime(new Date());
@ -219,6 +225,11 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
if (save(dcDevice)) {
// 更新缓存
updateRedisCache();
//中间库添加设备
MdDevice mdDevice = new MdDevice(dcDevice);
middleDataBaseService.insertMiddleDatabaseDeviceInfo(mdDevice);
return true;
}
@ -243,11 +254,27 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
throw new ServiceException("设备ID[" + id + "]不存在", HttpStatus.BAD_REQUEST);
}
Long productId = dcDevice.getProductId();
if (Objects.nonNull(productId)) {
DcProduct dcProduct = dcProdurtService.getById(productId);
// 产品不存在
if (Objects.isNull(dcProduct)) {
throw new ServiceException("所属产品[" + productId + "]不存在", HttpStatus.BAD_REQUEST);
}
//设备厂商
dcDevice.setManufacturer(dcProduct.getManufacturer());
}
dcDevice.setUpdateTime(new Date());
if (updateById(dcDevice)) {
// 更新缓存
updateRedisCache();
//中间库修改设备
MdDevice mdDevice = new MdDevice(dcDevice);
middleDataBaseService.updateMiddleDatabaseDeviceInfo(mdDevice);
return true;
}
@ -275,6 +302,9 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
if (removeByIds(ids)) {
// 更新缓存
updateRedisCache();
//中间库 假删设备
middleDataBaseService.deleteMiddleDatabaseDeviceInfoByIds(ids);
return true;
}

102
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -1,10 +1,5 @@
package com.zc.business.service.impl;
import java.awt.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
@ -17,6 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 事件信息Service业务层处理
@ -26,14 +25,13 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
public class DcEventServiceImpl implements IDcEventService
{
public class DcEventServiceImpl implements IDcEventService {
@Autowired
private DcEventMapper dcEventMapper;
//异常天气
@Autowired
private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
//交通事故事件
@Autowired
private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
//交通事故事件
@Autowired
private DcEventAccidentMapper dcEventAccidentMapper;
//施工建设
@ -48,7 +46,7 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
//车辆事故事件
@Autowired
private DcEventVehicleAccidentMapper dcEventVehicleAccidentMapper;
//交通管制事件
//交通管制事件
@Autowired
private DcEventTrafficControlMapper dcEventTrafficControlMapper;
@ -63,7 +61,6 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
private IMiddleDatabaseService middleDatabaseService;
/**
* 查询事件信息
*
@ -71,8 +68,7 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
* @return 事件信息
*/
@Override
public DcEvent selectDcEventById( String id)
{
public DcEvent selectDcEventById(String id) {
DcEvent dcEvent = dcEventMapper.selectDcEventById(id);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(Math.toIntExact(dcEvent.getEventType()));
@ -87,17 +83,16 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
* @return 事件信息
*/
@Override
public List<DcEvent> selectDcEventList(DcEvent dcEvent)
{
if (dcEvent.getStakeMark()!=null){
public List<DcEvent> selectDcEventList(DcEvent dcEvent) {
if (dcEvent.getStakeMark() != null) {
//处理URl地址栏获取参数+号消失
String replace = dcEvent.getStakeMark().replace(" ", "+");
dcEvent.setStakeMark(replace);
String replace1 = dcEvent.getEndStakeMark().replace(" ", "+");
dcEvent.setEndStakeMark(replace1);
}
List<DcEvent> dcEventList = dcEventMapper.selectDcEventList(dcEvent);
List<DcEvent> dcEventList = dcEventMapper.selectDcEventList(dcEvent);
for (DcEvent dcEvents : dcEventList) {
// 根据 deptId 获取部门名称
Long deptId = dcEvents.getDeptId();
@ -107,7 +102,7 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
dcEvents.setDeptName(deptName);
}
return dcEventMapper.selectDcEventList(dcEvent);
return dcEventList;
}
/**
@ -117,23 +112,21 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
* @return 结果
*/
@Override
public int insertDcEvent(DcEvent dcEvent)
{
public int insertDcEvent(DcEvent dcEvent) {
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcEvent.setId(uuid);
dcEvent.setEventState(0L);
//获取部门信息
dcEvent.setDeptId(SecurityUtils.getDeptId());
dcEvent.setDeptId(SecurityUtils.getDeptId());
//用户
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setCreateTime(DateUtils.getNowDate());
int i7 = dcEventMapper.insertDcEvent(dcEvent);
if (i7>0){
if (i7 > 0) {
//中间库
// MdEvent mdEvent = new MdEvent(dcEvent);
@ -141,26 +134,36 @@ dcEvent.setUserId(SecurityUtils.getUserId());
//获取事件类型
int eventType = Math.toIntExact(dcEvent.getEventType());
switch (eventType){
switch (eventType) {
//交通事故
case 1:
if (dcEvent.getDcEventAccident() != null) {
dcEvent.getDcEventAccident().setId(uuid);
int i1 = dcEventAccidentMapper.insertDcEventAccident(dcEvent.getDcEventAccident());
}
break;
//车辆事故
case 2:
if (dcEvent.getDcEventVehicleAccident()!=null){
dcEvent.getDcEventVehicleAccident().setId(uuid);
int i5 = dcEventVehicleAccidentMapper.insertDcEventVehicleAccident(dcEvent.getDcEventVehicleAccident());
}
break;
//交通管制
case 3:
if (dcEvent.getDcEventTrafficControl()!=null){
dcEvent.getDcEventTrafficControl().setId(uuid);
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}
break;
//交通拥堵
case 4:
if (dcEvent.getDcEventTrafficCongestion()!=null){
dcEvent.getDcEventTrafficCongestion().setId(uuid);
int i4 = dcEventTrafficCongestionMapper.insertDcEventTrafficCongestion(dcEvent.getDcEventTrafficCongestion());
}
break;
//非法上路
@ -171,21 +174,28 @@ dcEvent.setUserId(SecurityUtils.getUserId());
break;
//施工建设
case 7:
if (dcEvent.getDcEventConstruction()!=null){
dcEvent.getDcEventConstruction().setId(uuid);
int i2 = dcEventConstructionMapper.insertDcEventConstruction(dcEvent.getDcEventConstruction());
}
break;
//服务区异常
case 8:
if (dcEvent.getDcEventServiceArea()!=null){
dcEvent.getDcEventServiceArea().setId(uuid);
int i3 = dcEventServiceAreaMapper.insertDcEventServiceArea(dcEvent.getDcEventServiceArea());
}
break;
//设施设备隐患
case 9:
break;
//异常天气
case 10:
if (dcEvent.getDcEventAbnormalWeather()!=null){
dcEvent.getDcEventAbnormalWeather().setId(uuid);
int i = dcEventAbnormalWeatherMapper.insertDcEventAbnormalWeather(dcEvent.getDcEventAbnormalWeather());
}
break;
//其他事件
case 11:
@ -196,7 +206,7 @@ dcEvent.setUserId(SecurityUtils.getUserId());
}
return i7;
}else {
} else {
return -1;
}
}
@ -208,18 +218,17 @@ dcEvent.setUserId(SecurityUtils.getUserId());
* @return 结果
*/
@Override
public int updateDcEvent(DcEvent dcEvent)
{
public int updateDcEvent(DcEvent dcEvent) {
dcEvent.setUpdateTime(DateUtils.getNowDate());
int i7 = dcEventMapper.updateDcEvent(dcEvent);
if (i7>0) {
if (i7 > 0) {
//中间库
// MdEvent mdEvent = new MdEvent(dcEvent);
// middleDatabaseService.updateMiddleDatabaseEvent(mdEvent);
int eventType = Math.toIntExact(dcEvent.getEventType());
switch (eventType){
switch (eventType) {
//交通事故
case 1:
int i1 = dcEventAccidentMapper.updateDcEventAccident(dcEvent.getDcEventAccident());
@ -267,7 +276,7 @@ dcEvent.setUserId(SecurityUtils.getUserId());
}
return i7;
}else {
} else {
return -1;
}
@ -280,10 +289,9 @@ dcEvent.setUserId(SecurityUtils.getUserId());
* @return 结果
*/
@Override
public int deleteDcEventByIds( int eventType,String[] ids)
{
public int deleteDcEventByIds(int eventType, String[] ids) {
int i7 = dcEventMapper.deleteDcEventByIds(ids);
if (i7>0){
if (i7 > 0) {
switch (eventType) {
//交通事故
case 1:
@ -331,10 +339,11 @@ dcEvent.setUserId(SecurityUtils.getUserId());
break;
}
return i7;
}else {
} else {
return -1;
}
}
/**
* 删除事件信息信息
*
@ -342,12 +351,12 @@ dcEvent.setUserId(SecurityUtils.getUserId());
* @return 结果
*/
@Override
public int deleteDcEventById(String id)
{
public int deleteDcEventById(String id) {
return dcEventMapper.deleteDcEventById(id);
}
/**调度记录-事件列表 按时间展示交通事件默认当天时间 可查询条件 交通事件状态 时间范围
*
/**
* 调度记录-事件列表 按时间展示交通事件默认当天时间 可查询条件 交通事件状态 时间范围
*/
@Override
public List<DcEvent> selectDispatchEventList(DcEvent dcEvent) {
@ -356,6 +365,7 @@ dcEvent.setUserId(SecurityUtils.getUserId());
/**
* 获取事件以及子类详细信息
*
* @param eventType
* @param id
* @return
@ -421,17 +431,17 @@ dcEvent.setUserId(SecurityUtils.getUserId());
}
@Override
public Map<String,Object> selectCount() {
Map<String,Object> map = new HashMap<>();
public Map<String, Object> selectCount() {
Map<String, Object> map = new HashMap<>();
int i = dcWarningMapper.selectCount();
System.out.println("***********************************"+i);
List<Map<String,String>> strings = dcEventMapper.selectCount();
System.out.println("***********************************" + i);
List<Map<String, String>> strings = dcEventMapper.selectCount();
for (int i1 = 0; i1 < strings.size(); i1++) {
strings.get(i1).get("status");
strings.get(i1).get("count");
map.put(strings.get(i1).get("status"),strings.get(i1).get("count"));
map.put(strings.get(i1).get("status"), strings.get(i1).get("count"));
}
map.put("warningCount",i);
map.put("warningCount", i);
return map;
}
}

206
zc-business/src/main/java/com/zc/business/service/impl/DcYzsqbdcHmbldDataServiceImpl.java

@ -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()));
}
}

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

@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.SecurityUtils;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDevice;
import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import com.zc.business.mapper.MiddleDatabaseMapper;
@ -39,7 +40,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData)
{
@ -53,7 +53,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param listDevice 设备列表
* @return 结果
*/
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseDeviceByList(List<DcDevice> listDevice)
{
@ -63,6 +62,55 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
return true;
}
/**
* 新增中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
@Override
public boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice)
{
return middleDatabaseMapper.insertMiddleDatabaseDeviceInfo(mdDevice);
}
/**
* 修改中间库设备
*
* @param mdDevice 设备
* @return 结果
*/
@Override
public boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice)
{
return middleDatabaseMapper.updateMiddleDatabaseDeviceInfo(mdDevice);
}
/**
* 批量删除中间库设备
* 假删
*
* @param ids 设备ids
* @return 结果
*/
@Override
public boolean deleteMiddleDatabaseDeviceInfoByIds(List<String> ids)
{
return middleDatabaseMapper.deleteMiddleDatabaseDeviceInfoByIds(ids);
}
/**
* 批量更新中间库设备
* 有则修改,无则新增
*
* @param mdDeviceList 设备列表
* @return 结果
*/
@Override
public boolean synchronizeMdDevice(List<MdDevice> mdDeviceList){
return middleDatabaseMapper.synchronizeMdDevice(mdDeviceList);
}
/**
* 更新中间库设备
@ -70,7 +118,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param device 设备
* @return 结果
*/
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseDevice(DcDevice device)
{
@ -85,10 +132,10 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
*/
@Override
public boolean insertMiddleDatabaseEvent(MdEvent mdEvent){
/* LoginUser loginUser = SecurityUtils.getLoginUser();
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
mdEvent.setCreatorUserId(loginUser.getUserId());
}*/
}
return middleDatabaseMapper.insertMiddleDatabaseEvent(mdEvent);
}
@ -98,7 +145,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param mdEvent 事件
* @return 结果
*/
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseEvent(MdEvent mdEvent){
LoginUser loginUser = SecurityUtils.getLoginUser();

78
zc-business/src/main/java/com/zc/business/task/MiddleDatabaseTask.java

@ -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 + "秒");
}
}

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

@ -62,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name, t1.device_code, t1.device_type,
t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,
t2.longitude,t2.latitude
t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction
<where>

10
zc-business/src/main/resources/mapper/business/DcEventMapper.xml

@ -143,7 +143,10 @@
id,
dc_event.dept_id as dept_id,
stake_mark,
direction,
CASE direction
WHEN '1' THEN '菏泽方向'
WHEN '3' THEN '济南方向'
END AS direction,
dc_event.user_id as user_id,
sys_user.nick_name as nickName,
start_time,
@ -353,7 +356,10 @@
/*详情可以调用事件处理流程*/
SELECT dc_event.id AS id,
dc_event.stake_mark,
dc_event.direction,
CASE dc_event.direction
WHEN '1' THEN '菏泽方向'
WHEN '3' THEN '济南方向'
END AS direction,
dc_event.user_id,
dc_event.user_id as user_id,
sys_user.nick_name as nickName,

31
zc-business/src/main/resources/mapper/business/DcYzsqbdcHmbldDataMapper.xml

@ -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>

149
zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

@ -117,7 +117,152 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="updateMiddleDatabaseDevice" parameterType="MdEvent">
<insert id="insertMiddleDatabaseDeviceInfo" parameterType="MdDevice">
insert into device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="devNo != null">dev_no,</if>
<if test="devName != null">dev_name,</if>
<if test="stakeNum != null">stake_num,</if>
<if test="direction != null">direction,</if>
<if test="typeCode != null">type_code,</if>
<if test="facilitiesType != null">facilities_type,</if>
<if test="devStatus != null">dev_status,</if>
<if test="opmaManagerId != null">opma_manager_id,</if>
<if test="opmaManagerName != null">opma_manager_name,</if>
<if test="supplierName != null">supplier_name,</if>
<if test="sectionId != null">section_id,</if>
CreationTime,
<if test="creatorUserId != null">CreatorUserId,</if>
<if test="lastModificationTime != null">LastModificationTime,</if>
<if test="lastModifierUserId != null">LastModifierUserId,</if>
<if test="isDeleted != null">IsDeleted,</if>
<if test="deleterUserId != null">DeleterUserId,</if>
<if test="deletionTime != null">DeletionTime,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="devNo != null">#{devNo},</if>
<if test="devName != null">#{devName},</if>
<if test="stakeNum != null">#{stakeNum},</if>
<if test="direction != null">#{direction},</if>
<if test="typeCode != null">#{typeCode},</if>
<if test="facilitiesType != null">#{facilitiesType},</if>
<if test="devStatus != null">#{devStatus},</if>
<if test="opmaManagerId != null">#{opmaManagerId},</if>
<if test="opmaManagerName != null">#{opmaManagerName},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="sectionId != null">#{sectionId},</if>
now(),
<if test="creatorUserId != null">#{creatorUserId},</if>
<if test="lastModificationTime != null">#{lastModificationTime},</if>
<if test="lastModifierUserId != null">#{lastModifierUserId},</if>
<if test="isDeleted != null">#{isDeleted},</if>
<if test="deleterUserId != null">#{deleterUserId},</if>
<if test="deletionTime != null">#{deletionTime},</if>
</trim>
</insert>
<insert id="synchronizeMdDevice" parameterType="java.util.List">
<foreach collection ="list" item="mdDevice" index= "index" separator =";">
insert into device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mdDevice.id != null">id,</if>
<if test="mdDevice.devNo != null">dev_no,</if>
<if test="mdDevice.devName != null">dev_name,</if>
<if test="mdDevice.stakeNum != null">stake_num,</if>
<if test="mdDevice.direction != null">direction,</if>
<if test="mdDevice.typeCode != null">type_code,</if>
<if test="mdDevice.facilitiesType != null">facilities_type,</if>
<if test="mdDevice.devStatus != null">dev_status,</if>
<if test="mdDevice.opmaManagerId != null">opma_manager_id,</if>
<if test="mdDevice.opmaManagerName != null">opma_manager_name,</if>
<if test="mdDevice.supplierName != null">supplier_name,</if>
<if test="mdDevice.sectionId != null">section_id,</if>
CreationTime,
<if test="mdDevice.creatorUserId != null">CreatorUserId,</if>
<if test="mdDevice.lastModificationTime != null">LastModificationTime,</if>
<if test="mdDevice.lastModifierUserId != null">LastModifierUserId,</if>
<if test="mdDevice.isDeleted != null">IsDeleted,</if>
<if test="mdDevice.deleterUserId != null">DeleterUserId,</if>
<if test="mdDevice.deletionTime != null">DeletionTime,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mdDevice.id != null">#{mdDevice.id},</if>
<if test="mdDevice.devNo != null">#{mdDevice.devNo},</if>
<if test="mdDevice.devName != null">#{mdDevice.devName},</if>
<if test="mdDevice.stakeNum != null">#{mdDevice.stakeNum},</if>
<if test="mdDevice.direction != null">#{mdDevice.direction},</if>
<if test="mdDevice.typeCode != null">#{mdDevice.typeCode},</if>
<if test="mdDevice.facilitiesType != null">#{mdDevice.facilitiesType},</if>
<if test="mdDevice.devStatus != null">#{mdDevice.devStatus},</if>
<if test="mdDevice.opmaManagerId != null">#{mdDevice.opmaManagerId},</if>
<if test="mdDevice.opmaManagerName != null">#{mdDevice.opmaManagerName},</if>
<if test="mdDevice.supplierName != null">#{mdDevice.supplierName},</if>
<if test="mdDevice.sectionId != null">#{mdDevice.sectionId},</if>
now(),
<if test="mdDevice.creatorUserId != null">#{mdDevice.creatorUserId},</if>
<if test="mdDevice.lastModificationTime != null">#{mdDevice.lastModificationTime},</if>
<if test="mdDevice.lastModifierUserId != null">#{mdDevice.lastModifierUserId},</if>
<if test="mdDevice.isDeleted != null">#{mdDevice.isDeleted},</if>
<if test="mdDevice.deleterUserId != null">#{mdDevice.deleterUserId},</if>
<if test="mdDevice.deletionTime != null">#{mdDevice.deletionTime},</if>
</trim>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
<if test="mdDevice.devNo != null">dev_no = #{mdDevice.devNo},</if>
<if test="mdDevice.devName != null">dev_name = #{mdDevice.devName},</if>
<if test="mdDevice.stakeNum != null">stake_num = #{mdDevice.stakeNum},</if>
<if test="mdDevice.direction != null">direction = #{mdDevice.direction},</if>
<if test="mdDevice.typeCode != null">type_code = #{mdDevice.typeCode},</if>
<if test="mdDevice.facilitiesType != null">facilities_type = #{mdDevice.facilitiesType},</if>
<if test="mdDevice.devStatus != null">dev_status = #{mdDevice.devStatus},</if>
<if test="mdDevice.opmaManagerId != null">opma_manager_id = #{mdDevice.opmaManagerId},</if>
<if test="mdDevice.opmaManagerName != null">opma_manager_name = #{mdDevice.opmaManagerName},</if>
<if test="mdDevice.supplierName != null">supplier_name = #{mdDevice.supplierName},</if>
<if test="mdDevice.sectionId != null">section_id = #{mdDevice.sectionId},</if>
LastModificationTime = now(),
<if test="mdDevice.lastModifierUserId != null">LastModifierUserId = #{mdDevice.lastModifierUserId},</if>
<if test="mdDevice.isDeleted != null">IsDeleted = #{mdDevice.isDeleted},</if>
<if test="mdDevice.deleterUserId != null">DeleterUserId = #{mdDevice.deleterUserId},</if>
<if test="mdDevice.deletionTime != null">DeletionTime = #{mdDevice.deletionTime},</if>
</trim>
</foreach>
</insert>
<update id="updateMiddleDatabaseDeviceInfo" parameterType="MdDevice">
update device
<set>
<if test="devNo != null">dev_no = #{devNo},</if>
<if test="devName != null">dev_name = #{devName},</if>
<if test="stakeNum != null">stake_num = #{stakeNum},</if>
<if test="direction != null">direction = #{direction},</if>
<if test="typeCode != null">type_code = #{typeCode},</if>
<if test="facilitiesType != null">facilities_type = #{facilitiesType},</if>
<if test="devStatus != null">dev_status = #{devStatus},</if>
<if test="opmaManagerId != null">opma_manager_id = #{opmaManagerId},</if>
<if test="opmaManagerName != null">opma_manager_name = #{opmaManagerName},</if>
<if test="supplierName != null">supplier_name = #{supplierName},</if>
<if test="sectionId != null">section_id = #{sectionId},</if>
LastModificationTime = now(),
<if test="lastModifierUserId != null">LastModifierUserId = #{lastModifierUserId},</if>
<if test="isDeleted != null">IsDeleted = #{isDeleted},</if>
<if test="deleterUserId != null">DeleterUserId = #{deleterUserId},</if>
<if test="deletionTime != null">DeletionTime = #{deletionTime},</if>
</set>
where id = #{id}
</update>
<delete id="deleteMiddleDatabaseDeviceInfoByIds">
update device set IsDeleted = '1',DeletionTime = now()
where id in
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateMiddleDatabaseDevice" parameterType="DcDevice">
update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId}
</update>
@ -164,4 +309,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
</mapper>

Loading…
Cancel
Save