Commit 0ba40fb7 authored by caotao's avatar caotao

工单推送

1.消息发送代码编写提交。 2.消息接收代码编写提交。
parent 6dc2be23
......@@ -49,7 +49,7 @@ public class HYGFMaintenanceTicketsDto extends BaseDto {
* 告警开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private DateTime warningEndTime;
private String warningEndTime;
/**
* 告警时长
*/
......
......@@ -5,7 +5,9 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterWarnDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterWarn;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
......@@ -19,11 +21,18 @@ public interface TdHygfJpInverterWarnMapper extends BaseMapper<TdHygfJpInverterW
List<Map<String, Object>> getCountTdHygfJpInverterWarn(@Param("dto") List<JpStation> dto);
List<TdHygfJpInverterWarnDto> list(@Param("param") TdHygfJpInverterWarnDto tdHygfJpInverterWarnDto);
@Select(" SELECT * from house_pv_data. td_hygf_jp_inverter_warn limit 0,10")
List<TdHygfJpInverterWarnDto> listAll();
TdHygfJpInverterWarnDto getByTime(@Param("createdTime") long createdTime);
List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size);
int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content);
}
@Select("SELECT * from td_hygf_jp_inverter_warn WHERE (third_station_id = #{thirdStationId} AND sn_code = #{sncode} AND created_time = #{createdTime})")
TdHygfJpInverterWarn getInverTerWarnByparams(@Param("createdTime") long createdTime, @Param("sncode") String snCode, @Param("thirdStationId") String thirdStationId);
}
......@@ -22,6 +22,8 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@Component
@Slf4j
......@@ -57,23 +59,26 @@ public class MaintenanceResultHandlerMessage extends EmqxListener {
@Async("async")
public void JxiopUpdateMaintenance(JSONObject jsonObject) {
if(jsonObject.containsKey("rawData")) {
if (jsonObject.containsKey("rawData")) {
JSONObject rawData = jsonObject.getJSONObject("rawData");
JSONObject bizInfo = rawData.getJSONObject("bizInfo");
JSONArray jsonArray = bizInfo.getJSONArray("dynamicDetails");
Map<String, Object> specialMap = new HashMap<>();
if (jsonArray.size() > 0) {
jsonObject = (JSONObject) jsonArray.get(0);
specialMap = jsonObject.get("specialMap") == null ? null : jsonObject.getJSONObject("specialMap").toJavaObject(Map.class);
}
HYGFMaintenanceTickets hygfMaintenanceTickets = new HYGFMaintenanceTickets();
String warningObjectName = "";
String warningObjectCode = "";//station_id@inverter_sn@maintenance_id@warn_id
String[] codes = warningObjectCode.split("@");
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("station_id", codes[0]));
TdHygfJpInverterWarn tdHygfJpInverterWarn = tdHygfJpInverterWarnMapper.selectOne(new QueryWrapper<TdHygfJpInverterWarn>()
.eq("thrid_station_id", codes[0])
.eq("sn_code", codes[1])
.eq("created_time", codes[3])
);
String stationid=specialMap.get("stationId") == null ? null : specialMap.get("stationId").toString();
Long warningId = Long.valueOf( specialMap.get("warningId").toString());
String sncode = specialMap.get("inverterSncode").toString();
String mantainancePersonId = specialMap.get("maintenancePersonId").toString();
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_station_id", stationid));
TdHygfJpInverterWarn tdHygfJpInverterWarn = tdHygfJpInverterWarnMapper.getInverTerWarnByparams(warningId,sncode,stationid);
hygfMaintenanceTickets.setHandlerStatus("未处理");
Maintenance maintenance = maintenanceMapper.selectById(codes[2]);
Maintenance maintenance = maintenanceMapper.selectOne(new QueryWrapper<Maintenance>().eq("sequence_nbr",mantainancePersonId));
if (ObjectUtil.isNotEmpty(maintenance)) {
hygfMaintenanceTickets.setMaintenancePersonId(codes[2]);
hygfMaintenanceTickets.setMaintenancePersonId(mantainancePersonId);
hygfMaintenanceTickets.setMaintenancePersonName(maintenance.getName());
hygfMaintenanceTickets.setMaintenancePersonPhone(maintenance.getTelephone());
}
......@@ -97,7 +102,7 @@ public class MaintenanceResultHandlerMessage extends EmqxListener {
}
if (ObjectUtil.isNotEmpty(tdHygfJpInverterWarn)) {
//snCode
hygfMaintenanceTickets.setInverterSn(codes[1]);
hygfMaintenanceTickets.setInverterSn(sncode);
//告警等级
hygfMaintenanceTickets.setWarningLevel(tdHygfJpInverterWarn.getLevel());
......
......@@ -52,6 +52,7 @@ public class HYGFMaintenanceTicketsServiceImpl extends BaseService<HYGFMaintenan
specialMap.put("stationId",hygfMaintenanceTicketsDto.getStationId());
//电站名称
specialMap.put("stationName",hygfMaintenanceTicketsDto.getStationName());
specialMap.put("inverterSncode",hygfMaintenanceTicketsDto.getInverterSn());
//告警id
specialMap.put("warningId",hygfMaintenanceTicketsDto.getWarningId());
if(ObjectUtil.isNotEmpty(hygfMaintenanceTicketsDto.getWarningId())){
......@@ -64,7 +65,7 @@ public class HYGFMaintenanceTicketsServiceImpl extends BaseService<HYGFMaintenan
//告警开始时间
specialMap.put("warningStartTime",hygfMaintenanceTicketsDto.getWarningStartTime());
}
specialMap.put("maintenance_person_id",hygfMaintenanceTicketsDto.getMaintenancePersonId());
specialMap.put("maintenancePersonId",hygfMaintenanceTicketsDto.getMaintenancePersonId());
//电站联系人
specialMap.put("stationContact",hygfMaintenanceTicketsDto.getStationContact());
//电站电话
......@@ -129,7 +130,7 @@ public class HYGFMaintenanceTicketsServiceImpl extends BaseService<HYGFMaintenan
// 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);
emqKeeper.getMqttClient().publish(WARNING_RESULT_MESSAGE, JSON.toJSONString(messageMain).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (Exception exception) {
exception.printStackTrace();
}
......
......@@ -86,7 +86,7 @@ public class TdHygfJpInverterWarnServiceImpl
* 列表查询 示例
*/
public List<TdHygfJpInverterWarnDto> queryForTdHygfJpInverterWarnList() {
return this.queryForList("", false);
return this.getBaseMapper().listAll();
}
public TdHygfJpInverterWarnDto queryByCreatedTime(long createdTime) {
......
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