Browse Source

1、修改导出报告代码;2、大气类型新增单位字段;3、接收灵嗅数据,格式化时间字段;

tags/V1.0.1^2
wanjing 1 year ago
parent
commit
a65148e6b1
7 changed files with 148 additions and 244 deletions
  1. +17
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java
  2. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/AirDataType.java
  3. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/report/ExportReportRequest.java
  4. +106
    -223
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/ExportReportService.java
  5. +16
    -17
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/GenerateReportWordService.java
  6. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/syncdata/SyncAirDataService.java
  7. +1
    -1
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/ExportReportServiceTest.java

+ 17
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java View File

@@ -23,6 +23,8 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils {

public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

public static String YYYY_MM_DD_HH_MM_SS_2 = "yyyy-MM-dd-HH-mm-ss";

private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
@@ -255,6 +257,21 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils {
}
}

public static String convert(String beforeFormat, String convertFormat, String dateString) {
if (StringUtils.isEmpty(dateString)) {
return "";
}
SimpleDateFormat format = new SimpleDateFormat(beforeFormat);
try {
Date date = format.parse(dateString);
SimpleDateFormat format2 = new SimpleDateFormat(convertFormat);
return format2.format(date);
} catch (ParseException e) {
e.printStackTrace();
return "";
}
}

