Commit 989b3ed0 authored by caotao's avatar caotao

运维工单后端代码新增消息发送代码

parent 769283f6
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author LiuLin
* @date 2023年08月02日 11:02
*/
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class BizMessage {
private String indexKey;
private String indexValue;
private String traceId;
private RiskBizInfoVo bizInfo;
/**
* 数据来源:实时数据、周期数据
*/
String dataSource;
private String traceId2;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
/**
* @author Administrator
* 自定义扩展内容项
*/
@Data
public class CustomizeItems {
/**
* 自定义的问题名称
*/
private String questionName;
/**
* 自定义的问题内容
*/
private String questionContent;
/**
* 自定义的预警内容 content
*/
private String warningContent;
}
...@@ -21,6 +21,10 @@ public class HYGFMaintenanceTicketsDto extends BaseDto { ...@@ -21,6 +21,10 @@ public class HYGFMaintenanceTicketsDto extends BaseDto {
*/ */
private String handlerStatus; private String handlerStatus;
/** /**
* 场站id
*/
private String stationId;
/**
* 场站名称 * 场站名称
*/ */
private String stationName; private String stationName;
...@@ -50,6 +54,11 @@ public class HYGFMaintenanceTicketsDto extends BaseDto { ...@@ -50,6 +54,11 @@ public class HYGFMaintenanceTicketsDto extends BaseDto {
* 告警时长 * 告警时长
*/ */
private String warningDuration; private String warningDuration;
/**
* 告警状态
*/
private String warningStatus;
/** /**
* 场站联系人 * 场站联系人
*/ */
......
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
import java.util.List;
/**
* @author LiuLin
* @date 2023年08月02日 11:02
*/
@Data
public class RiskBizInfoVo {
private String warningObjectName;
private String warningObjectCode;
private String warningTime;
private String sourceAttribution;
private String sourceAttributionDesc;
private String sourceSupplyField;
private String bussId;
private String bussName;
private String type;
private List<RiskDynamicDetailsVo> dynamicDetails;
private String warningObjectType;
private CustomizeItems customizeItems;
private String warningObjectLinkUrl;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author LiuLin
* @date 2023年08月02日 11:02
*/
@Data
public class RiskDynamicDetailsVo {
private String tabName;
private List<TableContentVo> tabContent;
private Map<String, Object> specialMap;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
/**
* @author LiuLin
* @date 2023年08月02日 11:02
*/
@Data
public class TableContentVo {
private String key;
private String label;
private Object value;
private String type;
public TableContentVo(String key, String label, Object value, String type) {
this.key = key;
this.label = label;
this.value = value;
this.type = type;
}
public TableContentVo() {
}
}
...@@ -24,6 +24,11 @@ public class HYGFMaintenanceTickets extends BaseEntity { ...@@ -24,6 +24,11 @@ public class HYGFMaintenanceTickets extends BaseEntity {
@TableField("handler_status") @TableField("handler_status")
private String handlerStatus; private String handlerStatus;
/** /**
* 场站id
*/
@TableField("station_id")
private String stationId;
/**
* 场站名称 * 场站名称
*/ */
@TableField("station_name") @TableField("station_name")
...@@ -39,6 +44,11 @@ public class HYGFMaintenanceTickets extends BaseEntity { ...@@ -39,6 +44,11 @@ public class HYGFMaintenanceTickets extends BaseEntity {
@TableField("warning_level") @TableField("warning_level")
private String warningLevel; private String warningLevel;
/** /**
* 告警状态
*/
@TableField("warning_status")
private String warningStatus;
/**
* 告警内容 * 告警内容
*/ */
@TableField("warning_content") @TableField("warning_content")
......
...@@ -25,7 +25,7 @@ import java.util.List; ...@@ -25,7 +25,7 @@ import java.util.List;
@RestController @RestController
@Api(tags = "运维工单Api") @Api(tags = "运维工单Api")
@RequestMapping(value = "/maintenanceTickets") @RequestMapping(value = "/maintenanceTickets")
public class HYGFMaintenanceTicketsServiceImplController extends BaseController { public class HYGFMaintenanceTicketsController extends BaseController {
@Autowired @Autowired
HYGFMaintenanceTicketsServiceImpl hygfMaintenanceTicketsServiceimpl; HYGFMaintenanceTicketsServiceImpl hygfMaintenanceTicketsServiceimpl;
...@@ -39,7 +39,7 @@ public class HYGFMaintenanceTicketsServiceImplController extends BaseController ...@@ -39,7 +39,7 @@ public class HYGFMaintenanceTicketsServiceImplController extends BaseController
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增运维工单", notes = "新增运维工单") @ApiOperation(httpMethod = "POST", value = "新增运维工单", notes = "新增运维工单")
public ResponseModel<HYGFMaintenanceTicketsDto> save(@RequestBody HYGFMaintenanceTicketsDto model) { public ResponseModel<HYGFMaintenanceTicketsDto> save(@RequestBody HYGFMaintenanceTicketsDto model) {
model = hygfMaintenanceTicketsServiceimpl.createWithModel(model); hygfMaintenanceTicketsServiceimpl.sendMeassageToMcb(model);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
} }
......
...@@ -57,51 +57,53 @@ public class MaintenanceResultHandlerMessage extends EmqxListener { ...@@ -57,51 +57,53 @@ public class MaintenanceResultHandlerMessage extends EmqxListener {
@Async("async") @Async("async")
public void JxiopUpdateMaintenance(JSONObject jsonObject) { public void JxiopUpdateMaintenance(JSONObject jsonObject) {
JSONObject rawData = jsonObject.getJSONObject("rawData"); if(jsonObject.containsKey("rawData")) {
JSONObject bizInfo = rawData.getJSONObject("bizInfo"); JSONObject rawData = jsonObject.getJSONObject("rawData");
HYGFMaintenanceTickets hygfMaintenanceTickets = new HYGFMaintenanceTickets(); JSONObject bizInfo = rawData.getJSONObject("bizInfo");
String warningObjectName = ""; HYGFMaintenanceTickets hygfMaintenanceTickets = new HYGFMaintenanceTickets();
String warningObjectCode = "";//station_id@inverter_sn@maintenance_id@warn_id String warningObjectName = "";
String[] codes = warningObjectCode.split("@"); String warningObjectCode = "";//station_id@inverter_sn@maintenance_id@warn_id
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("station_id", codes[0])); String[] codes = warningObjectCode.split("@");
TdHygfJpInverterWarn tdHygfJpInverterWarn = tdHygfJpInverterWarnMapper.selectOne(new QueryWrapper<TdHygfJpInverterWarn>() JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("station_id", codes[0]));
.eq("thrid_station_id", codes[0]) TdHygfJpInverterWarn tdHygfJpInverterWarn = tdHygfJpInverterWarnMapper.selectOne(new QueryWrapper<TdHygfJpInverterWarn>()
.eq("sn_code", codes[1]) .eq("thrid_station_id", codes[0])
.eq("created_time", codes[3]) .eq("sn_code", codes[1])
); .eq("created_time", codes[3])
hygfMaintenanceTickets.setHandlerStatus("未处理"); );
Maintenance maintenance = maintenanceMapper.selectById(codes[2]); hygfMaintenanceTickets.setHandlerStatus("未处理");
if(ObjectUtil.isNotEmpty(maintenance)){ Maintenance maintenance = maintenanceMapper.selectById(codes[2]);
hygfMaintenanceTickets.setMaintenancePersonId(codes[2]); if (ObjectUtil.isNotEmpty(maintenance)) {
hygfMaintenanceTickets.setMaintenancePersonName(maintenance.getName()); hygfMaintenanceTickets.setMaintenancePersonId(codes[2]);
hygfMaintenanceTickets.setMaintenancePersonPhone(maintenance.getTelephone()); hygfMaintenanceTickets.setMaintenancePersonName(maintenance.getName());
} hygfMaintenanceTickets.setMaintenancePersonPhone(maintenance.getTelephone());
if (ObjectUtil.isNotEmpty(jpStation)) { }
//场站名称 if (ObjectUtil.isNotEmpty(jpStation)) {
hygfMaintenanceTickets.setStationName(jpStation.getName()); //场站名称
//区域公司编码 hygfMaintenanceTickets.setStationName(jpStation.getName());
hygfMaintenanceTickets.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); //区域公司编码
//经销商orgCode hygfMaintenanceTickets.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
hygfMaintenanceTickets.setAmosCompanyCode(jpStation.getAmosCompanyCode()); //经销商orgCode
//地址 hygfMaintenanceTickets.setAmosCompanyCode(jpStation.getAmosCompanyCode());
hygfMaintenanceTickets.setStationAddress(jpStation.getAddress()); //地址
//经度 hygfMaintenanceTickets.setStationAddress(jpStation.getAddress());
hygfMaintenanceTickets.setStationLongitude(jpStation.getLongitude()); //经度
//纬度 hygfMaintenanceTickets.setStationLongitude(jpStation.getLongitude());
hygfMaintenanceTickets.setStationLatitude(jpStation.getLatitude()); //纬度
//电站联系人电话 hygfMaintenanceTickets.setStationLatitude(jpStation.getLatitude());
//电站联系人电话
// hygfMaintenanceTickets.setStationContactPhone(jpStation.getContactPhone()); // hygfMaintenanceTickets.setStationContactPhone(jpStation.getContactPhone());
//电站联系人 //电站联系人
// hygfMaintenanceTickets.setStationContact(); // hygfMaintenanceTickets.setStationContact();
} }
if (ObjectUtil.isNotEmpty(tdHygfJpInverterWarn)) { if (ObjectUtil.isNotEmpty(tdHygfJpInverterWarn)) {
//snCode //snCode
hygfMaintenanceTickets.setInverterSn(codes[1]); hygfMaintenanceTickets.setInverterSn(codes[1]);
//告警等级 //告警等级
hygfMaintenanceTickets.setWarningLevel(tdHygfJpInverterWarn.getLevel()); hygfMaintenanceTickets.setWarningLevel(tdHygfJpInverterWarn.getLevel());
}
hygfMaintenanceTicketsMapper.insert(hygfMaintenanceTickets);
log.info("创建运维工单成功{}", JSON.toJSONString(hygfMaintenanceTickets));
} }
hygfMaintenanceTicketsMapper.insert(hygfMaintenanceTickets);
log.info("创建运维工单成功{}", JSON.toJSONString(hygfMaintenanceTickets));
} }
} }
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.HYGFMaintenanceTicketsDto; import com.yeejoin.amos.boot.module.hygf.api.dto.*;
import com.yeejoin.amos.boot.module.hygf.api.entity.HYGFMaintenanceTickets; import com.yeejoin.amos.boot.module.hygf.api.entity.HYGFMaintenanceTickets;
import com.yeejoin.amos.boot.module.hygf.api.mapper.HYGFMaintenanceTicketsMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.HYGFMaintenanceTicketsMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IHYGFMaintenanceTicketsService; import com.yeejoin.amos.boot.module.hygf.api.service.IHYGFMaintenanceTicketsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Service @Service
public class HYGFMaintenanceTicketsServiceImpl extends BaseService<HYGFMaintenanceTicketsDto, HYGFMaintenanceTickets, HYGFMaintenanceTicketsMapper> implements IHYGFMaintenanceTicketsService { public class HYGFMaintenanceTicketsServiceImpl extends BaseService<HYGFMaintenanceTicketsDto, HYGFMaintenanceTickets, HYGFMaintenanceTicketsMapper> implements IHYGFMaintenanceTicketsService {
public static final String WARNING_RESULT_MESSAGE = "hygfmaintenance/warning/result";
@Autowired
EmqKeeper emqKeeper;
/** /**
* 分页查询 * 分页查询
*/ */
public Page<HYGFMaintenanceTicketsDto> queryForHYGFMaintenanceTicketsDtoPage(Page<HYGFMaintenanceTicketsDto> page) { public Page<HYGFMaintenanceTicketsDto> queryForHYGFMaintenanceTicketsDtoPage(Page<HYGFMaintenanceTicketsDto> page) {
return this.queryForPage(page, null, false); return this.queryForPage(page, null, false);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<HYGFMaintenanceTicketsDto> queryHYGFMaintenanceTicketsDtoList() { public List<HYGFMaintenanceTicketsDto> queryHYGFMaintenanceTicketsDtoList() {
return this.queryForList("" , false); return this.queryForList("", false);
}
public void sendMeassageToMcb(HYGFMaintenanceTicketsDto hygfMaintenanceTicketsDto) {
HashMap<String,Object> messageMain = new HashMap<>();
HashMap<String,Object> rawData = new HashMap<>();
HashMap<String,Object> bizInfo = new HashMap<>();
HashMap<String,Object> specialMap = new HashMap<>();
List<RiskDynamicDetailsVo> riskDynamicDetailsVoList = new ArrayList<>();
RiskDynamicDetailsVo riskDynamicDetailsVo = new RiskDynamicDetailsVo();
riskDynamicDetailsVo.setSpecialMap(specialMap);
//电站id
specialMap.put("stationId",hygfMaintenanceTicketsDto.getStationId());
//电站名称
specialMap.put("stationName",hygfMaintenanceTicketsDto.getStationName());
//告警id
specialMap.put("warningId",hygfMaintenanceTicketsDto.getWarningId());
if(ObjectUtil.isNotEmpty(hygfMaintenanceTicketsDto.getWarningId())){
//告警内容
specialMap.put("warningContent",hygfMaintenanceTicketsDto.getWarningContent());
//告警等级
specialMap.put("warningLevel",hygfMaintenanceTicketsDto.getWarningLevel());
//告警状态
specialMap.put("warningStatus",hygfMaintenanceTicketsDto.getWarningStatus());
//告警开始时间
specialMap.put("warningStartTime",hygfMaintenanceTicketsDto.getWarningStartTime());
}
specialMap.put("maintenance_person_id",hygfMaintenanceTicketsDto.getMaintenancePersonId());
//电站联系人
specialMap.put("stationContact",hygfMaintenanceTicketsDto.getStationContact());
//电站电话
specialMap.put("stationContactPhone",hygfMaintenanceTicketsDto.getStationContactPhone());
//场站地址
specialMap.put("stationAddress",hygfMaintenanceTicketsDto.getStationAddress());
riskDynamicDetailsVoList.add(riskDynamicDetailsVo);
bizInfo.put("sourceAttributionDesc",hygfMaintenanceTicketsDto.getStationName());
bizInfo.put("sourceAttribution",hygfMaintenanceTicketsDto.getStationName());
bizInfo.put("dynamicDetails",riskDynamicDetailsVoList);
bizInfo.put("warningObjectCode",hygfMaintenanceTicketsDto.getInverterSn());
bizInfo.put("warningTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
bizInfo.put("warningObjectName",hygfMaintenanceTicketsDto.getStationName());
rawData.put("traceId",hygfMaintenanceTicketsDto.getInverterSn());
rawData.put("bizInfo",bizInfo);
rawData.put("indexKey",hygfMaintenanceTicketsDto.getInverterSn());
rawData.put("dataSource","户用光伏-告警");
rawData.put("indexValue",hygfMaintenanceTicketsDto.getInverterSn());
messageMain.put("rawData",rawData);
// BizMessage bizMessage = new BizMessage();
// bizMessage.setIndexKey(hygfMaintenanceTicketsDto.getStationName());
// bizMessage.setIndexValue(hygfMaintenanceTicketsDto.getInverterSn());
// RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo();
// riskBizInfoVo.setWarningObjectName(hygfMaintenanceTicketsDto.getStationName());
// riskBizInfoVo.setWarningObjectCode(idxBizPvWarningRecord.getKks());
// riskBizInfoVo.setSourceAttribution(stationMap.get(idxBizPvWarningRecord.getGatewayId()).getProjectOrgCode());
// riskBizInfoVo.setSourceAttributionDesc(idxBizPvWarningRecord.getStation());
// riskBizInfoVo.setWarningObjectType("hygfmaintenance");
// riskBizInfoVo.setWarningTime(DateUtil.now());
// riskBizInfoVo.setWarningObjectLinkUrl(null);
// List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>();
// RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo();
// dynamicDetailsVo.setTabName("预警详情");
// List<TableContentVo> tabContent =new ArrayList<>();
// TableContentVo tableContentVo1=new TableContentVo("1", "场站名称", idxBizPvWarningRecord.getStation(), "text");
// TableContentVo tableContentVo3=new TableContentVo("2", "子阵", idxBizPvWarningRecord.getSubarray(), "text");
// TableContentVo tableContentVo2=new TableContentVo("3", "设备名称", idxBizPvWarningRecord.getEquipmentName(), "text");
// TableContentVo tableContentVo4=new TableContentVo("4", "分析变量", idxBizPvWarningRecord.getPointName(), "text");
// TableContentVo tableContentVo5=new TableContentVo("5", "健康状态指数", idxBizPvWarningRecord.getHealthIndex(), "text");
// TableContentVo tableContentVo6=new TableContentVo("6", "健康等级", idxBizPvWarningRecord.getHealthLevel(), "text");
// TableContentVo tableContentVo7=new TableContentVo("7", "预警周期", idxBizPvWarningRecord.getWarningPeriod(), "text");
// TableContentVo tableContentVo8=new TableContentVo("8", "预警时间", idxBizPvWarningRecord.getRecDate(), "text");
// TableContentVo tableContentVo10=new TableContentVo("9", "预警等级", idxBizPvWarningRecord.getWarningName(), "text");
// TableContentVo tableContentVo11=new TableContentVo("10", "预警原因", idxBizPvWarningRecord.getContent(), "text");
// tabContent.add(tableContentVo1);
// tabContent.add(tableContentVo2);
// tabContent.add(tableContentVo3);
// tabContent.add(tableContentVo4);
// tabContent.add(tableContentVo5);
// tabContent.add(tableContentVo6);
// tabContent.add(tableContentVo7);
// tabContent.add(tableContentVo8);
// tabContent.add(tableContentVo10);
// tabContent.add(tableContentVo11);
// dynamicDetailsVo.setTabContent(tabContent);
// detailsVos.add(dynamicDetailsVo);
// riskBizInfoVo.setDynamicDetails(detailsVos);
// bizMessage.setBizInfo(riskBizInfoVo);
// 子系统@健康指数@预警周期
// String traceId2 = idxBizPvWarningRecord.getSubarray()+"@"+idxBizPvWarningRecord.getHealthLevel()+"@"+idxBizPvWarningRecord.getWarningPeriod();
// bizMessage.setTraceId2(traceId2);
try {
emqKeeper.getMqttClient().publish(WARNING_RESULT_MESSAGE, JSON.toJSONString(hygfMaintenanceTicketsDto).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (Exception exception) {
exception.printStackTrace();
}
} }
} }
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