Browse Source

优化非机预警事件订阅方式 新增页面 新增跟随项目自启动

优化设备新增页面组件应用
develop
zhaoxianglong 1 year ago
parent
commit
56a371f7ad
  1. 10
      ruoyi-ui/src/api/system/NonAutomaticWarning.js
  2. 18
      ruoyi-ui/src/views/system/device/index.vue
  3. 83
      ruoyi-ui/src/views/system/non-automatic-warning/index.vue
  4. 37
      zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java
  5. 24
      zc-business/src/main/java/com/zc/business/domain/NonAutomaticWarning.java

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

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

@ -140,7 +140,7 @@
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -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,
//

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

@ -0,0 +1,83 @@
<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) {
console.log(this.form)
eventSubscription(this.form).then((response)=>{
console.log(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);
}
}

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;
}
Loading…
Cancel
Save