楼下报告调整
This commit is contained in:
@@ -27,6 +27,7 @@ import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
|||||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
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 com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.gather.type.pojo.po.DevType;
|
import com.njcn.gather.type.pojo.po.DevType;
|
||||||
import com.njcn.gather.type.service.IDevTypeService;
|
import com.njcn.gather.type.service.IDevTypeService;
|
||||||
@@ -78,11 +79,7 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateReport(DevReportParam devReportParam) {
|
public void generateReport(DevReportParam devReportParam) {
|
||||||
// 读取模板文件
|
// 根据设备类型找到报告模板
|
||||||
ClassPathResource resource = new ClassPathResource("/model/BaseModel.docx");
|
|
||||||
try (InputStream inputStream = resource.getInputStream()) {
|
|
||||||
// 加载Word文档
|
|
||||||
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
|
|
||||||
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
||||||
if (Objects.isNull(pqDevVO)) {
|
if (Objects.isNull(pqDevVO)) {
|
||||||
throw new BusinessException("请检查装置是否存在!");
|
throw new BusinessException("请检查装置是否存在!");
|
||||||
@@ -90,10 +87,19 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
// 获取设备型号
|
// 获取设备型号
|
||||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||||
if (Objects.isNull(devType)) {
|
if (Objects.isNull(devType)) {
|
||||||
throw new BusinessException("设备类型丢失,请联系管理员!");
|
throw new BusinessException("设备类型缺失,请联系管理员!");
|
||||||
}
|
}
|
||||||
|
DictData reportName = devTypeService.getReportName(pqDevVO.getDevType());
|
||||||
|
if (Objects.isNull(reportName)) {
|
||||||
|
throw new BusinessException("报告模板缺失,请联系管理员!");
|
||||||
|
}
|
||||||
|
// 读取模板文件
|
||||||
|
ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ".docx");
|
||||||
|
try (InputStream inputStream = resource.getInputStream()) {
|
||||||
|
// 加载Word文档
|
||||||
|
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
|
||||||
// 处理基础模版中的信息
|
// 处理基础模版中的信息
|
||||||
dealBaseModel(baseModelDocument, pqDevVO);
|
dealBaseModel(baseModelDocument, pqDevVO, devType);
|
||||||
// 处理数据页中的信息
|
// 处理数据页中的信息
|
||||||
dealDataModel(baseModelDocument, devReportParam, pqDevVO);
|
dealDataModel(baseModelDocument, devReportParam, pqDevVO);
|
||||||
// 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx
|
// 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx
|
||||||
@@ -124,7 +130,7 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
updateWrapper.set(AdPlan::getReportState, PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
updateWrapper.set(AdPlan::getReportState, PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
adPlanService.update(updateWrapper);
|
adPlanService.update(updateWrapper);
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
log.error("生成报告文件失败", e);
|
log.error("生成报告文件失败", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -179,11 +185,10 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
*
|
*
|
||||||
* @param baseModelDocument 模板文件
|
* @param baseModelDocument 模板文件
|
||||||
*/
|
*/
|
||||||
private void dealBaseModel(XWPFDocument baseModelDocument, PqDevVO pqDevVO) {
|
private void dealBaseModel(XWPFDocument baseModelDocument, PqDevVO pqDevVO, DevType devType) {
|
||||||
// 首先获取非数据页中需要的信息
|
// 首先获取非数据页中需要的信息
|
||||||
Map<String, String> baseModelMap = new HashMap<>(16);
|
Map<String, String> baseModelMap = new HashMap<>(16);
|
||||||
// 获取设备型号
|
// 获取设备型号
|
||||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
|
||||||
baseModelMap.put("${devType}", devType.getName());
|
baseModelMap.put("${devType}", devType.getName());
|
||||||
// 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死
|
// 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死
|
||||||
baseModelMap.put("${userName}", "管理员");
|
baseModelMap.put("${userName}", "管理员");
|
||||||
@@ -195,6 +200,8 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
}
|
}
|
||||||
// 装置编码
|
// 装置编码
|
||||||
baseModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
baseModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||||
|
// 工作电源
|
||||||
|
baseModelMap.put("${power}", devType.getPower());
|
||||||
// 额定电流
|
// 额定电流
|
||||||
baseModelMap.put("${devCurr}", pqDevVO.getDevCurr().toString().concat("A"));
|
baseModelMap.put("${devCurr}", pqDevVO.getDevCurr().toString().concat("A"));
|
||||||
// 额定电压
|
// 额定电压
|
||||||
@@ -226,7 +233,7 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
String scriptId = adPlan.getScriptId();
|
String scriptId = adPlan.getScriptId();
|
||||||
Integer devChns = pqDevVO.getDevChns();
|
Integer devChns = pqDevVO.getDevChns();
|
||||||
for (int i = 1; i <= devChns; i++) {
|
for (int i = 1; i <= devChns; i++) {
|
||||||
ClassPathResource resource = new ClassPathResource("/model/BaseDataModel.docx");
|
ClassPathResource resource = new ClassPathResource("/model/report_table.docx");
|
||||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||||
|
|
||||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||||
@@ -399,11 +406,18 @@ public class ReportServiceImpl implements IReportService {
|
|||||||
private void fillMapValueHarm(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol, double baseValue, int percent) {
|
private void fillMapValueHarm(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol, double baseValue, int percent) {
|
||||||
AdHarmonicResult adHarmonicResult = adHarmonicService.getSingleResult(singleNonHarmParam);
|
AdHarmonicResult adHarmonicResult = adHarmonicService.getSingleResult(singleNonHarmParam);
|
||||||
if (Objects.nonNull(adHarmonicResult)) {
|
if (Objects.nonNull(adHarmonicResult)) {
|
||||||
|
|
||||||
// 要处理 2 5 7 11 23 35 43 50
|
// 要处理 2 5 7 11 23 35 43 50
|
||||||
|
// 基波
|
||||||
|
dataModelMap.put("${" + aSymbol + "1}", devValue(adHarmonicResult.getAValue1(), baseValue, percent));
|
||||||
|
dataModelMap.put("${" + bSymbol + "1}", devValue(adHarmonicResult.getBValue1(), baseValue, percent));
|
||||||
|
dataModelMap.put("${" + cSymbol + "1}", devValue(adHarmonicResult.getCValue1(), baseValue, percent));
|
||||||
|
|
||||||
dataModelMap.put("${" + aSymbol + "2}", devValue(adHarmonicResult.getAValue2(), baseValue, percent));
|
dataModelMap.put("${" + aSymbol + "2}", devValue(adHarmonicResult.getAValue2(), baseValue, percent));
|
||||||
dataModelMap.put("${" + bSymbol + "2}", devValue(adHarmonicResult.getBValue2(), baseValue, percent));
|
dataModelMap.put("${" + bSymbol + "2}", devValue(adHarmonicResult.getBValue2(), baseValue, percent));
|
||||||
dataModelMap.put("${" + cSymbol + "2}", devValue(adHarmonicResult.getCValue2(), baseValue, percent));
|
dataModelMap.put("${" + cSymbol + "2}", devValue(adHarmonicResult.getCValue2(), baseValue, percent));
|
||||||
|
|
||||||
|
|
||||||
dataModelMap.put("${" + aSymbol + "5}", devValue(adHarmonicResult.getAValue5(), baseValue, percent));
|
dataModelMap.put("${" + aSymbol + "5}", devValue(adHarmonicResult.getAValue5(), baseValue, percent));
|
||||||
dataModelMap.put("${" + bSymbol + "5}", devValue(adHarmonicResult.getBValue5(), baseValue, percent));
|
dataModelMap.put("${" + bSymbol + "5}", devValue(adHarmonicResult.getBValue5(), baseValue, percent));
|
||||||
dataModelMap.put("${" + cSymbol + "5}", devValue(adHarmonicResult.getCValue5(), baseValue, percent));
|
dataModelMap.put("${" + cSymbol + "5}", devValue(adHarmonicResult.getCValue5(), baseValue, percent));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.gather.type.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
||||||
import com.njcn.gather.type.pojo.po.DevType;
|
import com.njcn.gather.type.pojo.po.DevType;
|
||||||
|
|
||||||
@@ -79,4 +80,11 @@ public interface IDevTypeService extends IService<DevType> {
|
|||||||
* @return 成功返回true,失败返回false
|
* @return 成功返回true,失败返回false
|
||||||
*/
|
*/
|
||||||
boolean deleteDevType(List<String> ids);
|
boolean deleteDevType(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备蕾西id获取报告名称
|
||||||
|
* @param devType 设备类型Id
|
||||||
|
* @return 报告字典
|
||||||
|
*/
|
||||||
|
DictData getReportName(String devType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.gather.type.mapper.DevTypeMapper;
|
import com.njcn.gather.type.mapper.DevTypeMapper;
|
||||||
import com.njcn.gather.type.pojo.enums.DevTypeResponseEnum;
|
import com.njcn.gather.type.pojo.enums.DevTypeResponseEnum;
|
||||||
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
||||||
@@ -16,7 +18,9 @@ import com.njcn.web.factory.PageFactory;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -29,6 +33,10 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> implements IDevTypeService {
|
public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> implements IDevTypeService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IDictDataService dictDataService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DevType> listAll() {
|
public List<DevType> listAll() {
|
||||||
LambdaQueryWrapper<DevType> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DevType> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -87,6 +95,15 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
|||||||
return this.lambdaUpdate().in(DevType::getId, ids).set(DevType::getState, DataStateEnum.DELETED.getCode()).update();
|
return this.lambdaUpdate().in(DevType::getId, ids).set(DevType::getState, DataStateEnum.DELETED.getCode()).update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DictData getReportName(String devTypeId) {
|
||||||
|
DevType devType = this.lambdaQuery().eq(DevType::getId, devTypeId).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||||
|
if (Objects.nonNull(devType)) {
|
||||||
|
return dictDataService.getDictDataById(devType.getReportName());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void checkRepeat(DevTypeParam param, boolean isExcludeSelf) {
|
private void checkRepeat(DevTypeParam param, boolean isExcludeSelf) {
|
||||||
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(DevType::getName, param.getName())
|
wrapper.eq(DevType::getName, param.getName())
|
||||||
|
|||||||
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882A.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882A.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B1.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B1.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B2.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B2.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B3.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B3.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B4.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B4.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B5.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B5.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B6.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B6.docx
Normal file
Binary file not shown.
Reference in New Issue
Block a user