Merge remote-tracking branch 'origin/xc' into xc
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
-- QH_WAT_MONITOR_DATA 新增 EVENT_ID(事件ID)和 LOCATE_TIME(定位时间)字段
|
||||||
|
-- 数据库:118-DM 达梦数据库,SQL 全大写规范
|
||||||
|
ALTER TABLE "QH_WAT_MONITOR_DATA" ADD "EVENT_ID" VARCHAR(64) DEFAULT NULL;
|
||||||
|
ALTER TABLE "QH_WAT_MONITOR_DATA" ADD "LOCATE_TIME" DATETIME DEFAULT NULL;
|
||||||
|
|
||||||
|
COMMENT ON COLUMN "QH_WAT_MONITOR_DATA"."EVENT_ID" IS '事件ID';
|
||||||
|
COMMENT ON COLUMN "QH_WAT_MONITOR_DATA"."LOCATE_TIME" IS '定位时间';
|
||||||
|
|
||||||
|
CREATE INDEX "IDX_EVENT_ID" ON "QH_WAT_MONITOR_DATA"("EVENT_ID");
|
||||||
|
CREATE INDEX "IDX_WATCH_NO_EVENT_ID" ON "QH_WAT_MONITOR_DATA"("WATCH_NO", "EVENT_ID");
|
||||||
+14
@@ -52,4 +52,18 @@ public class AbnormalEvent extends BaseUser {
|
|||||||
private Date bindDate;
|
private Date bindDate;
|
||||||
@Schema(title = "重点指标用户(0:非重点指标用户 1:大病异常 2:慢病异常 3:指标异常)")
|
@Schema(title = "重点指标用户(0:非重点指标用户 1:大病异常 2:慢病异常 3:指标异常)")
|
||||||
private List<WatchKeyUser> keyUserList;
|
private List<WatchKeyUser> keyUserList;
|
||||||
|
/**
|
||||||
|
* 事件ID(用于告警事件与GPS位置更新关联的唯一标识)
|
||||||
|
*/
|
||||||
|
@Excel(name = "事件ID", width = 32, orderNum = "12")
|
||||||
|
@Schema(title = "事件ID")
|
||||||
|
private String eventId;
|
||||||
|
/**
|
||||||
|
* 定位时间(手表定时上报的GPS定位时间)
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "定位时间", format = "yyyy-MM-dd HH:mm:ss", width = 20, orderNum = "13")
|
||||||
|
@Schema(title = "定位时间")
|
||||||
|
private Date locateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -151,6 +151,20 @@ public class WatchMonitorData implements Serializable {
|
|||||||
@Excel(name = "部门编码", width = 15)
|
@Excel(name = "部门编码", width = 15)
|
||||||
@Schema(title = "部门编码")
|
@Schema(title = "部门编码")
|
||||||
private java.lang.String orgCode;
|
private java.lang.String orgCode;
|
||||||
|
/**
|
||||||
|
* 事件ID(用于告警事件与GPS位置更新关联的唯一标识)
|
||||||
|
*/
|
||||||
|
@Excel(name = "事件ID", width = 32)
|
||||||
|
@Schema(title = "事件ID")
|
||||||
|
private java.lang.String eventId;
|
||||||
|
/**
|
||||||
|
* 定位时间(手表上报的GPS定位时间,定时上报场景使用)
|
||||||
|
*/
|
||||||
|
@Excel(name = "定位时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(title = "定位时间")
|
||||||
|
private java.util.Date locateTime;
|
||||||
|
|
||||||
@Schema(title = "员工编号")
|
@Schema(title = "员工编号")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|||||||
@@ -45,4 +45,15 @@ public class WatchNotifyVo implements Serializable {
|
|||||||
private Date warnTime;
|
private Date warnTime;
|
||||||
|
|
||||||
private String gpsErrorMsg;
|
private String gpsErrorMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件ID(用于告警事件与GPS位置更新关联的唯一标识)
|
||||||
|
*/
|
||||||
|
private String eventId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定位时间(手表上报的GPS定位时间,定时上报场景使用)
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date locateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -44,6 +44,21 @@ public class WatchApiController {
|
|||||||
return watchMonitorDataService.notice(json);
|
return watchMonitorDataService.notice(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新告警事件GPS位置信息接口
|
||||||
|
* 根据 watchNo + eventId 联合定位已有告警数据;
|
||||||
|
* 仅更新GPS相关字段,不推送大屏与短信;
|
||||||
|
* 内部会调用高德接口进行GPS84→GCJ02坐标转换与地址反查。
|
||||||
|
*
|
||||||
|
* @param json 入参(watchNo、eventId、lon、lat、address、locateTime、gpsErrorMsg)
|
||||||
|
* @return 处理结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateMonitorGps")
|
||||||
|
@Operation(summary = "更新告警事件GPS位置信息")
|
||||||
|
public AjaxJson updateMonitorGps(@RequestBody JSONObject json) {
|
||||||
|
return watchMonitorDataService.updateMonitorGps(json);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/setData")
|
@GetMapping("/setData")
|
||||||
public AjaxJson setData() {
|
public AjaxJson setData() {
|
||||||
AjaxJson ajaxJson = new AjaxJson();
|
AjaxJson ajaxJson = new AjaxJson();
|
||||||
|
|||||||
+11
@@ -38,6 +38,17 @@ public interface IWatchMonitorDataService extends IService<WatchMonitorData> {
|
|||||||
*/
|
*/
|
||||||
AjaxJson notice(JSONObject jsonObject);
|
AjaxJson notice(JSONObject jsonObject);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新告警事件GPS位置信息
|
||||||
|
* 根据 watchNo + eventId 联合定位已有告警数据;
|
||||||
|
* 缺失任一定位字段则忽略;已存在GPS信息则忽略;
|
||||||
|
* 仅更新数据,不推送大屏与短信。
|
||||||
|
*
|
||||||
|
* @param jsonObject 入参(含 watchNo、eventId、lon、lat、address、locateTime、gpsErrorMsg 等)
|
||||||
|
* @return 处理结果
|
||||||
|
*/
|
||||||
|
AjaxJson updateMonitorGps(JSONObject jsonObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理历史数据 orgCode为空的问题
|
* 处理历史数据 orgCode为空的问题
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
+99
@@ -265,6 +265,102 @@ public class WatchMonitorDataServiceImpl extends ServiceImpl<WatchMonitorDataMap
|
|||||||
return ajaxJson;
|
return ajaxJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新告警事件GPS位置信息
|
||||||
|
* 根据 watchNo + eventId 联合定位已有告警数据;
|
||||||
|
* watchNo 或 eventId 任一缺失则忽略;
|
||||||
|
* 已存在 GPS 信息则忽略本次更新;
|
||||||
|
* 参考 createMonitorData 进行 GPS84 → GCJ02 坐标转换 + 高德地址反查;
|
||||||
|
* 仅更新数据,不推送大屏与短信。
|
||||||
|
*
|
||||||
|
* @param json 入参(含 watchNo、eventId、lon、lat、address、locateTime、gpsErrorMsg 等)
|
||||||
|
* @return 处理结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxJson updateMonitorGps(JSONObject json) {
|
||||||
|
GlobalUtils.setHttpFeignToken();
|
||||||
|
|
||||||
|
AjaxJson ajaxJson = new AjaxJson();
|
||||||
|
logger.info("接收更新告警事件GPS信息=={}", json.toJSONString());
|
||||||
|
|
||||||
|
WatchNotifyVo data = json.toJavaObject(WatchNotifyVo.class);
|
||||||
|
|
||||||
|
// watchNo 或 eventId 任一缺失则忽略
|
||||||
|
if (StrUtil.isBlank(data.getWatchNo()) || StrUtil.isBlank(data.getEventId())) {
|
||||||
|
logger.warn("更新GPS信息缺失关键定位字段,忽略本次请求 watchNo={}, eventId={}", data.getWatchNo(), data.getEventId());
|
||||||
|
ajaxJson.setSuccess(true);
|
||||||
|
return ajaxJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
// watchNo + eventId 联合定位已有告警数据
|
||||||
|
LambdaQueryWrapper<WatchMonitorData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(WatchMonitorData::getWatchNo, data.getWatchNo())
|
||||||
|
.eq(WatchMonitorData::getEventId, data.getEventId());
|
||||||
|
List<WatchMonitorData> existList = this.list(queryWrapper);
|
||||||
|
if (CollUtil.isEmpty(existList)) {
|
||||||
|
logger.warn("更新GPS信息失败,未匹配到告警记录 watchNo={}, eventId={}", data.getWatchNo(), data.getEventId());
|
||||||
|
ajaxJson.setSuccess(true);
|
||||||
|
return ajaxJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已存在GPS信息则忽略本次更新,避免覆盖已有有效坐标
|
||||||
|
boolean hasGps = existList.stream().anyMatch(m -> m.getLon() != null && m.getLat() != null);
|
||||||
|
if (hasGps) {
|
||||||
|
logger.info("告警记录已有GPS信息,忽略本次更新 watchNo={}, eventId={}", data.getWatchNo(), data.getEventId());
|
||||||
|
ajaxJson.setSuccess(true);
|
||||||
|
return ajaxJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算高德坐标与高德地址(参考 createMonitorData 逻辑)
|
||||||
|
WatchMonitorData updateEntity = new WatchMonitorData();
|
||||||
|
updateEntity.setLon(data.getLon());
|
||||||
|
updateEntity.setLat(data.getLat());
|
||||||
|
updateEntity.setAddress(data.getAddress());
|
||||||
|
updateEntity.setGpsErrorMsg(data.getGpsErrorMsg());
|
||||||
|
updateEntity.setLocateTime(data.getLocateTime());
|
||||||
|
|
||||||
|
if (Stream.of(data.getLon(), data.getLat()).allMatch(value -> ObjUtil.isNotEmpty(value) && value != 0)) {
|
||||||
|
Gps gps = GPS84ToGCJ02(data.getLon(), data.getLat());
|
||||||
|
if (null != gps) {
|
||||||
|
// 写入高德坐标
|
||||||
|
updateEntity.setLonGd(BigDecimal.valueOf(gps.getLongitude()));
|
||||||
|
updateEntity.setLatGd(BigDecimal.valueOf(gps.getLatitude()));
|
||||||
|
// 调用高德接口获取地址信息
|
||||||
|
AmapResultVo amapResultVo = amapService.getFormattedAddress(gps.getLongitude(), gps.getLatitude(), 5000);
|
||||||
|
if (amapResultVo.isSuccess()) {
|
||||||
|
updateEntity.setAddressGd(amapResultVo.getAddress());
|
||||||
|
updateEntity.setAddress(amapResultVo.getAddress());
|
||||||
|
} else {
|
||||||
|
String originError = StrUtil.isBlank(updateEntity.getGpsErrorMsg()) ? "" : updateEntity.getGpsErrorMsg() + ";";
|
||||||
|
updateEntity.setGpsErrorMsg(originError + amapResultVo.getErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅更新 GPS 相关字段,不推送大屏、不发短信
|
||||||
|
boolean updated = this.lambdaUpdate()
|
||||||
|
.eq(WatchMonitorData::getWatchNo, data.getWatchNo())
|
||||||
|
.eq(WatchMonitorData::getEventId, data.getEventId())
|
||||||
|
.set(WatchMonitorData::getLon, updateEntity.getLon())
|
||||||
|
.set(WatchMonitorData::getLat, updateEntity.getLat())
|
||||||
|
.set(WatchMonitorData::getAddress, updateEntity.getAddress())
|
||||||
|
.set(WatchMonitorData::getLonGd, updateEntity.getLonGd())
|
||||||
|
.set(WatchMonitorData::getLatGd, updateEntity.getLatGd())
|
||||||
|
.set(WatchMonitorData::getAddressGd, updateEntity.getAddressGd())
|
||||||
|
.set(WatchMonitorData::getGpsErrorMsg, updateEntity.getGpsErrorMsg())
|
||||||
|
.set(WatchMonitorData::getLocateTime, updateEntity.getLocateTime())
|
||||||
|
.update();
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
logger.warn("更新GPS信息失败 watchNo={}, eventId={}", data.getWatchNo(), data.getEventId());
|
||||||
|
} else {
|
||||||
|
logger.info("更新GPS信息成功 watchNo={}, eventId={}, 共更新{}条", data.getWatchNo(), data.getEventId(), existList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
ajaxJson.setSuccess(true);
|
||||||
|
return ajaxJson;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建异常数据
|
* 构建异常数据
|
||||||
*
|
*
|
||||||
@@ -272,13 +368,16 @@ public class WatchMonitorDataServiceImpl extends ServiceImpl<WatchMonitorDataMap
|
|||||||
* @return 异常数据
|
* @return 异常数据
|
||||||
*/
|
*/
|
||||||
private WatchMonitorData createMonitorData(WatchNotifyVo data) {
|
private WatchMonitorData createMonitorData(WatchNotifyVo data) {
|
||||||
|
|
||||||
log.info("开始构建异常数据 => {}", JSONObject.toJSONString(data));
|
log.info("开始构建异常数据 => {}", JSONObject.toJSONString(data));
|
||||||
WatchMonitorData monitorDataEntity = new WatchMonitorData();
|
WatchMonitorData monitorDataEntity = new WatchMonitorData();
|
||||||
monitorDataEntity.setAddress(data.getAddress());
|
monitorDataEntity.setAddress(data.getAddress());
|
||||||
monitorDataEntity.setWatchNo(data.getWatchNo());
|
monitorDataEntity.setWatchNo(data.getWatchNo());
|
||||||
monitorDataEntity.setLon(data.getLon());
|
monitorDataEntity.setLon(data.getLon());
|
||||||
monitorDataEntity.setLat(data.getLat());
|
monitorDataEntity.setLat(data.getLat());
|
||||||
|
monitorDataEntity.setLocateTime(data.getLocateTime());
|
||||||
monitorDataEntity.setEventType(data.getEventType());
|
monitorDataEntity.setEventType(data.getEventType());
|
||||||
|
monitorDataEntity.setEventId(data.getEventId());
|
||||||
monitorDataEntity.setDataValue(data.getDataValue());
|
monitorDataEntity.setDataValue(data.getDataValue());
|
||||||
monitorDataEntity.setCreateDate(data.getCreateTime());
|
monitorDataEntity.setCreateDate(data.getCreateTime());
|
||||||
monitorDataEntity.setWarnTime(data.getWarnTime());
|
monitorDataEntity.setWarnTime(data.getWarnTime());
|
||||||
|
|||||||
Reference in New Issue
Block a user