Commit f6401551 authored by 刘林's avatar 刘林

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

parents 1621984d e89864e9
package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("dz_point_system")
@ApiModel(value="PointSystem对象", description="")
public class PointSystem extends BaseEntity {
@ApiModelProperty(value = "场站")
@TableField("station")
private String station;
@ApiModelProperty(value = "二维码")
@TableField("number")
private String number;
@ApiModelProperty(value = "类型")
@TableField("type")
private String type;
@ApiModelProperty(value = "'地址'")
@TableField("address")
private String address;
@ApiModelProperty(value = "测点类型")
@TableField("point_type")
private String pointType;
@ApiModelProperty(value = "测点值")
@TableField("value")
private String value;
@ApiModelProperty(value = "功能码")
@TableField("function_num")
private String functionNum;
@ApiModelProperty(value = "kks码")
@TableField("kks")
private String kks;
}
...@@ -453,19 +453,25 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -453,19 +453,25 @@ public class EquipmentSpecificController extends AbstractBaseController {
query.notIn(EquipQrcodeRecord::getSourceId,id); query.notIn(EquipQrcodeRecord::getSourceId,id);
query.isNull(EquipQrcodeRecord::getCleanTime); query.isNull(EquipQrcodeRecord::getCleanTime);
List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query); List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query);
//修改本次清除的装备事件
LambdaQueryWrapper<EquipQrcodeRecord> one = new LambdaQueryWrapper<>();
one.eq(EquipQrcodeRecord::getEquipid,equipId);
one.eq(EquipQrcodeRecord::getSourceId,id);
one.isNull(EquipQrcodeRecord::getCleanTime);
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecordMapper.selectOne(one);
equipQrcodeRecord.setCleanTime(new Date());
equipQrcodeRecordMapper.updateById(equipQrcodeRecord);
if (equipQrcodeRecords.size() == 0) { //如果记录表中此装备无未消除的故障等 则恢复绿码 if (equipQrcodeRecords.size() == 0) { //如果记录表中此装备无未消除的故障等 则恢复绿码
//修改装备二维码状态为合格 此处为0代表绿色 是idx只有在合格是才会触发此接口 //修改装备二维码状态为合格 此处为0代表绿色 是idx只有在合格是才会触发此接口
equipmentSpecificSerivce.updateEquipSpecificStatus("0", equipId); equipmentSpecificSerivce.updateEquipSpecificStatus("0", equipId);
} else { } else {
//先修改本次清除的装备事件
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecords.stream().filter(e -> e.getSourceId().equals(id)).findFirst().get();
equipQrcodeRecords.remove(equipQrcodeRecord);
equipQrcodeRecord.setCleanTime(new Date());
equipQrcodeRecordMapper.updateById(equipQrcodeRecord);
//然后取结果集中剩余状态最高的颜色赋码 //然后取结果集中剩余状态最高的颜色赋码
String status = equipQrcodeRecords.stream().sorted(Comparator.comparing(EquipQrcodeRecord::getStatus)).findFirst().get().getStatus(); String status = equipQrcodeRecords.stream().sorted(Comparator.comparing(EquipQrcodeRecord::getStatus)).findFirst().get().getStatus();
equipmentSpecificSerivce.updateEquipSpecificStatus(status, equipId); equipmentSpecificSerivce.updateEquipSpecificStatus(status, equipId);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
package com.yeejoin.equipmanage.dto;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Data
public class BizInfo {
private String sourceAttributionDesc;
private String sourceAttribution;
private List<DynamicDetails> dynamicDetails;
private String warningObjectCode;
private String warningTime;
private String warningObjectName;
public BizInfo(String sourceAttributionDesc,
String sourceAttribution,
List<DynamicDetails> dynamicDetails,
String warningObjectCode,
String warningTime,
String warningObjectName) {
this.sourceAttributionDesc = sourceAttributionDesc;
this.sourceAttribution = sourceAttribution;
this.dynamicDetails = dynamicDetails;
this.warningObjectCode = warningObjectCode;
this.warningTime = warningTime;
this.warningObjectName = warningObjectName;
}
}
package com.yeejoin.equipmanage.dto;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Data
public class DynamicDetails {
private String tabName;
private List<TabContent> tabContent;
public DynamicDetails(String tabName, List<TabContent> tabContent) {
this.tabName = tabName;
this.tabContent = tabContent;
}
}
package com.yeejoin.equipmanage.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Data
public class TabContent {
private String label;
private String type;
private Object value;
private String key;
public TabContent(String label, String type, Object value, String key) {
this.label = label;
this.type = type;
this.value = value;
this.key = key;
}
}
package com.yeejoin.equipmanage.dto;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Data
public class WarningDto {
private BizInfo bizInfo;
private String indexKey;
private String indexValue;
private String traceId;
public WarningDto( String indexKey, String indexValue, String traceId,
String sourceAttributionDesc,
String sourceAttribution,
List<DynamicDetails> dynamicDetails,
String warningObjectCode,
String warningTime,
String warningObjectName
) {
this.bizInfo = new BizInfo( sourceAttributionDesc, sourceAttribution, dynamicDetails, warningObjectCode, warningTime, warningObjectName);
this.indexKey = indexKey;
this.indexValue = indexValue;
this.traceId = traceId;
}
}
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.entity.PointSystem;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
public interface PointSystemMapper extends BaseMapper<PointSystem> {
//推送预警
public void sendWarning();
}
package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
public interface IPointSystemService {
//触发风险预警
public void sendWarning(String address, String value);
}
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecific;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.common.entity.PointSystem;
import com.yeejoin.equipmanage.common.utils.HttpContentTypeUtil;
import com.yeejoin.equipmanage.dto.DynamicDetails;
import com.yeejoin.equipmanage.dto.TabContent;
import com.yeejoin.equipmanage.dto.WarningDto;
import com.yeejoin.equipmanage.mapper.PointSystemMapper;
import com.yeejoin.equipmanage.service.IPointSystemService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @description:
* @author: tw
* @createDate: 2023/6/19
*/
@Service
public class PointSystemServiceImpl extends ServiceImpl<PointSystemMapper, PointSystem> implements IPointSystemService {
@Autowired
PointSystemMapper pointSystemMapper;
@Value("${power.station.url}")
private String powerStationUrl;
private final String TABNAME="预警问题";
private final String TEXT= "text";
@Value("${power.station.warning:104/data/analysis}")
private String STATIONWARNING;
@Autowired
protected EmqKeeper emqKeeper;
@Override
public void sendWarning(String address, String value) {
try {
//通过测点地址获取,和对应值 获取kks
QueryWrapper<PointSystem> pointSystemWrapper = new QueryWrapper<>();
pointSystemWrapper.lambda().eq(PointSystem::getAddress, address);
pointSystemWrapper.lambda().eq(PointSystem::getValue, value);
PointSystem pointSystem = pointSystemMapper.selectOne(pointSystemWrapper);
if (pointSystem == null) {
throw new RuntimeException("获取kks码失败!");
}
//调用获取设备相关信息
Map<String, String> maps = new HashMap<>();
maps.put("type", "equipinfo");
maps.put("kksbm", pointSystem.getKks());
String data = HttpContentTypeUtil.sendHttpPost(powerStationUrl, maps);
if (StringUtils.isEmpty(data) || !(Boolean) JSON.parseObject(data).get("success")) {
throw new RuntimeException("获取设备信息失败!");
}
JSONObject json = JSON.parseObject(data);
JSONObject jsond = (JSONObject) json.get("dataset");
JSONArray list = (JSONArray) jsond.get("datas");
JSONObject eqdata = null;
if (list == null || list.isEmpty()) {
throw new RuntimeException("获取设备信息失败!");
}
eqdata = (JSONObject) list.get(0);
//组装数据,发送预警
WarningDto warningDto = setWarningDto(pointSystem, eqdata);
emqKeeper.getMqttClient().publish(STATIONWARNING, JSON.toJSONString(warningDto).getBytes(), 0, false);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("预警消息发送失败!");
}
}
public WarningDto setWarningDto(PointSystem pointSystem,JSONObject eqdata ){
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time= sdf.format(new Date());
String warningObjectCode=pointSystem.getKks();
List<TabContent> tabContent=new ArrayList<>();
tabContent.add(new TabContent( "KKS编码", TEXT, warningObjectCode, "key1"));
tabContent.add(new TabContent( "设备名称", TEXT, eqdata.get("kksms"), "key2"));
tabContent.add(new TabContent( "发生时间", TEXT, time, "key3"));
DynamicDetails dynamicDetails=new DynamicDetails( TABNAME, tabContent);
List<DynamicDetails> dynamicDetailsList=new ArrayList<>();
dynamicDetailsList.add(dynamicDetails);
StringBuffer indexKey=new StringBuffer(pointSystem.getStation())
.append("#")
.append(pointSystem.getNumber())
.append("#")
.append(pointSystem.getFunctionNum());
StringBuffer indexValue=new StringBuffer(pointSystem.getPointType())
.append("#")
.append(pointSystem.getValue());
WarningDto WarningDto=new WarningDto(
indexKey.toString(),
indexValue.toString(),
null,
(String)eqdata.get("sourceAttributionDesc"),
(String)eqdata.get("sourceAttribution"),
dynamicDetailsList,
warningObjectCode,
time ,
(String)eqdata.get("kksms")
);
return WarningDto;
}
}
...@@ -24,7 +24,7 @@ pagehelper.support-methods-arguments=true ...@@ -24,7 +24,7 @@ pagehelper.support-methods-arguments=true
spring.main.allow-bean-definition-overriding=true spring.main.allow-bean-definition-overriding=true
#liquibase #liquibase
spring.liquibase.change-log=classpath:/changelog/changelog-master.xml spring.liquibase.change-log=classpath:/changelog/changelog-master.xml
spring.liquibase.enabled=true spring.liquibase.enabled=false
#\u4E0A\u4F20\u6587\u4EF6\u8BBE\u7F6E #\u4E0A\u4F20\u6587\u4EF6\u8BBE\u7F6E
spring.servlet.multipart.maxFileSize=100MB spring.servlet.multipart.maxFileSize=100MB
...@@ -159,3 +159,7 @@ spring.security.user.password=a1234560 ...@@ -159,3 +159,7 @@ spring.security.user.password=a1234560
stationCode=LSHLZ1bZAJU645Pgl7 stationCode=LSHLZ1bZAJU645Pgl7
##\u4EE3\u7801\u4E2D\u6709\u90E8\u5206\u903B\u8F91\u51B2\u7A81\u9700\u8981\u5904\u7406 \u4E3A\u533A\u5206\u673A\u573A\u548C\u7535\u529B\u903B\u8F91 \u589E\u52A0\u5F00\u5173 \u82E5\u4E3Atrue \u5219\u4E3A\u673A\u573A\u903B\u8F91 \u4E3Afalse \u5219\u4E3A\u7535\u529B\u903B\u8F91 ##\u4EE3\u7801\u4E2D\u6709\u90E8\u5206\u903B\u8F91\u51B2\u7A81\u9700\u8981\u5904\u7406 \u4E3A\u533A\u5206\u673A\u573A\u548C\u7535\u529B\u903B\u8F91 \u589E\u52A0\u5F00\u5173 \u82E5\u4E3Atrue \u5219\u4E3A\u673A\u573A\u903B\u8F91 \u4E3Afalse \u5219\u4E3A\u7535\u529B\u903B\u8F91
logic=false logic=false
#电站对接第三方查询设备kks码
power.station.url=http://139.9.169.123:5024/process/DataInterface
#电站104采集预警
power.station.warning=104/data/analysis
\ No newline at end of file
...@@ -915,4 +915,29 @@ ...@@ -915,4 +915,29 @@
alter table `wl_equipment_specific_index` add column `gateway_id` varchar(50) COMMENT '网关标识ID'; alter table `wl_equipment_specific_index` add column `gateway_id` varchar(50) COMMENT '网关标识ID';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="20230620" id="20230620-1" runAlways="true">
<comment>`dz_point_system`</comment>
<sql endDelimiter="#">
CREATE TABLE `dz_point_system` (
`id` bigint(0) NOT NULL,
`station` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '场站',
`number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '型号',
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型',
`address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地址',
`point_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '测点类型',
`value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '测点值',
`function_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '功能码',
`kks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'kks码',
`create_date` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment