Commit d55c9020 by 范富荣

优化对接思享驾接口逻辑

1 parent 0299db72
......@@ -241,7 +241,13 @@ public class AlarmElectricFenceService {
x.setIsAlarm(1);
//发送请求
try {
qyproAdminApiFacade.syncDeviceWarningContent(JSON.toJSONString(x));
qyproAdminApiFacade.syncDeviceWarningContent(
x.getId(),
x.getImei(),
x.getVinNumber(),
String.valueOf(x.getMessDataType()),
JSON.toJSONString(x)
);
} catch (Exception e) {
log.error("围栏报警第三方同步失败, item={}", x, e);
}
......
......@@ -158,10 +158,13 @@ public class AlarmWarnAnalyseService {
log.info("日期[{}],查询设备分离报警数据结束, 当前pageNum[{}]", date, pageNum);
break;
}
List<String> snList = deviceSeparationAlarmList.stream().flatMap(x -> {
List<String> snList = deviceSeparationAlarmList.stream().filter(x -> StringUtils.isNotBlank(x.getDeviceInfo())).flatMap(x -> {
String[] split = x.getDeviceInfo().split(";");
return Arrays.stream(split);
}).collect(Collectors.toList());
if (CollectionUtils.isEmpty(snList)) {
continue;
}
//根据设备号查询设备信息
List<Device> devices = deviceMapper.selectBySns(snList);
Map<String, Device> deviceMap = new HashMap<>();
......@@ -170,7 +173,7 @@ public class AlarmWarnAnalyseService {
deviceMap = devices.stream().collect(Collectors.toMap(Device::getSn, Function.identity()));
}
Map<String, Device> finalDeviceMap = deviceMap;
deviceSeparationAlarmList.forEach(x -> {
deviceSeparationAlarmList.stream().filter(x -> StringUtils.isNotBlank(x.getDeviceInfo())).forEach(x -> {
String[] split = x.getDeviceInfo().split(";");
for (String rawSn : split) {
String sn = StringUtils.trimToEmpty(rawSn);
......@@ -192,7 +195,13 @@ public class AlarmWarnAnalyseService {
}
}
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);
}
......
......@@ -38,14 +38,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);
......
......@@ -243,7 +243,13 @@ public class VehicleDeviceService {
}
//发送请求
try {
qyproAdminApiFacade.syncDeviceWarningContent(JSON.toJSONString(offlineAlarmInfo));
qyproAdminApiFacade.syncDeviceWarningContent(
offlineAlarmInfo.getId(),
offlineAlarmInfo.getImei(),
offlineAlarmInfo.getVinNumber(),
offlineAlarmInfo.getMessDataType(),
JSON.toJSONString(offlineAlarmInfo)
);
} catch (Exception e) {
log.error("离线报警第三方同步失败, item:{}", offlineAlarmInfo, e);
}
......
......@@ -199,7 +199,7 @@
select tvd.sn, tv.vin,tvd.wire_type as wireType,tdp.soc, tvd.created_date as createDate
from t_vehicle tv
left join t_vehicle_device tvd on tv.id =tvd.vehicle_id
left join t_device_power tdp on tvd.sn = tdp.sn and tdp.del_flag = 0
left join t_device_power tdp on tvd.sn = tdp.sn and tdp.del_flag = 0 and tdp.vd_id = tvd.id
where tvd.del_flag = 0
and tv.created_by in (
select id from t_user tu where tu.tenant_id =#{tenantId} and tu.del_flag =0
......
......@@ -37,4 +37,9 @@ public class VehicleDeviceServiceTest {
public void testPushSXJOfflineAlarmData() throws Exception {
Boolean flag = vehicleDeviceService.pushSXJOfflineAlarmData(null);
}
@Test
public void testPushSXJDeviceSeparationAlarmData() throws Exception {
Boolean flag = vehicleDeviceService.pushSXJDeviceSeparationAlarmData(null);
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!