From 80758f1033c5064970175d965759cdddb1c4b439 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 13 Sep 2023 14:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/task/SynProjectCollectionTask.java | 2 +- .../projectCollection/ProjectCollectionTest.java | 63 ++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java index 30d53e3..f8abfab 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java @@ -183,7 +183,7 @@ public class SynProjectCollectionTask { } if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){ StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile()); - approve.setApprovalFile(sj.toString()); + approve.setApprovalFilePdf(sj.toString()); } if(StringUtils.isBlank(approve.getPreliminaryDesignFilePdf()) && StringUtils.isNotBlank(approve.getPreliminaryDesignFile())){ StringJoiner sj = collectionManage.convertAndUpload(approve.getPreliminaryDesignFile()); diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java index 3ff4859..ffd891e 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java @@ -1,8 +1,14 @@ package com.ningdatech.pmapi.projectCollection; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.ningdatech.log.model.domain.OptLog; +import com.ningdatech.log.service.OptLogService; import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; @@ -12,12 +18,15 @@ import com.ningdatech.pmapi.gov.model.entity.*; import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.scheduler.task.SynProjectCollectionTask; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; /** * @Classname ProjectCollectionTest @@ -51,6 +60,9 @@ public class ProjectCollectionTest extends AppTests { @Autowired private SynProjectCollectionTask collectionTask; + @Autowired + private OptLogService optLogService; + @Test public void test(){ List baseProjIds = Lists.newArrayList("33110000020230100061"); @@ -95,4 +107,55 @@ public class ProjectCollectionTest extends AppTests { public void test3() throws UnknownHostException { collectionTask.stagingConvertPdf("33112200020230100008"); } + + /** + * 去补文件 + */ + @Test + public void test4(){ + List approves = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getApprovalFile,"null")); + + System.out.println("approves size :" + approves.size()); + + for(GovBizProjectApprove approve : approves){ + //https://sjxmglxt-oss.oss-cn-hangzhou-zjzwy01-d01-a.cloud-inner.zj.gov.cn/20230912/6a5c00def2db41b199d8cc99ff04728e.pdf + String baseProjId = approve.getBaseProjId(); + + List opLogs = optLogService.list(Wrappers.lambdaQuery(OptLog.class) + .like(OptLog::getParams, approve.getBaseProjName()) + .like(OptLog::getParams, "\"approvalFile\"") + .last(BizConst.LIMIT_1)); + if(CollUtil.isEmpty(opLogs)){ + System.out.println("没有这个记录"); + continue; + } + + for(OptLog opLog : opLogs){ + System.out.println(opLog.getParams()); + + if(StringUtils.isNotBlank(opLog.getParams())){ + StringJoiner sj = new StringJoiner(";"); + JSONArray jsonArray = JSON.parseArray(opLog.getParams()); + jsonArray.forEach(j -> { + JSONObject json = JSON.parseObject(JSON.toJSONString(j)); + JSONObject approveJson = json.getJSONObject("approve"); + if(Objects.nonNull(approveJson)){ + String approvalFile = approveJson.getString("approvalFile"); + System.out.println("approvalFile:" + approvalFile); + if(StringUtils.isBlank(approvalFile) || "null".equals(approvalFile)){ + return; + } + sj.add(approvalFile); + } + }); + if(StringUtils.isNotBlank(sj.toString())){ + approve.setApprovalFile(sj.toString()); + approveService.updateById(approve); + break; + } + } + } + } + } }