楼下报告输出
This commit is contained in:
@@ -54,6 +54,35 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- WordToHtml .doc .odcx poi -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 操作excel的库 注意版本保持一致 poi poi-ooxml poi-scratchpad -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--poi-ooxml和*poi-ooxml-schemas*是poi对2007及以上版本的扩充。-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>4.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.njcn.gather.report.controller;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.gather.report.pojo.DevReportParam;
|
||||||
|
import com.njcn.gather.report.service.IReportService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/9 14:02
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "报表管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/report")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ReportController extends BaseController {
|
||||||
|
|
||||||
|
private final IReportService reportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 此方法临时的,给楼下使用,实际需要优化
|
||||||
|
* 1、不同的设备需要不同的模板;
|
||||||
|
* 2、数据页的内容暂时是固定的,后期可能是动态的;
|
||||||
|
*/
|
||||||
|
@OperateInfo
|
||||||
|
@PostMapping("/generateReport")
|
||||||
|
@ApiOperation("生成测试报告")
|
||||||
|
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||||
|
public void generateReport(@RequestBody DevReportParam devReportParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("list");
|
||||||
|
LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam);
|
||||||
|
reportService.generateReport(devReportParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.gather.report.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/9 20:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DevReportParam implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划ID
|
||||||
|
*/
|
||||||
|
private String planId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 被检设备ID
|
||||||
|
*/
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.njcn.gather.report.service;
|
||||||
|
|
||||||
|
import com.njcn.gather.report.pojo.DevReportParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/9 20:59
|
||||||
|
*/
|
||||||
|
public interface IReportService {
|
||||||
|
void generateReport(DevReportParam devReportParam);
|
||||||
|
}
|
||||||
@@ -0,0 +1,448 @@
|
|||||||
|
package com.njcn.gather.report.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||||
|
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
|
||||||
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||||
|
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
|
||||||
|
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||||
|
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
|
||||||
|
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||||
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
|
import com.njcn.gather.report.pojo.DevReportParam;
|
||||||
|
import com.njcn.gather.report.service.IReportService;
|
||||||
|
import com.njcn.gather.report.utils.WordUtil;
|
||||||
|
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||||
|
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||||
|
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||||
|
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||||
|
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/9 21:00
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ReportServiceImpl implements IReportService {
|
||||||
|
|
||||||
|
private final IPqDevService iPqDevService;
|
||||||
|
|
||||||
|
private final IDictDataService dictDataService;
|
||||||
|
|
||||||
|
private final IAdPlanService adPlanService;
|
||||||
|
|
||||||
|
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||||
|
|
||||||
|
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||||
|
|
||||||
|
private final AdNonHarmonicService adNonHarmonicService;
|
||||||
|
|
||||||
|
private final AdHarmonicService adHarmonicService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateReport(DevReportParam devReportParam) {
|
||||||
|
// 读取模板文件
|
||||||
|
Resource baseModel = new ClassPathResource("model/BaseModel.docx");
|
||||||
|
try (FileInputStream baseModelFis = new FileInputStream(baseModel.getFile())) {
|
||||||
|
// 加载Word文档
|
||||||
|
XWPFDocument baseModelDocument = new XWPFDocument(baseModelFis);
|
||||||
|
|
||||||
|
// 处理基础模版中的信息
|
||||||
|
dealBaseModel(baseModelDocument, devReportParam);
|
||||||
|
// 处理数据页中的信息
|
||||||
|
dealDataModel(baseModelDocument, devReportParam);
|
||||||
|
//最终文件输出的路径
|
||||||
|
FileOutputStream out = new FileOutputStream("C:\\Users\\hongawen\\Desktop\\testModel\\BaseDataModel" + DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_PATTERN) + ".docx");
|
||||||
|
// 4. 保存新的Word文档
|
||||||
|
try {
|
||||||
|
baseModelDocument.write(out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException("生成报告文件失败");
|
||||||
|
}
|
||||||
|
out.close();
|
||||||
|
System.out.println("报告生成成功!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理基础模版中的信息,非数据页报告
|
||||||
|
*
|
||||||
|
* @param baseModelDocument 模板文件
|
||||||
|
* @param devReportParam 被检设备参数
|
||||||
|
*/
|
||||||
|
private void dealBaseModel(XWPFDocument baseModelDocument, DevReportParam devReportParam) {
|
||||||
|
// 首先获取非数据页中需要的信息
|
||||||
|
Map<String, String> baseModelMap = new HashMap<>(16);
|
||||||
|
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
||||||
|
// 获取设备型号
|
||||||
|
DictData devTypeDictData = dictDataService.getDictDataById(pqDevVO.getDevType());
|
||||||
|
baseModelMap.put("${devType}", devTypeDictData.getName());
|
||||||
|
// 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死
|
||||||
|
baseModelMap.put("${userName}", "管理员");
|
||||||
|
// 调试日期
|
||||||
|
baseModelMap.put("${testDate}", DateUtil.format(new Date(), DatePattern.CHINESE_DATE_PATTERN));
|
||||||
|
// 装置编码
|
||||||
|
baseModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||||
|
// 额定电流
|
||||||
|
baseModelMap.put("${devCurr}", pqDevVO.getDevCurr().toString().concat("A"));
|
||||||
|
// 额定电压
|
||||||
|
baseModelMap.put("${devVolt}", pqDevVO.getDevVolt().toString().concat("V"));
|
||||||
|
|
||||||
|
// 共有多少通道参与测试
|
||||||
|
// if (CollectionUtil.isEmpty(pqDevById.getMonitorList())) {
|
||||||
|
// baseModelMap.put("${count}", "0");
|
||||||
|
// } else {
|
||||||
|
// baseModelMap.put("${count}", pqDevById.getMonitorList().size() + "");
|
||||||
|
// }
|
||||||
|
|
||||||
|
baseModelMap.put("${count}", pqDevVO.getDevChns().toString());
|
||||||
|
|
||||||
|
// 替换模板中的信息,避免信息丢失,段落和表格均参与替换
|
||||||
|
WordUtil.replacePlaceholdersInParagraphs(baseModelDocument, baseModelMap);
|
||||||
|
WordUtil.replacePlaceholdersInTables(baseModelDocument, baseModelMap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据页的信息
|
||||||
|
*
|
||||||
|
* @param baseModelDocument 非数据页的内容
|
||||||
|
* @param devReportParam 查询参数
|
||||||
|
*/
|
||||||
|
private void dealDataModel(XWPFDocument baseModelDocument, DevReportParam devReportParam) throws IOException {
|
||||||
|
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
||||||
|
AdPlan adPlan = adPlanService.getById(devReportParam.getPlanId());
|
||||||
|
String scriptId = adPlan.getScriptId();
|
||||||
|
Integer devChns = pqDevVO.getDevChns();
|
||||||
|
for (int i = 1; i <= devChns; i++) {
|
||||||
|
Resource dataModel = new ClassPathResource("model/BaseDataModel.docx");
|
||||||
|
FileInputStream dataModelFis = new FileInputStream(dataModel.getFile());
|
||||||
|
XWPFDocument dataModelDocumentTemp = new XWPFDocument(dataModelFis);
|
||||||
|
|
||||||
|
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||||
|
singleNonHarmParam.setPlanCode(adPlan.getCode());
|
||||||
|
singleNonHarmParam.setDevId(pqDevVO.getId());
|
||||||
|
singleNonHarmParam.setChannelNo(i);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||||
|
dataModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||||
|
dataModelMap.put("${total}", pqDevVO.getDevChns().toString());
|
||||||
|
dataModelMap.put("${count}", i + "");
|
||||||
|
// 区分谐波和非谐波数据
|
||||||
|
// 谐波类
|
||||||
|
|
||||||
|
|
||||||
|
// 非谐波类
|
||||||
|
// 57V电压 电压&相角 index 不用计算了,固定为1
|
||||||
|
// Integer testItemIndex = getTestItemIndex(scriptId, "e797c4b940389404e64fb92e4507c5f4", "Base", "VOL", 57);
|
||||||
|
// 获取输出脚本ID
|
||||||
|
Integer testItemIndex = 1;
|
||||||
|
// String pqScriptCheckDataService = getPqScriptCheckDataByScriptId(scriptId,testItemIndex,1,Arrays.asList("A","B","C"));
|
||||||
|
String pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "57Ua", "57Ub", "57Uc");
|
||||||
|
|
||||||
|
// 57V相角
|
||||||
|
testItemIndex = 1;
|
||||||
|
pqScriptCheckDataService = "e8bbfaad7a3fa343d3c46d345fb45fa3";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "57UaA", "57UbA", "57UcA");
|
||||||
|
|
||||||
|
// 10V电压
|
||||||
|
testItemIndex = 2;
|
||||||
|
pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "10Ua", "10Ub", "10Uc");
|
||||||
|
|
||||||
|
// 5A 电流
|
||||||
|
testItemIndex = 3;
|
||||||
|
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "5Ia", "5Ib", "5Ic");
|
||||||
|
|
||||||
|
// 5A 电流相角
|
||||||
|
testItemIndex = 3;
|
||||||
|
pqScriptCheckDataService = "fdffc6b5dfdc8751b9fde9b599b8ea51";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "5IaA", "5IbA", "5IcA");
|
||||||
|
|
||||||
|
// 1A 电流
|
||||||
|
testItemIndex = 4;
|
||||||
|
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "1Ia", "1Ib", "1Ic");
|
||||||
|
|
||||||
|
// 电压偏差
|
||||||
|
testItemIndex = 5;
|
||||||
|
pqScriptCheckDataService = "148faabd2630aaac0b70be8609075f69";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValue(singleNonHarmParam, dataModelMap, "DELTA_Ua", "DELTA_Ub", "DELTA_Uc");
|
||||||
|
|
||||||
|
// 三相电压不平衡度
|
||||||
|
testItemIndex = 6;
|
||||||
|
pqScriptCheckDataService = "9e9910f3627870c7fcf5846342f29d26";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueT(singleNonHarmParam, dataModelMap, "V_UNBAN");
|
||||||
|
|
||||||
|
|
||||||
|
// 频率 45
|
||||||
|
testItemIndex = 7;
|
||||||
|
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ45");
|
||||||
|
|
||||||
|
|
||||||
|
// 频率 50
|
||||||
|
testItemIndex = 7;
|
||||||
|
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ50");
|
||||||
|
|
||||||
|
|
||||||
|
// 频率 55
|
||||||
|
testItemIndex = 9;
|
||||||
|
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ55");
|
||||||
|
|
||||||
|
// 谐波电压,少了基波 todo...
|
||||||
|
testItemIndex = 10;
|
||||||
|
pqScriptCheckDataService = "cce92410f1902897a61f644d875f2216";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Uha", "Uhb", "Uhc", 57.74);
|
||||||
|
|
||||||
|
// 谐波电电流,少了基波 todo...
|
||||||
|
testItemIndex = 11;
|
||||||
|
pqScriptCheckDataService = "3e5e384d38485ca4242152fba336de1d";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Iha", "Ihb", "Ihc", 1);
|
||||||
|
|
||||||
|
// 间谐波电压
|
||||||
|
testItemIndex = 12;
|
||||||
|
pqScriptCheckDataService = "d57ea0e085ecf6c4e9f4da09b948befe";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InUa", "InUb", "InUc", 57.74);
|
||||||
|
|
||||||
|
// 间谐波电流
|
||||||
|
testItemIndex = 13;
|
||||||
|
pqScriptCheckDataService = "6bc58769dcbb2f83a13ff965a20a3cf3";
|
||||||
|
// 获取数据
|
||||||
|
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||||
|
singleNonHarmParam.setSort(testItemIndex);
|
||||||
|
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InIa", "InIb", "InIc", 1);
|
||||||
|
|
||||||
|
|
||||||
|
// 替换文档内容
|
||||||
|
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
|
||||||
|
WordUtil.replacePlaceholdersInTables(dataModelDocumentTemp, dataModelMap);
|
||||||
|
WordUtil.appendDocument(baseModelDocument, dataModelDocumentTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充谐波Map数据
|
||||||
|
*/
|
||||||
|
private void fillMapValueHarm(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol, double baseValue) {
|
||||||
|
AdHarmonicResult adHarmonicResult = adHarmonicService.getSingleResult(singleNonHarmParam);
|
||||||
|
if (Objects.nonNull(adHarmonicResult)) {
|
||||||
|
// 要处理 2 5 7 11 23 35 43 50
|
||||||
|
dataModelMap.put("${" + aSymbol + "2}", devValue(adHarmonicResult.getAValue2(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "2}", devValue(adHarmonicResult.getBValue2(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "2}", devValue(adHarmonicResult.getCValue2(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "5}", devValue(adHarmonicResult.getAValue5(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "5}", devValue(adHarmonicResult.getBValue5(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "5}", devValue(adHarmonicResult.getCValue5(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "7}", devValue(adHarmonicResult.getAValue7(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "7}", devValue(adHarmonicResult.getBValue7(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "7}", devValue(adHarmonicResult.getCValue7(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "11}", devValue(adHarmonicResult.getAValue11(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "11}", devValue(adHarmonicResult.getBValue11(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "11}", devValue(adHarmonicResult.getCValue11(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "23}", devValue(adHarmonicResult.getAValue23(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "23}", devValue(adHarmonicResult.getBValue23(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "23}", devValue(adHarmonicResult.getCValue23(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "35}", devValue(adHarmonicResult.getAValue35(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "35}", devValue(adHarmonicResult.getBValue35(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "35}", devValue(adHarmonicResult.getCValue35(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "43}", devValue(adHarmonicResult.getAValue43(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "43}", devValue(adHarmonicResult.getBValue43(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "43}", devValue(adHarmonicResult.getCValue43(), baseValue));
|
||||||
|
|
||||||
|
dataModelMap.put("${" + aSymbol + "50}", devValue(adHarmonicResult.getAValue50(), baseValue));
|
||||||
|
dataModelMap.put("${" + bSymbol + "50}", devValue(adHarmonicResult.getBValue50(), baseValue));
|
||||||
|
dataModelMap.put("${" + cSymbol + "50}", devValue(adHarmonicResult.getCValue50(), baseValue));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String devValue(String dataJson, double baseValue) {
|
||||||
|
DetectionData tempA = JSONUtil.toBean(dataJson, DetectionData.class);
|
||||||
|
if (Objects.nonNull(tempA) && Objects.nonNull(tempA.getData())) {
|
||||||
|
return doubleRound(4, (tempA.getData()/100) * baseValue);
|
||||||
|
}
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充非谐波Map数据,ABC三相
|
||||||
|
*/
|
||||||
|
private void fillMapValue(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol) {
|
||||||
|
AdNonHarmonicResult adNonHarmonicResult = adNonHarmonicService.getSingleResult(singleNonHarmParam);
|
||||||
|
if (Objects.nonNull(adNonHarmonicResult)) {
|
||||||
|
dataModelMap.put("${".concat(aSymbol).concat("}"), devValue(adNonHarmonicResult.getAValue(), 1));
|
||||||
|
dataModelMap.put("${".concat(bSymbol).concat("}"), devValue(adNonHarmonicResult.getBValue(), 1));
|
||||||
|
dataModelMap.put("${".concat(cSymbol).concat("}"), devValue(adNonHarmonicResult.getCValue(), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充非谐波Map数据,T相
|
||||||
|
*/
|
||||||
|
private void fillMapValueT(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String tSymbol) {
|
||||||
|
AdNonHarmonicResult adNonHarmonicResult = adNonHarmonicService.getSingleResult(singleNonHarmParam);
|
||||||
|
if (Objects.nonNull(adNonHarmonicResult)) {
|
||||||
|
dataModelMap.put("${".concat(tSymbol).concat("}"), devValue(adNonHarmonicResult.getTValue(), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getPqScriptCheckDataByScriptId(String scriptId, Integer index, Integer errFlag, List<String> phase) {
|
||||||
|
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// todo... 不参与比较的数据没有了
|
||||||
|
queryWrapper.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||||
|
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||||
|
.in(PqScriptCheckData::getPhase, phase)
|
||||||
|
.eq(PqScriptCheckData::getIndex, index);
|
||||||
|
List<PqScriptCheckData> list = pqScriptCheckDataService.list(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
return list.get(0).getValueType();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
String path = "F:\\gitea\\fusionForce\\CN_Gather\\entrance\\src\\main\\resources\\model\\BaseDataModel.docx";
|
||||||
|
FileInputStream dataModelFis = new FileInputStream(new File(path));
|
||||||
|
XWPFDocument dataModelDocumentTemp = new XWPFDocument(dataModelFis);
|
||||||
|
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||||
|
dataModelMap.put("${CreateId}", "123");
|
||||||
|
dataModelMap.put("${total}", "123");
|
||||||
|
dataModelMap.put("${count}", "1");
|
||||||
|
dataModelMap.put("${57Ua}", "123456");
|
||||||
|
dataModelMap.put("${Uha1}", "123456");
|
||||||
|
dataModelMap.put("${Uha2}", "123456");
|
||||||
|
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
|
||||||
|
WordUtil.replacePlaceholdersInTables(dataModelDocumentTemp, dataModelMap);
|
||||||
|
//最终文件输出的路径
|
||||||
|
FileOutputStream out = new FileOutputStream("C:\\Users\\hongawen\\Desktop\\testModel\\BaseDataModel" + DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_PATTERN) + ".docx");
|
||||||
|
// 4. 保存新的Word文档
|
||||||
|
try {
|
||||||
|
dataModelDocumentTemp.write(out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException("生成报告文件失败");
|
||||||
|
}
|
||||||
|
out.close();
|
||||||
|
System.out.println("报告生成成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取测试小项的index
|
||||||
|
* 注:测试项下发的ABCT的index均是一样的
|
||||||
|
*/
|
||||||
|
private Integer getTestItemIndex(String scriptId, String sourceScriptId, String subType, String valueType, Integer value) {
|
||||||
|
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(PqScriptDtls::getScriptId, scriptId)
|
||||||
|
.eq(PqScriptDtls::getScriptType, sourceScriptId)
|
||||||
|
.eq(PqScriptDtls::getScriptSubType, subType)
|
||||||
|
.eq(PqScriptDtls::getValueType, valueType)
|
||||||
|
.in(PqScriptDtls::getPhase, Arrays.asList("A", "B", "C"))
|
||||||
|
.eq(PqScriptDtls::getValue, value);
|
||||||
|
List<PqScriptDtls> pqScriptDtls = pqScriptDtlsService.list(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(pqScriptDtls)) {
|
||||||
|
return pqScriptDtls.get(0).getIndex();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数返回double的四舍五入值
|
||||||
|
*
|
||||||
|
* @param i 保留的位数
|
||||||
|
* @param value double原值
|
||||||
|
*/
|
||||||
|
public static String doubleRound(int i, double value) {
|
||||||
|
BigDecimal bp = new BigDecimal(value);
|
||||||
|
return String.format("%.4f", bp.setScale(i, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package com.njcn.gather.report.utils;
|
||||||
|
|
||||||
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/9 20:52
|
||||||
|
*/
|
||||||
|
public class WordUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将源文档的内容(包括段落、表格等)追加到目标文档中
|
||||||
|
*
|
||||||
|
* @param target 目标文档
|
||||||
|
* @param source 源文档
|
||||||
|
*/
|
||||||
|
public static void appendDocument(XWPFDocument target, XWPFDocument source) {
|
||||||
|
// 在追加内容之前,插入分页符
|
||||||
|
// insertPageBreak(target);
|
||||||
|
// 遍历源文档的所有块(段落、表格等)
|
||||||
|
source.getBodyElements().forEach(bodyElement -> {
|
||||||
|
switch (bodyElement.getElementType()) {
|
||||||
|
case PARAGRAPH:
|
||||||
|
// 处理段落
|
||||||
|
XWPFParagraph sourceParagraph = (XWPFParagraph) bodyElement;
|
||||||
|
XWPFParagraph newParagraph = target.createParagraph();
|
||||||
|
newParagraph.getCTP().set(sourceParagraph.getCTP());
|
||||||
|
break;
|
||||||
|
case TABLE:
|
||||||
|
// 处理表格
|
||||||
|
XWPFTable sourceTable = (XWPFTable) bodyElement;
|
||||||
|
XWPFTable newTable = target.createTable();
|
||||||
|
newTable.getCTTbl().set(sourceTable.getCTTbl());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 针对其他类型(如图片、页眉页脚等)可以扩展处理逻辑
|
||||||
|
System.out.println("未处理的内容类型:" + bodyElement.getElementType());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void insertPageBreak(XWPFDocument target) {
|
||||||
|
if(!isDocumentEmpty(target)){
|
||||||
|
// 获取最后一个页面的段落
|
||||||
|
XWPFParagraph pageBreakParagraph = getLastPageParagraph(target);
|
||||||
|
// 设置分页符
|
||||||
|
pageBreakParagraph.setPageBreak(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDocumentEmpty(XWPFDocument document) {
|
||||||
|
// 检查段落
|
||||||
|
List<XWPFParagraph> paragraphs = document.getParagraphs();
|
||||||
|
if (paragraphs != null && !paragraphs.isEmpty()) {
|
||||||
|
for (XWPFParagraph paragraph : paragraphs) {
|
||||||
|
if (paragraph.getText() != null && !paragraph.getText().trim().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表格
|
||||||
|
List<XWPFTable> tables = document.getTables();
|
||||||
|
if (tables != null && !tables.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XWPFParagraph getLastPageParagraph(XWPFDocument document) {
|
||||||
|
XWPFParagraph lastPageParagraph = null;
|
||||||
|
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||||
|
lastPageParagraph = paragraph;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastPageParagraph;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean containsPageBreak(XWPFParagraph paragraph) {
|
||||||
|
for (XWPFRun run : paragraph.getRuns()) {
|
||||||
|
if (run.getText(0) != null && run.getText(0).contains("\f")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换表格中的占位符
|
||||||
|
* @param document 文档
|
||||||
|
* @param placeholders 待替换的占位符
|
||||||
|
*/
|
||||||
|
public static void replacePlaceholdersInTables(XWPFDocument document, Map<String, String> placeholders) {
|
||||||
|
for (XWPFTable table : document.getTables()) {
|
||||||
|
for (XWPFTableRow row : table.getRows()) {
|
||||||
|
for (XWPFTableCell cell : row.getTableCells()) {
|
||||||
|
for (XWPFParagraph paragraph : cell.getParagraphs()) {
|
||||||
|
List<XWPFRun> runs = paragraph.getRuns();
|
||||||
|
if (runs != null) {
|
||||||
|
for (XWPFRun run : runs) {
|
||||||
|
String text = run.getText(0);
|
||||||
|
if (text != null) {
|
||||||
|
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||||
|
text = text.replace(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
run.setText(text, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换段落中的占位符
|
||||||
|
* @param document 文档
|
||||||
|
* @param placeholders 待替换的占位符
|
||||||
|
*/
|
||||||
|
public static void replacePlaceholdersInParagraphs(XWPFDocument document, Map<String, String> placeholders) {
|
||||||
|
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||||
|
List<XWPFRun> runs = paragraph.getRuns();
|
||||||
|
if (runs != null) {
|
||||||
|
for (XWPFRun run : runs) {
|
||||||
|
String text = run.getText(0);
|
||||||
|
if (text != null) {
|
||||||
|
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||||
|
text = text.replace(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
run.setText(text, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,4 @@
|
|||||||
* 被检设备管理
|
* 被检设备管理
|
||||||
* 检测脚本管理
|
* 检测脚本管理
|
||||||
* 误差体系管理
|
* 误差体系管理
|
||||||
* 检测源管理
|
* 检测源管理
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +18,6 @@ import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
|||||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.HttpResultUtil;
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
import com.sun.xml.internal.bind.v2.runtime.output.SAXOutput;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|||||||
@@ -65,6 +65,14 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
druid:
|
druid:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
url: jdbc:mysql://127.0.0.1:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||||
username: root
|
username: root
|
||||||
password: njcnpqs
|
password: njcnpqs
|
||||||
#初始化建立物理连接的个数、最小、最大连接数
|
#初始化建立物理连接的个数、最小、最大连接数
|
||||||
|
|||||||
BIN
entrance/src/main/resources/model/BaseDataModel.docx
Normal file
BIN
entrance/src/main/resources/model/BaseDataModel.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/BaseModel.docx
Normal file
BIN
entrance/src/main/resources/model/BaseModel.docx
Normal file
Binary file not shown.
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.gather.storage.pojo.param;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2025/1/10 16:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SingleNonHarmParam implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测计划编码
|
||||||
|
*/
|
||||||
|
private Integer planCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 被检设备ID
|
||||||
|
*/
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道数
|
||||||
|
*/
|
||||||
|
private Integer channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试项类型Id
|
||||||
|
*/
|
||||||
|
private String adType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试项所在脚本的位置
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.storage.service;
|
package com.njcn.gather.storage.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||||
@@ -20,7 +21,6 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
|||||||
* 根据设备ID和通道号获取谐波结果
|
* 根据设备ID和通道号获取谐波结果
|
||||||
*
|
*
|
||||||
* @param scriptId 脚本id
|
* @param scriptId 脚本id
|
||||||
* @param sort 序号列表
|
|
||||||
* @param deviceId 设备ID
|
* @param deviceId 设备ID
|
||||||
* @param chnNum 通道号,从1开始
|
* @param chnNum 通道号,从1开始
|
||||||
* @param code 计划code
|
* @param code 计划code
|
||||||
@@ -45,4 +45,6 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
|||||||
|
|
||||||
|
|
||||||
List<Integer> getIndex(StorageParam param);
|
List<Integer> getIndex(StorageParam param);
|
||||||
|
|
||||||
|
AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.storage.service;
|
package com.njcn.gather.storage.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||||
@@ -39,4 +40,10 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param);
|
Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数查询指定非谐波结果
|
||||||
|
* @param singleNonHarmParam 查询参数
|
||||||
|
*/
|
||||||
|
AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.gather.storage.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -11,6 +12,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||||
import com.njcn.gather.storage.mapper.AdHarmonicMappper;
|
import com.njcn.gather.storage.mapper.AdHarmonicMappper;
|
||||||
import com.njcn.gather.storage.mapper.AdNonHarmonicMapper;
|
import com.njcn.gather.storage.mapper.AdNonHarmonicMapper;
|
||||||
|
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||||
@@ -191,6 +193,24 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
|||||||
return indexes;
|
return indexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam) {
|
||||||
|
if(ObjectUtil.isNotNull(singleNonHarmParam)){
|
||||||
|
String prefix = "ad_harmonic_result_";
|
||||||
|
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
|
||||||
|
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.like(AdHarmonicResult::getMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
|
||||||
|
.eq(AdHarmonicResult::getSort, singleNonHarmParam.getSort())
|
||||||
|
.eq(AdHarmonicResult::getAdType, singleNonHarmParam.getAdType());
|
||||||
|
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(adHarmonicResults)){
|
||||||
|
return adHarmonicResults.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double isHarmOrInHarm(Double value) {
|
public Double isHarmOrInHarm(Double value) {
|
||||||
if (value == value.longValue()) {
|
if (value == value.longValue()) {
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.gather.storage.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||||
import com.njcn.gather.storage.mapper.AdNonHarmonicMapper;
|
import com.njcn.gather.storage.mapper.AdNonHarmonicMapper;
|
||||||
|
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||||
@@ -131,6 +133,23 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam) {
|
||||||
|
if(ObjectUtil.isNotNull(singleNonHarmParam)){
|
||||||
|
String prefix = "ad_non_harmonic_result_";
|
||||||
|
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
|
||||||
|
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.like(AdNonHarmonicResult::getMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
|
||||||
|
.eq(AdNonHarmonicResult::getSort, singleNonHarmParam.getSort())
|
||||||
|
.eq(AdNonHarmonicResult::getAdType, singleNonHarmParam.getAdType());
|
||||||
|
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(adHarmonicResults)){
|
||||||
|
return adHarmonicResults.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String unit(String code){
|
private String unit(String code){
|
||||||
String unit="";
|
String unit="";
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AuthGlobalFilter implements Filter, Ordered {
|
public class AuthGlobalFilter implements Filter, Ordered {
|
||||||
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login");
|
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login","/report/generateReport");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
|
|||||||
Reference in New Issue
Block a user