|
|
@@ -2,19 +2,13 @@ package com.tuoheng.admin.service.airData.syncdata; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.tuoheng.admin.entity.domain.AirData; |
|
|
|
import com.tuoheng.admin.entity.domain.Inspection; |
|
|
|
import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; |
|
|
|
import com.tuoheng.admin.entity.third.LingXiuDataResponse; |
|
|
|
import com.tuoheng.admin.enums.AirportLineEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.InspectionTypeEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.AirDataMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
@@ -22,7 +16,6 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@@ -44,8 +37,8 @@ public class SyncAirDataService { |
|
|
|
log.info("收到灵嗅设备推送数据"); |
|
|
|
//校验参数值 |
|
|
|
JsonResult jsonResult = this.check(response); |
|
|
|
if(jsonResult.getCode() != 0){ |
|
|
|
log.info("校验失败:{}",jsonResult.getMsg()); |
|
|
|
if (jsonResult.getCode() != 0) { |
|
|
|
log.info("校验失败:{}", jsonResult.getMsg()); |
|
|
|
return jsonResult; |
|
|
|
} |
|
|
|
Inspection inspection = (Inspection) jsonResult.getData(); |
|
|
@@ -63,16 +56,18 @@ public class SyncAirDataService { |
|
|
|
airData.setHumidity(response.getHumidity()); // 湿度 |
|
|
|
airData.setHdop(response.getHdop()); // 水平精度因子 |
|
|
|
airData.setPressure(response.getPressure()); // 大气压 |
|
|
|
if (StringUtils.isNotEmpty(response.getUtcTime())) { |
|
|
|
String utcTime = DateUtils.convert(DateUtils.YYYY_MM_DD_HH_MM_SS_2, DateUtils.YYYY_MM_DD_HH_MM_SS, response.getUtcTime()); // UTC时间 |
|
|
|
Date dateTimeStr = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, utcTime); |
|
|
|
Date dateTime = DateUtils.addDateTimeToDate(dateTimeStr, 0, 8, 0, 0); |
|
|
|
String result = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, dateTime); |
|
|
|
airData.setCUtcTime(result); |
|
|
|
} |
|
|
|
airData.setCUtcTime(DateUtils.convert(DateUtils.YYYY_MM_DD_HH_MM_SS_2, DateUtils.YYYY_MM_DD_HH_MM_SS, response.getUtcTime())); // UTC时间 |
|
|
|
// if (StringUtils.isNotEmpty(response.getUtcTime())) { |
|
|
|
// String utcTime = DateUtils.convert(DateUtils.YYYY_MM_DD_HH_MM_SS_2, DateUtils.YYYY_MM_DD_HH_MM_SS, response.getUtcTime()); // UTC时间 |
|
|
|
// Date dateTimeStr = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, utcTime); |
|
|
|
// Date dateTime = DateUtils.addDateTimeToDate(dateTimeStr, 0, 8, 0, 0); |
|
|
|
// String result = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, dateTime); |
|
|
|
// airData.setCUtcTime(result); |
|
|
|
// } |
|
|
|
|
|
|
|
Map<String, Object> airDataMap = response.getAirData(); |
|
|
|
String cl2 = this.getValue(airDataMap,"CL2(ppm)"); // 氯气(单位ppm) |
|
|
|
String co = this.getValue(airDataMap,"CO(ppm)"); // 一氧化碳(单位ppm) |
|
|
|
String cl2 = this.getValue(airDataMap, "CL2(ppm)"); // 氯气(单位ppm) |
|
|
|
String co = this.getValue(airDataMap, "CO(ppm)"); // 一氧化碳(单位ppm) |
|
|
|
String co2 = this.getValue(airDataMap, "CO2(ppm)"); // 二氧化碳(单位ppm) |
|
|
|
String cxhy = this.getValue(airDataMap, "CxHy(%)"); // 碳氢化合物(单位%) |
|
|
|
String h2 = this.getValue(airDataMap, "H2(ppm)"); // 氢气(单位ppm) |
|
|
@@ -110,7 +105,7 @@ public class SyncAirDataService { |
|
|
|
airData.setPm1(pm_1_0); |
|
|
|
airData.setPm10(pm_10); |
|
|
|
airData.setPm25(pm_2_5); |
|
|
|
airData.setSo2(so2); |
|
|
|
airData.setSo2(this.getSo2(so2)); |
|
|
|
airData.setTsp(tsp); |
|
|
|
airData.setVocs(vocs); |
|
|
|
airData.setWrSo2(wrSo2); |
|
|
@@ -131,7 +126,6 @@ public class SyncAirDataService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param response |
|
|
|
* @return |
|
|
|
*/ |
|
|
@@ -166,10 +160,10 @@ public class SyncAirDataService { |
|
|
|
if (CollectionUtil.isNotEmpty(inspectionList) || inspectionList.size() != 0) { |
|
|
|
inspection = inspectionList.get(0); |
|
|
|
log.info("正在飞行的巡检任务,inspection={}", inspection); |
|
|
|
} else if(inspection == null){ |
|
|
|
} else if (inspection == null) { |
|
|
|
log.info("没有正在飞行的任务,无法关联推送的灵嗅数据,serial={}", response.getSerial()); |
|
|
|
return JsonResult.error("没有正在飞行的任务"); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
log.info("查询出的任务数据不存在"); |
|
|
|
} |
|
|
|
|
|
|
@@ -201,4 +195,15 @@ public class SyncAirDataService { |
|
|
|
} |
|
|
|
return o3; |
|
|
|
} |
|
|
|
|
|
|
|
private String getSo2(String so2) { |
|
|
|
if (StringUtils.isEmpty(so2)) { |
|
|
|
return "0.0"; |
|
|
|
} else { |
|
|
|
Double value = Double.valueOf(so2); |
|
|
|
value = value * 1000 * 64.07 / 22.4; |
|
|
|
return String.valueOf(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |