1.技术监督试运行评估-试运行结束后生成试运行报告

2.技术监督计划管理,权限调整为负责地市进行信息修改
3.调整常态化干扰源用户信息更新逻辑
4.调整谐波报告数据请求格式
This commit is contained in:
wr
2024-07-02 16:55:08 +08:00
parent 5ca027513f
commit 50cd5d3895
27 changed files with 510 additions and 283 deletions

View File

@@ -38,6 +38,12 @@
<artifactId>common-poi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>
<version>1.0.0</version>
<scope>${project.version}</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>user-api</artifactId>

View File

@@ -0,0 +1,36 @@
package com.njcn.harmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.api.fallback.RStatLimitRateDFeignClientFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@FeignClient(
value = ServerInfo.HARMONIC,
path = "/exportmodel",
fallbackFactory = RStatLimitRateDFeignClientFallbackFactory.class,
contextId = "exportmodel")
public interface ReportFeignClient {
@PostMapping(value ="/exportModel",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
HttpResult<String> exportWorld(
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") Integer type,
@RequestParam("lineIndex") String lineIndex,
@RequestParam("name") String name,
@RequestParam("reportNumber") String reportNumber,
@RequestParam("crmName") String crmName,
@RequestParam("isUrl") Boolean isUrl,
@RequestPart("file") MultipartFile file) throws IOException;
}

View File

@@ -0,0 +1,51 @@
package com.njcn.harmonic.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import com.njcn.harmonic.api.PqTypicalSourceFeignClient;
import com.njcn.harmonic.api.RStatLimitRateDClient;
import com.njcn.harmonic.api.ReportFeignClient;
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.param.UploadParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author hongawen
* @version 1.0.0
* @date 2023年07月21日 14:31
*/
@Slf4j
@Component
public class ReportClientFallbackFactory implements FallbackFactory<ReportFeignClient> {
@Override
public ReportFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new ReportFeignClient() {
@Override
public HttpResult<String> exportWorld( String startTime, String endTime, Integer type, String lineIndex, String name, String reportNumber, String crmName, Boolean isUrl, MultipartFile file) throws IOException {
log.error("{}异常,降级处理,异常为:{}", "获取谐波报告失败", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,12 +1,13 @@
package com.njcn.harmonic.utils;
import ch.qos.logback.core.rolling.helper.FileStoreUtil;
import cn.hutool.core.collection.CollUtil;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.CollectionUtils;
import org.springframework.stereotype.Component;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@@ -16,10 +17,14 @@ import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@Component
@RequiredArgsConstructor
public class WordUtil2 {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(WordUtil2.class);
private final FileStorageUtil fileStorageUtil;
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response)
throws Exception {
@@ -33,7 +38,7 @@ public class WordUtil2 {
this.replaceInTable(doc, params); // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量
} catch (IOException e) {
logger.error("获取报告模板异常,原因为:" + e);
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
@@ -46,7 +51,7 @@ public class WordUtil2 {
doc.write(outputStream);
outputStream.close();
} catch (Exception e) {
logger.error("输出稳态报告异常,原因为:" + e);
getError("输出稳态报告异常,原因为:" + e);
} finally {
if (doc != null) {
doc.close();
@@ -66,7 +71,7 @@ public class WordUtil2 {
this.replaceInTable(doc,params,tableList);
this.replaceInPara(doc, params);
} catch (IOException e) {
logger.error("获取报告模板异常,原因为:" + e);
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
@@ -80,7 +85,7 @@ public class WordUtil2 {
in = new ByteArrayInputStream(docByteAry);
out.close();
} catch (Exception e) {
logger.error("输出稳态报告异常,原因为:" + e);
getError("输出稳态报告异常,原因为:" + e);
} finally {
if (doc != null) {
doc.close();
@@ -90,6 +95,43 @@ public class WordUtil2 {
}
public String getReportFileUrl(String path,String fileName, Map<String, Object> params)
throws Exception {
path = ClearPathUtil.cleanString(path);
InputStream inStream = null,in = null;
CustomXWPFDocument doc = null;
//读取报告模板
try {
inStream = new ClassPathResource(path).getInputStream();;
doc = new CustomXWPFDocument(inStream);
this.replaceInTable(doc, params); // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量
//临时缓冲区
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out);
byte[] docByteAry = out.toByteArray();
in = new ByteArrayInputStream(docByteAry);
out.close();
} catch (IOException e) {
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
}
if (doc != null) {
doc.close();
}
}
//上传文件服务器
return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName);
}
private static void getError(String e) {
log.error(e);
}
/**
* 替换段落里面的变量
*
@@ -155,7 +197,7 @@ public class WordUtil2 {
s,paragraph);
bflag = "break";
} catch (Exception e) {
logger.error("文本替换发生异常,异常是" + e.getMessage());
getError("文本替换发生异常,异常是" + e.getMessage());
}
}
}
@@ -234,7 +276,7 @@ public class WordUtil2 {
para.createRun().setText(str, 0);
break;
} catch (Exception e) {
logger.error("文件替换发生异常,异常是" + e.getMessage());
getError("文件替换发生异常,异常是" + e.getMessage());
}
}
}
@@ -336,33 +378,4 @@ public class WordUtil2 {
return res;
}
/**
* 关闭输入流
*
* @param is
*/
private void close(InputStream is) {
if (is != null) {
try {
is.close();
} catch (IOException e) {
logger.error("关闭输入流发生异常,异常是" + e.getMessage());
}
}
}
/**
* 关闭输出流
*
* @param os
*/
private void close(OutputStream os) {
if (os != null) {
try {
os.close();
} catch (IOException e) {
logger.error("关闭输出流发生异常,异常是" + e.getMessage());
}
}
}
}