Kaynağa Gözat

修改导出报告代码

tags/V1.0.1^2
wanjing 1 yıl önce
ebeveyn
işleme
c8789489a2
3 değiştirilmiş dosya ile 19 ekleme ve 26 silme
  1. +3
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/ExportReportService.java
  2. +15
    -16
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/GenerateReportWordService.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/utils/WordUtils.java

+ 3
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/ExportReportService.java Dosyayı Görüntüle

@@ -57,34 +57,28 @@ public class ExportReportService {
log.info("导出报告:校验失败:{}", result.getMsg());
return result;
}

AirDataExport airDataExport = this.checkAirDataExport(request);
if (ObjectUtil.isNotEmpty(airDataExport)) {
return JsonResult.success( airDataExport.getOssUrl(), "导出成功");
return JsonResult.success(airDataExport.getOssUrl(), "导出成功");
}

Inspection inspection = (Inspection) result.getData();
AirDataType airDataType = airDataTypeMapper.selectById(request.getAirDataTypeId());

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())
.orderByDesc(AirData::getCUtcTime)
.orderByAsc(AirData::getCUtcTime)
.last(" limit 1"));

AirData endAirData = airDataMapper.selectOne(new LambdaQueryWrapper<AirData>()
.eq(AirData::getInspectionId, request.getInspectionId())
.eq(AirData::getMark, MarkEnum.VALID.getCode())
.orderByAsc(AirData::getCUtcTime)
.orderByDesc(AirData::getCUtcTime)
.last(" limit 1"));

// 生成word
File f = new File(filePath);
if (!f.exists() || f.length() < 1000) {

+ 15
- 16
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/report/GenerateReportWordService.java Dosyayı Görüntüle

@@ -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("采样点数量:" + request.getSamplingPointsNum(), 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() + "检测区域平均浓度:" + request.getAverageConcentration(), 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() + "单点浓度最高值:" + request.getSinglePointConcentrationMax(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最低值:" + request.getSinglePointConcentrationMix(), 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, 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("监测设备:" + equipmentMountCode, 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测方式:" + airDataType.getDetection(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("采样点数量:" + request.getSamplingPointsNum(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测区域网格平均尺寸:" + request.getAverageGridSize(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("总检测区域网格面积:" + request.getGridArea(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext("检测区域中心点经纬度:" + request.getCenterPointLongitudeAndLatitude(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "检测区域平均浓度:" + request.getAverageConcentration(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最高值:" + request.getGridConcentrationMax(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "网格浓度最小值:" + request.getGridConcentrationMix(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最高值:" + request.getSinglePointConcentrationMax(), 12, Font.NORMAL, Element.ALIGN_LEFT, 20, 2, 2);
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最低值:" + request.getSinglePointConcentrationMix(), 12, 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/utils/WordUtils.java Dosyayı Görüntüle

@@ -227,7 +227,7 @@ public class WordUtils {
* @throws IOException
* @throws com.lowagie.text.DocumentException
*/
public void insertImg(String imgUrl, int imageAlign, int height, int weight, int percent, int heightPercent, int weightPercent, int rotation) throws MalformedURLException, IOException, DocumentException {
public void insertImg(String imgUrl, int imageAlign, int weight, int height, int percent, int heightPercent, int weightPercent, int rotation) throws MalformedURLException, IOException, DocumentException {
// 添加图片
Image img = Image.getInstance(imgUrl);
if (img == null)

Yükleniyor…
İptal
Kaydet