diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java index 667c54a..a33d18b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java @@ -193,4 +193,10 @@ public class PurchaseController { purchaseManage.pushToMhNotice(id.getId()); } + @PostMapping("/repairXcfhxReportFiles") + @PreAuthorize("hasAuthority('SUPER_ADMIN')") + public void repairXcfhxReportFiles() { + purchaseManage.repairXcfhxReportFiles(); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXchxFileHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxFileHelper.java similarity index 91% rename from hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXchxFileHelper.java rename to hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxFileHelper.java index 40c3d50..668faa7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXchxFileHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/helper/MhXcfhxFileHelper.java @@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.nio.file.Files; +import java.util.Collections; /** * @Classname MhXchxFileHelper @@ -30,7 +31,7 @@ import java.nio.file.Files; @Component @RequiredArgsConstructor @Slf4j -public class MhXchxFileHelper { +public class MhXcfhxFileHelper { private final MhFileClient mhFileClient; @@ -45,9 +46,9 @@ public class MhXchxFileHelper { FileInputStream fis = null; try { tmpFile = mhFileClient.downloadToTmpFile(reportFile); - if(StringUtils.isNotBlank(fileName)){ + if (StringUtils.isNotBlank(fileName)) { fileName = fileName + FileUtil.getSuffix(tmpFile); - }else{ + } else { fileName = tmpFile.getName(); } fis = new FileInputStream(tmpFile); @@ -65,7 +66,7 @@ public class MhXchxFileHelper { IOUtils.closeQuietly(fis); } } - return JSONUtil.toJsonStr(retFileInfo); + return JSONUtil.toJsonStr(Collections.singletonList(retFileInfo.getData())); } public void exportReport(String reportFile, HttpServletResponse response) throws UnsupportedEncodingException { @@ -76,7 +77,7 @@ public class MhXchxFileHelper { File file = mhFileClient.downloadToTmpFile(reportFile); // 设置响应的内容类型和头信息 response.setContentType("application/pdf"); - response.setHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(file.getName(),"utf-8") + "\""); + response.setHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(file.getName(), "utf-8") + "\""); // 使用ServletOutputStream写文件内容 try (InputStream in = Files.newInputStream(file.toPath()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java index 4d70d2b..fd59600 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java @@ -21,7 +21,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.MhXchxFileHelper; +import com.hz.pm.api.projectdeclared.helper.MhXcfhxFileHelper; 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; @@ -105,7 +105,7 @@ public class ConstructionManage { private final IProjectAnnualPaymentPlanService projectPaymentPlanService; private final TenderStateMachineUtil tenderStateMachineUtil; private final XcfhxStateMachineUtil xcfhxStateMachineUtil; - private final MhXchxFileHelper mhXchxFileHelper; + private final MhXcfhxFileHelper mhXcfhxFileHelper; private final IXinchuangService xinchuangService; private final TaskService taskService; @@ -642,7 +642,7 @@ public class ConstructionManage { if (StrUtils.isBlank(purchase.getMhXcfhxReportFile()) || req.getMhXcfhxReportFile().equals(purchase.getMhXcfhxReportFile())) { String fileName = purchase.getBidName() + "-信创符合性测评报告."; - purchase.setXcfhxReportFiles(mhXchxFileHelper.getXcfhxFile(req.getMhXcfhxReportFile(), fileName)); + purchase.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(req.getMhXcfhxReportFile(), fileName)); } purchase.setMhXcfhxReportRecordId(req.getMhXcfhxReportRecordId()); purchase.setMhXcfhxReportFile(req.getMhXcfhxReportFile()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 0a9f5e3..4d553f8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import cn.hutool.http.HttpUtil; @@ -31,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.MhXchxFileHelper; +import com.hz.pm.api.projectdeclared.helper.MhXcfhxFileHelper; 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; @@ -69,6 +70,7 @@ import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; @@ -135,7 +137,7 @@ public class PurchaseManage { private final IProjectInstService projectInstService; private final EnvironmentUtil environmentUtil; private final IXinchuangService xinchuangService; - private final MhXchxFileHelper mhXchxFileHelper; + private final MhXcfhxFileHelper mhXcfhxFileHelper; private final IPurchaseStatusChangeService purchaseStatusChangeService; private final MhUnitQueryAuthHelper mhUnitQueryAuthHelper; private final IProjectGovSystemReplaceInfosService projectGovSystemReplaceInfosService; @@ -552,6 +554,28 @@ public class PurchaseManage { projectGovSystemReplaceInfosService.updateBatchById(projectGovSystemReplaceInfos); } + + public void repairXcfhxReportFiles() { + List purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) + .select(Purchase::getId, Purchase::getXcfhxReportFiles) + .isNotNull(Purchase::getXcfhxReportFiles)); + for (Purchase purchase : purchases) { + BizUtils.notBlank(purchase.getXcfhxReportFiles(), w -> { + try { + ApiResponse response = JSONUtil.toBean(w, new TypeReference>() { + }, false); + if (response.getCode() == ApiResponse.SUCCESS_CODE) { + purchase.setXcfhxReportFiles(JSONUtil.toJsonStr(Collections.singletonList(response.getData()))); + purchaseService.updateById(purchase); + } + log.warn("修复采购信息xcfhxReportFiles成功:{}", w); + } catch (Exception ex) { + log.warn("修复采购信息xcfhxReportFiles失败:{}", w); + } + }); + } + } + public synchronized void pushToMhNotice(Long purchaseId) { Purchase purchase = purchaseService.getById(purchaseId); if (Boolean.TRUE.equals(mhPurchaseNoticeOpen)) { @@ -1080,7 +1104,7 @@ public class PurchaseManage { if (Boolean.TRUE.equals(dto.getMatchXcfhx()) && StrUtils.isNotBlank(dto.getMhXcfhxReportFile())) { String fileName = xinchuang.getBidName() + "-信创符合性测评报告."; - xinchuang.setXcfhxReportFiles(mhXchxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName)); + xinchuang.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName)); } if (xinchuangService.save(xinchuang)) { @@ -1097,7 +1121,7 @@ public class PurchaseManage { && StrUtils.isNotBlank(dto.getMhXcfhxReportFile()) && !dto.getMhXcfhxReportFile().equals(old.getMhXcfhxReportFile())) { String fileName = xinchuang.getBidName() + "-信创符合性测评报告."; - xinchuang.setXcfhxReportFiles(mhXchxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName)); + xinchuang.setXcfhxReportFiles(mhXcfhxFileHelper.getXcfhxFile(dto.getMhXcfhxReportFile(), fileName)); } if (xinchuangService.updateById(xinchuang)) { return xinchuang.getId(); @@ -1106,11 +1130,11 @@ public class PurchaseManage { } public String xcfhxReportFiles(String code) { - return mhXchxFileHelper.getXcfhxFile(code, null); + return mhXcfhxFileHelper.getXcfhxFile(code, null); } public void exportXcfhFile(String code, HttpServletResponse response) throws UnsupportedEncodingException { - mhXchxFileHelper.exportReport(code, response); + mhXcfhxFileHelper.exportReport(code, response); } @Transactional(rollbackFor = Exception.class)