This commit is contained in:
高云鹏 2024-11-22 11:12:35 +08:00
commit e61c278b65
11 changed files with 292 additions and 70 deletions

38
Jenkinsfile vendored
View File

@ -1,15 +1,17 @@
pipeline {
parameters {
choice choices: ['all', 'ui', 'service'], description: 'all - 前端和后端 ; ui - 仅发版前端 ; service - 仅发版后端', name: 'publish_type'
choice choices: ['all', 'ui', 'dn', 'service'], description: 'all - 前端和后端 ; ui - 仅发版前端 ; dn - 采集程序 service - 仅发版后端', name: 'publish_type'
}
agent any
agent none
stages {
stage('拉取源码') {
agent any
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'd62224c5-69cf-474a-8845-c2c2bbe1fc00', url: 'https://git.jsspisoft.com/ry-das.git']])
}
}
stage('编译UI') {
agent any
when {
expression { params.publish_type == "ui" || params.publish_type == "all" }
}
@ -23,6 +25,7 @@ pipeline {
}
}
stage('编译后端') {
agent any
when {
expression { params.publish_type == "service" || params.publish_type == "all" }
}
@ -34,8 +37,24 @@ pipeline {
}
}
}
stage('编译采集程序') {
agent {
docker {
image 'docker.jsspisoft.com/common/openeuler:24.03-builder'
}
}
when {
expression { params.publish_type == "dn" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/das-dn") {
sh 'cmake --preset default'
sh 'cmake --build build'
}
}
}
stage('发版前端') {
agent any
when {
expression { params.publish_type == "ui" || params.publish_type == "all" }
}
@ -46,6 +65,7 @@ pipeline {
}
}
stage('发版后端') {
agent any
when {
expression { params.publish_type == "service" || params.publish_type == "all" }
}
@ -56,5 +76,17 @@ pipeline {
}
}
}
stage('发版采集程序') {
agent any
when {
expression { params.publish_type == "dn" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/das-dn") {
sh 'sudo rsync -av build/application root@192.168.109.187:/das/app/das-dn/bin/'
sh 'sudo ssh -t root@192.168.109.187 systemctl restart das-dn'
}
}
}
}
}

View File

