调整监测告警逻辑
This commit is contained in:
parent
e91b89bd0c
commit
6c69ac15ad
|
|
@ -80,7 +80,7 @@ public class MybatisPlusGenerator {
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
new MybatisPlusGenerator().generator("surv_hisdata_livestockwater_error","surv_hisdata_orientwater_error");//指标
|
||||
new MybatisPlusGenerator().generator("surv_station_info");//指标
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.lanhai.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测站点表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/survStationInfo")
|
||||
public class SurvStationInfoController {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -132,8 +132,15 @@ public class SurvAlertRecord extends Model<SurvAlertRecord> {
|
|||
@TableField("ALERT_TIME")
|
||||
private Date alertTime;
|
||||
|
||||
|
||||
/**
|
||||
* 监测项
|
||||
* 监测项编号
|
||||
*/
|
||||
@TableField("ITEM_CODE")
|
||||
private String itemCode;
|
||||
|
||||
/**
|
||||
* 监测项名称
|
||||
*/
|
||||
@TableField("ITEM_NAME")
|
||||
private String itemName;
|
||||
|
|
@ -160,6 +167,32 @@ public class SurvAlertRecord extends Model<SurvAlertRecord> {
|
|||
private String orgMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 正常值
|
||||
*/
|
||||
@TableField("NORMAL_VALUE")
|
||||
private String normalValue;
|
||||
|
||||
/**
|
||||
* 监测值
|
||||
*/
|
||||
@TableField("SURV_VALUE")
|
||||
private String survValue;
|
||||
|
||||
|
||||
/**
|
||||
* 监测情况
|
||||
*/
|
||||
@TableField("READ_STATUS")
|
||||
private String readStatus;
|
||||
|
||||
/**
|
||||
* 监测单位
|
||||
*/
|
||||
@TableField("SURV_UNIT")
|
||||
private String survUnit;
|
||||
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,190 @@
|
|||
package com.lanhai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测站点表
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SurvStationInfo extends Model<SurvStationInfo> {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
@TableField("STATION_NAME")
|
||||
private String stationName;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("STATION_LATITUDE")
|
||||
private String stationLatitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField("STATION_LONGITUDE")
|
||||
private String stationLongitude;
|
||||
|
||||
/**
|
||||
* 站点类型,livestock=畜禽,orient=农田
|
||||
*/
|
||||
@TableField("STATION_TYPE")
|
||||
private String stationType;
|
||||
|
||||
/**
|
||||
* 所属企业ID
|
||||
*/
|
||||
@TableField("CORP_ID")
|
||||
private String corpId;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@TableField("SORT_NO")
|
||||
private Integer sortNo;
|
||||
|
||||
/**
|
||||
* 站点负责人
|
||||
*/
|
||||
@TableField("CONTACT_NAME")
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 站点编号
|
||||
*/
|
||||
@TableField("STATION_CODE")
|
||||
private String stationCode;
|
||||
|
||||
/**
|
||||
* 站点联系电话
|
||||
*/
|
||||
@TableField("CONTACT_PHONE")
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 建站时间
|
||||
*/
|
||||
@TableField("BUILD_TIME")
|
||||
private Date buildTime;
|
||||
|
||||
/**
|
||||
* 站点位置
|
||||
*/
|
||||
@TableField("STATION_LOCATION")
|
||||
private String stationLocation;
|
||||
|
||||
/**
|
||||
* 监测范围
|
||||
*/
|
||||
@TableField("SURV_RANGE")
|
||||
private String survRange;
|
||||
|
||||
/**
|
||||
* 监测对象;数组
|
||||
*/
|
||||
@TableField("SURV_OBJ")
|
||||
private String survObj;
|
||||
|
||||
/**
|
||||
* 监测频率
|
||||
*/
|
||||
@TableField("SURV_FREQUENCY")
|
||||
private String survFrequency;
|
||||
|
||||
/**
|
||||
* 租户号
|
||||
*/
|
||||
@TableField("TENANT_ID")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@TableField("RE_VISION")
|
||||
private Integer reVision;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("CREATED_BY")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("CREATE_TIME")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("UPDATED_BY")
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("UPDATED_TIME")
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
@TableField("IS_DEL")
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 站点图片
|
||||
*/
|
||||
@TableField("STATION_PIC")
|
||||
private String stationPic;
|
||||
|
||||
/**
|
||||
* 站点图标
|
||||
*/
|
||||
@TableField("STATION_ICON")
|
||||
private String stationIcon;
|
||||
|
||||
/**
|
||||
* 站点管理
|
||||
*/
|
||||
@TableField("STATION_ORG")
|
||||
private String stationOrg;
|
||||
|
||||
/**
|
||||
* 站点介绍
|
||||
*/
|
||||
@TableField("STATION_INTRO")
|
||||
private String stationIntro;
|
||||
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.lanhai.mapper;
|
||||
|
||||
import com.lanhai.entity.SurvStationInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测站点表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
public interface SurvStationInfoMapper extends BaseMapper<SurvStationInfo> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.lanhai.mapper.SurvStationInfoMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.lanhai.service;
|
||||
|
||||
import com.lanhai.entity.SurvStationInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测站点表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
public interface ISurvStationInfoService extends IService<SurvStationInfo> {
|
||||
|
||||
SurvStationInfo getByCode(String stationCode);
|
||||
}
|
||||
|
|
@ -9,10 +9,12 @@ import com.lanhai.constant.CommonConstant;
|
|||
import com.lanhai.constant.DeviceReadConstants;
|
||||
import com.lanhai.entity.SurvAlertRecord;
|
||||
import com.lanhai.entity.SurvDeviceDeploy;
|
||||
import com.lanhai.entity.SurvStationInfo;
|
||||
import com.lanhai.mapper.SurvAlertRecordMapper;
|
||||
import com.lanhai.service.IScEquZhibiaoService;
|
||||
import com.lanhai.service.ISurvAlertRecordService;
|
||||
import com.lanhai.service.ISurvDeviceDeployService;
|
||||
import com.lanhai.service.ISurvStationInfoService;
|
||||
import com.lanhai.util.DataUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -34,6 +36,8 @@ public class SurvAlertRecordServiceImpl extends ServiceImpl<SurvAlertRecordMappe
|
|||
private IScEquZhibiaoService zhibiaoService;
|
||||
@Autowired
|
||||
private ISurvDeviceDeployService deviceDeployService;
|
||||
@Autowired
|
||||
private ISurvStationInfoService survStationInfoService;
|
||||
|
||||
@Override
|
||||
public void saveBaojing(Map<String, String> baowenMap) {
|
||||
|
|
@ -187,38 +191,42 @@ public class SurvAlertRecordServiceImpl extends ServiceImpl<SurvAlertRecordMappe
|
|||
}
|
||||
|
||||
// List<VOEmailContent> mails = new ArrayList<VOEmailContent>();
|
||||
// if(StringUtils.isNotBlank(sb.toString()) || jsonarr.size()>0){
|
||||
// List<SurvAlertRecord> saveList = new ArrayList<>();
|
||||
// for (int i=0;i<jsonarr.size();i++) {
|
||||
// JSONObject jsonObject = jsonarr.getJSONObject(i);
|
||||
// SurvAlertRecord baojing = new SurvAlertRecord();
|
||||
if(StringUtils.isNotBlank(sb.toString()) || jsonarr.size()>0){
|
||||
List<SurvAlertRecord> saveList = new ArrayList<>();
|
||||
for (int i=0;i<jsonarr.size();i++) {
|
||||
JSONObject jsonObject = jsonarr.getJSONObject(i);
|
||||
SurvAlertRecord baojing = new SurvAlertRecord();
|
||||
// baojing.setFarmId(deviceDeploy.getFarmId());
|
||||
// baojing.setCorpId(deviceDeploy.getCompanyId());
|
||||
// baojing.setDeployId(jsonObject.getString("deployId"));
|
||||
// if(StringUtils.isNotBlank(baojing.getDeployId())){
|
||||
// SurvDeviceDeploy deploy = deviceDeployService.getById(baojing.getDeployId());
|
||||
// if(deploy!=null){
|
||||
// baojing.setDeviceName(StringUtils.isNotBlank(deploy.getCommonName())? deploy.getCommonName():deploy.getDeployRemark());
|
||||
// }
|
||||
// }
|
||||
// if(StringUtils.isBlank(baojing.getDeviceName())){
|
||||
// baojing.setDeviceName("物联网设备");
|
||||
// }
|
||||
// baojing.setCreatedBy("zhihang");
|
||||
// baojing.setCreateTime(new Date());
|
||||
// baojing.setAlertTime(DateUtil.parse(DataTime));
|
||||
// baojing.setDeployCode(mn);
|
||||
// baojing.setDeviceCode(jsonObject.getString("entityField"));//用于保存检测项字段
|
||||
//
|
||||
// baojing.setItemName(jsonObject.getString("name"));
|
||||
//// baojing.setAlertContent(sb.toString());
|
||||
// baojing.setAlertContent(jsonarr.toJSONString());
|
||||
// baojing.setReadStatus(jsonObject.getString("readStatus"));
|
||||
// baojing.setSurvValue(jsonObject.getString("val"));
|
||||
// baojing.setNormalValue(jsonObject.getString(CommonConstant.VAL_LOW)+"~"+jsonObject.getString(CommonConstant.VAL_HEIGHT));
|
||||
// baojing.setSurvUnit(jsonObject.getString("unit"));
|
||||
baojing.setDeployId(jsonObject.getString("deployId"));
|
||||
if(StringUtils.isNotBlank(baojing.getDeployId())){
|
||||
SurvDeviceDeploy deploy = deviceDeployService.getById(baojing.getDeployId());
|
||||
if(deploy!=null){
|
||||
baojing.setDeviceName(deploy.getDeployDes());
|
||||
}
|
||||
}
|
||||
if(StringUtils.isBlank(baojing.getDeviceName())){
|
||||
baojing.setDeviceName("物联网设备");
|
||||
}
|
||||
baojing.setCreatedBy("lanhai");
|
||||
baojing.setCreateTime(new Date());
|
||||
baojing.setAlertTime(DateUtil.parse(DataTime));
|
||||
baojing.setDeployCode(mn);
|
||||
baojing.setDeviceCode(deviceDeploy.getDeployCode());
|
||||
baojing.setStationCdoe(deviceDeploy.getStationCode());
|
||||
SurvStationInfo survStationInfo = survStationInfoService.getByCode(deviceDeploy.getStationCode());
|
||||
baojing.setStationName(survStationInfo!=null?survStationInfo.getStationName():"");
|
||||
baojing.setItemCode(jsonObject.getString("entityField"));
|
||||
|
||||
baojing.setItemName(jsonObject.getString("name"));
|
||||
// baojing.setAlertContent(sb.toString());
|
||||
baojing.setAlertContent(jsonarr.toJSONString());
|
||||
baojing.setReadStatus(jsonObject.getString("readStatus"));
|
||||
baojing.setSurvValue(jsonObject.getString("val"));
|
||||
baojing.setNormalValue(jsonObject.getString(CommonConstant.VAL_LOW)+"~"+jsonObject.getString(CommonConstant.VAL_HEIGHT));
|
||||
baojing.setSurvUnit(jsonObject.getString("unit"));
|
||||
// baojing.setNoticeEmail(jsonObject.getString("email"));
|
||||
// saveList.add(baojing);
|
||||
saveList.add(baojing);
|
||||
// if(StringUtils.isNotBlank(jsonObject.getString("email"))){
|
||||
// VOEmailContent voEmailContent = new VOEmailContent();
|
||||
// voEmailContent.setContent("设备:"+baojing.getDeviceName()+"-监测项-"+baojing.getItemName()+"于"+DataTime+"监测值为:"+baojing.getSurvValue()+baojing.getSurvUnit()+",设定阈值范围:"+baojing.getNormalValue());
|
||||
|
|
@ -226,10 +234,10 @@ public class SurvAlertRecordServiceImpl extends ServiceImpl<SurvAlertRecordMappe
|
|||
// voEmailContent.setMailBox(jsonObject.getString("email"));
|
||||
// mails.add(voEmailContent);
|
||||
// }
|
||||
// }
|
||||
// if(saveList.size()>0){
|
||||
// saveBatch(saveList);
|
||||
// }
|
||||
}
|
||||
if(saveList.size()>0){
|
||||
saveBatch(saveList);
|
||||
}
|
||||
// if(!mails.isEmpty()){
|
||||
// for (VOEmailContent mail : mails) {
|
||||
// log.error("======xxxxxxxxxxxxxxxxxxxxxxxxxx====预警触发发送邮件至:"+mail.getMailBox());
|
||||
|
|
@ -246,8 +254,8 @@ public class SurvAlertRecordServiceImpl extends ServiceImpl<SurvAlertRecordMappe
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.lanhai.service.Impl;
|
||||
|
||||
import com.lanhai.entity.SurvStationInfo;
|
||||
import com.lanhai.mapper.SurvStationInfoMapper;
|
||||
import com.lanhai.service.ISurvStationInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测站点表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
@Service
|
||||
public class SurvStationInfoServiceImpl extends ServiceImpl<SurvStationInfoMapper, SurvStationInfo> implements ISurvStationInfoService {
|
||||
|
||||
@Override
|
||||
public SurvStationInfo getByCode(String stationCode) {
|
||||
SurvStationInfo survStationInfo = lambdaQuery().eq(SurvStationInfo::getStationCode,stationCode)
|
||||
.orderByDesc(SurvStationInfo::getCreateTime)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
return survStationInfo;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue