Commit 0ba40fb7 authored by caotao's avatar caotao

工单推送

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