|
@@ -12,6 +12,7 @@ import com.ruoyi.manage.mapper.EquipmentManageMapper;
|
|
|
import com.ruoyi.manage.mapper.WarnManageMapper;
|
|
|
import com.ruoyi.manage.service.IWarnManageService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -385,6 +386,7 @@ public class WarnManageServiceImpl implements IWarnManageService {
|
|
|
*/
|
|
|
public void addWarnManage(MqttMessage message, String algorithmType) {
|
|
|
try {
|
|
|
+ WarnManage warnManage = new WarnManage();
|
|
|
String payload = message.getPayload();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payload);
|
|
|
String equipmentIp = jsonObject.getString("equipmentIp");
|
|
@@ -394,22 +396,28 @@ public class WarnManageServiceImpl implements IWarnManageService {
|
|
|
Long channelId = jsonObject.getLong("channelId");
|
|
|
String parameterSet = jsonObject.getString("parameterSet");
|
|
|
String algorithmResult = jsonObject.getString("algorithmResult");
|
|
|
- String photoUrl = "http://114.99.51.58:15010/prod-api/profile" + jsonObject.getString("photoUrl");
|
|
|
- String videoUrl = jsonObject.getString("videoUrl");
|
|
|
- String rangName = jsonObject.getString("name");
|
|
|
- WarnManage warnManage = new WarnManage();
|
|
|
+ if (StringUtils.isNotEmpty(jsonObject.getString("photoUrl"))) {
|
|
|
+ String photoUrl = "http://114.99.51.58:15000/prod-api" + jsonObject.getString("photoUrl");
|
|
|
+ warnManage.setWarnImage(photoUrl);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(jsonObject.getString("videoUrl"))) {
|
|
|
+ warnManage.setVideoAddress("http://114.99.51.58:15000/prod-api" + jsonObject.getString("videoUrl"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(jsonObject.getString("name"))) {
|
|
|
+ warnManage.setRangName(jsonObject.getString("name"));
|
|
|
+ }
|
|
|
warnManage.setEquipmentIp(equipmentIp);
|
|
|
- warnManage.setEquipmentName(equipmentManageOld.getEquipmentName());
|
|
|
- warnManage.setEquipmentId(equipmentManageOld.getEquipmentId());
|
|
|
+ warnManage.setEquipmentName("未知设备");
|
|
|
+ if (ObjectUtils.isNotEmpty(equipmentManageOld)) {
|
|
|
+ warnManage.setEquipmentName(equipmentManageOld.getEquipmentName());
|
|
|
+ warnManage.setEquipmentId(equipmentManageOld.getEquipmentId());
|
|
|
+ }
|
|
|
warnManage.setChannelId(channelId);
|
|
|
warnManage.setParameterSet(parameterSet);
|
|
|
warnManage.setAlgorithmType(algorithmType);
|
|
|
warnManage.setReportStatus(algorithmResult);
|
|
|
- warnManage.setVideoAddress(videoUrl);
|
|
|
- warnManage.setWarnImage(photoUrl);
|
|
|
warnManage.setCreateTime(DateUtils.getNowDate());
|
|
|
warnManage.setWarnTime(DateUtils.getNowDate());
|
|
|
- warnManage.setRangName(rangName);
|
|
|
warnManageMapper.insertWarnManage(warnManage);
|
|
|
} catch (Exception e) {
|
|
|
log.info("新增告警信息异常:{}", e.getMessage());
|