public static void main(String[] args) {
// 当前时间
Date date = new Date(System.currentTimeMillis());

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/AirDataType.java View File

@@ -28,6 +28,11 @@ public class AirDataType extends BaseEntity {
*/
private String name;

/**
* 单位
*/
private String unit;

/**
* 检测方式
*/

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/report/ExportReportRequest.java View File

@@ -22,7 +22,7 @@ public class ExportReportRequest {
* 大气数据类型
*/
private String airDataType;
//private String airDataTypeId;
// private String airDataTypeId;

/**
* 网格大小
@@ -72,7 +72,7 @@ public class ExportReportRequest {
/**
* 单点浓度最低值
*/
private String singlePointConcentrationMix;
private String singlePointConcentrationMin;

/**
* 图片oss地址

+ 106
- 223
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/ExportReportService.java View File

@@ -1,5 +1,6 @@
package com.tuoheng.admin.service.airData.report;

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;
@@ -29,9 +30,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@Service
@@ -62,60 +63,36 @@ public class ExportReportService {
return result;
}
AirDataType airDataType = airDataTypeMapper.selectOne(Wrappers.<AirDataType>lambdaQuery()
.eq(AirDataType::getDataType,request.getAirDataType()));
if(ObjectUtil.isNull(airDataType)){
return JsonResult.error("大气数据类型为空");
.eq(AirDataType::getDataType, request.getAirDataType())
.eq(AirDataType::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isEmpty(airDataType)) {
log.info("导出报告,大气类型不存在,airDataType={}", request.getAirDataType());
throw new ServiceException("大气类型不存在");
}
AirDataExport airDataExport = this.checkAirDataExport(request,airDataType);
AirDataExport airDataExport = this.checkAirDataExport(request, airDataType);
if (ObjectUtil.isNotEmpty(airDataExport)) {
return JsonResult.success(airDataExport.getOssUrl(), "导出成功");
}
Inspection inspection = (Inspection) result.getData();


String filename = inspection.getName() + "-" + inspection.getCode() + "-" + airDataType.getDataType() + ".doc";
List<AirData> airDataList = airDataMapper.selectList(Wrappers.<AirData>lambdaQuery()
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.eq(AirData::getInspectionId, request.getInspectionId())
.orderByAsc(AirData::getCreateTime));
String detectionTime = "";
if (CollectionUtil.isNotEmpty(airDataList)) {
detectionTime = this.getDetectionTime(airDataList);
this.handle(request, airDataType, airDataList);
}
String filename = inspection.getName() + "-" + inspection.getCode() + "-" + airDataType.getDataType() + ".doc";
String filePath = UploadFileConfig.uploadFolder + "/report/" + filename;
File fd = new File(UploadFileConfig.uploadFolder + "/report");
if (!fd.exists()) {
fd.mkdirs();
}
AirData beginAirData = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getCUtcTime)
.last(" limit 1"));
AirData endAirData = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getCUtcTime)
.last(" limit 1"));

//根据大气数据类型进行判断
Map<String, String> dataTypeMap = this.getData(airDataType, request);

// 生成word
File f = new File(filePath);
if (!f.exists() || f.length() < 1000) {
String detectionTime = "";
if (ObjectUtil.isNotEmpty(beginAirData)) {
detectionTime += beginAirData.getCUtcTime();
}
detectionTime += "至";
if (ObjectUtil.isNotEmpty(endAirData)) {
detectionTime += endAirData.getCUtcTime();
}
String dataTypeMin = "";
String dataTypeMax = "";
String dataTypeCount = "";
String dataTypeAvg = "";

if(!dataTypeMap.isEmpty()){
dataTypeMin = dataTypeMap.get("min");
dataTypeMax = dataTypeMap.get("max");
dataTypeCount = dataTypeMap.get("count");
dataTypeAvg = dataTypeMap.get("avg");
}
result = generateReportWordService.buildWord(filePath, request, airDataType, detectionTime, dataTypeMin,dataTypeMax,dataTypeCount,dataTypeAvg,inspection.getEquipmentMountCode());
result = generateReportWordService.buildWord(filePath, request, airDataType, detectionTime, inspection.getEquipmentMountCode());
if (0 != result.getCode()) {
log.info("导出报告业务:生成word失败:{}", result.getMsg());
return result;
@@ -134,182 +111,6 @@ public class ExportReportService {
return JsonResult.success(ossUrl, "导出成功");
}

private Map<String, String> getData(AirDataType airDataType, ExportReportRequest request) {
List<AirData> airDataList = airDataMapper.selectList(Wrappers.<AirData>lambdaQuery()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode()));
Integer count = Math.toIntExact(airDataList.stream().count());
String dataTypeCount = String.valueOf(count);

String dataType = airDataType.getDataType();
//判断dataType值是哪一个
Map<String,String> dataTypeMap = new HashMap<>();
if(dataType.equals("co")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getCo)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getCo)
.last(" limit 1"));
Double co = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getCo());
co += tempCo;
}
String ndAvg = String.valueOf(co / count);
String coMax = airDataMax.getCo();
String coMin = airDataMin.getCo();
dataTypeMap.put("min",coMin);
dataTypeMap.put("max",coMax);
dataTypeMap.put("avg",ndAvg);

}
if(dataType.equals("pm_10")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getPm10)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getPm10)
.last(" limit 1"));
String pm10Max = airDataMax.getPm10();
String pm10Min = airDataMin.getPm10();
Double pm10 = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getPm10());
pm10 += tempCo;
}
String ndAvg = String.valueOf(pm10 / count);
dataTypeMap.put("min",pm10Min);
dataTypeMap.put("max",pm10Max);
dataTypeMap.put("avg",ndAvg);
}
if(dataType.equals("pm_2_5")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getPm25)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getPm25)
.last(" limit 1"));
Double pm25 = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getPm25());
pm25 += tempCo;
}
String ndAvg = String.valueOf(pm25 / count);
String pm25Max = airDataMax.getPm25();
String pm25Min = airDataMin.getPm25();
dataTypeMap.put("min",pm25Min);
dataTypeMap.put("max",pm25Max);
dataTypeMap.put("avg",ndAvg);
}
if(dataType.equals("so2")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getSo2)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getSo2)
.last(" limit 1"));
Double so2 = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getSo2());
so2 += tempCo;
}
String ndAvg = String.valueOf(so2 / count);
String so2Max = airDataMax.getSo2();
String so2Min = airDataMin.getSo2();
dataTypeMap.put("min",so2Min);
dataTypeMap.put("max",so2Max);
dataTypeMap.put("avg",ndAvg);
}
if(dataType.equals("vocs")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getVocs)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getVocs)
.last(" limit 1"));
String vocsMax = airDataMax.getVocs();
String vocsMin = airDataMin.getVocs();
Double vocs = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getVocs());
vocs += tempCo;
}
String ndAvg = String.valueOf(vocs / count);
dataTypeMap.put("min",vocsMin);
dataTypeMap.put("max",vocsMax);
dataTypeMap.put("avg",ndAvg);
}
if(dataType.equals("no2")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getNo2)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getNo2)
.last(" limit 1"));
Double no2 = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getNo2());
no2 += tempCo;
}
String ndAvg = String.valueOf(no2 / count);
String no2Max = airDataMax.getNo2();
String no2Min = airDataMin.getNo2();
dataTypeMap.put("min",no2Min);
dataTypeMap.put("max",no2Max);
dataTypeMap.put("avg",ndAvg);
}
if(dataType.equals("o3")){
AirData airDataMax = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByDesc(AirData::getO3)
.last(" limit 1"));
AirData airDataMin = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getO3)
.last(" limit 1"));
Double o3 = null;
for (AirData airData : airDataList) {
double tempCo = Double.parseDouble(airData.getO3());
o3 += tempCo;
}
String ndAvg = String.valueOf(o3 / count);
String o3Max = airDataMax.getO3();
String o3Min = airDataMin.getO3();
dataTypeMap.put("min",o3Min);
dataTypeMap.put("max",o3Max);
dataTypeMap.put("avg",ndAvg);
}
dataTypeMap.put("count",dataTypeCount);
return dataTypeMap;
}

/**
* 检查参数
*
@@ -337,20 +138,102 @@ public class ExportReportService {
return JsonResult.success(inspection);
}

private AirDataExport checkAirDataExport(ExportReportRequest request,AirDataType airDataType) {
private AirDataExport checkAirDataExport(ExportReportRequest request, AirDataType airDataType) {
AirDataExport airDataExport = airDataExportMapper.selectOne(new LambdaQueryWrapper<AirDataExport>()
.eq(AirDataExport::getInspectionId, request.getInspectionId())
.eq(AirDataExport::getAirDataTypeId, airDataType.getId())
.eq(AirDataExport::getExportType, "report")
.eq(AirDataExport::getGridSize, request.getGridSize())
.eq(AirDataExport::getMark, MarkEnum.VALID.getCode()));
.eq(AirDataExport::getMark, MarkEnum.VALID.getCode())
.last("limit 1"));
return airDataExport;
}

/**
* @param airDataList
* @return
*/
private String getDetectionTime(List<AirData> airDataList) {
AirData beginAirData = airDataList.get(0);
AirData endAirData = airDataList.get(airDataList.size() - 1);
String detectionTime = "";
if (ObjectUtil.isNotEmpty(beginAirData)) {
detectionTime += beginAirData.getCUtcTime();
}
detectionTime += "至";
if (ObjectUtil.isNotEmpty(endAirData)) {
detectionTime += endAirData.getCUtcTime();
}
return detectionTime;
}

private void handle(ExportReportRequest request, AirDataType airDataType, List<AirData> airDataList) {
List<Double> list = null;
AirData airDataMax = null;
AirData airDataMin = null;
String singlePointConcentrationMax = "";
String singlePointConcentrationMin = "";
if ("co".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getCo())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getCo()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getCo()))).get();
singlePointConcentrationMax = airDataMax.getCo();
singlePointConcentrationMin = airDataMin.getCo();
} else if ("pm_10".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getPm10())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getPm10()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getPm10()))).get();
singlePointConcentrationMax = airDataMax.getPm10();
singlePointConcentrationMin = airDataMin.getPm10();
} else if ("pm_2_5".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getPm25())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getPm25()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getPm25()))).get();
singlePointConcentrationMax = airDataMax.getPm25();
singlePointConcentrationMin = airDataMin.getPm25();
} else if ("so2".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getSo2())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getSo2()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getSo2()))).get();
singlePointConcentrationMax = airDataMax.getSo2();
singlePointConcentrationMin = airDataMin.getSo2();
} else if ("vocs".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getVocs())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getVocs()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getVocs()))).get();
singlePointConcentrationMax = airDataMax.getVocs();
singlePointConcentrationMin = airDataMin.getVocs();
} else if ("no2".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getNo2())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getNo2()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getNo2()))).get();
singlePointConcentrationMax = airDataMax.getNo2();
singlePointConcentrationMin = airDataMin.getNo2();
} else if ("o3".equals(airDataType.getDataType())) {
list = airDataList.stream().map(p -> Double.parseDouble(p.getO3())).collect(Collectors.toList());
airDataMax = airDataList.stream().max(Comparator.comparing(x -> Double.parseDouble(x.getO3()))).get();
airDataMin = airDataList.stream().min(Comparator.comparing(x -> Double.parseDouble(x.getO3()))).get();
singlePointConcentrationMax = airDataMax.getO3();
singlePointConcentrationMin = airDataMin.getO3();
} else {
log.info("大气类型,暂不提供, airDataType={}", airDataType.getDataType());
return;
}
double average = list.stream().collect(Collectors.averagingDouble(Double::doubleValue));
String averageConcentration = average + airDataType.getUnit();
singlePointConcentrationMax = singlePointConcentrationMax + " " + airDataType.getUnit() + "(" + airDataMax.getLongitude() + "E, " + airDataMax.getLatitude() + "N) " + airDataMax.getCUtcTime();
singlePointConcentrationMin = singlePointConcentrationMin + " " + airDataType.getUnit() + "(" + airDataMin.getLongitude() + "E, " + airDataMin.getLatitude() + "N) " + airDataMin.getCUtcTime();

