|
|
|
|
@@ -2020,6 +2020,12 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.DEV_TYPE.getKey(), devType.getName());
|
|
|
|
|
// 检测员
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.INSPECTOR.getKey(), pqDevVO.getCheckBy() + "");
|
|
|
|
|
// 出厂日期
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.CREATEDATE.getKey(), pqDevVO.getCreateDate().format(DateTimeFormatter.ofPattern(datePattern)));
|
|
|
|
|
// 硬件版本
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.HW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getHardwareVersion()) ? pqDevVO.getHardwareVersion() : StrUtil.EMPTY);
|
|
|
|
|
// 软件版本
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.SW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getSoftwareVersion()) ? pqDevVO.getSoftwareVersion() : StrUtil.EMPTY);
|
|
|
|
|
// 调试日期
|
|
|
|
|
if (pqDevVO.getCheckTime() != null) {
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.TEST_DATE.getKey(), DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
|
|
|
|
|
@@ -2059,7 +2065,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|
|
|
|
// 实验室温度
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.TEMPERATURE.getKey(), Objects.isNull(pqDevVO.getTemperature()) ? StrPool.TAB : pqDevVO.getTemperature().toString());
|
|
|
|
|
// 实验室湿度
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.HUMIDITY.getKey(), Objects.isNull(pqDevVO.getHumidity()) ? StrPool.TAB : pqDevVO.getHumidity().toString());
|
|
|
|
|
baseModelMap.put(prefix + BaseReportKeyEnum.HUMIDITY.getKey() + suffix, Objects.isNull(pqDevVO.getHumidity()) ? StrPool.TAB : pqDevVO.getHumidity().toString());
|
|
|
|
|
|
|
|
|
|
// 样品编号
|
|
|
|
|
baseModelMap.put(BaseReportKeyEnum.SAMPLE_ID.getKey(), StrUtil.isEmpty(pqDevVO.getSampleId()) ? StrPool.TAB : pqDevVO.getSampleId());
|
|
|
|
|
@@ -2160,7 +2166,19 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|
|
|
|
private void dealDataModel(List<InputStream> wordFileInputStreams, DevReportParam devReportParam, PqDevVO pqDevVO) throws Exception {
|
|
|
|
|
Integer devChns = pqDevVO.getDevChns();
|
|
|
|
|
for (int i = 1; i <= devChns; i++) {
|
|
|
|
|
ClassPathResource resource = new ClassPathResource("/model/report_table.docx");
|
|
|
|
|
String path = "/model/report_table.docx";
|
|
|
|
|
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
|
|
|
|
if (devType.getName().equals("PQ-COM")) {
|
|
|
|
|
path = "/model/report_table - PQ-COM.docx";
|
|
|
|
|
}
|
|
|
|
|
ClassPathResource resource = new ClassPathResource(path);
|
|
|
|
|
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
|
|
|
|
|
|
|
|
|
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
|
|
|
|
singleNonHarmParam.setPlanCode(devReportParam.getPlanCode());
|
|
|
|
|
singleNonHarmParam.setDevId(pqDevVO.getId());
|
|
|
|
|
singleNonHarmParam.setChannelNo(i);
|
|
|
|
|
|
|
|
|
|
// 获取数据
|
|
|
|
|
Map<String, String> dataModelMap = new HashMap<>(16);
|
|
|
|
|
// 读取模板文件中的占位符
|
|
|
|
|
@@ -2178,11 +2196,20 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|
|
|
|
List<SimAndDigHarmonicResult> adHarmonicResultList = adHarmonicService.listAllResultData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + i);
|
|
|
|
|
|
|
|
|
|
// 填充数据
|
|
|
|
|
int finalI = i;
|
|
|
|
|
indexKeysMap.forEach((index, keys) -> {
|
|
|
|
|
String s1 = keys.stream().findFirst().get();
|
|
|
|
|
// 谐波类
|
|
|
|
|
if (DetectionCodeEnum.V2_50.getCode().equals(s1) || DetectionCodeEnum.I2_50.getCode().equals(s1) || DetectionCodeEnum.SV_1_49.getCode().equals(s1) || DetectionCodeEnum.SI_1_49.getCode().equals(s1)) {
|
|
|
|
|
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index);
|
|
|
|
|
// 查找一下U1
|
|
|
|
|
double u1 = 57.74;
|
|
|
|
|
List<AdHarmonicResult> rawData = adHarmonicService.listAllRawData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + finalI);
|
|
|
|
|
AdHarmonicResult adHarmonicResult = rawData.stream().filter(obj -> obj.getAdType().equals(DetectionCodeEnum.V2_50.getCode())).sorted((obj1, obj2) -> obj2.getTimeId().compareTo(obj1.getTimeId())).findFirst().orElse(null);
|
|
|
|
|
if (ObjectUtil.isNotNull(adHarmonicResult)) {
|
|
|
|
|
String aValue1 = adHarmonicResult.getAValue1();
|
|
|
|
|
u1 = Double.parseDouble(aValue1);
|
|
|
|
|
}
|
|
|
|
|
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index, u1);
|
|
|
|
|
} else {
|
|
|
|
|
// 非谐波类
|
|
|
|
|
if (DetectionCodeEnum.V_UNBAN.getCode().equals(s1) || DetectionCodeEnum.FREQ.getCode().equals(s1)) {
|
|
|
|
|
@@ -2250,14 +2277,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|
|
|
|
* @param keys key
|
|
|
|
|
* @param index index
|
|
|
|
|
*/
|
|
|
|
|
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
|
|
|
|
|
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index, double baseValue) {
|
|
|
|
|
keys.forEach(key -> {
|
|
|
|
|
List<SimAndDigHarmonicResult> resultList = allHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(resultList)) {
|
|
|
|
|
SimAndDigHarmonicResult adHarmonicResult = resultList.get(0);
|
|
|
|
|
if (Objects.nonNull(adHarmonicResult)) {
|
|
|
|
|
if (DetectionCodeEnum.V2_50.getCode().equals(key) || DetectionCodeEnum.SV_1_49.getCode().equals(key)) {
|
|
|
|
|
fillHarm(dataModelMap, adHarmonicResult, index, key, 57.74, 100);
|
|
|
|
|
fillHarm(dataModelMap, adHarmonicResult, index, key, baseValue, 100);
|
|
|
|
|
}
|
|
|
|
|
if (DetectionCodeEnum.I2_50.getCode().equals(key) || DetectionCodeEnum.SI_1_49.getCode().equals(key)) {
|
|
|
|
|
fillHarm(dataModelMap, adHarmonicResult, index, key, 1, 1);
|
|
|
|
|
|