Browse Source

feat:

1. 修复信创报告数据存储结构;
2. 手动新增系统申请信创测评状态校验修改;
tags/24121201
WendyYang 4 weeks ago
parent
commit
9096160925
4 changed files with 67 additions and 53 deletions
  1. +2
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java
  2. +28
    -33
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxReportHelper.java
  3. +9
    -10
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java
  4. +28
    -9
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java

+ 2
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java View File

@@ -12,6 +12,7 @@ import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.basic.model.IdVo;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.file.entity.vo.result.FileResultVO;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -163,7 +164,7 @@ public class PurchaseController {

@GetMapping("/xcfhxReportFiles/{code}")
@ApiOperation("获取信创文件预览")
public String xcfhxReportFiles(@PathVariable String code) {
public FileResultVO xcfhxReportFiles(@PathVariable String code) {
return purchaseManage.xcfhxReportFiles(code);
}



hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxFileHelper.java → hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxReportHelper.java View File

@@ -1,7 +1,8 @@
package com.hz.pm.api.projectdeclared.helper;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.external.MhFileClient;
import com.ningdatech.basic.exception.BizException;
@@ -10,8 +11,6 @@ import com.ningdatech.file.controller.FileController;
import com.ningdatech.file.entity.vo.result.FileResultVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;

@@ -20,56 +19,46 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.util.Collections;

/**
* @Classname MhXchxFileHelper
* @Classname MhXcFhxFileHelper
* @Description
* @Date 2024/7/3 10:41
* @Author PoffyZhang
*/
@Slf4j
@Component
@RequiredArgsConstructor
@Slf4j
public class MhXcfhxFileHelper {
public class MhXcfhxReportHelper {

private final MhFileClient mhFileClient;

private final FileController fileController;

public String getXcfhxFile(String reportFile, String fileName) {
public FileResultVO getXcfhxFile(String reportFile, String fileName) {
if (StrUtils.isBlank(reportFile)) {
throw BizException.wrap("信创报告文件不能为空");
}
ApiResponse<FileResultVO> retFileInfo;
File tmpFile = null;
FileInputStream fis = null;
try {
tmpFile = mhFileClient.downloadToTmpFile(reportFile);
if (StringUtils.isNotBlank(fileName)) {
fileName = fileName + FileUtil.getSuffix(tmpFile);
File tmpFile = mhFileClient.downloadToTmpFile(reportFile);
try (FileInputStream fis = new FileInputStream(tmpFile)) {
String newFileName;
if (StrUtil.isNotBlank(fileName)) {
newFileName = fileName + FileUtil.getSuffix(tmpFile);
} else {
fileName = tmpFile.getName();
newFileName = tmpFile.getName();
}
fis = new FileInputStream(tmpFile);
String mimeType = FileUtil.getMimeType(tmpFile.getPath());
MockMultipartFile multipartFile = new MockMultipartFile(fileName, fileName, mimeType, fis);
retFileInfo = fileController.upload(multipartFile, "default");
MockMultipartFile multipartFile = new MockMultipartFile(newFileName, newFileName, mimeType, fis);
ApiResponse<FileResultVO> retFileInfo = fileController.upload(multipartFile, "default");
return retFileInfo.getData();
} catch (IOException e) {
log.error("信创报告上传失败", e);
throw BizException.wrap("信创符合性测评报告上传失败");
} finally {
if (tmpFile != null) {
tmpFile.deleteOnExit();
}
if (fis != null) {
IOUtils.closeQuietly(fis);
}
FileUtil.del(tmpFile);
}
return JSONUtil.toJsonStr(Collections.singletonList(retFileInfo.getData()));
}

public void exportReport(String reportFile, HttpServletResponse response) throws UnsupportedEncodingException {
public void download(String reportFile, HttpServletResponse response) {
if (StrUtils.isBlank(reportFile)) {
throw BizException.wrap("信创报告文件不能为空");
}
@@ -77,19 +66,25 @@ public class MhXcfhxFileHelper {
File file = mhFileClient.downloadToTmpFile(reportFile);
// 设置响应的内容类型和头信息
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(file.getName(), "utf-8") + "\"");

String fileName;
try {
fileName = URLEncoder.encode(file.getName(), "utf-8");
} catch (UnsupportedEncodingException e) {
log.warn("文件名编码失败:{}", file.getName(), e);
fileName = UUID.randomUUID().toString(true) + ".pdf";
}
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
// 使用ServletOutputStream写文件内容
try (InputStream in = Files.newInputStream(file.toPath());
ServletOutputStream out = response.getOutputStream()) {
byte[] buffer = new byte[1024];
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
throw new RuntimeException(e);
log.error("导出信创报告失败", e);
throw BizException.wrap("导出信创测评报告失败");
}

}
}

+ 9
- 10
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java View File

@@ -3,13 +3,14 @@ package com.hz.pm.api.projectdeclared.manage;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.enumeration.ProjectProcessType;
import com.hz.pm.api.common.exception.ReturnException;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.ExistsSqlConst;
@@ -21,7 +22,7 @@ import com.hz.pm.api.common.util.ExcelDownUtil;
import com.hz.pm.api.common.util.ExcelExportStyle;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum;
import com.hz.pm.api.projectdeclared.helper.MhXcfhxFileHelper;
import com.hz.pm.api.projectdeclared.helper.MhXcfhxReportHelper;
import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO;
import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSupplementDTO;
import com.hz.pm.api.projectdeclared.model.dto.PreInsSaveDTO;
@@ -58,6 +59,7 @@ import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.file.entity.vo.result.FileResultVO;
import com.wflow.bean.entity.WflowModels;
import com.wflow.workflow.bean.dto.OrgInfoDTO;
import com.wflow.workflow.bean.vo.ProcessStartParamsVo;
@@ -65,7 +67,6 @@ import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -105,7 +106,7 @@ public class ConstructionManage {
private final IProjectAnnualPaymentPlanService projectPaymentPlanService;
private final TenderStateMachineUtil tenderStateMachineUtil;
private final XcfhxStateMachineUtil xcfhxStateMachineUtil;
private final MhXcfhxFileHelper mhXcfhxFileHelper;
private final MhXcfhxReportHelper mhXcfhxReportHelper;
private final IXinchuangService xinchuangService;

private final TaskService taskService;
@@ -642,7 +643,8 @@ public class ConstructionManage {
if (StrUtils.isBlank(purchase.getMhXcfhxReportFile()) ||
req.getMhXcfhxReportFile().equals(purchase.getMhXcfhxReportFile())) {
String fileName = purchase.getBidName() + "-信创符合性测评报告.";
purchase.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(req.getMhXcfhxReportFile(), fileName));
FileResultVO xcfhxFile = mhXcfhxReportHelper.getXcfhxFile(req.getMhXcfhxReportFile(), fileName);
purchase.setXcfhxReportFiles(JSONUtil.toJsonStr(Collections.singletonList(xcfhxFile)));
}
purchase.setMhXcfhxReportRecordId(req.getMhXcfhxReportRecordId());
purchase.setMhXcfhxReportFile(req.getMhXcfhxReportFile());
@@ -663,11 +665,8 @@ public class ConstructionManage {
public synchronized String submitXcfhxApplyManual(Long id) {
Xinchuang xinhcuang = xinchuangService.getById(id);
VUtils.isTrue(Objects.isNull(xinhcuang)).throwMessage("信创符合性申请不存在");
if (StringUtils.isNotBlank(xinhcuang.getInstCode())) {
List<Task> tasks = taskService.createTaskQuery().active()
.processInstanceId(xinhcuang.getInstCode())
.list();
VUtils.isTrue(CollUtil.isNotEmpty(tasks)).throwMessage("此信创符合性已经发起过审核 并且还没审核完!");
if (xinhcuang.getStatus() != null && !TenderXcfhxApplyStatus.XCFHX_APPLY_FAILED.eq(xinhcuang.getStatus())) {
throw ReturnException.wrap("不支持提交信创符合性申请");
}

UserInfoDetails user = LoginUserUtil.userDetailNotNull();


+ 28
- 9
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java View File

@@ -32,7 +32,7 @@ import com.hz.pm.api.external.model.dto.MhPurchaseNoticeDTO;
import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum;
import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum;
import com.hz.pm.api.projectdeclared.chain.ProjectStatusRewriteHandlerContext;
import com.hz.pm.api.projectdeclared.helper.MhXcfhxFileHelper;
import com.hz.pm.api.projectdeclared.helper.MhXcfhxReportHelper;
import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO;
import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO;
import com.hz.pm.api.projectdeclared.model.dto.XcfhxApplyEditDTO;
@@ -90,7 +90,6 @@ import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
@@ -137,7 +136,7 @@ public class PurchaseManage {
private final IProjectInstService projectInstService;
private final EnvironmentUtil environmentUtil;
private final IXinchuangService xinchuangService;
private final MhXcfhxFileHelper mhXcfhxFileHelper;
private final MhXcfhxReportHelper mhXcfhxReportHelper;
private final IPurchaseStatusChangeService purchaseStatusChangeService;
private final MhUnitQueryAuthHelper mhUnitQueryAuthHelper;
private final IProjectGovSystemReplaceInfosService projectGovSystemReplaceInfosService;
@@ -574,6 +573,24 @@ public class PurchaseManage {
}
});
}
List<Xinchuang> xinchuangList = xinchuangService.list(Wrappers.lambdaQuery(Xinchuang.class)
.select(Xinchuang::getId, Xinchuang::getXcfhxReportFiles)
.isNotNull(Xinchuang::getXcfhxReportFiles));
for (Xinchuang xinchuang : xinchuangList) {
BizUtils.notBlank(xinchuang.getXcfhxReportFiles(), w -> {
try {
ApiResponse<FileResultVO> response = JSONUtil.toBean(w, new TypeReference<ApiResponse<FileResultVO>>() {
}, false);
if (response.getCode() == ApiResponse.SUCCESS_CODE) {
xinchuang.setXcfhxReportFiles(JSONUtil.toJsonStr(Collections.singletonList(response.getData())));
xinchuangService.updateById(xinchuang);
}
log.warn("修复采购信息xcfhxReportFiles成功:{}", w);
} catch (Exception ex) {
log.warn("修复采购信息xcfhxReportFiles失败:{}", w);
}
});
}
}

public synchronized void pushToMhNotice(Long purchaseId) {
@@ -1104,7 +1121,8 @@ public class PurchaseManage {
if (Boolean.TRUE.equals(dto.getMatchXcfhx())
&& StrUtils.isNotBlank(dto.getMhXcfhxReportFile())) {
String fileName = xinchuang.getBidName() + "-信创符合性测评报告.";
xinchuang.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName));
FileResultVO xcfhxFile = mhXcfhxReportHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName);
xinchuang.setXcfhxReportFiles(JSONUtil.toJsonStr(Collections.singletonList(xcfhxFile)));
}

if (xinchuangService.save(xinchuang)) {
@@ -1121,7 +1139,8 @@ public class PurchaseManage {
&& StrUtils.isNotBlank(dto.getMhXcfhxReportFile()) &&
!dto.getMhXcfhxReportFile().equals(old.getMhXcfhxReportFile())) {
String fileName = xinchuang.getBidName() + "-信创符合性测评报告.";
xinchuang.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName));
FileResultVO xcfhxFile = mhXcfhxReportHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName);
xinchuang.setXcfhxReportFiles(JSONUtil.toJsonStr(Collections.singletonList(xcfhxFile)));
}
if (xinchuangService.updateById(xinchuang)) {
return xinchuang.getId();
@@ -1129,12 +1148,12 @@ public class PurchaseManage {
throw BizException.wrap("编辑失败");
}

public String xcfhxReportFiles(String code) {
return mhXcfhxFileHelper.getXcfhxFile(code, null);
public FileResultVO xcfhxReportFiles(String code) {
return mhXcfhxReportHelper.getXcfhxFile(code, null);
}

public void exportXcfhFile(String code, HttpServletResponse response) throws UnsupportedEncodingException {
mhXcfhxFileHelper.exportReport(code, response);
public void exportXcfhFile(String code, HttpServletResponse response) {
mhXcfhxReportHelper.download(code, response);
}

@Transactional(rollbackFor = Exception.class)


Loading…
Cancel
Save