request.setSamplingPointsNum(String.valueOf(airDataList.size()));
request.setAverageConcentration(averageConcentration);
request.setSinglePointConcentrationMax(singlePointConcentrationMax);
request.setSinglePointConcentrationMin(singlePointConcentrationMin);
}

private String uploadOss(String filePath, String filename) {
File file = new File(filePath);
InputStream in = null;
String fileUrl = "";
InputStream in;
String fileUrl;
try {
in = new FileInputStream(file);
aliyunOSSUtil.uploadFile2OSS(in, filename);

+ 16
- 17
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/GenerateReportWordService.java View File

@@ -28,7 +28,7 @@ public class GenerateReportWordService {
*
* @return
*/
public JsonResult buildWord(String filepath, ExportReportRequest request, AirDataType airDataType, String detectionTime,String dataTypeMin, String dataTypeMax,String dataTypeCount, String dataTypeAvg,String equipmentMountCode) {
public JsonResult buildWord(String filepath, ExportReportRequest request, AirDataType airDataType, String detectionTime,String equipmentMountCode) {
WordUtils wordUtils = new WordUtils();
wordUtils.getDocument().setPageSize(PageSize.A4);
wordUtils.getDocument().setMargins(71f, 71f, 72f, 72f);
@@ -39,22 +39,21 @@ public class GenerateReportWordService {
// String titleName = airDataType.getDataType() + "报告";
// wordUtils.insertTitlePattern(titleName, wordUtils.rtfGsBt1);

wordUtils.insertContext(airDataType.getDataType() + "浓度分布", 10, Font.BOLD, Element.ALIGN_LEFT, 20, 0, 0);

wordUtils.insertContext("检测时间:" + detectionTime, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("监测设备:" + equipmentMountCode, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("检测方式:" + airDataType.getDetection(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("采样点数量:" + dataTypeCount, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("检测区域网格平均尺寸:" + request.getAverageGridSize(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("总检测区域网格面积:" + request.getGridArea(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext("检测区域中心点经纬度:" + request.getCenterPointLongitudeAndLatitude(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "检测区域平均浓度:" + dataTypeAvg, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最高值:" + request.getGridConcentrationMax(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最小值:" + request.getGridConcentrationMix(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最高值:" + dataTypeMax, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最低值:" + dataTypeMin, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertImg(request.getOssUrl(), Image.ALIGN_CENTER, 400, 500, 100, 100, 100, 0);
wordUtils.insertImg(airDataType.getReferenceIndicatorHorizontalImage(), Image.ALIGN_CENTER, 100, 500, 100, 100, 100, 0);
wordUtils.insertContext(airDataType.getDataType() + "浓度分布", 14, Font.BOLD, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测时间:" + detectionTime, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("监测设备:" + equipmentMountCode, 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测方式:" + airDataType.getDetection(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("采样点数量:" + request.getSamplingPointsNum(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测区域网格平均尺寸:" + request.getAverageGridSize(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("总检测区域网格面积:" + request.getGridArea(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测区域中心点经纬度:" + request.getCenterPointLongitudeAndLatitude(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "检测区域平均浓度:" + request.getAverageConcentration(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最高值:" + request.getGridConcentrationMax(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最小值:" + request.getGridConcentrationMix(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最高值:" + request.getSinglePointConcentrationMax(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最低值:" + request.getSinglePointConcentrationMin(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertImg(request.getOssUrl(), Image.ALIGN_CENTER, 500, 400, 100, 100, 100, 0);
wordUtils.insertImg(airDataType.getReferenceIndicatorHorizontalImage(), Image.ALIGN_CENTER, 500, 10, 100, 10, 10, 0);
} catch (DocumentException e) {
log.info("生成报告word异常");
throw new RuntimeException(e);

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/syncdata/SyncAirDataService.java View File

@@ -58,7 +58,7 @@ public class SyncAirDataService {
airData.setHumidity(response.getHumidity()); // 湿度
airData.setHdop(response.getHdop()); // 水平精度因子
airData.setPressure(response.getPressure()); // 大气压
airData.setCUtcTime(response.getUtcTime()); // UTC时间
airData.setCUtcTime(DateUtils.convert(DateUtils.YYYY_MM_DD_HH_MM_SS_2, DateUtils.YYYY_MM_DD_HH_MM_SS, response.getUtcTime())); // UTC时间

Map<String, Object> airDataMap = response.getAirData();
String cl2 = this.getValue(airDataMap,"CL2(ppm)"); // 氯气(单位ppm)

+ 1
- 1
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/ExportReportServiceTest.java View File

@@ -35,7 +35,7 @@ public class ExportReportServiceTest {
request.setGridConcentrationMax("24714u/m31187726E318253N"); // 网格浓度最高值
request.setGridConcentrationMix("16000ug/m3(1187761E318291N)"); // 网格浓度最小值
request.setSinglePointConcentrationMax("25000ug/m3(1187718318252N)2022/04/29 14:06:40"); // 单点浓度最高值
request.setSinglePointConcentrationMix("16000ug/m3(1187753318286 N)2022/04/2914:02:21"); // 单点浓度最低值
request.setSinglePointConcentrationMin("16000ug/m3(1187753318286 N)2022/04/2914:02:21"); // 单点浓度最低值
request.setGridSize(1);

JSONObject json = (JSONObject) JSONObject.toJSON(request);

Loading…
Cancel
Save