Commit c4a52869 authored by suhuiguang's avatar suhuiguang

1.维保周期

parent dbd1a819
......@@ -41,6 +41,7 @@ import com.yeejoin.amos.maintenance.core.util.DateUtil;
import com.yeejoin.amos.maintenance.core.util.StringUtil;
import com.yeejoin.amos.maintenance.dao.entity.*;
import com.yeejoin.amos.maintenance.feign.RemoteSecurityService;
import com.yeejoin.amos.maintenance.mqtt.MqttGateway;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.common.util.CollectionUtils;
import org.assertj.core.util.Sets;
......@@ -101,9 +102,15 @@ public class CheckServiceImpl implements ICheckService {
@Autowired
IPointDao iPointDao;
@Autowired
MqttGateway mqttGateway;
@Value("${file.url}")
private String fileUrl;
final String CHECK_UPDATE_TOPIC = "maintenance/date/update";
@Override
public Page<CheckInfoVo> getCheckInfo(String toke, String product, String appKey, CheckInfoPageParam param) {
long total = checkMapper.countCheckInfoData(param);
......@@ -236,7 +243,14 @@ public class CheckServiceImpl implements ICheckService {
}
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), recordParam.getPointId(), recordParam.getPlanTaskId(), mtUserSeq);
//6.返回不合格记录
//6.消息广播最近维保日期
if(StringUtil.isNotEmpty(point.getOriginalId())){
JSONObject jsonObject = new JSONObject();
jsonObject.put("facilityId",point.getOriginalId());
jsonObject.put("checkTime",check.getCheckTime());
mqttGateway.publish(CHECK_UPDATE_TOPIC,jsonObject.toJSONString());
}
//7.返回不合格记录
return new CheckDto(check.getId(), unqualifiedCheckItemList);
} catch (Exception e) {
throw new Exception(e.getMessage());
......
package com.yeejoin.amos.maintenance.mqtt;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
/**
* @author DELL
*/
@Component
public class WebMqttComponent {
@Slf4j
public class MqttGateway {
@Autowired
private EmqKeeper emqKeeper;
public void publish(String topic, String jsonStr) {
try {
this.emqKeeper.getMqttClient().publish(topic, jsonStr.getBytes(), 1, false);
} catch (MqttPersistenceException e) {
e.printStackTrace();
} catch (MqttException e) {
e.printStackTrace();
log.error("消息发送失败:{}、{}、{}", e.getMessage(), topic, jsonStr);
}
}
}
......@@ -14,7 +14,7 @@ import com.yeejoin.amos.maintenance.common.enums.*;
import com.yeejoin.amos.maintenance.core.async.AsyncTask;
import com.yeejoin.amos.maintenance.dao.entity.*;
import com.yeejoin.amos.maintenance.feign.RemoteSecurityService;
import com.yeejoin.amos.maintenance.mqtt.WebMqttComponent;
import com.yeejoin.amos.maintenance.mqtt.MqttGateway;
import org.quartz.Job;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -76,7 +76,7 @@ public class JobService implements IJobService {
@Value("${amosRefresh.patrol.topic}")
private String patrolTopic;
@Autowired
private WebMqttComponent webMqttComponent;
private MqttGateway webMqttComponent;
@Override
@Transactional
......
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