二级评估联调和导出评估结果
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.njcn.advance.pojo.param.assess;
|
||||
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/8/26 17:05
|
||||
*/
|
||||
@Data
|
||||
public class AssessParam extends StatisticsBizBaseParam {
|
||||
|
||||
@ApiModelProperty(name="assessId",value="评估用户id")
|
||||
private String assessId;
|
||||
|
||||
}
|
||||
@@ -90,6 +90,9 @@ public class AssessUserQuery extends BaseParam implements Serializable {
|
||||
@ApiModelProperty(value = "线路名称,例:35kV 南站一线")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(value = "线路名称,例:35kV 南站一线")
|
||||
private String lineScale;
|
||||
|
||||
@ApiModelProperty(value = "供电设备容量,单位MVA,例:100.00")
|
||||
private BigDecimal powersupplyCapacity;
|
||||
|
||||
|
||||
@@ -106,6 +106,11 @@ public class AssessUser extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String lineName;
|
||||
|
||||
/**
|
||||
* 线路名称:例:35kV 南站一线
|
||||
*/
|
||||
private String lineScale;
|
||||
|
||||
/**
|
||||
* 供电设备容量,单位MVA,例:100.00
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.njcn.advance.pojo.vo.assess;
|
||||
|
||||
import com.njcn.advance.pojo.po.assess.AssessUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/8/20 17:22
|
||||
*/
|
||||
@Data
|
||||
public class AssessResultVO {
|
||||
|
||||
private AssessUser user;
|
||||
|
||||
/**
|
||||
* 电压波动结果
|
||||
*/
|
||||
private EvaluationResult fluc;
|
||||
|
||||
/**
|
||||
* 闪变评估结果
|
||||
*/
|
||||
private EvaluationResult plt;
|
||||
|
||||
/**
|
||||
* 无功设备不运行
|
||||
*/
|
||||
private List<Useless> capOff;
|
||||
|
||||
/**
|
||||
* 无功设备全运行
|
||||
*/
|
||||
private List<Useless> capOn;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡
|
||||
*/
|
||||
private List<EvaluationResult> unblance;
|
||||
|
||||
|
||||
/**
|
||||
* 谐波电压评估结果
|
||||
*/
|
||||
private List<Harm> harmV;
|
||||
|
||||
/**
|
||||
* 谐波电流评估结果
|
||||
*/
|
||||
private List<Harm> harmI;
|
||||
|
||||
@Data
|
||||
public static class EvaluationResult {
|
||||
|
||||
@ApiModelProperty("冲击负荷个数")
|
||||
private Integer inPactLoadNum;
|
||||
|
||||
@ApiModelProperty("值")
|
||||
private BigDecimal data;
|
||||
|
||||
@ApiModelProperty("国标限值")
|
||||
private BigDecimal limitData;
|
||||
|
||||
@ApiModelProperty("判断")
|
||||
private Boolean isQualified;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户无功设备不运行
|
||||
*/
|
||||
@Data
|
||||
public static class Useless {
|
||||
|
||||
@ApiModelProperty("百分比")
|
||||
private BigDecimal percent;
|
||||
|
||||
@ApiModelProperty("有名值")
|
||||
private BigDecimal voltagePercent;
|
||||
|
||||
@ApiModelProperty("电压上偏差限值")
|
||||
private BigDecimal capUP;
|
||||
|
||||
@ApiModelProperty("电压下偏差限值")
|
||||
private BigDecimal capDown;
|
||||
|
||||
@ApiModelProperty("判断")
|
||||
private Boolean isQualified;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Harm {
|
||||
|
||||
@ApiModelProperty("未投入")
|
||||
private BigDecimal notInvested;
|
||||
|
||||
@ApiModelProperty("已投入")
|
||||
private BigDecimal hasInvested;
|
||||
|
||||
@ApiModelProperty("限值")
|
||||
private BigDecimal limitData;
|
||||
|
||||
@ApiModelProperty("未投入判断")
|
||||
private Boolean isNotQualified;
|
||||
|
||||
@ApiModelProperty("已投入判断")
|
||||
private Boolean isHasQualified;
|
||||
|
||||
@ApiModelProperty("判断")
|
||||
private Boolean isQualified;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.njcn.advance.utils;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFColor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExcelTemplateReplacer {
|
||||
|
||||
// 用于包装替换值和样式启用状态的类
|
||||
public static class ReplacementData {
|
||||
private Object value;
|
||||
private boolean enableStyle;
|
||||
|
||||
public ReplacementData(Object value, boolean enableStyle) {
|
||||
this.value = value;
|
||||
this.enableStyle = enableStyle;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isEnableStyle() {
|
||||
return enableStyle;
|
||||
}
|
||||
|
||||
// 便捷的创建方法
|
||||
public static ReplacementData create(Object value, boolean enableStyle) {
|
||||
return new ReplacementData(value, enableStyle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换Excel模板中的占位符,支持设置是否启用样式
|
||||
*
|
||||
* @param templatePath 模板文件路径
|
||||
* @param outputPath 输出文件路径
|
||||
* @param data 替换数据,包含值和样式启用状态
|
||||
* @param fixedStyle 固定样式配置
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static void replaceTemplate(String templatePath, String outputPath,
|
||||
Map<String, ReplacementData> data, CellStyleConfig fixedStyle)
|
||||
throws IOException {
|
||||
try (InputStream is = new FileInputStream(templatePath);
|
||||
Workbook workbook = new XSSFWorkbook(is)) {
|
||||
// 创建固定样式
|
||||
CellStyle style = createFixedStyle(workbook, fixedStyle);
|
||||
for (Sheet sheet : workbook) {
|
||||
for (Row row : sheet) {
|
||||
if (row == null) continue;
|
||||
for (Cell cell : row) {
|
||||
if (cell == null) continue;
|
||||
|
||||
String cellValue = getCellValue(cell);
|
||||
if (cellValue != null && !cellValue.isEmpty()) {
|
||||
for (Map.Entry<String, ReplacementData> entry : data.entrySet()) {
|
||||
String placeholder = entry.getKey();
|
||||
ReplacementData replacement = entry.getValue();
|
||||
|
||||
if (cellValue.contains(placeholder)) {
|
||||
// 替换占位符内容
|
||||
setCellValue(cell, replacement.getValue());
|
||||
|
||||
// 根据标志决定是否应用样式
|
||||
if (replacement.isEnableStyle() && style != null) {
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 写入输出文件
|
||||
try (OutputStream os = new FileOutputStream(outputPath)) {
|
||||
workbook.write(os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void replaceDownTemplate(String templatePath,
|
||||
String fileName,
|
||||
Map<String, ReplacementData> data,
|
||||
CellStyleConfig fixedStyle,
|
||||
HttpServletResponse response)
|
||||
throws IOException {
|
||||
try (InputStream is = new ClassPathResource(templatePath).getInputStream();
|
||||
Workbook workbook = new XSSFWorkbook(is)) {
|
||||
// 创建固定样式
|
||||
CellStyle style = createFixedStyle(workbook, fixedStyle);
|
||||
for (Sheet sheet : workbook) {
|
||||
for (Row row : sheet) {
|
||||
if (row == null) continue;
|
||||
for (Cell cell : row) {
|
||||
if (cell == null) continue;
|
||||
|
||||
String cellValue = getCellValue(cell);
|
||||
if (cellValue != null && !cellValue.isEmpty()) {
|
||||
for (Map.Entry<String, ReplacementData> entry : data.entrySet()) {
|
||||
String placeholder = entry.getKey();
|
||||
ReplacementData replacement = entry.getValue();
|
||||
|
||||
if (cellValue.contains(placeholder)) {
|
||||
// 替换占位符内容
|
||||
setCellValue(cell, replacement.getValue());
|
||||
|
||||
// 根据标志决定是否应用样式
|
||||
if (replacement.isEnableStyle() && style != null) {
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 写入输出文件
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("评估结果异常" + e);
|
||||
} finally {
|
||||
if (workbook != null) {
|
||||
workbook.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建固定样式
|
||||
*/
|
||||
private static CellStyle createFixedStyle(Workbook workbook, CellStyleConfig config) {
|
||||
if (config == null) return null;
|
||||
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
|
||||
// 设置背景颜色
|
||||
if (config.getBackgroundColor() != null) {
|
||||
if (config.getBackgroundColor() instanceof XSSFColor) {
|
||||
((XSSFCellStyle) style).setFillForegroundColor((XSSFColor) config.getBackgroundColor());
|
||||
} else if (config.getBackgroundColor() instanceof Short) {
|
||||
style.setFillForegroundColor((Short) config.getBackgroundColor());
|
||||
}
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
}
|
||||
// 可以添加更多固定样式设置,如边框、对齐方式等
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
// 设置字体颜色
|
||||
if (config.getFontColor() != null) {
|
||||
Font font = workbook.getFontAt((short)0);
|
||||
if (config.getFontColor() instanceof XSSFColor) {
|
||||
((XSSFFont) font).setColor((XSSFColor) config.getFontColor());
|
||||
} else if (config.getFontColor() instanceof Short) {
|
||||
font.setColor((Short) config.getFontColor());
|
||||
}
|
||||
font.setFontHeightInPoints((short)10);
|
||||
font.setBold(true);
|
||||
font.setItalic(true);
|
||||
font.setUnderline(Font.U_SINGLE_ACCOUNTING);
|
||||
style.setFont(font);
|
||||
style.setAlignment(HorizontalAlignment.RIGHT);
|
||||
}else{
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单元格的值
|
||||
*/
|
||||
private static String getCellValue(Cell cell) {
|
||||
if (cell == null) return "";
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
}
|
||||
return String.valueOf(cell.getNumericCellValue());
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA:
|
||||
return cell.getCellFormula();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单元格的值
|
||||
*/
|
||||
private static void setCellValue(Cell cell, Object value) {
|
||||
// 自动判断类型
|
||||
if (value instanceof BigDecimal) {
|
||||
cell.setCellType(CellType.NUMERIC);
|
||||
cell.setCellValue(((BigDecimal) value).doubleValue());
|
||||
} else if (value instanceof Number) {
|
||||
cell.setCellType(CellType.NUMERIC);
|
||||
cell.setCellValue(((Number) value).doubleValue());
|
||||
} else if (value instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue((Boolean) value);
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// 单元格样式配置类
|
||||
@Data
|
||||
public static class CellStyleConfig {
|
||||
private Object backgroundColor; // 支持Short(索引色)或XSSFColor(自定义色)
|
||||
private Object fontColor; // 支持Short(索引色)或XSSFColor(自定义色)
|
||||
private short fontSize; // 支持Short(索引色)或XSSFColor(自定义色)
|
||||
|
||||
public CellStyleConfig(Object backgroundColor, Object fontColor, short fontSize) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.fontColor = fontColor;
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 准备替换数据,第三个参数为样式启用标志:true启用,false不启用
|
||||
Map<String, ReplacementData> data = new HashMap<>();
|
||||
data.put("${name}", ReplacementData.create("2024-10-25", true)); // 不启用样式
|
||||
data.put("${noti2}", ReplacementData.create(30.35, true)); // 启用样式
|
||||
data.put("${age}", ReplacementData.create(30, true)); // 启用样式
|
||||
|
||||
// 执行替换
|
||||
replaceTemplate("C:\\Users\\web2023\\Desktop\\xf.xlsx", "C:\\Users\\web2023\\Desktop\\cc.xlsx", data, getCellStyleConfig());
|
||||
System.out.println("Excel模板替换完成!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义固定样式:浅蓝色背景,黑色字体
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CellStyleConfig getCellStyleConfig() {
|
||||
XSSFColor lightBlue = new XSSFColor(new java.awt.Color(166, 165, 165), null);
|
||||
CellStyleConfig fixedStyle = new CellStyleConfig(
|
||||
lightBlue,
|
||||
IndexedColors.BLACK.getIndex(),
|
||||
(short)10
|
||||
);
|
||||
return fixedStyle;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,6 @@ public class AssessLoadParamController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除评估用户负荷参数")
|
||||
@ApiImplicitParam(name = "loadId", value = "用户负荷ID", required = true, type = "String")
|
||||
@PostMapping("/delete")
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> loadId) {
|
||||
boolean result = assessLoadParamService.removeByIds(loadId);
|
||||
|
||||
@@ -18,5 +18,6 @@ import com.njcn.web.controller.BaseController;
|
||||
@RequestMapping("/assessResult")
|
||||
public class AssessResultController extends BaseController {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ public class AssessShockLoadParamController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除评估用户冲击负荷参数")
|
||||
@ApiImplicitParam(name = "inpactloadId", value = "冲击负荷ID", required = true, type = "String")
|
||||
@PostMapping("/delete")
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> inpactloadId) {
|
||||
boolean result = assessShockLoadParamService.removeByIds(inpactloadId);
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package com.njcn.advance.controller.assess;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.advance.pojo.param.assess.AssessUserQuery;
|
||||
import com.njcn.advance.pojo.po.assess.AssessUser;
|
||||
import com.njcn.advance.service.assess.IAssessUserService;
|
||||
import com.njcn.advance.pojo.po.assess.*;
|
||||
import com.njcn.advance.service.assess.*;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -26,7 +25,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
@@ -39,6 +38,12 @@ import java.util.List;
|
||||
public class AssessUserController extends BaseController {
|
||||
|
||||
private final IAssessUserService assessUserService;
|
||||
private final IAssessTransformerParamService transformerParamService;
|
||||
private final IAssessCapacitorParamService capacitorParamService;
|
||||
private final IAssessWindLoadParamService windLoadParamService;
|
||||
private final IAssessLoadParamService loadParamService;
|
||||
private final IAssessShockLoadParamService shockLoadParamService;
|
||||
|
||||
|
||||
@ApiOperation("获取评估用户列表")
|
||||
@PostMapping("/list")
|
||||
@@ -47,40 +52,40 @@ public class AssessUserController extends BaseController {
|
||||
.like(assessUserQuery.getDeptName() != null, AssessUser::getDeptName, assessUserQuery.getDeptName())
|
||||
.like(assessUserQuery.getUserScale() != null, AssessUser::getUserScale, assessUserQuery.getUserScale());
|
||||
List<AssessUser> list = assessUserService.list(wrapper);
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), list,CommonResponseEnum.SUCCESS.getMessage());
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), list, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询评估用户")
|
||||
@PostMapping("/page")
|
||||
public HttpResult<Page<AssessUser>> page(@RequestBody AssessUserQuery assessUserQuery) {
|
||||
Page<AssessUser> pageData = assessUserService.page(assessUserQuery);
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), pageData,CommonResponseEnum.SUCCESS.getMessage());
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), pageData, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
@ApiOperation("根据ID获取评估用户详情")
|
||||
@ApiImplicitParam(name = "assessId", value = "评估用户ID", required = true, type = "String")
|
||||
@GetMapping("getInfo")
|
||||
@GetMapping("/getInfo")
|
||||
public HttpResult<AssessUser> getInfo(@RequestParam("assessId") String assessId) {
|
||||
AssessUser assessUser = assessUserService.getByAssessId(assessId);
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), assessUser,CommonResponseEnum.SUCCESS.getMessage());
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), assessUser, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
@ApiOperation("新增评估用户")
|
||||
@PostMapping("add")
|
||||
@PostMapping("/add")
|
||||
public HttpResult<String> add(@RequestBody @Validated AssessUserQuery assessUser) {
|
||||
String result = assessUserService.add(assessUser);
|
||||
if(StrUtil.isNotBlank(result)){
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), result,CommonResponseEnum.SUCCESS.getMessage());
|
||||
}else {
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.FAIL.getCode(), null,CommonResponseEnum.FAIL.getMessage());
|
||||
if (StrUtil.isNotBlank(result)) {
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), result, CommonResponseEnum.SUCCESS.getMessage());
|
||||
} else {
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.FAIL.getCode(), null, CommonResponseEnum.FAIL.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("修改评估用户")
|
||||
@PostMapping("edit")
|
||||
@PostMapping("/edit")
|
||||
public HttpResult<Boolean> edit(@RequestBody @Validated AssessUserQuery.UpdateAssessUserQuery updateAssessUserQuery) {
|
||||
assessUserService.update(updateAssessUserQuery);
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), true,CommonResponseEnum.SUCCESS.getMessage());
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), true, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -88,11 +93,18 @@ public class AssessUserController extends BaseController {
|
||||
@ApiImplicitParam(name = "assessIds", value = "评估用户ID列表,用逗号分隔", required = true, type = "String")
|
||||
@PostMapping("/batchDel")
|
||||
public HttpResult<Boolean> batchDelete(@RequestBody List<String> assessIds) {
|
||||
boolean result = assessUserService.removeByIds(assessIds);
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), result,CommonResponseEnum.SUCCESS.getMessage());
|
||||
boolean result = false;
|
||||
if (CollUtil.isNotEmpty(assessIds)) {
|
||||
transformerParamService.remove(new LambdaQueryWrapper<AssessTransformerParam>().in(AssessTransformerParam::getAssessId, assessIds));
|
||||
capacitorParamService.remove(new LambdaQueryWrapper<AssessCapacitorParam>().in(AssessCapacitorParam::getAssessId, assessIds));
|
||||
windLoadParamService.remove(new LambdaQueryWrapper<AssessWindLoadParam>().in(AssessWindLoadParam::getAssessId, assessIds));
|
||||
loadParamService.remove(new LambdaQueryWrapper<AssessLoadParam>().in(AssessLoadParam::getAssessId, assessIds));
|
||||
shockLoadParamService.remove(new LambdaQueryWrapper<AssessShockLoadParam>().in(AssessShockLoadParam::getAssessId, assessIds));
|
||||
result = assessUserService.removeByIds(assessIds);
|
||||
}
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), result, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
package com.njcn.advance.controller.assess;
|
||||
|
||||
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityQueryDataParam;
|
||||
import com.njcn.advance.pojo.carrycapacity.vo.CarryCapacityDataVO;
|
||||
import com.njcn.advance.pojo.dto.assess.AssessTreeDTO;
|
||||
import com.njcn.advance.pojo.param.assess.AssessParam;
|
||||
import com.njcn.advance.pojo.vo.assess.AssessResultVO;
|
||||
import com.njcn.advance.service.assess.SecondaryEvaluationService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -33,24 +35,61 @@ import java.util.List;
|
||||
@Api(tags = "二级评估")
|
||||
@RequiredArgsConstructor
|
||||
public class SecondaryEvaluationController extends BaseController {
|
||||
|
||||
private final SecondaryEvaluationService secondaryEvaluationService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/evaluation")
|
||||
@ApiOperation("评估-主页面")
|
||||
public HttpResult<Boolean> evaluation(@RequestParam String assessId,@RequestParam("file") MultipartFile file) {
|
||||
@ApiOperation("导入数据计算评估结果")
|
||||
public HttpResult<Boolean> evaluation(@RequestParam("assessId") String assessId,
|
||||
@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file) {
|
||||
String methodDescribe = getMethodDescribe("evaluation");
|
||||
secondaryEvaluationService.evaluation(assessId,file);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,true , methodDescribe);
|
||||
AssessParam param=new AssessParam();
|
||||
param.setAssessId(assessId);
|
||||
secondaryEvaluationService.evaluation(param, file);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/lineEvaluation")
|
||||
@ApiOperation("监测点数据计算评估结果")
|
||||
public HttpResult<Boolean> lineEvaluation(@RequestBody AssessParam param) {
|
||||
String methodDescribe = getMethodDescribe("lineEvaluation");
|
||||
secondaryEvaluationService.evaluation(param, null);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/evaluationTree")
|
||||
@ApiOperation("评估-树")
|
||||
public HttpResult<Boolean> evaluationTree(@RequestParam("deptId")String deptId) {
|
||||
@ApiOperation("评估树")
|
||||
public HttpResult<List<AssessTreeDTO>> evaluationTree(@RequestParam("deptId") String deptId) {
|
||||
String methodDescribe = getMethodDescribe("evaluationTree");
|
||||
List<AssessTreeDTO> tree = secondaryEvaluationService.evaluationTree(deptId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,true , methodDescribe);
|
||||
List<AssessTreeDTO> tree = secondaryEvaluationService.evaluationTree(deptId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/assessResult")
|
||||
@ApiOperation("评估结果")
|
||||
public HttpResult<AssessResultVO> assessResult(@RequestParam("assessId") String assessId) {
|
||||
String methodDescribe = getMethodDescribe("assessResult");
|
||||
AssessResultVO resultVO = secondaryEvaluationService.assessResult(assessId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resultVO, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/downAssessResult")
|
||||
@ApiOperation("导出评估结果")
|
||||
public void assessResult(HttpServletResponse response, @RequestParam("assessId") String assessId) throws IOException {
|
||||
secondaryEvaluationService.downAssessResult(response, assessId);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/downTemplateAssessResult")
|
||||
@ApiOperation("导出评估结果模板")
|
||||
public void assessResult(HttpServletResponse response) throws IOException {
|
||||
secondaryEvaluationService.downTemplateAssessResult(response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.njcn.advance.service.assess;
|
||||
|
||||
import com.njcn.advance.pojo.dto.assess.AssessTreeDTO;
|
||||
import com.njcn.advance.pojo.param.assess.AssessParam;
|
||||
import com.njcn.advance.pojo.vo.assess.AssessResultVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -13,7 +17,29 @@ import java.util.List;
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface SecondaryEvaluationService {
|
||||
void evaluation(String assessId, MultipartFile file);
|
||||
|
||||
void evaluation(AssessParam param, MultipartFile file);
|
||||
|
||||
List<AssessTreeDTO> evaluationTree(String deptId);
|
||||
|
||||
/**
|
||||
* 查询评估结果
|
||||
* @param assessId
|
||||
* @return
|
||||
*/
|
||||
AssessResultVO assessResult(String assessId);
|
||||
|
||||
/**
|
||||
* 导出评估结果
|
||||
* @param response
|
||||
*/
|
||||
void downAssessResult(HttpServletResponse response,String assessId) throws IOException;
|
||||
|
||||
/**
|
||||
* 导出pms3.0模板
|
||||
* @param response
|
||||
* @param
|
||||
* @throws IOException
|
||||
*/
|
||||
void downTemplateAssessResult(HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,9 @@ public class AssessUserServiceImpl extends ServiceImpl<AssessUserMapper, AssessU
|
||||
.eq(StrUtil.isNotBlank(assessUserQuery.getDeptName()), AssessUser::getDeptName, assessUserQuery.getDeptName())
|
||||
.in(CollUtil.isNotEmpty(assessUserQuery.getBusScaleList()),AssessUser::getBusId,assessUserQuery.getBusScaleList())
|
||||
.in(CollUtil.isNotEmpty(assessUserQuery.getPowerstationScaleList()),AssessUser::getPowerstationScale,assessUserQuery.getPowerstationScaleList())
|
||||
.like(StrUtil.isNotBlank(assessUserQuery.getSearchValue()), AssessUser::getAssessName, assessUserQuery.getSearchValue())
|
||||
.like(StrUtil.isNotBlank(assessUserQuery.getSearchValue()), AssessUser::getPowerstationName, assessUserQuery.getSearchValue());
|
||||
.like(StrUtil.isNotBlank(assessUserQuery.getAssessName()), AssessUser::getAssessName, assessUserQuery.getAssessName())
|
||||
.eq(StrUtil.isNotBlank(assessUserQuery.getIsWindfarm()), AssessUser::getIsWindfarm, assessUserQuery.getIsWindfarm())
|
||||
.like(StrUtil.isNotBlank(assessUserQuery.getPowerstationName()), AssessUser::getPowerstationName, assessUserQuery.getPowerstationName());
|
||||
Page<AssessUser> pageData = this.page(pageParam, wrapper);
|
||||
return pageData;
|
||||
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
package com.njcn.advance.service.assess.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.advance.pojo.dto.assess.AssessTreeDTO;
|
||||
import com.njcn.advance.pojo.dto.assess.HarmonicsIAndZDTO;
|
||||
import com.njcn.advance.pojo.param.assess.AssessParam;
|
||||
import com.njcn.advance.pojo.po.assess.*;
|
||||
import com.njcn.advance.pojo.vo.assess.AssessResultVO;
|
||||
import com.njcn.advance.service.assess.*;
|
||||
import com.njcn.advance.utils.EasyExcelUtil;
|
||||
import com.njcn.advance.utils.ExcelTemplateReplacer;
|
||||
import com.njcn.advance.utils.assess.*;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.biz.utils.COverlimitUtil;
|
||||
import com.njcn.harmonic.api.HarmDataFeignClient;
|
||||
import com.njcn.harmonic.pojo.vo.AssessEvaluation;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.math3.complex.Complex;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -57,70 +73,84 @@ public class SecondaryEvaluationServiceImpl implements SecondaryEvaluationServic
|
||||
private final IAssessWindLoadParamService iAssessWindLoadParamService;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
private final HarmDataFeignClient harmDataFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void evaluation(String assessId, MultipartFile file) {
|
||||
public void evaluation(AssessParam param, MultipartFile file) {
|
||||
//解析文件取CP95值 2-50次谐波电流含有率,电压含有率,负序电流,三项不平衡度,A,B,C三项最大;
|
||||
|
||||
String assessId = param.getAssessId();
|
||||
List<Double> iMax;
|
||||
Double unbalance;
|
||||
List<Double> uMax;
|
||||
Double iNeg;
|
||||
try {
|
||||
List<Map<Integer, String>> maps = EasyExcelUtil.syncRead(file.getInputStream(), 0, 0);
|
||||
//电流含有率
|
||||
List<Map<Integer, String>> maps1 = maps.subList(3, 52);
|
||||
//负序电流
|
||||
List<Map<Integer, String>> maps2 = maps.subList(52, 53);
|
||||
//电压含有率
|
||||
List<Map<Integer, String>> maps3 = maps.subList(56, 105);
|
||||
//三项不平衡度
|
||||
List<Map<Integer, String>> maps4 = maps.subList(105, 106);
|
||||
if (StrUtil.isNotBlank(param.getId())) {
|
||||
AssessEvaluation data = harmDataFeignClient.getHarmIAndHarmVData(param).getData();
|
||||
if (ObjUtil.isNotNull(data)){
|
||||
iMax = data.getIMax();
|
||||
unbalance = data.getUnbalance();
|
||||
uMax = data.getUMax();
|
||||
iNeg = data.getINeg();
|
||||
}else{
|
||||
throw new BusinessException("评估原始数据有误!请检查数据是否为空");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
List<Map<Integer, String>> maps = EasyExcelUtil.syncRead(file.getInputStream(), 0, 0);
|
||||
//电流含有率
|
||||
List<Map<Integer, String>> maps1 = maps.subList(3, 52);
|
||||
//负序电流
|
||||
List<Map<Integer, String>> maps2 = maps.subList(52, 53);
|
||||
//电压含有率
|
||||
List<Map<Integer, String>> maps3 = maps.subList(56, 105);
|
||||
//三项不平衡度
|
||||
List<Map<Integer, String>> maps4 = maps.subList(105, 106);
|
||||
|
||||
iMax = maps1.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
iMax = maps1.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
iNeg = maps2.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
}).collect(Collectors.toList());
|
||||
iNeg = maps2.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
|
||||
}).findFirst().get();
|
||||
}).findFirst().get();
|
||||
|
||||
uMax = maps3.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
uMax = maps3.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
unbalance = maps4.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
unbalance = maps4.stream().map(temp -> {
|
||||
double a = Double.valueOf(temp.get(5));
|
||||
double b = Double.valueOf(temp.get(10));
|
||||
double c = Double.valueOf(temp.get(15));
|
||||
double v = a > b ? a : b;
|
||||
double max = v > c ? v : c;
|
||||
return max;
|
||||
|
||||
}).findFirst().get();
|
||||
}).findFirst().get();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("解析文件失败,请按模版上传文件");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("解析文件失败,请按模版上传文件");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
AssessResult assessResult = new AssessResult();
|
||||
AssessResultAddition assessResultAddition = new AssessResultAddition();
|
||||
AssessOverlimit assessOverlimit = new AssessOverlimit();
|
||||
@@ -482,6 +512,266 @@ public class SecondaryEvaluationServiceImpl implements SecondaryEvaluationServic
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssessResultVO assessResult(String assessId) {
|
||||
AssessResultVO resultVO = null;
|
||||
AssessResult result = iAssessResultService.getById(assessId);
|
||||
AssessUser byId = iAssessUserService.getById(assessId);
|
||||
if (ObjUtil.isNotNull(result) && ObjUtil.isNotNull(byId)) {
|
||||
resultVO = new AssessResultVO();
|
||||
resultVO.setUser(byId);
|
||||
//取出电压字典,并获取电压系数
|
||||
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
|
||||
AssessUser assessUser = iAssessUserService.lambdaQuery().eq(AssessUser::getAssessId, assessId).one();
|
||||
Double userScale = getVoltage(assessUser.getUserScale(), dictDataList);
|
||||
|
||||
AssessResultAddition resultAddition = iAssessResultAdditionService.getById(assessId);
|
||||
AssessOverlimit overLimit = iAssessOverlimitService.getById(assessId);
|
||||
List<AssessShockLoadParam> list = iAssessShockLoadParamService.list(new LambdaQueryWrapper<AssessShockLoadParam>()
|
||||
.eq(AssessShockLoadParam::getAssessId, assessId));
|
||||
|
||||
//冲击负荷数量
|
||||
Integer sum = list.stream().mapToInt(x -> x.getInpactloadNum().intValue()).sum();
|
||||
|
||||
//电压波动评估结果
|
||||
AssessResultVO.EvaluationResult fluc = new AssessResultVO.EvaluationResult();
|
||||
fluc.setInPactLoadNum(sum);
|
||||
fluc.setData(result.getApproFluc());
|
||||
fluc.setLimitData(overLimit.getFluc());
|
||||
fluc.setIsQualified(NumberUtil.isLess(fluc.getData(), fluc.getLimitData()));
|
||||
resultVO.setFluc(fluc);
|
||||
//闪变评估结果
|
||||
AssessResultVO.EvaluationResult plt = new AssessResultVO.EvaluationResult();
|
||||
plt.setInPactLoadNum(sum);
|
||||
plt.setData(result.getPlt());
|
||||
plt.setLimitData(overLimit.getPlt());
|
||||
plt.setIsQualified(NumberUtil.isLess(plt.getData(), plt.getLimitData()));
|
||||
resultVO.setPlt(plt);
|
||||
|
||||
//用户无功设备不运行
|
||||
resultVO.setCapOff(capOff(result, userScale, overLimit));
|
||||
|
||||
//用户无功设备全运行
|
||||
resultVO.setCapOn(capOn(result, userScale, overLimit));
|
||||
|
||||
//三项电压不平平衡
|
||||
List<AssessResultVO.EvaluationResult> unblance = new ArrayList<>();
|
||||
AssessResultVO.EvaluationResult evaluationResult = new AssessResultVO.EvaluationResult();
|
||||
evaluationResult.setData(result.getAccurUnblance());
|
||||
evaluationResult.setLimitData(overLimit.getUnblance());
|
||||
evaluationResult.setIsQualified(NumberUtil.isLess(evaluationResult.getData(), evaluationResult.getLimitData()));
|
||||
unblance.add(evaluationResult);
|
||||
|
||||
evaluationResult = new AssessResultVO.EvaluationResult();
|
||||
evaluationResult.setData(result.getApproUnblance().multiply(BigDecimal.valueOf(200)));
|
||||
evaluationResult.setLimitData(overLimit.getUnblance());
|
||||
evaluationResult.setIsQualified(NumberUtil.isLess(evaluationResult.getData(), evaluationResult.getLimitData()));
|
||||
unblance.add(evaluationResult);
|
||||
|
||||
resultVO.setUnblance(unblance);
|
||||
|
||||
resultVO.setHarmI(getHarms(result, resultAddition, overLimit, "i"));
|
||||
resultVO.setHarmV(getHarms(result, resultAddition, overLimit, "v"));
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downAssessResult(HttpServletResponse response, String assessId) throws IOException {
|
||||
AssessResultVO resultVO = this.assessResult(assessId);
|
||||
if (ObjUtil.isNotNull(resultVO)) {
|
||||
Map<String, ExcelTemplateReplacer.ReplacementData> data = new HashMap<>();
|
||||
data.put("${name}", ExcelTemplateReplacer.ReplacementData.create(resultVO.getUser().getAssessName(), false));
|
||||
data.put("${subname}", ExcelTemplateReplacer.ReplacementData.create(resultVO.getUser().getPowerstationName(), false));
|
||||
data.put("${subvname}", ExcelTemplateReplacer.ReplacementData.create(resultVO.getUser().getBusName(), false));
|
||||
data.put("${linename}", ExcelTemplateReplacer.ReplacementData.create(resultVO.getUser().getLineName(), false));
|
||||
//电压
|
||||
AssessResultVO.EvaluationResult fluc = resultVO.getFluc();
|
||||
data.put("${num}", ExcelTemplateReplacer.ReplacementData.create(fluc.getInPactLoadNum(), false));
|
||||
data.put("${fluc}", ExcelTemplateReplacer.ReplacementData.create(fluc.getData(), !fluc.getIsQualified()));
|
||||
data.put("${fluclimt}", ExcelTemplateReplacer.ReplacementData.create(fluc.getLimitData(), false));
|
||||
data.put("${isfluc}", ExcelTemplateReplacer.ReplacementData.create(isData(fluc.getIsQualified()), false));
|
||||
|
||||
//闪变
|
||||
AssessResultVO.EvaluationResult plt = resultVO.getPlt();
|
||||
data.put("${plt}", ExcelTemplateReplacer.ReplacementData.create(plt.getData(), !plt.getIsQualified()));
|
||||
data.put("${pltlimt}", ExcelTemplateReplacer.ReplacementData.create(plt.getLimitData(), false));
|
||||
data.put("${isplt}", ExcelTemplateReplacer.ReplacementData.create(isData(plt.getIsQualified()), false));
|
||||
|
||||
List<AssessResultVO.EvaluationResult> unblance = resultVO.getUnblance();
|
||||
data.put("${app}", ExcelTemplateReplacer.ReplacementData.create(unblance.get(0).getData(), !unblance.get(0).getIsQualified()));
|
||||
data.put("${acc}", ExcelTemplateReplacer.ReplacementData.create(unblance.get(1).getData(), !unblance.get(1).getIsQualified()));
|
||||
data.put("${unblance}", ExcelTemplateReplacer.ReplacementData.create(unblance.get(0).getLimitData(), false));
|
||||
data.put("${isapp}", ExcelTemplateReplacer.ReplacementData.create(isData(unblance.get(0).getIsQualified()), false));
|
||||
data.put("${isacc}", ExcelTemplateReplacer.ReplacementData.create(isData(unblance.get(1).getIsQualified()), false));
|
||||
|
||||
List<AssessResultVO.Useless> capOff = resultVO.getCapOff();
|
||||
data.put("${up}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(0).getCapUP(), false));
|
||||
data.put("${down}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(0).getCapDown(), false));
|
||||
|
||||
data.put("${noth100}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(0).getPercent(), !capOff.get(0).getIsQualified()));
|
||||
data.put("${noth60}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(1).getPercent(), !capOff.get(1).getIsQualified()));
|
||||
data.put("${noth0}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(2).getPercent(), !capOff.get(2).getIsQualified()));
|
||||
data.put("${notl100}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(3).getPercent(), !capOff.get(3).getIsQualified()));
|
||||
data.put("${notl60}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(4).getPercent(), !capOff.get(4).getIsQualified()));
|
||||
data.put("${notl0}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(5).getPercent(), !capOff.get(5).getIsQualified()));
|
||||
data.put("${ynoth100}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(0).getVoltagePercent(), false));
|
||||
data.put("${ynoth60}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(1).getVoltagePercent(), false));
|
||||
data.put("${ynoth0}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(2).getVoltagePercent(), false));
|
||||
data.put("${ynotl100}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(3).getVoltagePercent(), false));
|
||||
data.put("${ynotl60}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(4).getVoltagePercent(), false));
|
||||
data.put("${ynotl0}", ExcelTemplateReplacer.ReplacementData.create(capOff.get(5).getVoltagePercent(), false));
|
||||
data.put("${isnoth100}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(0).getIsQualified()), false));
|
||||
data.put("${isnoth60}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(1).getIsQualified()), false));
|
||||
data.put("${isnoth0}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(2).getIsQualified()), false));
|
||||
data.put("${isnotl100}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(3).getIsQualified()), false));
|
||||
data.put("${isnotl60}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(4).getIsQualified()), false));
|
||||
data.put("${isnotl0}", ExcelTemplateReplacer.ReplacementData.create(isData(capOff.get(5).getIsQualified()), false));
|
||||
|
||||
List<AssessResultVO.Useless> capOn = resultVO.getCapOn();
|
||||
data.put("${hash100}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(0).getPercent(), !capOn.get(0).getIsQualified()));
|
||||
data.put("${hash60}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(1).getPercent(), !capOn.get(1).getIsQualified()));
|
||||
data.put("${hash0}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(2).getPercent(), !capOn.get(2).getIsQualified()));
|
||||
data.put("${hasl100}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(3).getPercent(), !capOn.get(3).getIsQualified()));
|
||||
data.put("${hasl60}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(4).getPercent(), !capOn.get(4).getIsQualified()));
|
||||
data.put("${hasl0}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(5).getPercent(), !capOn.get(5).getIsQualified()));
|
||||
data.put("${yhash100}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(0).getVoltagePercent(), false));
|
||||
data.put("${yhash60}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(1).getVoltagePercent(), false));
|
||||
data.put("${yhash0}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(2).getVoltagePercent(), false));
|
||||
data.put("${yhasl100}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(3).getVoltagePercent(), false));
|
||||
data.put("${yhasl60}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(4).getVoltagePercent(), false));
|
||||
data.put("${yhasl0}", ExcelTemplateReplacer.ReplacementData.create(capOn.get(5).getVoltagePercent(), false));
|
||||
data.put("${ishash100}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(0).getIsQualified()), false));
|
||||
data.put("${ishash60}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(1).getIsQualified()), false));
|
||||
data.put("${ishash0}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(2).getIsQualified()), false));
|
||||
data.put("${ishasl100}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(3).getIsQualified()), false));
|
||||
data.put("${ishasl60}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(4).getIsQualified()), false));
|
||||
data.put("${ishasl0}", ExcelTemplateReplacer.ReplacementData.create(isData(capOn.get(5).getIsQualified()), false));
|
||||
List<AssessResultVO.Harm> harmI = resultVO.getHarmI();
|
||||
for (int i = 2; i < harmI.size() + 2; i++) {
|
||||
data.put("${noti" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmI.get(i - 2).getNotInvested(), !harmI.get(i - 2).getIsNotQualified()));
|
||||
data.put("${hasi" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmI.get(i - 2).getHasInvested(), !harmI.get(i - 2).getIsHasQualified()));
|
||||
data.put("${limi" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmI.get(i - 2).getLimitData(), false));
|
||||
data.put("${isi" + i + "}", ExcelTemplateReplacer.ReplacementData.create(isData(harmI.get(i - 2).getIsQualified()), false));
|
||||
}
|
||||
List<AssessResultVO.Harm> harmV = resultVO.getHarmV();
|
||||
for (int i = 2; i < harmV.size() + 2; i++) {
|
||||
data.put("${notv" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmV.get(i - 2).getNotInvested(), !harmV.get(i - 2).getIsNotQualified()));
|
||||
data.put("${hasv" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmV.get(i - 2).getHasInvested(), !harmV.get(i - 2).getIsHasQualified()));
|
||||
data.put("${limv" + i + "}", ExcelTemplateReplacer.ReplacementData.create(harmV.get(i - 2).getLimitData(), false));
|
||||
data.put("${isv" + i + "}", ExcelTemplateReplacer.ReplacementData.create(isData(harmV.get(i - 2).getIsQualified()), false));
|
||||
}
|
||||
|
||||
ExcelTemplateReplacer.replaceDownTemplate("pgjg.xlsx",
|
||||
resultVO.getUser().getAssessName() + "_评估结果.xlsx",
|
||||
data,
|
||||
ExcelTemplateReplacer.getCellStyleConfig(),
|
||||
response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downTemplateAssessResult(HttpServletResponse response) throws IOException {
|
||||
try (InputStream is = new ClassPathResource("pgjgmb.xlsx").getInputStream();
|
||||
Workbook workbook = new XSSFWorkbook(is)) {
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.setHeader("Content-Disposition", "attachment; filename= 评估模板");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("评估结果异常" + e);
|
||||
} finally {
|
||||
if (workbook != null) {
|
||||
workbook.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String isData(Boolean b) {
|
||||
if (b) {
|
||||
return "合格";
|
||||
}
|
||||
return "不合格";
|
||||
}
|
||||
|
||||
private List<AssessResultVO.Harm> getHarms(AssessResult result, AssessResultAddition resultAddition, AssessOverlimit overLimit, String type) {
|
||||
List<AssessResultVO.Harm> harmI = new ArrayList<>();
|
||||
try {
|
||||
AssessResultVO.Harm harm;
|
||||
for (int i = 2; i < 51; i++) {
|
||||
harm = new AssessResultVO.Harm();
|
||||
String fieldName = type + i;
|
||||
Field notField = result.getClass().getDeclaredField(fieldName);
|
||||
notField.setAccessible(true);
|
||||
harm.setNotInvested(new BigDecimal(notField.get(result).toString()));
|
||||
Field hasField = resultAddition.getClass().getDeclaredField(fieldName);
|
||||
hasField.setAccessible(true);
|
||||
harm.setHasInvested(new BigDecimal(hasField.get(resultAddition).toString()));
|
||||
if (ObjUtil.equals(type, "v")) {
|
||||
if (i % 2 == 0) {
|
||||
fieldName = "vevent";
|
||||
} else {
|
||||
fieldName = "vodd";
|
||||
}
|
||||
Field limitField = overLimit.getClass().getDeclaredField(fieldName);
|
||||
limitField.setAccessible(true);
|
||||
harm.setLimitData(new BigDecimal(limitField.get(overLimit).toString()));
|
||||
} else {
|
||||
Field limitField = overLimit.getClass().getDeclaredField(fieldName);
|
||||
limitField.setAccessible(true);
|
||||
harm.setLimitData(new BigDecimal(limitField.get(overLimit).toString()));
|
||||
}
|
||||
harm.setIsNotQualified(NumberUtil.isLess(harm.getNotInvested(), harm.getLimitData()));
|
||||
harm.setIsHasQualified(NumberUtil.isLess(harm.getHasInvested(), harm.getLimitData()));
|
||||
harm.setIsQualified(harm.getIsNotQualified() && harm.getIsHasQualified());
|
||||
harmI.add(harm);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return harmI;
|
||||
}
|
||||
|
||||
private List<AssessResultVO.Useless> capOn(AssessResult result, Double userScale, AssessOverlimit overLimit) {
|
||||
List<AssessResultVO.Useless> capOn = new ArrayList<>();
|
||||
capOn.add(getUseless(result.getCapOnH100Deltav(), userScale, overLimit));
|
||||
capOn.add(getUseless(result.getCapOnH60Deltav(), userScale, overLimit));
|
||||
capOn.add(getUseless(result.getCapOnH0Deltav(), userScale, overLimit));
|
||||
capOn.add(getUseless(result.getCapOnL100Deltav(), userScale, overLimit));
|
||||
capOn.add(getUseless(result.getCapOnL60Deltav(), userScale, overLimit));
|
||||
capOn.add(getUseless(result.getCapOnL0Deltav(), userScale, overLimit));
|
||||
return capOn;
|
||||
}
|
||||
|
||||
private List<AssessResultVO.Useless> capOff(AssessResult result, Double userScale, AssessOverlimit overLimit) {
|
||||
List<AssessResultVO.Useless> capOff = new ArrayList<>();
|
||||
capOff.add(getUseless(result.getCapOffH100Deltav(), userScale, overLimit));
|
||||
capOff.add(getUseless(result.getCapOffH60Deltav(), userScale, overLimit));
|
||||
capOff.add(getUseless(result.getCapOffH0Deltav(), userScale, overLimit));
|
||||
capOff.add(getUseless(result.getCapOffL100Deltav(), userScale, overLimit));
|
||||
capOff.add(getUseless(result.getCapOffL60Deltav(), userScale, overLimit));
|
||||
capOff.add(getUseless(result.getCapOffL0Deltav(), userScale, overLimit));
|
||||
return capOff;
|
||||
}
|
||||
|
||||
private AssessResultVO.Useless getUseless(BigDecimal result, Double userScale, AssessOverlimit overLimit) {
|
||||
AssessResultVO.Useless uselessOffH100;
|
||||
uselessOffH100 = new AssessResultVO.Useless();
|
||||
uselessOffH100.setPercent(result);
|
||||
uselessOffH100.setVoltagePercent(NumberUtil.round(uselessOffH100.getPercent().multiply(BigDecimal.valueOf(userScale)), 2));
|
||||
uselessOffH100.setCapUP(overLimit.getDltavUp());
|
||||
uselessOffH100.setCapDown(overLimit.getDltavDown());
|
||||
uselessOffH100.setIsQualified(NumberUtil.isLess(uselessOffH100.getPercent(), uselessOffH100.getCapUP()) &&
|
||||
NumberUtil.isGreater(uselessOffH100.getPercent(), uselessOffH100.getCapDown()));
|
||||
return uselessOffH100;
|
||||
}
|
||||
|
||||
private AssessOverlimit assembleOverlimit(AssessOverlimit assessOverlimit, String assessId, Overlimit overlimit, double dmaxLimit, double flickerLimit, VoltageDeviationUtil.VoltageDeviationLimits voltageDeviationLimits, double voltageUnbalanceLimit) {
|
||||
assessOverlimit.setAssessId(assessId);
|
||||
assessOverlimit.setVodd(BigDecimal.valueOf(overlimit.getUharm3()).setScale(3, RoundingMode.HALF_UP));
|
||||
|
||||
BIN
pqs-advance/advance-boot/src/main/resources/pgjg.xlsx
Normal file
BIN
pqs-advance/advance-boot/src/main/resources/pgjg.xlsx
Normal file
Binary file not shown.
BIN
pqs-advance/advance-boot/src/main/resources/pgjgmb.xlsx
Normal file
BIN
pqs-advance/advance-boot/src/main/resources/pgjgmb.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user