@ -11,6 +11,8 @@ public class DeviceEventInfo {
@JsonSerialize(using = ToStringSerializer.class)
private Long eventId;
private String attributeCode;
private Integer eventType;
private Integer eventLevel;

View File

@ -255,7 +255,7 @@ public class TDEngineService {
});
//初始化event_info
String eventInfo = "create stable IF NOT EXISTS event_info (event_time timestamp,event_id bigint primary key,event_type tinyint,event_level tinyint,event_text varchar(256),confirmed tinyint,confirm_account varchar(32),confirm_time timestamp) tags (device_id bigint,device_code varchar(64),device_name varchar(192))";
String eventInfo = "create stable IF NOT EXISTS event_info (event_time timestamp,event_id bigint primary key,attributecode varchar(64),event_type tinyint,event_level tinyint,event_text varchar(256),confirmed tinyint,confirm_account varchar(32),confirm_time timestamp) tags (device_id bigint,device_code varchar(64),device_name varchar(192))";
try {
pstmt.executeUpdate(eventInfo);
} catch (SQLException ex) {
@ -399,7 +399,9 @@ public class TDEngineService {
sb.append(dv.getEventTime());
sb.append(",");
sb.append(dv.getEventId());
sb.append(",");
sb.append(",'");
sb.append(dv.getAttributeCode());
sb.append("',");
sb.append(dv.getEventType());
sb.append(",");
sb.append(dv.getEventLevel());
@ -417,7 +419,7 @@ public class TDEngineService {
pstmt.executeUpdate(sb.toString());
log.info("告警信息入库:{}",sb.toString());
} catch (SQLException ex) {
log.error("save yc error", ex);
log.error("save deviceEvent error", ex);
}
});
} catch (SQLException ex) {

View File

@ -218,7 +218,7 @@ public class DataServiceImpl implements DataService {
Map<String, String> HighModelFieldList = allIotModelField.stream().filter(field -> field.getHighSpeed() == 1 && field.getAttributeType() != 199).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
Map<String, String> calculateFieldList = allIotModelField.stream().filter(field -> field.getAttributeType() == 199).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
Map<String, String> fieldCodeNameList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getAttributeName, (value1, value2) -> value1));
Map<String, Integer> eventLevelList = allIotModelField.stream().filter(field -> field.getAttributeType() == 140 && field.getLevel() != null).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getLevel, (value1, value2) -> value1));
Map<String, Integer> eventLevelList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getLevel, (value1, value2) -> value1));
Map<String, Object> map = new HashMap<>();
for (String field : HighModelFieldList.keySet()) {
map.put(field, HighModelFieldList.get(field));

View File

@ -622,6 +622,17 @@ public class SysIotModelServiceImpl implements SysIotModelService {
else {
fieldCodeNameMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getAttributeName());
}
if (sysIotModelField.getLevel() != null){
Map<String, Integer> levelMap = dataService.eventLevelMap.get(modelCode);
if (levelMap == null) {
Map<String, Integer> calMap = new HashMap<>();
calMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getLevel());
dataService.eventLevelMap.put(modelCode, calMap);
} else {
levelMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getLevel());
}
}
if (sysIotModelField.getAttributeType() == 199) {
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
if (map == null) {
@ -670,6 +681,9 @@ public class SysIotModelServiceImpl implements SysIotModelService {
String modelCode = dataService.iotModelMap.get(sysIotModelField.getIotModelId().toString());
Map<String, String> fieldCodeName = dataService.fieldCodeNameMap.get(modelCode);
fieldCodeName.remove(sysIotModelField.getAttributeCode());
if (sysIotModelField.getLevel() != null){
dataService.eventLevelMap.remove(sysIotModelField.getAttributeCode());
}
if (sysIotModelField.getAttributeType() == 199) {
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
map.remove(sysIotModelField.getAttributeCode());

View File

@ -346,6 +346,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
DeviceEventInfo deviceEventInfo = new DeviceEventInfo();
deviceEventInfo.setEventTime(item.getEventTime());
deviceEventInfo.setEventId(IdWorker.getId());
deviceEventInfo.setAttributeCode(item.getAttrCode());
deviceEventInfo.setDeviceId(item.getDeviceId());
deviceEventInfo.setDeviceName(deviceInfoCache.getDeviceName());
deviceEventInfo.setDeviceCode(deviceInfoCache.getDeviceCode());
@ -363,10 +364,14 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")) {
if (item.getAttrValue().equals(0)) {
deviceEventInfo.setEventText(fieldName + " 复归");
deviceEventInfo.setEventLevel(0);
} else {
deviceEventInfo.setEventText(fieldName + " 动作");
deviceEventInfo.setEventLevel(dataService.eventLevelMap.get(model).get(fieldName));
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
log.info("level:{}",level);
log.info("fieldname{}",fieldName);
deviceEventInfo.setEventLevel( level == null ? 0 : level);
}
} else {
deviceEventInfo.setEventText(fieldName + eventType + ",属性值为:" + item.getAttrValue() + ",越限值为:" + item.getLimitValue());

View File

@ -78,7 +78,7 @@
where se.id = #{id}
</select>
<select id="getAllIotModelField" resultType="com.das.modules.equipment.entity.SysIotModelField">
select simf.attribute_name as attributeName, simf.attribute_code as attributeCode,simf.highspeed as highSpeed,simf.datatype as dataType,simf.attribute_type as attributeType from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
select simf.attribute_name as attributeName, simf.attribute_code as attributeCode,simf.highspeed as highSpeed,simf.datatype as dataType,simf.attribute_type as attributeType,simf.level as level from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
</select>

View File

@ -63,12 +63,7 @@ PS: 同一节点只允许建立一条连接。
"protocol": 1,
//协议参数
"params": {},
"devices": ["11234131","1234123"]
}
],
//物模型信息
"equipments": [
{
"devices": [ {
//设备ID
"id": "11234131",
//设备IOT地址
@ -128,9 +123,204 @@ PS: 同一节点只允许建立一条连接。
}
}
]
}, {
//设备ID
"id": "11234131",
//设备IOT地址
"addr": "12341235",
//属性列表
"attrs":[
{
//属性名
"name": "Ia",
//属性类型
"type": "yc",
//是否高频属性, 0 - 不是, 1 - 是
"highSpeed": 1,
//属性参数
"params": {
//上界
"upBound": 9999,
//下界
"lowBound": 0,
//基值, default: 0
"base": 0,
//系数, default: 1
"coef": 1,
//限值1, default: 0
"limit1Enable": 0,
//限值1下限
"limit1Low": 123.0,
//限值1上限
"limit1High": 999.0,
//限值2, default: 0
"limit2Enable": 0,
//限值2上限
"limit2High": 999.0,
//限值2下限
"limit2Low": 0.0
}
},
{
"name": "Switch01",
"type": "yx",
"params": {
//是否取反,default: 0
"invert": 0
}
}
],
//服务列表
"services": [
{
//服务名
"name": "start",
//服务类型
"type": "yk",
//服务参数
"params": {
}
}
]
}]
},
{
//链路ID
"linkId": "1235112",
//链路名称
"linkName": "2#风机",
//协议号
"protocol": 12,
//协议参数
"params": {},
"devices": [ {
//设备ID
"id": "11234131",
//设备IOT地址
"addr": "12341235",
//属性列表
"attrs":[
{
//属性名
"name": "Ia",
//属性类型
"type": "yc",
//是否高频属性, 0 - 不是, 1 - 是
"highSpeed": 1,
//属性参数
"params": {
//上界
"upBound": 9999,
//下界
"lowBound": 0,
//基值, default: 0
"base": 0,
//系数, default: 1
"coef": 1,
//限值1, default: 0
"limit1Enable": 0,
//限值1下限
"limit1Low": 123.0,
//限值1上限
"limit1High": 999.0,
//限值2, default: 0
"limit2Enable": 0,
//限值2上限
"limit2High": 999.0,
//限值2下限
"limit2Low": 0.0
}
},
{
"name": "Switch01",
"type": "yx",
"params": {
//是否取反,default: 0
"order": 0,
"invert": 0
}
}
],
//服务列表
"services": [
{
//服务名
"name": "start",
//服务类型
"type": "yk",
//服务参数
"params": {
"order": 0
}
}
]
}, {
//设备ID
"id": "11234131",
//设备IOT地址
"addr": "12341235",
//属性列表
"attrs":[
{
//属性名
"name": "Ia",
//属性类型
"type": "yc",
//是否高频属性, 0 - 不是, 1 - 是
"highSpeed": 1,
//属性参数
"params": {
"order": 0
//上界
"upBound": 9999,
//下界
"lowBound": 0,
//基值, default: 0
"base": 0,
//系数, default: 1
"coef": 1,
//限值1, default: 0
"limit1Enable": 0,
//限值1下限
"limit1Low": 123.0,
//限值1上限
"limit1High": 999.0,
//限值2, default: 0
"limit2Enable": 0,
//限值2上限
"limit2High": 999.0,
//限值2下限
"limit2Low": 0.0
}
},
{
"name": "Switch01",
"type": "yx",
"params": {
//是否取反,default: 0
"invert": 0,
"order": 0
}
}
],
//服务列表
"services": [
{
//服务名
"name": "start",
//服务类型
"type": "yk",
//服务参数
"params": {
"order": 0
}
}
]
}]
}
]
]
}
```

View File

@ -18,7 +18,6 @@
<span>{{item.eventText}}</span>
<span>{{item.eventTimeFormate}}</span>
</p>
<!-- <span v-if="tableData.length==0">暂无告警</span>-->
</div>
</div>
@ -28,29 +27,6 @@
</div>
</div>
</el-col>
<!-- <el-col :md="24" :lg="8" style="padding: 0px">
<div class="grid-content ep-bg-purple cardContentRight">
&lt;!&ndash;实时告警&ndash;&gt;
<div class="realPart panelBg" style="margin-bottom: 0">
<el-text class="mx-1 homelabel">实时告警</el-text>
<div class="realAlert"
ref="scrollRef"
@mouseover.native="clearScroll"
@mouseleave.native="createScroll">
<ul>
<li v-for="(item,index) in tableData"
:key="index"
@click="open(item)"
>
<span>{{item.deviceCode}}</span>
<span>{{item.eventText}}</span>
<span>{{item.eventTimeFormate}}</span>
</li>
</ul>
</div>
</div>
</div>
</el-col>-->
</el-row>
</div>
</template>
@ -150,19 +126,19 @@ const StatusListData = () => {
item.attributeMap.iwindspeed !== undefined
? item.attributeMap.iwindspeed % 1 === 0
? item.attributeMap.iwindspeed
: item.attributeMap.iwindspeed.toFixed(2)
: item.attributeMap.iwindspeed.toFixed(1)
: '--'
item.attributeMap.igenpower =
item.attributeMap.igenpower !== undefined
? item.attributeMap.igenpower % 1 === 0
? item.attributeMap.igenpower
: item.attributeMap.igenpower.toFixed(2)
: item.attributeMap.igenpower.toFixed(1)
: '--'
item.attributeMap.ikwhthisday =
item.attributeMap.ikwhthisday !== undefined
? item.attributeMap.ikwhthisday % 1 === 0
? item.attributeMap.ikwhthisday
: item.attributeMap.ikwhthisday.toFixed(2)
: item.attributeMap.ikwhthisday.toFixed(1)
: '--'
//
if (index === 0) {

View File

@ -52,22 +52,28 @@
</el-col>
</el-row>
<el-row class="fanlist-data">
<!-- <div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.iwindspeed }}</span><span>m/s</span>
</div>
<div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.igenpower }}</span><span>MW</span>
</div>
<div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.ikwhthisday }}</span><span>kWh</span>
</div>-->
<el-col :span="8">
<div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.iwindspeed }}</span
><span>风速m/s</span>
<span class="content-number">{{ item.attributeMap.iwindspeed }}</span><span>风速m/s</span>
</div>
</el-col>
<el-col :span="8">
<div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.igenpower }}</span
><span>功率MW</span>
<span class="content-number">{{ item.attributeMap.igenpower }}</span><span>功率MW</span>
</div>
</el-col>
<el-col :span="8">
<div class="fanlist-text">
<span class="content-number">{{ item.attributeMap.ikwhthisday }}</span
><span>日发电量kWh</span>
<span class="content-number">{{ item.attributeMap.ikwhthisday }}</span><span>日发电量kWh</span>
</div>
</el-col>
</el-row>
@ -97,7 +103,7 @@ const props = defineProps({
const getAnimationStyle = (item) => {
const irotorspeed = item.attributeMap?.irotorspeed ?? 0
const animationDuration = (1 / irotorspeed) * 10
const animationDuration = 60 / irotorspeed
return {
'animation-duration': `${animationDuration}s`,
'animation-timing-function': 'linear',

View File

@ -234,10 +234,10 @@ const tableItem1: any = [
{
label: '限电原因',
unit: ' ',
prop: '',
prop: 'powerlimitsource',
align: 'center',
custom: 'header',
name:'',
name:'PowerLimitSource',
title: '限电原因'
},
{
@ -317,7 +317,7 @@ const defaultdeviceQuery = () => {
if(attributeCodeLower!='name'){
if (attributeCodeLower) {
const value=tsnapshotVoItem[attributeCodeLower];
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(1)) : '-';
if (enumStore.keys.includes(item1.name)) {
formattedValue = enumStore.data[item1.name][formattedValue]?enumStore.data[item1.name][formattedValue]:'-'
}
@ -575,7 +575,7 @@ const getTableData = () => {
if (item.id === itemKey) {
const attributeCodeLower = item1.attributeCode?.toLowerCase();
const value = tsnapshotVoObject[itemKey]?.[attributeCodeLower];
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(1)) : '-';
if (enumStore.keys.includes(item1.attributeCode)) {
formattedValue = enumStore.data[item1.attributeCode][formattedValue]?enumStore.data[item1.attributeCode][formattedValue]:'-'
}
@ -608,22 +608,17 @@ const downFun=(tableColumn,tableData)=>{
}
const columnSet = new Set(tableColumn.map(item => item.prop));
const result = [];
try {
itemsWithoutAge.forEach((item) => {
const newItem = {};
for (const itemKey in item) {
if (columnSet.has(itemKey)) {
newItem[itemKey] = item[itemKey];
}
itemsWithoutAge.forEach((item) => {
const newItem = {};
for (const itemKey in item) {
if (columnSet.has(itemKey)) {
newItem[itemKey] = item[itemKey];
}
if (Object.keys(newItem).length > 0) {
result.push(newItem);
}
});
} catch (error) {
console.error('Error in code execution:', error);
return [];
}
}
if (Object.keys(newItem).length > 0) {
result.push(newItem);
}
});
let addobj = {}
tableColumn.map((v, i) => {
addobj['rowData' + i] = v.label