Commit 2e61ce4e by 范富荣

优化对接思享驾接口逻辑

1 parent b27a705b
......@@ -151,7 +151,13 @@ public class AlarmJobService {
if (CollectionUtils.isNotEmpty(collect)) {
for (LightSensorAlarmItem item : collect) {
try {
qyproAdminApiFacade.syncDeviceWarningContent(JSON.toJSONString(item));
qyproAdminApiFacade.syncDeviceWarningContent(
item.getId(),
item.getImei(),
item.getVinNumber(),
String.valueOf(item.getMessDataType()),
JSON.toJSONString(item)
);
} catch (Exception e) {
log.error("光敏预警同步第三方失败, item:{}", item, e);
}
......@@ -269,7 +275,13 @@ public class AlarmJobService {
}
for (AbnormalGatherAlarmItem item : collect) {
try {
qyproAdminApiFacade.syncDeviceWarningContent(JSON.toJSONString(item));
qyproAdminApiFacade.syncDeviceWarningContent(
item.getId(),
item.getImei(),
item.getVinNumber(),
item.getMessDataType(),
JSON.toJSONString(item)
);
} catch (Exception e) {
log.error("异常聚集预警同步第三方失败, item:{}", item, e);
}
......@@ -310,7 +322,13 @@ public class AlarmJobService {
}
for (BlackAreaWarnRequest item : collect) {
try {
qyproAdminApiFacade.syncDeviceWarningContent(JSON.toJSONString(item));
qyproAdminApiFacade.syncDeviceWarningContent(
item.getId(),
item.getDeviceNumber(),
item.getVinNumber(),
String.valueOf(item.getMessDataType()),
JSON.toJSONString(item)
);
} catch (Exception e) {
log.error("黑区预警同步第三方失败, item:{}", item, e);
}
......@@ -345,8 +363,8 @@ public class AlarmJobService {
public void sendDeviceLocation(String date) {
Date now = new Date();
if (StringUtils.isBlank(date)) {
//取今日日期
date = DateUtil.formatDate(now);
//默认取昨日
date = DateUtil.formatDate(DateUtil.offsetDay(now, -1));
}
String beginTime = date + " 00:00:00";
String endTime = date + " 23:59:59";
......@@ -411,7 +429,10 @@ public class AlarmJobService {
}
DateTime parse = DateUtil.parse(trackPointDTO.getDateTime());
dataItem.setT(parse.getTime());
dataItem.setBat(x.getSoc());
//增加电量判空
if (x.getSoc() != null) {
dataItem.setBat(x.getSoc());
}
return dataItem;
}).filter(Objects::nonNull).collect(Collectors.toList());
// 发送 GPS 信息同步请求(第三方接口支持 Token 认证)
......
......@@ -39,14 +39,29 @@ public class QyproAdminApiFacade implements DisposableBean {
/**
* 预警信息内容格式同步:POST {@value #API_DEVICE_WARNING_CONTENT},Token 模式(与 {@link ApiClient#main} 示例一致)。
*
* @param jsonBody application/json 请求体
* @param id 设备ID
* @param imei IMEI号
* @param vinNumber VIN号
* @param messDataType 消息类型
* @param contentJson 内容JSON
* @throws ApiClient.ApiException 业务 code 非 200 或解析失败
*/
public void syncDeviceWarningContent(String jsonBody) {
public void syncDeviceWarningContent(String id, String imei, String vinNumber, String messDataType, String contentJson) {
if (StringUtils.isAnyBlank(id, imei, vinNumber)) {
log.warn("Qypro warning-content 参数缺失,跳过请求 id={}, imei={}, vinNumber={}", id, imei, vinNumber);
return;
}
ApiClient client = getOrCreateClient();
if (client == null) {
return;
}
JSONObject payload = new JSONObject();
payload.put("id", id);
payload.put("imei", imei);
payload.put("vin_number", vinNumber);
payload.put("mess_data_type", messDataType);
payload.put("content", contentJson);
String jsonBody = payload.toJSONString();
for (int attempt = 1; attempt <= WARNING_CONTENT_MAX_ATTEMPTS; attempt++) {
log.info("Qypro warning-content 请求 attempt={}/{} api={} body={}",
attempt, WARNING_CONTENT_MAX_ATTEMPTS, API_DEVICE_WARNING_CONTENT, jsonBody);
......
......@@ -23,7 +23,7 @@ public class RegularStopoverPointJob implements SimpleJob {
try {
log.info("开始推送车辆常停地,参数:{}", shardingContext.getJobParameter());
// 处理数据
alarmJobService.sendRegularStopoverPointData();
//alarmJobService.sendRegularStopoverPointData();
log.info("推送车辆常停地完成,参数:{}", shardingContext.getJobParameter());
} catch (Exception e) {
log.error("推送车辆常停地异常,参数:{}", shardingContext.getJobParameter(), e);
......
......@@ -40,7 +40,7 @@ public class AlarmJobServiceTest {
@Test
public void testSendAggregateAlarmMsg() {
alarmJobService.sendAggregateAlarmMsg(null, 2);
alarmJobService.sendAggregateAlarmMsg(null, 3);
}
@Test
......@@ -59,7 +59,8 @@ public class AlarmJobServiceTest {
@Test
public void testSendDeviceLocation() {
String date = "2025-12-01";
String date = "2025-02-20";
String sn = "1510922145";
alarmJobService.sendDeviceLocation(date);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!