From e3982315b71bbdb23685989fc381a1fbe857f4f0 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Mon, 4 Sep 2023 16:31:14 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E5=88=97=E8=A1=A8=E6=9D=83=E9=99=90=E5=92=8C=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov/manage/GovProjectCollectionManage.java | 62 +++++++++++++++++----- .../pmapi/gov/model/entity/GovBizProjectApply.java | 9 ++++ .../gov/model/entity/GovBizProjectApprove.java | 9 ++++ .../gov/model/entity/GovBizProjectBaseinfo.java | 9 ++++ .../gov/model/entity/GovBizProjectCimplement.java | 9 ++++ .../gov/model/entity/GovBizProjectMimplement.java | 9 ++++ .../gov/model/entity/GovBizProjectProcure.java | 9 ++++ .../pmapi/gov/model/vo/GovBizProjectApplyVO.java | 9 ++++ .../pmapi/gov/model/vo/GovBizProjectApproveVO.java | 9 ++++ .../gov/model/vo/GovBizProjectBaseinfoVO.java | 9 ++++ .../gov/model/vo/GovBizProjectCimplementVO.java | 9 ++++ .../gov/model/vo/GovBizProjectMimplementVO.java | 9 ++++ .../pmapi/gov/model/vo/GovBizProjectProcureVO.java | 9 ++++ 13 files changed, 157 insertions(+), 13 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 7045db5..c0319fb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -22,6 +22,10 @@ import com.ningdatech.pmapi.gov.model.vo.*; import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; +import com.ningdatech.pmapi.sys.model.entity.Role; +import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -106,7 +110,9 @@ public class GovProjectCollectionManage { .eq(StringUtils.isNotBlank(req.getRegionCode()),GovBizProjectBaseinfo::getBaseAreaCode,req.getRegionCode() + BizConst.NINE_AREA_CODE_LAST) .gt(Objects.nonNull(req.getCreateOnMin()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMin()) .le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMax()) + .eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) .orderByDesc(GovBizProjectBaseinfo::getBizTime); + permissions(wrapper); baseinfoService.page(page,wrapper); if(CollUtil.isEmpty(page.getRecords())){ @@ -145,6 +151,25 @@ public class GovProjectCollectionManage { return PageVo.of(res,page.getTotal()); } + /** + * 数据权限 + * @param wrapper + */ + private void permissions(LambdaQueryWrapper wrapper) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + List userRoleList = user.getUserRoleList(); + for(Role role : userRoleList){ + //超管和区域管理员 + if(RoleEnum.SUPER_ADMIN.name().equals(role.getCode()) || + RoleEnum.REGION_MANAGER.name().equals(role.getCode())){ + log.info("超管和区管 可以看所有"); + }else{ + //其他情况 都只能看 自己单位的 + wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); + } + } + } + public Long count(ProjectListReq req) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .like(StringUtils.isNotBlank(req.getProjectName()),GovBizProjectBaseinfo::getBaseProjName,req.getProjectName()) @@ -231,8 +256,11 @@ public class GovProjectCollectionManage { */ @Transactional public String save(GovBizProjectSaveDTO saveDTO) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + GovBizProjectBaseinfoDTO base = saveDTO.getBaseinfo(); String baseProjId = base.getBaseProjId(); + String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; String baseProjName = base.getBaseProjName(); //如果是新增的话 要生成 项目编号 if(StringUtils.isBlank(baseProjId)){ @@ -258,6 +286,7 @@ public class GovProjectCollectionManage { saveBase.setId(oldBaseInfo.getId()); }else{ saveBase.setTongTime(LocalDateTime.now()); + saveBase.setBaseAreaCode(baseAreaCode); } if(Objects.nonNull(saveBase.getBaseAreaCode())){ saveBase.setBaseAreaCode(saveBase.getBaseAreaCode() + BizConst.NINE_AREA_CODE_LAST); @@ -396,24 +425,31 @@ public class GovProjectCollectionManage { VUtils.isTrue(Objects.isNull(baseinfo)).throwMessage("项目不存在!"); - baseinfoService.removeById(baseinfo); - projectApplyService.remove(Wrappers.lambdaQuery(GovBizProjectApply.class) - .eq(GovBizProjectApply::getBaseProjId,projId)); - approveService.remove(Wrappers.lambdaQuery(GovBizProjectApprove.class) - .eq(GovBizProjectApprove::getBaseProjId,projId)); - cimplementService.remove(Wrappers.lambdaQuery(GovBizProjectCimplement.class) - .eq(GovBizProjectCimplement::getBaseProjId,projId)); - mimplementService.remove(Wrappers.lambdaQuery(GovBizProjectMimplement.class) - .eq(GovBizProjectMimplement::getBaseProjId,projId)); - procureService.remove(Wrappers.lambdaQuery(GovBizProjectProcure.class) - .eq(GovBizProjectProcure::getBaseProjId,projId)); -// notEffectiveProject(BeanUtil.copyProperties(baseinfo,GovBizProjectBaseinfoDTO.class)); + //改正逻辑删除 + baseinfo.setDeleted(Boolean.TRUE); + baseinfoService.updateById(baseinfo); + projectApplyService.update(Wrappers.lambdaUpdate(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjId,projId) + .set(GovBizProjectApply::getDeleted,Boolean.TRUE)); + approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId,projId) + .set(GovBizProjectApprove::getDeleted,Boolean.TRUE)); + cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjId,projId) + .set(GovBizProjectCimplement::getDeleted,Boolean.TRUE)); + mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjId,projId) + .set(GovBizProjectMimplement::getDeleted,Boolean.TRUE)); + procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjId,projId) + .set(GovBizProjectProcure::getDeleted,Boolean.TRUE)); return BizConst.OP_SUCCESS; } private void checkName(String baseProjName, String baseProjId) { VUtils.isTrue(baseinfoService.count(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjName,baseProjName) + .eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) .ne(GovBizProjectBaseinfo::getBaseProjId,baseProjId)) > 0L) .throwMessage("项目名重复"); } @@ -431,7 +467,7 @@ public class GovProjectCollectionManage { MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); headers.setContentType(type); headers.add("Accept", MediaType.APPLICATION_JSON.toString()); - HttpEntity formEntity = new HttpEntity(req, headers); + HttpEntity formEntity = new HttpEntity(req, headers); ResponseEntity response = restTemplate.postForEntity(url, formEntity, String.class); log.info("推送结果 {} :{}",saveDTO.getBaseProjId(),response); }catch (Exception e){ diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java index 0fd52c1..db6c5d9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java @@ -140,4 +140,13 @@ public class GovBizProjectApply implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java index c385261..4542fb7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java @@ -90,4 +90,13 @@ public class GovBizProjectApprove implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectBaseinfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectBaseinfo.java index a2a7b35..a7b79c7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectBaseinfo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectBaseinfo.java @@ -104,4 +104,13 @@ public class GovBizProjectBaseinfo implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java index 742a5a9..6154c1f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java @@ -106,4 +106,13 @@ public class GovBizProjectCimplement implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java index f5352c0..8b25046 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java @@ -94,4 +94,13 @@ public class GovBizProjectMimplement implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java index 1a9a3e7..a87f7c9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java @@ -95,4 +95,13 @@ public class GovBizProjectProcure implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java index d503c38..9010530 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java @@ -135,4 +135,13 @@ public class GovBizProjectApplyVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java index b5c98b7..1b93930 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java @@ -85,4 +85,13 @@ public class GovBizProjectApproveVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectBaseinfoVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectBaseinfoVO.java index 489c1f4..5f36697 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectBaseinfoVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectBaseinfoVO.java @@ -98,4 +98,13 @@ public class GovBizProjectBaseinfoVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java index 85df69e..9a07ef9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java @@ -101,4 +101,13 @@ public class GovBizProjectCimplementVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java index 5a41dae..3676b42 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java @@ -89,4 +89,13 @@ public class GovBizProjectMimplementVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java index 941e777..9ff4798 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java @@ -90,4 +90,13 @@ public class GovBizProjectProcureVO implements Serializable { @ApiModelProperty("入库时间") private LocalDateTime tongTime; + + @ApiModelProperty("逻辑删除") + private Boolean deleted; + + @ApiModelProperty("最后修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("最后修改人") + private String updateBy; } From 3aae180fd680e357407ce5e53b1fdf3f67a9c2c9 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 13:52:46 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E8=8D=89=E7=A8=BF=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pmapi/pom.xml | 1 - .../pmapi/gov/contants/BizProjectContant.java | 4 + .../controller/GovProjectCollectionController.java | 28 ++- .../gov/manage/GovProjectCollectionManage.java | 271 +++++++++++++++++++-- .../pmapi/gov/mapper/GovBizProjectDraftMapper.java | 16 ++ .../pmapi/gov/model/dto/GovBizProjectSaveDTO.java | 3 + .../pmapi/gov/model/entity/GovBizProjectDraft.java | 134 ++++++++++ .../pmapi/gov/model/vo/GovBizProjectDetailVO.java | 3 + .../pmapi/gov/model/vo/GovBizProjectListVO.java | 3 + .../gov/service/IGovBizProjectDraftService.java | 16 ++ .../impl/GovBizProjectDraftServiceImpl.java | 21 ++ .../utils/GenerateProjectCodeUtil.java | 3 +- .../pmapi/collection/SaveCollectionTest.java | 145 +++++++++++ pmapi/src/test/resources/application-prod.yml | 6 +- pmapi/src/test/resources/application.yml | 2 +- 15 files changed, 632 insertions(+), 24 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/gov/mapper/GovBizProjectDraftMapper.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/gov/service/IGovBizProjectDraftService.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/gov/service/impl/GovBizProjectDraftServiceImpl.java create mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest.java diff --git a/pmapi/pom.xml b/pmapi/pom.xml index c89e950..19811fa 100644 --- a/pmapi/pom.xml +++ b/pmapi/pom.xml @@ -375,7 +375,6 @@ system ${project.basedir}/lib/dom4j-2.0.2.jar - diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java index bf4c321..ef45497 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java @@ -19,6 +19,10 @@ public interface BizProjectContant { public static final String IS_EFFECTIVE = "02"; //有效 public static final String NOT_EFFECTIVE = "01"; + public static final String DRAFT = "草稿"; + public static final String OP_INSERT = "insert"; + public static final String OP_UPDATE = "update"; + public static final String OP_DELETE = "delete"; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java index 894c479..f1bf99c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java @@ -62,7 +62,7 @@ public class GovProjectCollectionController { @ApiOperation("项目归集保存") @WebLog("项目归集保存") public String save(@Valid @RequestBody GovBizProjectSaveDTO saveDTO) { - return collectionManage.save(saveDTO); + return collectionManage.save(saveDTO,null); } @PostMapping("/remove/{projId}") @@ -72,6 +72,32 @@ public class GovProjectCollectionController { return collectionManage.remove(projId); } + @GetMapping("/draft-list") + @ApiOperation("项目归集草稿箱列表") + public PageVo draftList(ProjectListReq req) { + return collectionManage.draftList(req); + } + + @GetMapping("/draft-detail/{draftId}") + @ApiOperation("项目归集草稿箱详情") + public GovBizProjectDetailVO draftDetail(@PathVariable Long draftId) { + return collectionManage.draftDetail(draftId); + } + + @PostMapping("/draft") + @ApiOperation("项目归集暂存草稿箱") + @WebLog("项目归集暂存草稿箱") + public String draft(@Valid @RequestBody GovBizProjectSaveDTO saveDTO) { + return collectionManage.draft(saveDTO,null); + } + + @PostMapping("/draft-remove/{draftId}") + @ApiOperation("项目归集草稿箱删除") + @WebLog("项目归集草稿箱删除") + public String draftRemove(@PathVariable Long draftId) { + return collectionManage.draftRemove(draftId); + } + @PostMapping("/push-task") @ApiOperation("主动调用定时器方法") @WebLog("主动调用定时器方法") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index c0319fb..54c3f28 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.gov.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -71,6 +72,8 @@ public class GovProjectCollectionManage { private final GenerateProjectCodeUtil generateProjectCodeUtil; + private final IGovBizProjectDraftService draftService; + private final RestTemplate restTemplate; @Value("${project.push-url}") @@ -152,6 +155,48 @@ public class GovProjectCollectionManage { } /** + * 草稿箱列表 + * @param req + * @return + */ + public PageVo draftList(ProjectListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(GovBizProjectDraft.class) + .like(StringUtils.isNotBlank(req.getProjectName()),GovBizProjectDraft::getBaseProjName,req.getProjectName()) + .like(StringUtils.isNotBlank(req.getBuildOrg()),GovBizProjectDraft::getBaseBuildDeprt,req.getBuildOrg()) + .eq(StringUtils.isNotBlank(req.getAreaCode()),GovBizProjectDraft::getBaseAreaCode,req.getAreaCode() + BizConst.NINE_AREA_CODE_LAST) + .eq(StringUtils.isNotBlank(req.getRegionCode()),GovBizProjectDraft::getBaseAreaCode,req.getRegionCode() + BizConst.NINE_AREA_CODE_LAST) + .gt(Objects.nonNull(req.getCreateOnMin()),GovBizProjectDraft::getTongTime,req.getCreateOnMin()) + .le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectDraft::getTongTime,req.getCreateOnMax()) + .eq(GovBizProjectDraft::getDeleted,Boolean.FALSE) + .eq(GovBizProjectDraft::getCreateId,user.getUserId()) + .orderByDesc(GovBizProjectDraft::getBizTime); + draftService.page(page,wrapper); + + if(CollUtil.isEmpty(page.getRecords())){ + return PageVo.empty(); + } + + List res = page.getRecords().stream().map(p -> { + GovBizProjectListVO vo = new GovBizProjectListVO(); + vo.setBaseAreaCode(p.getBaseAreaCode()); + vo.setBaseAreaName(p.getBaseAreaName()); + vo.setBaseBuildDeprt(p.getBaseBuildDeprt()); + vo.setBaseBuildDeprtDing(p.getBaseBuildDeprtDing()); + vo.setBaseProjId(p.getBaseProjId()); + vo.setBaseProjName(p.getBaseProjName()); + vo.setBaseProjDeclAmount(p.getBaseProjDeclAmount()); + vo.setBaseProjTotalAmount(p.getBaseProjTotalAmount()); + vo.setBaseProjSetYear(p.getBaseProjSetYear()); + vo.setDraftId(p.getId()); + return vo; + }).collect(Collectors.toList()); + + return PageVo.of(res,page.getTotal()); + } + + /** * 数据权限 * @param wrapper */ @@ -250,20 +295,85 @@ public class GovProjectCollectionManage { } /** + * 草稿箱详情 + * @param draftId + * @return + */ + public GovBizProjectDetailVO draftDetail(Long draftId) { + GovBizProjectDetailVO res = new GovBizProjectDetailVO(); + //查询草稿表 + GovBizProjectDraft draft = draftService.getById(draftId); + + if(Objects.isNull(draft)){ + return null; + } + + //1.基本信息 + res.setBaseProjId(draft.getBaseProjId()); + res.setBaseProjName(draft.getBaseProjName()); + res.setBaseinfo(BeanUtil.copyProperties(draft, GovBizProjectBaseinfoVO.class)); + + //2.申报信息 + res.setApply(BeanUtil.copyProperties(draft, GovBizProjectApplyVO.class)); + + //3.再查 审批信息 + res.setApprove(BeanUtil.copyProperties(draft, GovBizProjectApproveVO.class)); + + //4 对应查询 实施项目还是运维项目 + GovBizProjectCimplementVO cimplementVo = BeanUtil.copyProperties(draft, GovBizProjectCimplementVO.class); + cimplementVo.setBaseChanFile(draft.getBaseChanFileCimplement()); + cimplementVo.setBaseEstaSummFile(draft.getBaseEstaSummFileCimplement()); + cimplementVo.setBaseEngineerPostpoFile(draft.getBaseEngineerPostpoFileCimplement()); + cimplementVo.setBaseInforLevelFile(draft.getBaseInforLevelFileCimplement()); + cimplementVo.setBasePasswAssessFile(draft.getBasePasswAssessFileCimplement()); + cimplementVo.setBaseUserConsFile(draft.getBaseUserConsFileCimplement()); + cimplementVo.setBaseThirdAcceptFile(draft.getBaseThirdAcceptFileCimplement()); + cimplementVo.setBaseFinalExpertOpinionFile(draft.getBaseFinalExpertOpinionFileCimplement()); + cimplementVo.setBaseLogAggregation(draft.getBaseLogAggregationCimplement()); + cimplementVo.setBaseBusinessMetrics(draft.getBaseBusinessMetricsCimplement()); + res.setCimplement(cimplementVo); + GovBizProjectMimplementVO mimplementVo = BeanUtil.copyProperties(draft, GovBizProjectMimplementVO.class); + mimplementVo.setBaseChanFile(draft.getBaseChanFileMimplement()); + mimplementVo.setBaseEstaSummFile(draft.getBaseEstaSummFileMimplement()); + mimplementVo.setBaseEngineerPostpoFile(draft.getBaseEngineerPostpoFileMimplement()); + mimplementVo.setBaseInforLevelFile(draft.getBaseInforLevelFileMimplement()); + mimplementVo.setBasePasswAssessFile(draft.getBasePasswAssessFileMimplement()); + mimplementVo.setBaseUserConsFile(draft.getBaseUserConsFileMimplement()); + mimplementVo.setBaseThirdAcceptFile(draft.getBaseThirdAcceptFileMimplement()); + mimplementVo.setBaseFinalExpertOpinionFile(draft.getBaseFinalExpertOpinionFileMimplement()); + mimplementVo.setBaseLogAggregation(draft.getBaseLogAggregationMimplement()); + mimplementVo.setBaseBusinessMetrics(draft.getBaseBusinessMetricsMimplement()); + res.setMimplement(mimplementVo); + + //5.最后查询采购信息 + if(StringUtils.isNotBlank(draft.getProcure())){ + try{ + res.setProcures(JSON.parseArray(draft.getProcure(),GovBizProjectProcureVO.class)); + }catch (Exception e){ + log.error("草稿箱采购出错:" + e.getMessage()); + } + } + + return res; + } + + /** * 项目归集保存 * @param saveDTO * @return */ @Transactional - public String save(GovBizProjectSaveDTO saveDTO) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); + public String save(GovBizProjectSaveDTO saveDTO,UserInfoDetails user) { + if(Objects.isNull(user)){ + user = LoginUserUtil.loginUserDetail(); + } GovBizProjectBaseinfoDTO base = saveDTO.getBaseinfo(); String baseProjId = base.getBaseProjId(); String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; String baseProjName = base.getBaseProjName(); //如果是新增的话 要生成 项目编号 - if(StringUtils.isBlank(baseProjId)){ + if(StringUtils.isBlank(baseProjId) || BizProjectContant.ProjectCollection.DRAFT.equals(baseProjId)){ baseProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); } @@ -288,11 +398,10 @@ public class GovProjectCollectionManage { saveBase.setTongTime(LocalDateTime.now()); saveBase.setBaseAreaCode(baseAreaCode); } - if(Objects.nonNull(saveBase.getBaseAreaCode())){ - saveBase.setBaseAreaCode(saveBase.getBaseAreaCode() + BizConst.NINE_AREA_CODE_LAST); - } saveBase.setAreaCode(RegionConst.RC_LS); saveBase.setBizTime(LocalDateTime.now()); + saveBase.setUpdateBy(user.getUsername()); + saveBase.setUpdateOn(LocalDateTime.now()); baseinfoService.saveOrUpdate(saveBase); // 2.保存 申报信息 @@ -313,6 +422,8 @@ public class GovProjectCollectionManage { } saveApply.setAreaCode(RegionConst.RC_LS); saveApply.setBizTime(LocalDateTime.now()); + saveApply.setUpdateBy(user.getUsername()); + saveApply.setUpdateOn(LocalDateTime.now()); projectApplyService.saveOrUpdate(saveApply); } @@ -334,6 +445,8 @@ public class GovProjectCollectionManage { } saveApprove.setBizTime(LocalDateTime.now()); saveApprove.setAreaCode(RegionConst.RC_LS); + saveApprove.setUpdateBy(user.getUsername()); + saveApprove.setUpdateOn(LocalDateTime.now()); approveService.saveOrUpdate(saveApprove); } @@ -356,6 +469,8 @@ public class GovProjectCollectionManage { } saveCimplement.setAreaCode(RegionConst.RC_LS); saveCimplement.setBizTime(LocalDateTime.now()); + saveCimplement.setUpdateBy(user.getUsername()); + saveCimplement.setUpdateOn(LocalDateTime.now()); cimplementService.saveOrUpdate(saveCimplement); } @@ -382,6 +497,8 @@ public class GovProjectCollectionManage { } saveMimplement.setAreaCode(RegionConst.RC_LS); saveMimplement.setBizTime(LocalDateTime.now()); + saveMimplement.setUpdateBy(user.getUsername()); + saveMimplement.setUpdateOn(LocalDateTime.now()); mimplementService.saveOrUpdate(saveMimplement); } @@ -402,6 +519,8 @@ public class GovProjectCollectionManage { saveProcure.setAreaCode(RegionConst.RC_LS); saveProcure.setTongTime(LocalDateTime.now()); saveProcure.setBizTime(LocalDateTime.now()); + saveProcure.setUpdateBy(user.getUsername()); + saveProcure.setUpdateOn(LocalDateTime.now()); procureService.save(saveProcure); index++; } @@ -414,11 +533,109 @@ public class GovProjectCollectionManage { } /** + * 暂存草稿箱 + * @param saveDTO + * @param user + * @return + */ + public String draft(GovBizProjectSaveDTO saveDTO, UserInfoDetails user) { + if(Objects.isNull(user)){ + user = LoginUserUtil.loginUserDetail(); + } + + GovBizProjectDraft draft = new GovBizProjectDraft(); + //草稿id + Long draftId = saveDTO.getDraftId(); + String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; + if(Objects.nonNull(draftId)){ + GovBizProjectDraft oldDraft = draftService.getById(draftId); + VUtils.isTrue(Objects.isNull(oldDraft)).throwMessage("该草稿不存在!"); + draft.setId(draftId); + }else{ + draft.setTongTime(LocalDateTime.now()); + draft.setBaseAreaCode(baseAreaCode); + draft.setCreateId(user.getUserId()); + draft.setTongTime(LocalDateTime.now()); + } + + //1.保存基本信息 + GovBizProjectBaseinfoDTO base = saveDTO.getBaseinfo(); + String baseProjId = base.getBaseProjId(); + String baseProjName = base.getBaseProjName(); + //要生成 草稿的项目编号 + if(StringUtils.isBlank(baseProjId)){ + baseProjId = BizProjectContant.ProjectCollection.DRAFT; + } + + BeanUtil.copyProperties(base, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseProjId(baseProjId); + draft.setBaseProjName(baseProjName); + draft.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); + draft.setAreaCode(RegionConst.RC_LS); + draft.setBizTime(LocalDateTime.now()); + draft.setUpdateBy(user.getUsername()); + draft.setUpdateOn(LocalDateTime.now()); + draft.setOp(BizProjectContant.ProjectCollection.OP_INSERT); + + // 2.保存 申报信息 + GovBizProjectApplyDTO apply = saveDTO.getApply(); + BeanUtil.copyProperties(apply, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + + // 3.保存 审批信息 + GovBizProjectApproveDTO approve = saveDTO.getApprove(); + BeanUtil.copyProperties(approve, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + + // 4.保存 建设项目 实施信息 + GovBizProjectCimplementDTO cimplement = saveDTO.getCimplement(); + BeanUtil.copyProperties(cimplement, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseBidCode(baseProjId + "-1"); + draft.setBaseChanFileCimplement(cimplement.getBaseChanFile()); + draft.setBaseLogAggregationCimplement(cimplement.getBaseLogAggregation()); + draft.setBaseBusinessMetricsCimplement(cimplement.getBaseBusinessMetrics()); + draft.setBaseEstaSummFileCimplement(cimplement.getBaseEstaSummFile()); + draft.setBaseInforLevelFileCimplement(cimplement.getBaseInforLevelFile()); + draft.setBaseEngineerPostpoFileCimplement(cimplement.getBaseEngineerPostpoFile()); + draft.setBaseUserConsFileCimplement(cimplement.getBaseUserConsFile()); + draft.setBasePasswAssessFileCimplement(cimplement.getBasePasswAssessFile()); + draft.setBaseThirdAcceptFileCimplement(cimplement.getBaseThirdAcceptFile()); + draft.setBaseFinalExpertOpinionFileCimplement(cimplement.getBaseFinalExpertOpinionFile()); + + // 5.保存 运维项目 实施信息 + GovBizProjectMimplementDTO mimplement = saveDTO.getMimplement(); + BeanUtil.copyProperties(mimplement, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseLogAggregationMimplement(mimplement.getBaseLogAggregation()); + draft.setBaseBusinessMetricsMimplement(mimplement.getBaseBusinessMetrics()); + draft.setBaseChanFileMimplement(mimplement.getBaseChanFile()); + draft.setBaseEstaSummFileMimplement(mimplement.getBaseEstaSummFile()); + draft.setBaseInforLevelFileMimplement(mimplement.getBaseInforLevelFile()); + draft.setBaseEngineerPostpoFileMimplement(mimplement.getBaseEngineerPostpoFile()); + draft.setBaseThirdAcceptFileMimplement(mimplement.getBaseThirdAcceptFile()); + draft.setBaseUserConsFileMimplement(mimplement.getBaseUserConsFile()); + draft.setBaseFinalExpertOpinionFileCimplement(mimplement.getBaseFinalExpertOpinionFile()); + + // 6.保存 采购信息 + List procures = saveDTO.getProcures(); + draft.setProcure(JSON.toJSONString(procures)); + + draftService.saveOrUpdate(draft); + + return BizConst.SAVE_SUCCESS; + } + + /** * 删除项目归集 * @param projId * @return */ public String remove(String projId) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + String username = user.getUsername(); + GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjId, projId) .last(BizConst.LIMIT_1)); @@ -430,22 +647,44 @@ public class GovProjectCollectionManage { baseinfoService.updateById(baseinfo); projectApplyService.update(Wrappers.lambdaUpdate(GovBizProjectApply.class) .eq(GovBizProjectApply::getBaseProjId,projId) - .set(GovBizProjectApply::getDeleted,Boolean.TRUE)); + .set(GovBizProjectApply::getDeleted,Boolean.TRUE) + .set(GovBizProjectApply::getUpdateOn,LocalDateTime.now()) + .set(GovBizProjectApply::getUpdateBy,username)); approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) .eq(GovBizProjectApprove::getBaseProjId,projId) - .set(GovBizProjectApprove::getDeleted,Boolean.TRUE)); + .set(GovBizProjectApprove::getDeleted,Boolean.TRUE) + .set(GovBizProjectApprove::getUpdateOn,LocalDateTime.now()) + .set(GovBizProjectApprove::getUpdateBy,username)); cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) .eq(GovBizProjectCimplement::getBaseProjId,projId) - .set(GovBizProjectCimplement::getDeleted,Boolean.TRUE)); + .set(GovBizProjectCimplement::getDeleted,Boolean.TRUE) + .set(GovBizProjectCimplement::getUpdateOn,LocalDateTime.now()) + .set(GovBizProjectCimplement::getUpdateBy,username)); mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) .eq(GovBizProjectMimplement::getBaseProjId,projId) - .set(GovBizProjectMimplement::getDeleted,Boolean.TRUE)); + .set(GovBizProjectMimplement::getDeleted,Boolean.TRUE) + .set(GovBizProjectMimplement::getUpdateOn,LocalDateTime.now()) + .set(GovBizProjectMimplement::getUpdateBy,username)); procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) .eq(GovBizProjectProcure::getBaseProjId,projId) - .set(GovBizProjectProcure::getDeleted,Boolean.TRUE)); + .set(GovBizProjectProcure::getDeleted,Boolean.TRUE) + .set(GovBizProjectProcure::getUpdateOn,LocalDateTime.now()) + .set(GovBizProjectProcure::getUpdateBy,username)); return BizConst.OP_SUCCESS; } + /** + * 项目归集 草稿箱删除 + * @param draftId + * @return + */ + public String draftRemove(Long draftId) { + if(draftService.removeById(draftId)){ + return BizConst.OP_SUCCESS; + } + return BizConst.OP_FAIL; + } + private void checkName(String baseProjName, String baseProjId) { VUtils.isTrue(baseinfoService.count(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjName,baseProjName) @@ -514,17 +753,17 @@ public class GovProjectCollectionManage { public void deleteAll() { String url = deleteAllUrl; - try{ - log.info("推送删除数据url {}",url); + try { + log.info("推送删除数据url {}", url); HttpHeaders headers = new HttpHeaders(); MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); headers.setContentType(type); headers.add("Accept", MediaType.APPLICATION_JSON.toString()); HttpEntity formEntity = new HttpEntity(null, headers); ResponseEntity response = restTemplate.postForEntity(url, formEntity, String.class); - log.info("推送删除结果 :{}",response); - }catch (Exception e){ - log.info("推送删除失败,{}",e.getMessage()); + log.info("推送删除结果 :{}", response); + } catch (Exception e) { + log.info("推送删除失败,{}", e.getMessage()); } } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/mapper/GovBizProjectDraftMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/mapper/GovBizProjectDraftMapper.java new file mode 100644 index 0000000..934dc17 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/mapper/GovBizProjectDraftMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.gov.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectDraft; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zpf + * @since 2023-08-23 + */ +public interface GovBizProjectDraftMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java index dd65506..a2dbbd7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java @@ -28,6 +28,9 @@ public class GovBizProjectSaveDTO implements Serializable { @ApiModelProperty("基本项目名称") private String baseProjName; + @ApiModelProperty("草稿id") + private Long draftId; + @ApiModelProperty("项目基本信息") private GovBizProjectBaseinfoDTO baseinfo; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java new file mode 100644 index 0000000..d0f9474 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -0,0 +1,134 @@ +package com.ningdatech.pmapi.gov.model.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * @Classname GovBizProjectDraft + * @Description + * @Date 2023/9/5 11:05 + * @Author PoffyZhang + */ +@Data +@TableName("gov_biz_project_draft") +@ApiModel(value = "GovBizProjectDraft", description = "草稿") +public class GovBizProjectDraft implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + private String baseProjId; + private String baseProjName; + private String baseAreaName; + private String baseAreaCode; + private String baseProjIsConfidentiality; + private String baseProjType; + private String baseConstructionType; + private String baseProjSetProg; + private String isEffective; + private String baseProvManDeprt; + private String baseProvManDeprtDing; + private String baseManDeprt; + private String baseManDeprtDing; + private String baseManDepartUsci; + private String baseBuildDeprt; + private String baseBuildDeprtDing; + private String baseBuildDepartUsci; + private String baseProjPrincipal; + private String baseProjPrincipalCall; + private String baseProjContacts; + private String baseProjContactsCall; + private Boolean deleted; + + private String baseDevelopCode; + private String setProjCodeFinan; + private String baseHistorProjName; + private String baseHistorProjId; + private String baseHistorProjYear; + private String baseProjSys; + private String baseProjSysCode; + private String baseAccountAppName; + private String baseBrainName; + private String baseCoreBusiness; + private String baseCoreBusinessCode; + private LocalDateTime baseProjStartTime; + private LocalDateTime baseProjEndTime; + private LocalDateTime baseProjDuration; + private String baseProjSetYear; + private String baseProjAmountOri; + private String baseBasisAmountOri; + private BigDecimal baseProjTotalAmount; + private BigDecimal baseProjDeclAmount; + private String baseProjConsClass; + private String baseLowestLevel; + private String baseProjBasis; + private String baseBasisEstablish; + private String baseProjBasisFile; + private String baseProjIntro; + private String beseExpectedResults; + private String baseResearchReportFile; + private String baseProjApplyFile; + private String baseOperatMaintenFile; + private String baseProjOtherFile; + private String baseProjRemark; + + private String baseReviewResults; + private String baseReviewOpinion; + private String baseReviewCommentsFile; + private BigDecimal baseExpertTotalMoney; + private BigDecimal baseExpertYearMoney; + private String approvalFile; + private BigDecimal baseInitialReviewTotalMoney; + private BigDecimal baseProjReplyAmount; + private String equalProtectionLevel; + private String preliminaryDesignScheme; + private String preliminaryDesignFile; + private BigDecimal releaseYearMoney; + + private String baseBidCode; + private String baseBidNamet; + + private String baseInitialOpinionFile; + private String baseInforLevelFileCimplement; + private String basePasswAssessFileCimplement; + private String baseThirdAcceptFileCimplement; + private String baseCheckFile; + private String baseFinanlAuditFile; + private String baseUserConsFileCimplement; + private String baseEstaSummFileCimplement; + private String baseIrsTestRunFile; + private String baseSummReportFile; + private String baseLogAggregationCimplement; + private String baseBusinessMetricsCimplement; + private String baseFinalExpertOpinionFileCimplement; + private String baseEngineerPostpoFileCimplement; + private String baseChangeFormFile; + private String baseChanFileCimplement; + + private String baseInforLevelFileMimplement; + private String basePasswAssessFileMimplement; + private String baseThirdAcceptFileMimplement; + private String baseUserConsFileMimplement; + private String baseEstaSummFileMimplement; + private String baseOperatMaintenSummFile; + private String baseLogAggregationMimplement; + private String baseBusinessMetricsMimplement; + private String baseFinalExpertOpinionFileMimplement; + private String baseEngineerPostpoFileMimplement; + private String baseEngineerAlterFile; + private String baseChanFileMimplement; + + private String procure; + + private String areaCode; + private LocalDateTime bizTime; + private String op; + private LocalDateTime tongTime; + private boolean deleted; + private LocalDateTime updateOn; + private String updateBy; + private Long createId; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectDetailVO.java index ef90ebb..c45999d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectDetailVO.java @@ -26,6 +26,9 @@ public class GovBizProjectDetailVO implements Serializable { @ApiModelProperty("基本项目名称") private String baseProjName; + @ApiModelProperty("草稿id") + private Long draftId; + @ApiModelProperty("项目基本信息") private GovBizProjectBaseinfoVO baseinfo; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectListVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectListVO.java index a1ba0b8..f1d8b4f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectListVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectListVO.java @@ -47,4 +47,7 @@ public class GovBizProjectListVO implements Serializable { @ApiModelProperty("申报年度预算") private BigDecimal baseProjDeclAmount; + + @ApiModelProperty("草稿编号") + private Long draftId; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/IGovBizProjectDraftService.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/IGovBizProjectDraftService.java new file mode 100644 index 0000000..5f74241 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/IGovBizProjectDraftService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.gov.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectDraft; + +/** + *

+ * 服务类 + *

+ * + * @author zpf + * @since 2023-08-23 + */ +public interface IGovBizProjectDraftService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/impl/GovBizProjectDraftServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/impl/GovBizProjectDraftServiceImpl.java new file mode 100644 index 0000000..11a00c9 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/service/impl/GovBizProjectDraftServiceImpl.java @@ -0,0 +1,21 @@ +package com.ningdatech.pmapi.gov.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.pmapi.gov.mapper.GovBizProjectDraftMapper; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectDraft; +import com.ningdatech.pmapi.gov.service.IGovBizProjectDraftService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author zpf + * @since 2023-08-23 + */ +@Service +public class GovBizProjectDraftServiceImpl extends + ServiceImpl implements IGovBizProjectDraftService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java index 05e4fc3..afee368 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java @@ -80,8 +80,7 @@ public class GenerateProjectCodeUtil { VUtils.isTrue(Objects.isNull(baseinfo)).throwMessage("没有项目基本信息 无法生成项目编号!"); VUtils.isTrue(Objects.isNull(apply)).throwMessage("没有项目申报信息 无法生成项目编号!"); - String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode())?baseinfo.getBaseAreaCode(): RegionConst.RC_LS) - + BizConst.NINE_AREA_CODE_LAST; + String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode())?baseinfo.getBaseAreaCode(): RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); // 获取建设年度 (10-13) String year = Objects.nonNull(apply.getBaseProjSetYear()) ? apply.getBaseProjSetYear() : String.valueOf(LocalDateTime.now().getYear()); diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest.java new file mode 100644 index 0000000..47ff237 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest.java @@ -0,0 +1,145 @@ +package com.ningdatech.pmapi.collection; + +import com.alibaba.fastjson.JSON; +import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.common.constant.RegionConst; +import com.ningdatech.pmapi.gov.contants.BizProjectContant; +import com.ningdatech.pmapi.gov.manage.GovProjectCollectionManage; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; +import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.*; +import java.time.LocalDateTime; +import java.util.*; + +/** + * @Classname SaveCollectionTest + * @Description + * @Date 2023/9/4 17:43 + * @Author PoffyZhang + */ +public class SaveCollectionTest extends AppTests {// + + @Autowired + private GovProjectCollectionManage manage; + + @Autowired + private GenerateProjectCodeUtil projectCodeUtil; + + @Test + public void importData() throws Exception { + Workbook wb; + File f = new File("C:\\Users\\PoffyZhang\\Desktop\\市本级组织code已核对.xlsx"); + wb = readExcel(new FileInputStream(f),f.getName()); + Row row = null; + if(wb != null) { + //获取第一个sheet + Sheet sheet = wb.getSheetAt(0); + //获取最大行数 + int rownum = sheet.getPhysicalNumberOfRows(); + + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + for (int i = 1; i < rownum; i++) { + row = sheet.getRow(i); + if(Objects.isNull(row) || Objects.isNull(row.getCell(0))){ + break; + } + GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); + + GovBizProjectBaseinfoDTO baseinfoDTO = new GovBizProjectBaseinfoDTO(); + // + String projName = Objects.nonNull(row.getCell(2)) ? row.getCell(2).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjName(projName); + baseinfoDTO.setBaseAreaCode(RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); + baseinfoDTO.setBaseAreaName("丽水市"); + baseinfoDTO.setAreaCode(RegionConst.RC_LS); + baseinfoDTO.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); + baseinfoDTO.setTongTime(LocalDateTime.now()); + baseinfoDTO.setBizTime(LocalDateTime.now()); + baseinfoDTO.setOp("insert"); + String principal = Objects.nonNull(row.getCell(5)) ? row.getCell(5).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjPrincipal(principal); + String contacts = Objects.nonNull(row.getCell(6)) ? row.getCell(6).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjContacts(contacts); + String contactsCall = Objects.nonNull(row.getCell(7)) ? row.getCell(7).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjContactsCall(contactsCall); + String baseProvManDeprt = Objects.nonNull(row.getCell(8)) ? row.getCell(8).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProvManDeprt(baseProvManDeprt); + String baseProvManDeprtDing = Objects.nonNull(row.getCell(9)) ? row.getCell(9).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProvManDeprtDing(baseProvManDeprtDing); + String baseManDeprt = Objects.nonNull(row.getCell(10)) ? row.getCell(10).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseManDeprt(baseManDeprt); + String baseManDeprtDing = Objects.nonNull(row.getCell(11)) ? row.getCell(11).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseManDeprtDing(baseManDeprtDing); + String baseProjType = Objects.nonNull(row.getCell(15)) ? row.getCell(15).toString() : StringUtils.EMPTY; + if("0".equals(baseProjType)){ + baseProjType = "01"; + }else if("1".equals(baseProjType)){ + baseProjType = "04"; + } + baseinfoDTO.setBaseProjType(baseProjType); + String baseProjSetProg = Objects.nonNull(row.getCell(17)) ? row.getCell(17).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjSetProg(baseProjSetProg); + + saveDTO.setBaseinfo(baseinfoDTO); + + GovBizProjectApplyDTO applyDTO = new GovBizProjectApplyDTO(); + String baseProjSetYear = Objects.nonNull(row.getCell(22)) ? row.getCell(22).toString() : StringUtils.EMPTY; + applyDTO.setBaseProjSetYear(baseProjSetYear); + String baseProjIntro = Objects.nonNull(row.getCell(23)) ? row.getCell(23).toString() : StringUtils.EMPTY; + applyDTO.setBaseProjIntro(baseProjIntro); + saveDTO.setApply(applyDTO); + //生产编号 + String projId = projectCodeUtil.generateProjectCode(saveDTO); + saveDTO.setBaseProjId(projId); + saveDTO.getBaseinfo().setBaseProjId(projId); + saveDTO.getApply().setBaseProjId(projId); + UserInfoDetails user = new UserInfoDetails(); + user.setRegionCode(RegionConst.RC_LS); + user.setUsername("系统导入"); + String save = ""; + try{ + save = manage.save(saveDTO, user); + }catch (Exception e){ + e.printStackTrace(); + } + System.out.println(JSON.toJSONString(save)); + } + } + + System.out.println("导入完成"); + } + + //这个下面是单独函数 + public static Workbook readExcel(InputStream is, String extString){ + Workbook wb = null; + extString = extString.substring(extString.lastIndexOf(".")); + try { + if(".xls".equals(extString)){ + return wb = new HSSFWorkbook(is); + }else if(".xlsx".equals(extString)){ + return wb = new XSSFWorkbook(is); + }else { + return wb = null; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return wb; + } +} diff --git a/pmapi/src/test/resources/application-prod.yml b/pmapi/src/test/resources/application-prod.yml index c1a40fa..55d190b 100644 --- a/pmapi/src/test/resources/application-prod.yml +++ b/pmapi/src/test/resources/application-prod.yml @@ -13,9 +13,9 @@ spring: namespace: "spring:session" redis: timeout: 5000 - host: 10.53.168.116 - port: 6379 - database: 0 + host: 47.98.125.47 + port: 26379 + database: 4 password: Ndkj1234 jedis: pool: diff --git a/pmapi/src/test/resources/application.yml b/pmapi/src/test/resources/application.yml index 3d7808a..9f96606 100644 --- a/pmapi/src/test/resources/application.yml +++ b/pmapi/src/test/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev + active: prod From a5724edd4b74d64361c531474fe0ed52392a4208 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 13:54:54 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E8=8D=89=E7=A8=BF=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java | 1 - 1 file changed, 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java index d0f9474..23d08e1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -127,7 +127,6 @@ public class GovBizProjectDraft implements Serializable { private LocalDateTime bizTime; private String op; private LocalDateTime tongTime; - private boolean deleted; private LocalDateTime updateOn; private String updateBy; private Long createId; From f424f0487d89a647f36fa6017493cdbeb1080b9c Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 13:55:41 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E8=8D=89=E7=A8=BF=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java | 1 - 1 file changed, 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java index d0f9474..23d08e1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -127,7 +127,6 @@ public class GovBizProjectDraft implements Serializable { private LocalDateTime bizTime; private String op; private LocalDateTime tongTime; - private boolean deleted; private LocalDateTime updateOn; private String updateBy; private Long createId; From 16382f443626599545bf8ca660faacc0d3ea48b4 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 14:09:01 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E8=8D=89=E7=A8=BF=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java index 23d08e1..a47d767 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -89,7 +89,7 @@ public class GovBizProjectDraft implements Serializable { private BigDecimal releaseYearMoney; private String baseBidCode; - private String baseBidNamet; + private String baseBidName; private String baseInitialOpinionFile; private String baseInforLevelFileCimplement; From ca77b9e8b516f0307c2699d34a67a48c8bdda646 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 16:07:04 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E8=8D=89=E7=A8=BF=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/constant/RegionConst.java | 3 + .../gov/manage/GovProjectCollectionManage.java | 57 ++++--- .../pmapi/collection/SaveCollectionTest331125.java | 176 +++++++++++++++++++++ .../pmapi/file/CommonInputStreamResource.java | 53 +++++++ .../com/ningdatech/pmapi/file/ProvinceOssTest.java | 79 +++++++++ 5 files changed, 343 insertions(+), 25 deletions(-) create mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java create mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java create mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java index d2ba86c..521d4b2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java @@ -27,6 +27,9 @@ public interface RegionConst { String RC_LS_SBJ_IRS = "331101"; //遂昌县 String RC_SC = "331123"; + //丽水开发区 + String LS_KF = "331118"; + String LS_KF_NAME = "开发区"; /** * 中国行政区划编码 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 54c3f28..7bfab79 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -590,37 +590,44 @@ public class GovProjectCollectionManage { // 4.保存 建设项目 实施信息 GovBizProjectCimplementDTO cimplement = saveDTO.getCimplement(); - BeanUtil.copyProperties(cimplement, draft, CopyOptions.create() - .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - draft.setBaseBidCode(baseProjId + "-1"); - draft.setBaseChanFileCimplement(cimplement.getBaseChanFile()); - draft.setBaseLogAggregationCimplement(cimplement.getBaseLogAggregation()); - draft.setBaseBusinessMetricsCimplement(cimplement.getBaseBusinessMetrics()); - draft.setBaseEstaSummFileCimplement(cimplement.getBaseEstaSummFile()); - draft.setBaseInforLevelFileCimplement(cimplement.getBaseInforLevelFile()); - draft.setBaseEngineerPostpoFileCimplement(cimplement.getBaseEngineerPostpoFile()); - draft.setBaseUserConsFileCimplement(cimplement.getBaseUserConsFile()); - draft.setBasePasswAssessFileCimplement(cimplement.getBasePasswAssessFile()); - draft.setBaseThirdAcceptFileCimplement(cimplement.getBaseThirdAcceptFile()); - draft.setBaseFinalExpertOpinionFileCimplement(cimplement.getBaseFinalExpertOpinionFile()); + if(Objects.nonNull(cimplement)){ + BeanUtil.copyProperties(cimplement, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseBidCode(baseProjId + "-1"); + draft.setBaseChanFileCimplement(cimplement.getBaseChanFile()); + draft.setBaseLogAggregationCimplement(cimplement.getBaseLogAggregation()); + draft.setBaseBusinessMetricsCimplement(cimplement.getBaseBusinessMetrics()); + draft.setBaseEstaSummFileCimplement(cimplement.getBaseEstaSummFile()); + draft.setBaseInforLevelFileCimplement(cimplement.getBaseInforLevelFile()); + draft.setBaseEngineerPostpoFileCimplement(cimplement.getBaseEngineerPostpoFile()); + draft.setBaseUserConsFileCimplement(cimplement.getBaseUserConsFile()); + draft.setBasePasswAssessFileCimplement(cimplement.getBasePasswAssessFile()); + draft.setBaseThirdAcceptFileCimplement(cimplement.getBaseThirdAcceptFile()); + draft.setBaseFinalExpertOpinionFileCimplement(cimplement.getBaseFinalExpertOpinionFile()); + } // 5.保存 运维项目 实施信息 GovBizProjectMimplementDTO mimplement = saveDTO.getMimplement(); - BeanUtil.copyProperties(mimplement, draft, CopyOptions.create() - .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - draft.setBaseLogAggregationMimplement(mimplement.getBaseLogAggregation()); - draft.setBaseBusinessMetricsMimplement(mimplement.getBaseBusinessMetrics()); - draft.setBaseChanFileMimplement(mimplement.getBaseChanFile()); - draft.setBaseEstaSummFileMimplement(mimplement.getBaseEstaSummFile()); - draft.setBaseInforLevelFileMimplement(mimplement.getBaseInforLevelFile()); - draft.setBaseEngineerPostpoFileMimplement(mimplement.getBaseEngineerPostpoFile()); - draft.setBaseThirdAcceptFileMimplement(mimplement.getBaseThirdAcceptFile()); - draft.setBaseUserConsFileMimplement(mimplement.getBaseUserConsFile()); - draft.setBaseFinalExpertOpinionFileCimplement(mimplement.getBaseFinalExpertOpinionFile()); + if(Objects.nonNull(mimplement)){ + BeanUtil.copyProperties(mimplement, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseLogAggregationMimplement(mimplement.getBaseLogAggregation()); + draft.setBaseBusinessMetricsMimplement(mimplement.getBaseBusinessMetrics()); + draft.setBaseChanFileMimplement(mimplement.getBaseChanFile()); + draft.setBaseEstaSummFileMimplement(mimplement.getBaseEstaSummFile()); + draft.setBaseInforLevelFileMimplement(mimplement.getBaseInforLevelFile()); + draft.setBaseEngineerPostpoFileMimplement(mimplement.getBaseEngineerPostpoFile()); + draft.setBaseThirdAcceptFileMimplement(mimplement.getBaseThirdAcceptFile()); + draft.setBaseUserConsFileMimplement(mimplement.getBaseUserConsFile()); + draft.setBaseFinalExpertOpinionFileCimplement(mimplement.getBaseFinalExpertOpinionFile()); + + } // 6.保存 采购信息 List procures = saveDTO.getProcures(); - draft.setProcure(JSON.toJSONString(procures)); + if(Objects.nonNull(procures)){ + draft.setProcure(JSON.toJSONString(procures)); + } draftService.saveOrUpdate(draft); diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java new file mode 100644 index 0000000..0b4d6b5 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java @@ -0,0 +1,176 @@ +package com.ningdatech.pmapi.collection; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.common.constant.RegionConst; +import com.ningdatech.pmapi.gov.contants.BizProjectContant; +import com.ningdatech.pmapi.gov.manage.GovProjectCollectionManage; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; +import com.ningdatech.pmapi.gov.model.entity.*; +import com.ningdatech.pmapi.gov.service.*; +import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.*; +import java.time.LocalDateTime; +import java.util.Objects; + +/** + * @Classname SaveCollectionTest + * @Description + * @Date 2023/9/4 17:43 + * @Author PoffyZhang + */ +public class SaveCollectionTest331125 extends AppTests {// + + @Autowired + private GovProjectCollectionManage manage; + + @Autowired + private GenerateProjectCodeUtil projectCodeUtil; + + @Autowired + private IGovBizProjectBaseinfoService baseinfoService; + @Autowired + private IGovBizProjectApplyService applyService; + @Autowired + private IGovBizProjectApproveService approveService; + @Autowired + private IGovBizProjectCimplementService cimplementService; + @Autowired + private IGovBizProjectMimplementService mimplementService; + @Autowired + private IGovBizProjectProcureService procureService; + + @Test + public void importData() throws Exception { + Workbook wb; + File f = new File("C:\\Users\\PoffyZhang\\Desktop\\丽水市项目底数清单.xlsx"); + wb = readExcel(new FileInputStream(f),f.getName()); + Row row = null; + if(wb != null) { + //获取第一个sheet + Sheet sheet = wb.getSheetAt(0); + //获取最大行数 + int rownum = sheet.getPhysicalNumberOfRows(); + + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + for (int i = 1; i < rownum; i++) { + row = sheet.getRow(i); + if(Objects.isNull(row) || Objects.isNull(row.getCell(0))){ + break; + } + GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); + + GovBizProjectBaseinfoDTO baseinfoDTO = new GovBizProjectBaseinfoDTO(); + // + String projName = Objects.nonNull(row.getCell(3)) ? row.getCell(3).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjName(projName); + baseinfoDTO.setBaseAreaCode(RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST); + baseinfoDTO.setBaseAreaName(RegionConst.LS_KF_NAME); + baseinfoDTO.setAreaCode(RegionConst.RC_LS); + baseinfoDTO.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); + baseinfoDTO.setTongTime(LocalDateTime.now()); + baseinfoDTO.setBizTime(LocalDateTime.now()); + baseinfoDTO.setOp("insert"); + String principal = Objects.nonNull(row.getCell(5)) ? row.getCell(5).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjPrincipal(principal); + String contacts = Objects.nonNull(row.getCell(6)) ? row.getCell(6).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjContacts(contacts); + baseinfoDTO.setBaseProjType("01"); + saveDTO.setBaseinfo(baseinfoDTO); + + GovBizProjectApplyDTO applyDTO = new GovBizProjectApplyDTO(); + String baseProjSetYear = Objects.nonNull(row.getCell(8)) ? row.getCell(8).toString() : StringUtils.EMPTY; + applyDTO.setBaseProjSetYear(baseProjSetYear); + String baseProjIntro = Objects.nonNull(row.getCell(9)) ? row.getCell(9).toString() : StringUtils.EMPTY; + applyDTO.setBaseProjIntro(baseProjIntro); + saveDTO.setApply(applyDTO); + //生产编号 + String projId = projectCodeUtil.generateProjectCode(saveDTO); + saveDTO.setBaseProjId(projId); + saveDTO.getBaseinfo().setBaseProjId(projId); + saveDTO.getApply().setBaseProjId(projId); + UserInfoDetails user = new UserInfoDetails(); + user.setRegionCode(RegionConst.LS_KF); + user.setUsername("系统导入"); + String save = ""; + try{ + GovBizProjectBaseinfo old = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .eq(GovBizProjectBaseinfo::getBaseProjName, projName) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(old)){ + save = manage.save(saveDTO, user); + }else{ + System.out.println(projName + ",重复了 要改到经开区里"); + String newProjId = old.getBaseProjId().replace("331100000","331118000"); + baseinfoService.update(Wrappers.lambdaUpdate(GovBizProjectBaseinfo.class) + .eq(GovBizProjectBaseinfo::getBaseProjName, projName) + .eq(GovBizProjectBaseinfo::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectBaseinfo::getBaseAreaCode,RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST) + .set(GovBizProjectBaseinfo::getBaseProjId,newProjId)); + applyService.update(Wrappers.lambdaUpdate(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjName, projName) + .eq(GovBizProjectApply::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectApply::getBaseProjId,newProjId)); + approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjName, projName) + .eq(GovBizProjectApprove::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectApprove::getBaseProjId,newProjId)); + cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjName, projName) + .eq(GovBizProjectCimplement::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectCimplement::getBaseProjId,newProjId)); + mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjName, projName) + .eq(GovBizProjectMimplement::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectMimplement::getBaseProjId,newProjId)); + procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjName, projName) + .eq(GovBizProjectProcure::getBaseProjId, old.getBaseProjId()) + .set(GovBizProjectProcure::getBaseProjId,newProjId)); + } + }catch (Exception e){ + e.printStackTrace(); + } + System.out.println(JSON.toJSONString(save)); + } + } + + System.out.println("导入完成"); + } + + //这个下面是单独函数 + public static Workbook readExcel(InputStream is, String extString){ + Workbook wb = null; + extString = extString.substring(extString.lastIndexOf(".")); + try { + if(".xls".equals(extString)){ + return wb = new HSSFWorkbook(is); + }else if(".xlsx".equals(extString)){ + return wb = new XSSFWorkbook(is); + }else { + return wb = null; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return wb; + } +} diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java b/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java new file mode 100644 index 0000000..a0275e8 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.file; + +import org.springframework.core.io.InputStreamResource; + +import java.io.InputStream; + +public class CommonInputStreamResource extends InputStreamResource { + /*** + * 文件長度 + */ + private int length; + /*** + * 文件名稱 + */ + private String fileName; + public CommonInputStreamResource(InputStream inputStream) { + super(inputStream); + } + public CommonInputStreamResource(InputStream inputStream, int length,String fileName) { + super(inputStream); + this.length = length; + this.fileName = fileName; + } + /** + * 覆写父类方法 + * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 + * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} + * + * @return + */ + @Override + public String getFilename() { + return this.fileName; + } + /** + * 覆写父类 contentLength 方法 + * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, + * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 + * + * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times + * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96) + * + *

+ * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() + * + * @return + */ + @Override + public long contentLength() { + int estimate = length; + return estimate == 0 ? 1 : estimate; + } +} \ No newline at end of file diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java new file mode 100644 index 0000000..c1a4500 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java @@ -0,0 +1,79 @@ +package com.ningdatech.pmapi.file; + +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; +import java.io.File; +import java.io.FileInputStream; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.mock.web.MockMultipartFile; +import org.apache.http.entity.ContentType; +import java.io.*; + +/** + * @Classname ProvinceOssTest + * @Description + * @Date 2023/9/5 14:21 + * @Author PoffyZhang + */ +public class ProvinceOssTest { + + @Test + public void test() throws FileNotFoundException { + File f = new File("C:\\Users\\PoffyZhang\\Desktop\\市本级组织code已核对.xlsx"); + String url = "https://pms.zj.gov.cn/prometheus-zhejiang_file_service/api/v1/file/uploadFile"; + MultiValueMap params = new LinkedMultiValueMap<>(); + byte[] fileBytes = getBytesByFile(f); + ByteArrayInputStream inputStream = new ByteArrayInputStream(fileBytes); + CommonInputStreamResource commonInputStreamResource = new CommonInputStreamResource(inputStream,fileBytes.length,f.getName()); + params.add("file",commonInputStreamResource); + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + MediaType type = MediaType.parseMediaType("multipart/form-data"); + headers.setContentType(type); + HttpEntity formEntity = new HttpEntity(params, headers); + ResponseEntity res = restTemplate.postForEntity(url, formEntity, String.class); + System.out.println(res); + } + + public static MultipartFile getMultipartFile(File file) { + try{ + FileInputStream fileInputStream = new FileInputStream(file); + MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(),ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream); + return multipartFile; + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + //将文件转换成Byte数组 + public static byte[] getBytesByFile(File file) { + try { + FileInputStream fis = new FileInputStream(file); + ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); + byte[] b = new byte[1000]; + int n; + while ((n = fis.read(b)) != -1) { + bos.write(b, 0, n); + } + fis.close(); + byte[] data = bos.toByteArray(); + bos.close(); + return data; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} From df82bf5bc62102b2232fe0b8d204707226f6286e Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 16:15:03 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6=20?= =?UTF-8?q?=E5=85=88=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 7bfab79..53adab4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -115,7 +115,7 @@ public class GovProjectCollectionManage { .le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMax()) .eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) .orderByDesc(GovBizProjectBaseinfo::getBizTime); - permissions(wrapper); +// permissions(wrapper); baseinfoService.page(page,wrapper); if(CollUtil.isEmpty(page.getRecords())){ From 858ba34f88e361f84de256be71642027d18225ad Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 17:04:23 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E8=8D=89=E7=A8=BF=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java index a47d767..e1d0af8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -1,7 +1,10 @@ package com.ningdatech.pmapi.gov.model.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; @@ -19,6 +22,8 @@ import java.time.LocalDateTime; public class GovBizProjectDraft implements Serializable { private static final long serialVersionUID = 1L; + @ApiModelProperty("主键") + @TableId(type = IdType.AUTO) private Long id; private String baseProjId; private String baseProjName; From 41b4f34758b777a8587cda0bf512d10dddd28812 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 17:18:27 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E8=8D=89=E7=A8=BF=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 53adab4..20648a4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -307,6 +307,7 @@ public class GovProjectCollectionManage { if(Objects.isNull(draft)){ return null; } + res.setDraftId(draftId); //1.基本信息 res.setBaseProjId(draft.getBaseProjId()); From b74a1ea74072ab76bb12383837417a611b370c45 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 17:43:35 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E8=8D=89=E7=A8=BF=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov/manage/GovProjectCollectionManage.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 20648a4..2eb71e2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -568,17 +568,6 @@ public class GovProjectCollectionManage { baseProjId = BizProjectContant.ProjectCollection.DRAFT; } - BeanUtil.copyProperties(base, draft, CopyOptions.create() - .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - draft.setBaseProjId(baseProjId); - draft.setBaseProjName(baseProjName); - draft.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); - draft.setAreaCode(RegionConst.RC_LS); - draft.setBizTime(LocalDateTime.now()); - draft.setUpdateBy(user.getUsername()); - draft.setUpdateOn(LocalDateTime.now()); - draft.setOp(BizProjectContant.ProjectCollection.OP_INSERT); - // 2.保存 申报信息 GovBizProjectApplyDTO apply = saveDTO.getApply(); BeanUtil.copyProperties(apply, draft, CopyOptions.create() @@ -630,6 +619,18 @@ public class GovProjectCollectionManage { draft.setProcure(JSON.toJSONString(procures)); } + //最后再保存 基本信息 + BeanUtil.copyProperties(base, draft, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + draft.setBaseProjId(baseProjId); + draft.setBaseProjName(baseProjName); + draft.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); + draft.setAreaCode(RegionConst.RC_LS); + draft.setBizTime(LocalDateTime.now()); + draft.setUpdateBy(user.getUsername()); + draft.setUpdateOn(LocalDateTime.now()); + draft.setOp(BizProjectContant.ProjectCollection.OP_INSERT); + draftService.saveOrUpdate(draft); return BizConst.SAVE_SUCCESS; From 8fe7ee66090eb2ccb4e2fd7a57f5c40fc62c2a40 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 5 Sep 2023 18:10:19 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E8=8D=89=E7=A8=BF=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 2eb71e2..404d64f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -529,6 +529,10 @@ public class GovProjectCollectionManage { //7. 推送数据(改为定时推送了) // pushProject(saveDTO); + //如果是草稿箱来的 就要删除 + if(Objects.nonNull(saveDTO.getDraftId())){ + draftService.removeById(saveDTO.getDraftId()); + } return BizConst.SAVE_SUCCESS; } From c54b2d22c68be31ffdfbca13f5052576df617a39 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 6 Sep 2023 10:18:01 +0800 Subject: [PATCH 12/22] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=BD=ACPDF=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/CommonInputStreamResource.java | 53 +++++++++ .../gov/manage/GovProjectCollectionManage.java | 69 +++++++++++- .../pmapi/gov/model/entity/GovBizProjectApply.java | 3 + .../provincial/contants/ProvincialContant.java | 15 +++ .../pmapi/provincial/manage/ProvincialManage.java | 56 ++++++++++ .../pmapi/provincial/model/res/OssApiData.java | 33 ++++++ .../pmapi/provincial/model/res/OssApiResponse.java | 120 +++++++++++++++++++++ .../pmapi/provincial/utils/FileUtil.java | 32 ++++++ .../pmapi/wps/manage/WpsConvertManage.java | 56 ++++++++++ .../pmapi/file/CommonInputStreamResource.java | 53 --------- .../com/ningdatech/pmapi/file/ProvinceOssTest.java | 10 +- 11 files changed, 436 insertions(+), 64 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/common/util/CommonInputStreamResource.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/contants/ProvincialContant.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/manage/ProvincialManage.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiData.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiResponse.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/utils/FileUtil.java delete mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CommonInputStreamResource.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CommonInputStreamResource.java new file mode 100644 index 0000000..81e9cd3 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CommonInputStreamResource.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.common.util; + +import org.springframework.core.io.InputStreamResource; + +import java.io.InputStream; + +public class CommonInputStreamResource extends InputStreamResource { + /*** + * 文件長度 + */ + private int length; + /*** + * 文件名稱 + */ + private String fileName; + public CommonInputStreamResource(InputStream inputStream) { + super(inputStream); + } + public CommonInputStreamResource(InputStream inputStream, int length,String fileName) { + super(inputStream); + this.length = length; + this.fileName = fileName; + } + /** + * 覆写父类方法 + * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 + * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} + * + * @return + */ + @Override + public String getFilename() { + return this.fileName; + } + /** + * 覆写父类 contentLength 方法 + * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, + * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 + * + * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times + * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96) + * + *

+ * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() + * + * @return + */ + @Override + public long contentLength() { + int estimate = length; + return estimate == 0 ? 1 : estimate; + } +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 404d64f..df0f4a0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; 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.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -23,10 +25,12 @@ import com.ningdatech.pmapi.gov.model.vo.*; import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; +import com.ningdatech.pmapi.provincial.manage.ProvincialManage; import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.ningdatech.pmapi.wps.manage.WpsConvertManage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -39,11 +43,9 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; +import java.lang.reflect.Field; import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -76,6 +78,8 @@ public class GovProjectCollectionManage { private final RestTemplate restTemplate; + private final WpsConvertManage wpsConvertManage; + @Value("${project.push-url}") private String pushUrl; @@ -425,7 +429,9 @@ public class GovProjectCollectionManage { saveApply.setBizTime(LocalDateTime.now()); saveApply.setUpdateBy(user.getUsername()); saveApply.setUpdateOn(LocalDateTime.now()); - projectApplyService.saveOrUpdate(saveApply); + if(projectApplyService.saveOrUpdate(saveApply)){ + uploadFileToProvincialOss(apply,oldApply,saveApply); + } } // 3.保存 审批信息 @@ -657,6 +663,8 @@ public class GovProjectCollectionManage { //改正逻辑删除 baseinfo.setDeleted(Boolean.TRUE); + baseinfo.setUpdateBy(username); + baseinfo.setUpdateOn(LocalDateTime.now()); baseinfoService.updateById(baseinfo); projectApplyService.update(Wrappers.lambdaUpdate(GovBizProjectApply.class) .eq(GovBizProjectApply::getBaseProjId,projId) @@ -779,4 +787,55 @@ public class GovProjectCollectionManage { log.info("推送删除失败,{}", e.getMessage()); } } + + /** + * 上传项目归集申报的文件到OSS 前提还要先转为PDF + * @param apply + * @param oldApply + */ + private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, + GovBizProjectApply oldApply,GovBizProjectApply saveApply) { + if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ + JSONArray fileArray = JSON.parseArray(apply.getBaseProjBasisFile()); + StringJoiner sj = new StringJoiner(";"); + fileArray.forEach(j -> { + JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); + byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); + String oss = ProvincialManage.uploadToOss(btyes, jsonObject.getString("originalFileName")); + sj.add(oss); + }); + saveApply.setBaseProjBasisFilePdf(sj.toString()); + } + projectApplyService.updateById(saveApply); + } + + private Boolean checkFieldHas(String field,GovBizProjectApply oldApply,String fieldName){ + if(StringUtils.isBlank(field)){ + return Boolean.FALSE; + } + + //如果没有老值 + if(Objects.isNull(oldApply)){ + return Boolean.TRUE; + } + + //和老值做个对比 不一样则true + Class clazz = oldApply.getClass(); + String oldFiled = StringUtils.EMPTY; + try { + Field fieldDeclared = clazz.getDeclaredField(fieldName); + fieldDeclared.setAccessible(Boolean.TRUE); + oldFiled = Objects.nonNull(fieldDeclared.get(oldApply)) ? String.valueOf(fieldDeclared.get(oldApply)) : null; + } catch (NoSuchFieldException e) { + log.error("转换PDF文件出错" + e); + } catch (IllegalAccessException e) { + log.error("转换PDF文件出错" + e); + } + + if(!oldFiled.equals(field)){ + return Boolean.TRUE; + } + + return Boolean.FALSE; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java index db6c5d9..b5ec5d6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java @@ -149,4 +149,7 @@ public class GovBizProjectApply implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("立项依据材料PDF版") + private String baseProjBasisFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/contants/ProvincialContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/contants/ProvincialContant.java new file mode 100644 index 0000000..88efe8b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/contants/ProvincialContant.java @@ -0,0 +1,15 @@ +package com.ningdatech.pmapi.provincial.contants; + +/** + * @Classname ProvincialContant + * @Description + * @Date 2023/9/6 9:16 + * @Author PoffyZhang + */ +public interface ProvincialContant { + + class OssUpload { + public static final String OSS_UPLOAD_URL = "https://pms.zj.gov.cn/prometheus-zhejiang_file_service/api/v1/file/uploadFile"; + public static final String MEDIA_TYPE = "multipart/form-data"; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/manage/ProvincialManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/manage/ProvincialManage.java new file mode 100644 index 0000000..6e0967d --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/manage/ProvincialManage.java @@ -0,0 +1,56 @@ +package com.ningdatech.pmapi.provincial.manage; + +import com.alibaba.fastjson.JSON; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.pmapi.common.util.CommonInputStreamResource; +import com.ningdatech.pmapi.provincial.contants.ProvincialContant; +import com.ningdatech.pmapi.provincial.model.res.OssApiData; +import com.ningdatech.pmapi.provincial.model.res.OssApiResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import java.io.ByteArrayInputStream; +import java.util.Objects; + +/** + * @Classname ProvincialManage + * @Description + * @Date 2023/9/6 9:08 + * @Author PoffyZhang + */ +@Component +@RequiredArgsConstructor +@Slf4j +public class ProvincialManage { + + public static String uploadToOss(byte[] fileBytes,String fileName) { + String url = ProvincialContant.OssUpload.OSS_UPLOAD_URL; + MultiValueMap params = new LinkedMultiValueMap<>(); + ByteArrayInputStream inputStream = new ByteArrayInputStream(fileBytes); + CommonInputStreamResource commonInputStreamResource = new CommonInputStreamResource(inputStream, fileBytes.length, fileName); + params.add("file", commonInputStreamResource); + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + MediaType type = MediaType.parseMediaType(ProvincialContant.OssUpload.MEDIA_TYPE); + headers.setContentType(type); + HttpEntity formEntity = new HttpEntity(params, headers); + ResponseEntity res = restTemplate.postForEntity(url, formEntity, OssApiResponse.class); + log.info("oss res :{}", res); + OssApiResponse body = res.getBody(); + if(Objects.isNull(body)){ + throw new BizException("上传省局oss请求失败"); + } + + if(HttpStatus.OK.value() != body.getRespCode()){ + throw new BizException("上传省局oss失败:" + body.getRespMsg()); + } + + OssApiData ossApiData = JSON.parseObject(JSON.toJSONString(body.getData()), OssApiData.class); + + return ossApiData.getAccessUrl(); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiData.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiData.java new file mode 100644 index 0000000..0e1fff7 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiData.java @@ -0,0 +1,33 @@ +package com.ningdatech.pmapi.provincial.model.res; + +import com.ningdatech.basic.enumeration.Status; +import com.ningdatech.basic.model.ApiStatus; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *

+ * OssApiResponse - + *

+ * + * @author ZPF + * @since 14:29 2022/9/29 + */ +@Data +@NoArgsConstructor +public class OssApiData implements Serializable { + + private String fileId; + + private String fileName; + + private String accessUrl; + + private Long fileSize; + + private String uploadUserCode; + + private String ossObject; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiResponse.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiResponse.java new file mode 100644 index 0000000..0507d73 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/res/OssApiResponse.java @@ -0,0 +1,120 @@ +package com.ningdatech.pmapi.provincial.model.res; + +import com.ningdatech.basic.enumeration.Status; +import com.ningdatech.basic.model.ApiStatus; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + *

+ * OssApiResponse - + *

+ * + * @author ZPF + * @since 14:29 2022/9/29 + */ +@Data +@NoArgsConstructor +public class OssApiResponse implements Serializable { + private static final long serialVersionUID = 1L; + + public static final int SUCCESS_CODE = 200; + + public static final String SUCCESS_MSG = "成功"; + + public static final int ERROR_CODE = 500; + + public static final String ERROR_MSG = "Internal server error"; + + /** + * 状态码 + */ + private Integer respCode; + + /** + * 返回描述 + */ + private String respMsg; + + /** + * 返回数据 + */ + private T data; + + /** + * 全参构造函数 + * + * @param respCode 状态码 + * @param respMsg 返回内容 + * @param data 返回数据 + */ + private OssApiResponse(Integer respCode, String respMsg, T data) { + this.respCode = respCode; + this.respMsg = respMsg; + this.data = data; + } + + /** + * 构造一个自定义的API返回 + * + * @param respCode 状态码 + * @param respMsg 返回内容 + * @param data 返回数据 + * @return ApiResponse + */ + public static OssApiResponse of(Integer respCode, String respMsg, T data) { + return new OssApiResponse(respCode, respMsg, data); + } + + /** + * 构造一个成功且不带数据的API返回 + * + * @return ApiResponse + */ + public static OssApiResponse ofSuccess() { + return ofSuccess(null); + } + + /** + * 构造一个成功且带数据的API返回 + * + * @param data 返回数据 + * @return ApiResponse + */ + public static OssApiResponse ofSuccess(T data) { + return ofStatus(Status.OK, data); + } + + /** + * 构造一个成功且自定义消息的API返回 + * + * @param msg 返回内容 + * @return ApiResponse + */ + public static OssApiResponse ofMessage(String msg) { + return of(Status.OK.getCode(), msg, null); + } + + /** + * 构造一个有状态的API返回 + * + * @param status 状态 {@link Status} + * @return ApiResponse + */ + public static OssApiResponse ofStatus(ApiStatus status) { + return ofStatus(status, null); + } + + /** + * 构造一个有状态且带数据的API返回 + * + * @param status 状态 {@link Status} + * @param data 返回数据 + * @return ApiResponse + */ + public static OssApiResponse ofStatus(ApiStatus status, T data) { + return of(status.getCode(), status.getReasonPhrase(), data); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/utils/FileUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/utils/FileUtil.java new file mode 100644 index 0000000..2cdc99b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/utils/FileUtil.java @@ -0,0 +1,32 @@ +package com.ningdatech.pmapi.provincial.utils; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; + +/** + * @Classname FileUtil + * @Description + * @Date 2023/9/6 9:09 + * @Author PoffyZhang + */ +public class FileUtil { + public static byte[] getBytesByFile(File file) { + try { + FileInputStream fis = new FileInputStream(file); + ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); + byte[] b = new byte[1000]; + int n; + while ((n = fis.read(b)) != -1) { + bos.write(b, 0, n); + } + fis.close(); + byte[] data = bos.toByteArray(); + bos.close(); + return data; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java index 42b7401..ce99659 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java @@ -96,6 +96,11 @@ public class WpsConvertManage { downloadAndToPdf(file, response); } + public byte[] downloadToPdfStream(Long fileId) { + com.ningdatech.file.entity.File file = fileService.getById(fileId); + return downloadAndToPdf(file); + } + private void downloadAndToPdf(com.ningdatech.file.entity.File file, HttpServletResponse response) { OSS oss = new OSSClientBuilder().build(fileServerProperties.getAli().getEndpoint(), fileServerProperties.getAli().getAccessKeyId(), fileServerProperties.getAli().getAccessKeySecret()); AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); @@ -154,6 +159,57 @@ public class WpsConvertManage { } } + private byte[] downloadAndToPdf(com.ningdatech.file.entity.File file) { + OSS oss = new OSSClientBuilder().build(fileServerProperties.getAli().getEndpoint(), fileServerProperties.getAli().getAccessKeyId(), fileServerProperties.getAli().getAccessKeySecret()); + AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); + try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath()); + InputStream stream = ossObject.getObjectContent();) { + String fileName = null; + byte[] bytes = new byte[4096]; + int read; + //测试环境 转不了PDF 请求不了 WPS转换服务器 + if(BizConst.DEV.equals(active)){ + byte[] byt = new byte[stream.available()]; + stream.read(byt); + return byt; + }else if(BizConst.PRE.equals(active) || + BizConst.PROD.equals(active)){ + String filePath = WpsContant.FIX_FILE_PATH + file.getOriginalFileName(); + convert(stream,filePath); + //转换PDF + List fileList =new ArrayList(); + //2)、定义转换后的pdf文件输出流 + OutputStream out = null; + //3)、添加原文件到集合 + fileList.add(new File(filePath)); + //4)、赋值转换后的pdf文件输出流 + File pdfFile = new File(WpsContant.PDF_PATH); + out = new FileOutputStream(pdfFile); + //5)、调用方法,执行将多个文件转为pdf文件 + ha.OFDToPDF(fileList, out); + FileInputStream fileInputStream = new FileInputStream(pdfFile); + fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8); + for(File f : fileList){ + //用完就删 + f.deleteOnExit(); + } + byte[] byt = new byte[fileInputStream.available()]; + fileInputStream.read(byt); + return byt; + } + }catch (Exception e){ + log.error(e.getMessage()); + }finally { + oss.shutdown(); + try { + ha.close(); + } catch (IOException e) { + log.error(e.getMessage()); + } + } + return null; + } + public static void convert(InputStream inputStream, String filePath) { try { File file = new File(filePath); diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java b/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java deleted file mode 100644 index a0275e8..0000000 --- a/pmapi/src/test/java/com/ningdatech/pmapi/file/CommonInputStreamResource.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ningdatech.pmapi.file; - -import org.springframework.core.io.InputStreamResource; - -import java.io.InputStream; - -public class CommonInputStreamResource extends InputStreamResource { - /*** - * 文件長度 - */ - private int length; - /*** - * 文件名稱 - */ - private String fileName; - public CommonInputStreamResource(InputStream inputStream) { - super(inputStream); - } - public CommonInputStreamResource(InputStream inputStream, int length,String fileName) { - super(inputStream); - this.length = length; - this.fileName = fileName; - } - /** - * 覆写父类方法 - * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 - * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} - * - * @return - */ - @Override - public String getFilename() { - return this.fileName; - } - /** - * 覆写父类 contentLength 方法 - * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, - * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 - * - * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times - * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96) - * - *

- * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() - * - * @return - */ - @Override - public long contentLength() { - int estimate = length; - return estimate == 0 ? 1 : estimate; - } -} \ No newline at end of file diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java index c1a4500..92242d3 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/file/ProvinceOssTest.java @@ -1,7 +1,6 @@ package com.ningdatech.pmapi.file; -import org.apache.tomcat.util.http.fileupload.IOUtils; -import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory; +import com.ningdatech.pmapi.common.util.CommonInputStreamResource; import org.junit.Test; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -12,11 +11,10 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.commons.CommonsMultipartFile; + import java.io.File; import java.io.FileInputStream; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.mock.web.MockMultipartFile; + import org.apache.http.entity.ContentType; import java.io.*; @@ -43,7 +41,7 @@ public class ProvinceOssTest { headers.setContentType(type); HttpEntity formEntity = new HttpEntity(params, headers); ResponseEntity res = restTemplate.postForEntity(url, formEntity, String.class); - System.out.println(res); + System.out.println(res.getBody()); } public static MultipartFile getMultipartFile(File file) { From c14b3a54eb77a63f822fd50298362a9be8f69056 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 6 Sep 2023 11:37:34 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ding/controller/DingInfoPullController.java | 5 +++ .../pmapi/ding/task/OrganizationBatchGetTask.java | 47 +++++++++++++++++++++- .../gov/manage/GovProjectCollectionManage.java | 20 +++++---- .../pmapi/wps/manage/WpsConvertManage.java | 25 +----------- 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java index 356c8c0..516cf06 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java @@ -84,6 +84,11 @@ public class DingInfoPullController { organizationBatchGetTask.batchGetOrganizationTask(); } + @GetMapping("/organization/{orgCode}") + public void organizationGetSubs(@PathVariable String orgCode) { + organizationBatchGetTask.organizationGetSubs(orgCode); + } + @GetMapping("/employeeByRegionCode/{regionCode}") public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java index f183d2f..2845e5a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.ningdatech.basic.model.GenericResult; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.ding.model.DingOrgInfoTreeDTO; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; @@ -21,6 +22,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -103,6 +105,50 @@ public class OrganizationBatchGetTask { } } + /** + * 更新 其 子单位 + * @param orgCode + */ + public void organizationGetSubs(String orgCode) { + log.info("----拉取浙政钉组织子单位开始---,顶级code:" + orgCode); + DingOrganization topOrg = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getOrganizationCode, orgCode) + .last(BizConst.LIMIT_1)); + // 顶级组织code + List topOrgCodes = Lists.newArrayList(orgCode); + GenericResult> listGenericResult = zwddClient.listOrganizationsByCodes(topOrgCodes); + log.info("listGenericResult: {}" + JSON.toJSONString(listGenericResult)); + List dingOrgInfoDtos = listGenericResult.getData(); + + for(DingOrgInfoDTO dingOrgInfo : dingOrgInfoDtos){ + DingOrganization old = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getOrganizationCode, dingOrgInfo.getOrganizationCode()) + .last(BizConst.LIMIT_1)); + if(Objects.nonNull(old)){ + log.info("该单位已经存在 :{}",old.getOrganizationName()); + continue; + } + + DingOrganization organization = new DingOrganization(); + organization.setOrganizationCode(dingOrgInfo.getOrganizationCode()); + organization.setOrganizationName(dingOrgInfo.getOrganizationName()); + //和顶级单位一个区域 + organization.setDivisionCode(topOrg.getDivisionCode()); + organization.setParentCode(dingOrgInfo.getParentCode()); + organization.setTypeName(dingOrgInfo.getTypeName()); + organization.setAddress(dingOrgInfo.getAddress()); + organization.setBusinessStripCodes(dingOrgInfo.getBusinessStripCodes()); + organization.setDisplayOrder(dingOrgInfo.getDisplayOrder()); + organization.setGmtCreate(LocalDateTime.now()); + organization.setInstitutionLevelCode(dingOrgInfo.getInstitutionLevelCode()); + organization.setParentName(dingOrgInfo.getParentName()); + iDingOrganizationService.save(organization); + } + + log.info("----拉取浙政钉组织子单位结束---,顶级code:" + orgCode); + + } + private void buildSaveRecordList(List treeDTOList, List saveRecordList) { if (CollectionUtils.isEmpty(treeDTOList)) { return; @@ -167,7 +213,6 @@ public class OrganizationBatchGetTask { } } } - } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index df0f4a0..a8e2e63 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -796,14 +796,20 @@ public class GovProjectCollectionManage { private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, GovBizProjectApply oldApply,GovBizProjectApply saveApply) { if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ - JSONArray fileArray = JSON.parseArray(apply.getBaseProjBasisFile()); + String[] baseProjBasisFileArr = apply.getBaseProjBasisFile().split(";"); StringJoiner sj = new StringJoiner(";"); - fileArray.forEach(j -> { - JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); - byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); - String oss = ProvincialManage.uploadToOss(btyes, jsonObject.getString("originalFileName")); - sj.add(oss); - }); + for(String baseProjBasisFile : baseProjBasisFileArr){ + JSONArray fileArray = JSON.parseArray(baseProjBasisFile); + fileArray.forEach(j -> { + JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); + byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); + String suffix = jsonObject.getString("suffix"); + String originalFileName = jsonObject.getString("originalFileName"); + String pdfName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); + String oss = ProvincialManage.uploadToOss(btyes, pdfName); + sj.add(oss); + }); + } saveApply.setBaseProjBasisFilePdf(sj.toString()); } projectApplyService.updateById(saveApply); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java index ce99659..2c399db 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java @@ -13,15 +13,12 @@ import com.suwell.ofd.custom.agent.AtomAgent; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Component; - import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; -import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -44,13 +41,11 @@ public class WpsConvertManage { @Value("${spring.profiles.active}") private String active; -// HTTPAgent ha = new HTTPAgent("http://127.0.0.1:8090"); //2、定义方法实现 多个文件合并转为1个pdf文件 public String offs2Pdf() { - AtomAgent ha = new AtomAgent("http://10.53.157.47"); + AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); try { - //2-1、传参文件对象转换输出PDF文件 //1)、定义集合,存储待转换的原文件 List fileList =new ArrayList(); @@ -58,25 +53,10 @@ public class WpsConvertManage { OutputStream out = null; //3)、添加原文件到集合 fileList.add(new File("/temp/111.xlsx")); -// fileList.add(new File("D:/cs.doc")); -// fileList.add(new File("D:/a.pdf")); -// fileList.add(new File("D:\\555.ofd")); //4)、赋值转换后的pdf文件输出流 out=new FileOutputStream(new File("/temp/offices2_pdf.pdf")); //5)、调用方法,执行将多个文件转为pdf文件 ha.OFDToPDF(fileList, out); - - //2-2、传参文件流转换输出PDF文件(与2-1二选一即可) - //1)、定义集合,存储待转换的原文件(支持传文件流) -// Param[] params = new Param[] { -// new Param(PackEntry.wrap(new FileInputStream("D:\\temp\\111.ofd")), "ofd"), -// new Param(PackEntry.wrap(new FileInputStream("D:\\2.ofd")), "ofd"), -// new Param(PackEntry.wrap(new FileInputStream("D:\\T3.txt")), "txt") -// }; - //2)、赋值转换后的pdf文件输出流 -// out=new FileOutputStream(new File("D:/convert/offices_pdf.pdf")); - //3)、调用方法,执行将多个文件转为pdf文件 -// ha.OFDToPDF(params,out); return "转换成功"; } catch (Exception e) { log.error(e.getMessage()); @@ -164,8 +144,6 @@ public class WpsConvertManage { AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath()); InputStream stream = ossObject.getObjectContent();) { - String fileName = null; - byte[] bytes = new byte[4096]; int read; //测试环境 转不了PDF 请求不了 WPS转换服务器 if(BizConst.DEV.equals(active)){ @@ -188,7 +166,6 @@ public class WpsConvertManage { //5)、调用方法,执行将多个文件转为pdf文件 ha.OFDToPDF(fileList, out); FileInputStream fileInputStream = new FileInputStream(pdfFile); - fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8); for(File f : fileList){ //用完就删 f.deleteOnExit(); From 06da01fbf4ce0a66a42339ac31f2badd55a53ed1 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 10:47:26 +0800 Subject: [PATCH 14/22] PDF --- .../ningdatech/pmapi/common/config/BeanConfig.java | 13 +++ .../gov/manage/GovProjectCollectionManage.java | 127 +++++++++++++++++---- .../pmapi/gov/model/entity/GovBizProjectApply.java | 13 +++ .../gov/model/entity/GovBizProjectApprove.java | 13 ++- .../gov/model/entity/GovBizProjectCimplement.java | 3 + 5 files changed, 145 insertions(+), 24 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java index 1dc5890..f176489 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java @@ -17,12 +17,14 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.web.client.RestTemplate; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -106,4 +108,15 @@ public class BeanConfig { .setRetryHandler(new DefaultHttpRequestRetryHandler(2, true)) .build(); } + + @Bean + public ThreadPoolTaskExecutor getThreadPoolTaskExecutor(){ + ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); + threadPoolTaskExecutor.setCorePoolSize(5); + threadPoolTaskExecutor.setKeepAliveSeconds(200); + threadPoolTaskExecutor.setMaxPoolSize(10); + threadPoolTaskExecutor.setQueueCapacity(20); + threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + return threadPoolTaskExecutor; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index a8e2e63..9c3d6ae 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -34,15 +34,21 @@ import com.ningdatech.pmapi.wps.manage.WpsConvertManage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.lang.reflect.Field; import java.time.LocalDateTime; import java.util.*; @@ -80,6 +86,8 @@ public class GovProjectCollectionManage { private final WpsConvertManage wpsConvertManage; + private final ThreadPoolTaskExecutor threadPoolTaskExecutor; + @Value("${project.push-url}") private String pushUrl; @@ -89,6 +97,9 @@ public class GovProjectCollectionManage { @Value("${project.delete-all-url}") private String deleteAllUrl; + @Value("${spring.profiles.active}") + private String active; + public List dictionary(String type) { List dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) @@ -430,7 +441,7 @@ public class GovProjectCollectionManage { saveApply.setUpdateBy(user.getUsername()); saveApply.setUpdateOn(LocalDateTime.now()); if(projectApplyService.saveOrUpdate(saveApply)){ - uploadFileToProvincialOss(apply,oldApply,saveApply); + threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); } } @@ -454,7 +465,9 @@ public class GovProjectCollectionManage { saveApprove.setAreaCode(RegionConst.RC_LS); saveApprove.setUpdateBy(user.getUsername()); saveApprove.setUpdateOn(LocalDateTime.now()); - approveService.saveOrUpdate(saveApprove); + if(approveService.saveOrUpdate(saveApprove)){ + threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); + } } // 4.保存 建设项目 实施信息 @@ -478,7 +491,9 @@ public class GovProjectCollectionManage { saveCimplement.setBizTime(LocalDateTime.now()); saveCimplement.setUpdateBy(user.getUsername()); saveCimplement.setUpdateOn(LocalDateTime.now()); - cimplementService.saveOrUpdate(saveCimplement); + if(cimplementService.saveOrUpdate(saveCimplement)){ + threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); + } } // 5.保存 运维项目 实施信息 @@ -793,45 +808,93 @@ public class GovProjectCollectionManage { * @param apply * @param oldApply */ - private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, + private void uploadFileToProvincialOssApply(GovBizProjectApplyDTO apply, GovBizProjectApply oldApply,GovBizProjectApply saveApply) { if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ - String[] baseProjBasisFileArr = apply.getBaseProjBasisFile().split(";"); - StringJoiner sj = new StringJoiner(";"); - for(String baseProjBasisFile : baseProjBasisFileArr){ - JSONArray fileArray = JSON.parseArray(baseProjBasisFile); - fileArray.forEach(j -> { - JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); - byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); - String suffix = jsonObject.getString("suffix"); - String originalFileName = jsonObject.getString("originalFileName"); - String pdfName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); - String oss = ProvincialManage.uploadToOss(btyes, pdfName); - sj.add(oss); - }); - } + StringJoiner sj = convertAndUpload(apply.getBaseProjBasisFile()); saveApply.setBaseProjBasisFilePdf(sj.toString()); } + if(checkFieldHas(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ + StringJoiner sj = convertAndUpload(apply.getBaseProjApplyFile()); + saveApply.setBaseProjApplyFilePdf(sj.toString()); + } + if(checkFieldHas(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ + StringJoiner sj = convertAndUpload(apply.getBaseOperatMaintenFile()); + saveApply.setBaseOperatMaintenFilePdf(sj.toString()); + } + if(checkFieldHas(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ + StringJoiner sj = convertAndUpload(apply.getBaseResearchReportFile()); + saveApply.setBaseResearchReportFilePdf(sj.toString()); + } + if(checkFieldHas(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ + StringJoiner sj = convertAndUpload(apply.getBaseProjOtherFile()); + saveApply.setBaseProjOtherFilePdf(sj.toString()); + } projectApplyService.updateById(saveApply); } - private Boolean checkFieldHas(String field,GovBizProjectApply oldApply,String fieldName){ + private void uploadFileToProvincialOssApprove(GovBizProjectApproveDTO approve, GovBizProjectApprove oldApprove, GovBizProjectApprove saveApprove) { + if(checkFieldHas(approve.getApprovalFile(),oldApprove,"approvalFile")){ + StringJoiner sj = convertAndUpload(approve.getApprovalFile()); + saveApprove.setApprovalFilePdf(sj.toString()); + } + if(checkFieldHas(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ + StringJoiner sj = convertAndUpload(approve.getBaseReviewCommentsFile()); + saveApprove.setBaseReviewCommentsFilePdf(sj.toString()); + } + if(checkFieldHas(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ + StringJoiner sj = convertAndUpload(approve.getPreliminaryDesignFile()); + saveApprove.setPreliminaryDesignFilePdf(sj.toString()); + } + approveService.updateById(saveApprove); + } + + private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { + if(checkFieldHas(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); + saveCimplement.setBaseChanFilePdf(sj.toString()); + } + cimplementService.updateById(saveCimplement); + } + + private StringJoiner convertAndUpload(String baseProjBasisFile) { + String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); + StringJoiner sj = new StringJoiner(";"); + for(String bpb : baseProjBasisFileArr){ + JSONArray fileArray = JSON.parseArray(bpb); + fileArray.forEach(j -> { + JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); + byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); + String suffix = jsonObject.getString("suffix"); + String originalFileName = jsonObject.getString("originalFileName"); + if(!BizConst.DEV.equals(active)){ + originalFileName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); + } +// upload(btyes,"/temp",originalFileName); + String oss = ProvincialManage.uploadToOss(btyes, originalFileName); + sj.add(oss); + }); + } + return sj; + } + + private Boolean checkFieldHas(String field, Object record, String fieldName){ if(StringUtils.isBlank(field)){ return Boolean.FALSE; } //如果没有老值 - if(Objects.isNull(oldApply)){ + if(Objects.isNull(record)){ return Boolean.TRUE; } //和老值做个对比 不一样则true - Class clazz = oldApply.getClass(); + Class clazz = record.getClass(); String oldFiled = StringUtils.EMPTY; try { Field fieldDeclared = clazz.getDeclaredField(fieldName); fieldDeclared.setAccessible(Boolean.TRUE); - oldFiled = Objects.nonNull(fieldDeclared.get(oldApply)) ? String.valueOf(fieldDeclared.get(oldApply)) : null; + oldFiled = Objects.nonNull(fieldDeclared.get(record)) ? String.valueOf(fieldDeclared.get(record)) : null; } catch (NoSuchFieldException e) { log.error("转换PDF文件出错" + e); } catch (IllegalAccessException e) { @@ -844,4 +907,24 @@ public class GovProjectCollectionManage { return Boolean.FALSE; } + + /** + * @param bytes byte数组 + * @param fileRoute 文件路径 + * @param fileName 文件名 + */ + public static void upload(byte[] bytes,String fileRoute,String fileName) { + try { + File directory=new File(fileRoute); + if (!directory.exists()){ + directory.mkdirs(); + } + File file = new File(directory, fileName); + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); + bos.write(bytes); + bos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java index b5ec5d6..e2fc162 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java @@ -152,4 +152,17 @@ public class GovBizProjectApply implements Serializable { @ApiModelProperty("立项依据材料PDF版") private String baseProjBasisFilePdf; + + @ApiModelProperty("项目申报书PDF版") + private String baseProjApplyFilePdf; + + @ApiModelProperty("运维方案PDF版") + private String baseOperatMaintenFilePdf; + + @ApiModelProperty("可研报告PDF版") + private String baseResearchReportFilePdf; + + @ApiModelProperty("其它文件PDF版") + private String baseProjOtherFilePdf; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java index 4542fb7..6230edb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApprove.java @@ -36,7 +36,7 @@ public class GovBizProjectApprove implements Serializable { @ApiModelProperty("基本项目名称") private String baseProjName; - @ApiModelProperty("'发改项目代码'") + @ApiModelProperty("发改项目代码") private String baseDevelopCode; @ApiModelProperty("'财政项目代码'") @@ -54,7 +54,7 @@ public class GovBizProjectApprove implements Serializable { @ApiModelProperty("建议总投资") private BigDecimal baseExpertTotalMoney; - @ApiModelProperty("'建议年度预算'") + @ApiModelProperty("建议年度预算") private BigDecimal baseExpertYearMoney; @ApiModelProperty("立项批复文件") @@ -99,4 +99,13 @@ public class GovBizProjectApprove implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("立项批复文件") + private String approvalFilePdf; + + @ApiModelProperty("评审意见附件PDF") + private String baseReviewCommentsFilePdf; + + @ApiModelProperty("初步设计方案批复函PDF") + private String preliminaryDesignFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java index 6154c1f..428011e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java @@ -115,4 +115,7 @@ public class GovBizProjectCimplement implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("生产批复文件PDF") + private String baseChanFilePdf; } From ee14581a84890cbe959365c30065dd03085fbdf4 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 11:37:42 +0800 Subject: [PATCH 15/22] pdf --- .../gov/manage/GovProjectCollectionManage.java | 59 +++++++++++++++++++++- .../gov/model/entity/GovBizProjectCimplement.java | 39 ++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 9c3d6ae..74b12ee 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -849,11 +849,68 @@ public class GovProjectCollectionManage { approveService.updateById(saveApprove); } - private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { + private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, + GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { if(checkFieldHas(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); saveCimplement.setBaseChanFilePdf(sj.toString()); } + if(checkFieldHas(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseCheckFile()); + saveCimplement.setBaseCheckFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseInforLevelFile()); + saveCimplement.setBaseInforLevelFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseChangeFormFile()); + saveCimplement.setBaseChangeFormFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseEstaSummFile()); + saveCimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); + saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); + saveCimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseThirdAcceptFile()); + saveCimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseUserConsFile()); + saveCimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseFinanlAuditFile()); + saveCimplement.setBaseFinanlAuditFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); + saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseInitialOpinionFile()); + saveCimplement.setBaseInitialOpinionFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBasePasswAssessFile()); + saveCimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseSummReportFile()); + saveCimplement.setBaseSummReportFilePdf(sj.toString()); + } + if(checkFieldHas(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ + StringJoiner sj = convertAndUpload(cimplement.getBaseIrsTestRunFile()); + saveCimplement.setBaseIrsTestRunFilePdf(sj.toString()); + } cimplementService.updateById(saveCimplement); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java index 428011e..6ac1acd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectCimplement.java @@ -118,4 +118,43 @@ public class GovBizProjectCimplement implements Serializable { @ApiModelProperty("生产批复文件PDF") private String baseChanFilePdf; + + @ApiModelProperty("初验意见PDF") + private String baseInitialOpinionFilePdf; + + @ApiModelProperty("信息安全等级保护测评报告PDF") + private String baseInforLevelFilePdf; + + @ApiModelProperty("'商业密码应用评估报告'") + private String basePasswAssessFilePdf; + + @ApiModelProperty("第三方验收测试报告PDF") + private String baseThirdAcceptFilePdf; + + @ApiModelProperty("建设核查表PDF") + private String baseCheckFilePdf; + + @ApiModelProperty("财务审计报告PDF") + private String baseFinanlAuditFilePdf; + + @ApiModelProperty("用户使用报告PDF") + private String baseUserConsFilePdf; + + @ApiModelProperty("监理总结报告PDF") + private String baseEstaSummFilePdf; + + @ApiModelProperty("IRS应用试运行报告PDF") + private String baseIrsTestRunFilePdf; + + @ApiModelProperty("项目总结报告PDF") + private String baseSummReportFilePdf; + + @ApiModelProperty("终审意见PDF") + private String baseFinalExpertOpinionFilePdf; + + @ApiModelProperty("项目延期申请表PDF") + private String baseEngineerPostpoFilePdf; + + @ApiModelProperty("变更申请单PDF") + private String baseChangeFormFilePdf; } From 00f660d042c4c2e85a65b4bcadddd429a4c23f89 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 11:51:17 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E8=B4=A2=E6=94=BF=E7=BC=96=E7=A0=81=20?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java index ff38f78..993abaa 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java @@ -18,7 +18,6 @@ public class ReqCompanyFiscalCodeAndSealSnPO { @ApiModelProperty("组织编码(需传入用户任职单位code)") private String organizationCode; - @NotBlank(message = "财政编码 不能为空") @ApiModelProperty("财政编码") private String fiscalCode; From 4045fa0e13a9697f8fd46c6f4df62272862b7fac Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 12:13:55 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E8=B4=A2=E6=94=BF=E7=BC=96=E7=A0=81=20?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/common/config/BeanConfig.java | 2 +- .../pmapi/gov/manage/GovProjectCollectionManage.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java index f176489..daf2840 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java @@ -109,7 +109,7 @@ public class BeanConfig { .build(); } - @Bean + @Bean(value = "projectThreadPool") public ThreadPoolTaskExecutor getThreadPoolTaskExecutor(){ ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(5); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 74b12ee..248662d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -35,6 +35,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -45,6 +46,8 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; +import javax.annotation.Resource; +import javax.annotation.Resources; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -86,7 +89,8 @@ public class GovProjectCollectionManage { private final WpsConvertManage wpsConvertManage; - private final ThreadPoolTaskExecutor threadPoolTaskExecutor; + @Resource(name = "projectThreadPool") + private ThreadPoolTaskExecutor projectThreadPool; @Value("${project.push-url}") private String pushUrl; @@ -441,7 +445,7 @@ public class GovProjectCollectionManage { saveApply.setUpdateBy(user.getUsername()); saveApply.setUpdateOn(LocalDateTime.now()); if(projectApplyService.saveOrUpdate(saveApply)){ - threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); + projectThreadPool.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); } } @@ -466,7 +470,7 @@ public class GovProjectCollectionManage { saveApprove.setUpdateBy(user.getUsername()); saveApprove.setUpdateOn(LocalDateTime.now()); if(approveService.saveOrUpdate(saveApprove)){ - threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); + projectThreadPool.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); } } @@ -492,7 +496,7 @@ public class GovProjectCollectionManage { saveCimplement.setUpdateBy(user.getUsername()); saveCimplement.setUpdateOn(LocalDateTime.now()); if(cimplementService.saveOrUpdate(saveCimplement)){ - threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); + projectThreadPool.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); } } From 5301ec11e5502c00664e1a6a9a1e945cd4bc2680 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 13:41:02 +0800 Subject: [PATCH 18/22] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/common/config/BeanConfig.java | 11 ----------- .../com/ningdatech/pmapi/common/constant/RegionConst.java | 3 +-- .../pmapi/gov/manage/GovProjectCollectionManage.java | 11 ++++++----- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java index daf2840..d850df4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/BeanConfig.java @@ -108,15 +108,4 @@ public class BeanConfig { .setRetryHandler(new DefaultHttpRequestRetryHandler(2, true)) .build(); } - - @Bean(value = "projectThreadPool") - public ThreadPoolTaskExecutor getThreadPoolTaskExecutor(){ - ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); - threadPoolTaskExecutor.setCorePoolSize(5); - threadPoolTaskExecutor.setKeepAliveSeconds(200); - threadPoolTaskExecutor.setMaxPoolSize(10); - threadPoolTaskExecutor.setQueueCapacity(20); - threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - return threadPoolTaskExecutor; - } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java index fecfab9..c9e327f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/RegionConst.java @@ -24,13 +24,12 @@ public interface RegionConst { * 丽水行政区划编码 */ String RC_LS = "331100"; + //丽水开发区 String LS_KF = "331118"; String LS_KF_IRS = "331151"; String RC_LS_SBJ_IRS = "331101"; //遂昌县 String RC_SC = "331123"; - //丽水开发区 - String LS_KF = "331118"; String LS_KF_NAME = "开发区"; /** diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 248662d..e994689 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -42,6 +42,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; @@ -89,8 +90,8 @@ public class GovProjectCollectionManage { private final WpsConvertManage wpsConvertManage; - @Resource(name = "projectThreadPool") - private ThreadPoolTaskExecutor projectThreadPool; + @Resource + private ThreadPoolTaskScheduler threadPoolTaskScheduler; @Value("${project.push-url}") private String pushUrl; @@ -445,7 +446,7 @@ public class GovProjectCollectionManage { saveApply.setUpdateBy(user.getUsername()); saveApply.setUpdateOn(LocalDateTime.now()); if(projectApplyService.saveOrUpdate(saveApply)){ - projectThreadPool.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); + threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); } } @@ -470,7 +471,7 @@ public class GovProjectCollectionManage { saveApprove.setUpdateBy(user.getUsername()); saveApprove.setUpdateOn(LocalDateTime.now()); if(approveService.saveOrUpdate(saveApprove)){ - projectThreadPool.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); + threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); } } @@ -496,7 +497,7 @@ public class GovProjectCollectionManage { saveCimplement.setUpdateBy(user.getUsername()); saveCimplement.setUpdateOn(LocalDateTime.now()); if(cimplementService.saveOrUpdate(saveCimplement)){ - projectThreadPool.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); + threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); } } From 915878864b9cbcb1612d028350b31136244ad331 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 15:07:40 +0800 Subject: [PATCH 19/22] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/gov/convert/ProjectConvert.java | 163 +++++++++++++++++++++ .../gov/manage/GovProjectCollectionManage.java | 123 ++++++++++++---- .../pmapi/gov/model/entity/GovBizProjectDraft.java | 4 + .../gov/model/entity/GovBizProjectMimplement.java | 30 ++++ .../gov/model/entity/GovBizProjectProcure.java | 9 ++ .../pmapi/gov/model/vo/GovBizProjectApplyVO.java | 15 ++ .../pmapi/gov/model/vo/GovBizProjectApproveVO.java | 9 ++ .../gov/model/vo/GovBizProjectCimplementVO.java | 42 ++++++ .../gov/model/vo/GovBizProjectMimplementVO.java | 30 ++++ .../pmapi/gov/model/vo/GovBizProjectProcureVO.java | 9 ++ 10 files changed, 407 insertions(+), 27 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java index 40c7ae2..d58fad1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java @@ -6,6 +6,7 @@ import com.ningdatech.pmapi.gov.contants.BizProjectContant; import com.ningdatech.pmapi.gov.model.dto.*; import com.ningdatech.pmapi.gov.model.req.*; import com.ningdatech.pmapi.gov.model.vo.*; +import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.List; @@ -47,6 +48,17 @@ public class ProjectConvert { return req; } + public static ProjectPushReq convertWithConvertPdf(GovBizProjectDetailVO vo) { + ProjectPushReq req = new ProjectPushReq(); + req.setBaseinfo(convertBaseVo(vo.getBaseinfo(),BizProjectContant.EFFECTIVE_CODE)); + req.setApply(convertApplyVoWithConvertPdf(vo.getApply())); + req.setApprove(convertApproveVoWithConvertPdf(vo.getApprove())); + req.setCimplement(convertCimplementVoWithConvertPdf(vo.getCimplement())); + req.setMimplement(convertMimplementVoWithConvertPdf(vo.getMimplement())); + req.setProcures(convertProcuresVoWithConvertPdf(vo.getProcures())); + return req; + } + private static List convertProcures(List procures) { if(CollUtil.isEmpty(procures)){ return Collections.emptyList(); @@ -81,6 +93,26 @@ public class ProjectConvert { return req; } + private static List convertProcuresVoWithConvertPdf(List procures) { + if(CollUtil.isEmpty(procures)){ + return Collections.emptyList(); + } + + List req = procures.stream() + .map(p -> { + ProjectProcureReq r = BeanUtil.copyProperties(p, ProjectProcureReq.class); + r.setBiddingFile(StringUtils.isNotBlank(p.getBiddingFilePdf()) ? p.getBiddingFilePdf() : + p.getBiddingFile()); + r.setPurchaseFile(StringUtils.isNotBlank(p.getPurchaseFilePdf()) ? p.getPurchaseFilePdf() : + p.getPurchaseFile()); + r.setPurchaseContract(StringUtils.isNotBlank(p.getPurchaseContractPdf()) ? p.getPurchaseContractPdf() : + p.getPurchaseContract()); + return r; + }) + .collect(Collectors.toList()); + return req; + } + private static ProjectMimplementReq convertMimplement(GovBizProjectMimplementDTO mimplement) { ProjectMimplementReq req = BeanUtil.copyProperties(mimplement,ProjectMimplementReq.class); return req; @@ -91,6 +123,31 @@ public class ProjectConvert { return req; } + private static ProjectMimplementReq convertMimplementVoWithConvertPdf(GovBizProjectMimplementVO mimplement) { + ProjectMimplementReq req = BeanUtil.copyProperties(mimplement,ProjectMimplementReq.class); + req.setBaseUserConsFile(StringUtils.isNotBlank(mimplement.getBaseUserConsFilePdf()) ? mimplement.getBaseUserConsFilePdf() : + mimplement.getBaseUserConsFile()); + req.setBaseChanFile(StringUtils.isNotBlank(mimplement.getBaseChanFilePdf()) ? mimplement.getBaseChanFilePdf() : + mimplement.getBaseChanFile()); + req.setBasePasswAssessFile(StringUtils.isNotBlank(mimplement.getBasePasswAssessFilePdf()) ? mimplement.getBasePasswAssessFilePdf() : + mimplement.getBasePasswAssessFile()); + req.setBaseInforLevelFile(StringUtils.isNotBlank(mimplement.getBaseInforLevelFilePdf()) ? mimplement.getBaseInforLevelFilePdf() : + mimplement.getBaseInforLevelFile()); + req.setBaseEngineerPostpoFile(StringUtils.isNotBlank(mimplement.getBaseEngineerPostpoFilePdf()) ? mimplement.getBaseEngineerPostpoFilePdf() : + mimplement.getBaseEngineerPostpoFile()); + req.setBaseEstaSummFile(StringUtils.isNotBlank(mimplement.getBaseEstaSummFilePdf()) ? mimplement.getBaseEstaSummFilePdf() : + mimplement.getBaseEstaSummFile()); + req.setBaseFinalExpertOpinionFile(StringUtils.isNotBlank(mimplement.getBaseFinalExpertOpinionFilePdf()) ? mimplement.getBaseFinalExpertOpinionFilePdf() : + mimplement.getBaseFinalExpertOpinionFile()); + req.setBaseThirdAcceptFile(StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFilePdf()) ? mimplement.getBaseThirdAcceptFilePdf() : + mimplement.getBaseThirdAcceptFile()); + req.setBaseOperatMaintenSummFile(StringUtils.isNotBlank(mimplement.getBaseOperatMaintenSummFilePdf()) ? mimplement.getBaseOperatMaintenSummFilePdf() : + mimplement.getBaseOperatMaintenSummFile()); + req.setBaseEngineerAlterFile(StringUtils.isNotBlank(mimplement.getBaseEngineerAlterFilePdf()) ? mimplement.getBaseEngineerAlterFilePdf() : + mimplement.getBaseEngineerAlterFile()); + return req; + } + public static ProjectCimplementReq convertCimplement(GovBizProjectCimplementDTO cimplement) { ProjectCimplementReq req = BeanUtil.copyProperties(cimplement,ProjectCimplementReq.class); return req; @@ -101,6 +158,39 @@ public class ProjectConvert { return req; } + public static ProjectCimplementReq convertCimplementVoWithConvertPdf(GovBizProjectCimplementVO cimplement) { + ProjectCimplementReq req = BeanUtil.copyProperties(cimplement,ProjectCimplementReq.class); + req.setBaseChangeFormFile(StringUtils.isNotBlank(cimplement.getBaseChangeFormFilePdf()) ? cimplement.getBaseChangeFormFilePdf() : + cimplement.getBaseChangeFormFile()); + req.setBaseUserConsFile(StringUtils.isNotBlank(cimplement.getBaseUserConsFilePdf()) ? cimplement.getBaseUserConsFilePdf() : + cimplement.getBaseUserConsFile()); + req.setBaseCheckFile(StringUtils.isNotBlank(cimplement.getBaseCheckFilePdf()) ? cimplement.getBaseCheckFilePdf() : + cimplement.getBaseCheckFile()); + req.setBaseChanFile(StringUtils.isNotBlank(cimplement.getBaseChanFilePdf()) ? cimplement.getBaseChanFilePdf() : + cimplement.getBaseChanFile()); + req.setBaseSummReportFile(StringUtils.isNotBlank(cimplement.getBaseSummReportFilePdf()) ? cimplement.getBaseSummReportFilePdf() : + cimplement.getBaseSummReportFile()); + req.setBasePasswAssessFile(StringUtils.isNotBlank(cimplement.getBasePasswAssessFilePdf()) ? cimplement.getBasePasswAssessFilePdf() : + cimplement.getBasePasswAssessFile()); + req.setBaseInforLevelFile(StringUtils.isNotBlank(cimplement.getBaseInforLevelFilePdf()) ? cimplement.getBaseInforLevelFilePdf() : + cimplement.getBaseInforLevelFile()); + req.setBaseEngineerPostpoFile(StringUtils.isNotBlank(cimplement.getBaseEngineerPostpoFilePdf()) ? cimplement.getBaseEngineerPostpoFilePdf() : + cimplement.getBaseEngineerPostpoFile()); + req.setBaseEstaSummFile(StringUtils.isNotBlank(cimplement.getBaseEstaSummFilePdf()) ? cimplement.getBaseEstaSummFilePdf() : + cimplement.getBaseEstaSummFile()); + req.setBaseFinanlAuditFile(StringUtils.isNotBlank(cimplement.getBaseFinanlAuditFilePdf()) ? cimplement.getBaseFinanlAuditFilePdf() : + cimplement.getBaseFinanlAuditFile()); + req.setBaseFinalExpertOpinionFile(StringUtils.isNotBlank(cimplement.getBaseFinalExpertOpinionFilePdf()) ? cimplement.getBaseFinalExpertOpinionFilePdf() : + cimplement.getBaseFinalExpertOpinionFile()); + req.setBaseThirdAcceptFile(StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFilePdf()) ? cimplement.getBaseThirdAcceptFilePdf() : + cimplement.getBaseThirdAcceptFile()); + req.setBaseInitialOpinionFile(StringUtils.isNotBlank(cimplement.getBaseInitialOpinionFilePdf()) ? cimplement.getBaseInitialOpinionFilePdf() : + cimplement.getBaseInitialOpinionFile()); + req.setBaseIrsTestRunFile(StringUtils.isNotBlank(cimplement.getBaseIrsTestRunFilePdf()) ? cimplement.getBaseIrsTestRunFilePdf() : + cimplement.getBaseIrsTestRunFile()); + return req; + } + public static ProjectApproveReq convertApprove(GovBizProjectApproveDTO approve) { ProjectApproveReq req = new ProjectApproveReq(); if(Objects.isNull(approve)){ @@ -151,6 +241,34 @@ public class ProjectConvert { return req; } + public static ProjectApproveReq convertApproveVoWithConvertPdf(GovBizProjectApproveVO approve) { + ProjectApproveReq req = new ProjectApproveReq(); + if(Objects.isNull(approve)){ + return req; + } + req.setBaseProjId(approve.getBaseProjId()); + req.setBaseProjName(approve.getBaseProjName()); + req.setOp(approve.getOp()); + req.setApprovalFile(StringUtils.isNotBlank(approve.getApprovalFilePdf()) ? approve.getApprovalFilePdf() : + approve.getApprovalFile()); + req.setBaseReviewCommentsFile(StringUtils.isNotBlank(approve.getBaseReviewCommentsFilePdf()) ? approve.getBaseReviewCommentsFilePdf(): + approve.getBaseReviewCommentsFile()); + req.setPreliminaryDesignFile(StringUtils.isNotBlank(approve.getPreliminaryDesignFilePdf()) ? approve.getPreliminaryDesignFilePdf() : + approve.getPreliminaryDesignFile()); + req.setAreaCode(approve.getAreaCode()); + req.setBaseDevelopCode(approve.getBaseDevelopCode()); + req.setBaseExpertTotalMoney(String.valueOf(approve.getBaseExpertTotalMoney())); + req.setBaseExpertYearMoney(String.valueOf(approve.getBaseExpertYearMoney())); + req.setReleaseYearMoney(String.valueOf(approve.getReleaseYearMoney())); + req.setBaseInitialReviewTotalMoney(String.valueOf(approve.getBaseInitialReviewTotalMoney())); + req.setBaseReviewOpinion(approve.getBaseReviewOpinion()); + req.setBaseReviewResults(approve.getBaseReviewResults()); + req.setEqualProtectionLevel(approve.getEqualProtectionLevel()); + req.setPreliminaryDesignScheme(approve.getPreliminaryDesignScheme()); + req.setSetProjCodeFinan(approve.getSetProjCodeFinan()); + return req; + } + public static ProjectApplyReq convertApply(GovBizProjectApplyDTO apply) { ProjectApplyReq req = new ProjectApplyReq(); if(Objects.isNull(apply)){ @@ -231,6 +349,51 @@ public class ProjectConvert { return req; } + public static ProjectApplyReq convertApplyVoWithConvertPdf(GovBizProjectApplyVO apply) { + ProjectApplyReq req = new ProjectApplyReq(); + if(Objects.isNull(apply)){ + return req; + } + req.setOp(apply.getOp()); + req.setBaseProjId(apply.getBaseProjId()); + req.setBaseProjName(apply.getBaseProjName()); + req.setAreaCode(apply.getAreaCode()); + req.setBaseAccountAppName(apply.getBaseAccountAppName()); + req.setBaseBasisEstablish(apply.getBaseBasisEstablish()); + req.setBaseCoreBusiness(apply.getBaseCoreBusiness()); + req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode()); + req.setBaseBrainName(apply.getBaseBrainName()); + req.setBaseDevelopCode(apply.getBaseDevelopCode()); + req.setBaseLowestLevel(apply.getBaseLowestLevel()); + req.setBaseHistorProjId(apply.getBaseHistorProjId()); + req.setBaseHistorProjName(apply.getBaseHistorProjName()); + req.setBaseOperatMaintenFile(StringUtils.isNotBlank(apply.getBaseOperatMaintenFilePdf()) ? apply.getBaseOperatMaintenFilePdf() : + apply.getBaseOperatMaintenFile()); + req.setBaseProjApplyFile(StringUtils.isNotBlank(apply.getBaseProjApplyFilePdf()) ? apply.getBaseProjApplyFilePdf() : + apply.getBaseProjApplyFile()); + req.setBaseProjBasisFile(StringUtils.isNotBlank(apply.getBaseProjBasisFilePdf()) ? apply.getBaseProjBasisFilePdf() : + apply.getBaseProjBasisFile()); + req.setBaseProjOtherFile(StringUtils.isNotBlank(apply.getBaseProjOtherFilePdf()) ? apply.getBaseProjOtherFilePdf() : + apply.getBaseProjOtherFile()); + req.setBaseResearchReportFile(StringUtils.isNotBlank(apply.getBaseResearchReportFilePdf()) ? apply.getBaseResearchReportFilePdf() : + apply.getBaseResearchReportFile()); + req.setBaseProjConsClass(apply.getBaseProjConsClass()); + req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration())); + req.setBaseProjIntro(apply.getBaseProjIntro()); + req.setBaseProjStartTime(String.valueOf(apply.getBaseProjStartTime())); + req.setBaseProjEndTime(String.valueOf(apply.getBaseProjEndTime())); + req.setBaseProjSetYear(apply.getBaseProjSetYear()); + req.setBaseProjSys(apply.getBaseProjSys()); + req.setBaseProjSysCode(apply.getBaseDevelopCode()); + req.setBaseProjDeclAmount(String.valueOf(apply.getBaseProjDeclAmount())); + req.setBaseProjTotalAmount(String.valueOf(apply.getBaseProjTotalAmount())); + req.setBaseBasisAmountOri(apply.getBaseBasisAmountOri()); + req.setBaseProjAmountOri(apply.getBaseProjAmountOri()); + req.setBaseProjRemark(apply.getBaseProjRemark()); + req.setBeseExpectedResults(apply.getBeseExpectedResults()); + return req; + } + public static ProjectBaseInfoReq convertBase(GovBizProjectBaseinfoDTO baseinfo,String isEffective) { ProjectBaseInfoReq req = BeanUtil.copyProperties(baseinfo,ProjectBaseInfoReq.class); req.setIsEffective(isEffective); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index e994689..4505ef1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -31,24 +31,19 @@ import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.ningdatech.pmapi.wps.manage.WpsConvertManage; +import io.swagger.annotations.ApiModelProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.formula.functions.T; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; - -import javax.annotation.Resource; -import javax.annotation.Resources; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -90,8 +85,7 @@ public class GovProjectCollectionManage { private final WpsConvertManage wpsConvertManage; - @Resource - private ThreadPoolTaskScheduler threadPoolTaskScheduler; + private final ThreadPoolTaskScheduler threadPoolTaskScheduler; @Value("${project.push-url}") private String pushUrl; @@ -526,31 +520,40 @@ public class GovProjectCollectionManage { saveMimplement.setBizTime(LocalDateTime.now()); saveMimplement.setUpdateBy(user.getUsername()); saveMimplement.setUpdateOn(LocalDateTime.now()); - mimplementService.saveOrUpdate(saveMimplement); + if(mimplementService.saveOrUpdate(saveMimplement)){ + threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssMimplement(mimplement,oldMimplement,saveMimplement)); + } } // 6.保存 采购信息 List procures = saveDTO.getProcures(); - Integer index = 1; + if(Objects.nonNull(procures)){ procureService.remove(Wrappers.lambdaQuery(GovBizProjectProcure.class) .eq(GovBizProjectProcure::getBaseProjId,baseProjId)); - for(GovBizProjectProcureDTO procure : procures){ - procure.setBaseProjId(baseProjId); - procure.setBaseProjName(baseProjName); - procure.setBaseBidCode(baseProjId + StrPool.DASH + index); - - GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); - saveProcure.setBaseProjId(baseProjId); - saveProcure.setId(null); - saveProcure.setAreaCode(RegionConst.RC_LS); - saveProcure.setTongTime(LocalDateTime.now()); - saveProcure.setBizTime(LocalDateTime.now()); - saveProcure.setUpdateBy(user.getUsername()); - saveProcure.setUpdateOn(LocalDateTime.now()); - procureService.save(saveProcure); - index++; - } + + String finalBaseProjId = baseProjId; + UserInfoDetails finalUser = user; + threadPoolTaskScheduler.execute(() -> { + Integer index = 1; + for(GovBizProjectProcureDTO procure : procures){ + procure.setBaseProjId(finalBaseProjId); + procure.setBaseProjName(baseProjName); + procure.setBaseBidCode(finalBaseProjId + StrPool.DASH + index); + GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); + saveProcure.setBaseProjId(finalBaseProjId); + saveProcure.setId(null); + saveProcure.setAreaCode(RegionConst.RC_LS); + saveProcure.setTongTime(LocalDateTime.now()); + saveProcure.setBizTime(LocalDateTime.now()); + saveProcure.setUpdateBy(finalUser.getUsername()); + saveProcure.setUpdateOn(LocalDateTime.now()); + if(procureService.save(saveProcure)){ + uploadFileToProvincialOssProcure(procure,null,saveProcure); + } + index++; + } + }); } //7. 推送数据(改为定时推送了) @@ -756,7 +759,7 @@ public class GovProjectCollectionManage { } public void pushProjectVo(GovBizProjectDetailVO vo) { String url = pushUrl; - ProjectPushReq req = ProjectConvert.convert(vo); + ProjectPushReq req = ProjectConvert.convertWithConvertPdf(vo); try{ log.info("推送消息体 {} ,{},{}",vo.getBaseProjId(),url, JSON.toJSONString(req)); HttpHeaders headers = new HttpHeaders(); @@ -919,6 +922,72 @@ public class GovProjectCollectionManage { cimplementService.updateById(saveCimplement); } + private void uploadFileToProvincialOssMimplement(GovBizProjectMimplementDTO mimplement, GovBizProjectMimplement oldMimplement, GovBizProjectMimplement saveMimplement) { + if(checkFieldHas(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseChanFile()); + saveMimplement.setBaseChanFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseInforLevelFile()); + saveMimplement.setBaseInforLevelFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBasePasswAssessFile()); + saveMimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseThirdAcceptFile()); + saveMimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseEstaSummFile()); + saveMimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseUserConsFile()); + saveMimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); + saveMimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); + saveMimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerPostpoFile()); + saveMimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(checkFieldHas(mimplement.getBaseEngineerAlterFile(),oldMimplement,"baseEngineerAlterFile")){ + StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerAlterFile()); + saveMimplement.setBaseEngineerAlterFilePdf(sj.toString()); + } + mimplementService.updateById(saveMimplement); + } + + /** + * 采购文件处理 + * @param procure + * @param o + * @param saveProcure + */ + private void uploadFileToProvincialOssProcure(GovBizProjectProcureDTO procure, Object o, GovBizProjectProcure saveProcure) { + if(checkFieldHas(procure.getPurchaseFile(),o,"purchaseFile")){ + StringJoiner sj = convertAndUpload(procure.getPurchaseFile()); + saveProcure.setPurchaseFilePdf(sj.toString()); + } + if(checkFieldHas(procure.getBiddingFile(),o,"biddingFile")){ + StringJoiner sj = convertAndUpload(procure.getBiddingFile()); + saveProcure.setBiddingFilePdf(sj.toString()); + } + if(checkFieldHas(procure.getPurchaseContract(),o,"purchaseContract")){ + StringJoiner sj = convertAndUpload(procure.getPurchaseContract()); + saveProcure.setPurchaseContractPdf(sj.toString()); + } + procureService.updateById(saveProcure); + } + private StringJoiner convertAndUpload(String baseProjBasisFile) { String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); StringJoiner sj = new StringJoiner(";"); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java index e1d0af8..880c06b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectDraft.java @@ -34,6 +34,10 @@ public class GovBizProjectDraft implements Serializable { private String baseConstructionType; private String baseProjSetProg; private String isEffective; + + @ApiModelProperty("是否省级 1省级 2非省级") + private Integer baseProvManDeprtType; + private String baseProvManDeprt; private String baseProvManDeprtDing; private String baseManDeprt; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java index 8b25046..24ff394 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectMimplement.java @@ -103,4 +103,34 @@ public class GovBizProjectMimplement implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("信息安全等级保护测评报告PDF") + private String baseInforLevelFilePdf; + + @ApiModelProperty("商业密码应用评估报告PDF") + private String basePasswAssessFilePdf; + + @ApiModelProperty("第三方验收测试报告PDF") + private String baseThirdAcceptFilePdf; + + @ApiModelProperty("用户使用报告PDF") + private String baseUserConsFilePdf; + + @ApiModelProperty("监理总结报告PDF") + private String baseEstaSummFilePdf; + + @ApiModelProperty("运维总结报告PDF") + private String baseOperatMaintenSummFilePdf; + + @ApiModelProperty("终审意见PDF") + private String baseFinalExpertOpinionFilePdf; + + @ApiModelProperty("项目延期申请表PDF") + private String baseEngineerPostpoFilePdf; + + @ApiModelProperty("变更报告PDF") + private String baseEngineerAlterFilePdf; + + @ApiModelProperty("变更批复文件PDF") + private String baseChanFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java index a87f7c9..286a3e9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectProcure.java @@ -104,4 +104,13 @@ public class GovBizProjectProcure implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("招标(采购)文件PDF") + private String purchaseFilePdf; + + @ApiModelProperty("采购合同PDF") + private String purchaseContractPdf; + + @ApiModelProperty("中标(成交)通知书PDF") + private String biddingFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java index 9010530..de11b72 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java @@ -144,4 +144,19 @@ public class GovBizProjectApplyVO implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("立项依据材料PDF版") + private String baseProjBasisFilePdf; + + @ApiModelProperty("项目申报书PDF版") + private String baseProjApplyFilePdf; + + @ApiModelProperty("运维方案PDF版") + private String baseOperatMaintenFilePdf; + + @ApiModelProperty("可研报告PDF版") + private String baseResearchReportFilePdf; + + @ApiModelProperty("其它文件PDF版") + private String baseProjOtherFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java index 1b93930..bc5b792 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApproveVO.java @@ -94,4 +94,13 @@ public class GovBizProjectApproveVO implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("立项批复文件") + private String approvalFilePdf; + + @ApiModelProperty("评审意见附件PDF") + private String baseReviewCommentsFilePdf; + + @ApiModelProperty("初步设计方案批复函PDF") + private String preliminaryDesignFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java index 9a07ef9..a30af3b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectCimplementVO.java @@ -110,4 +110,46 @@ public class GovBizProjectCimplementVO implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("生产批复文件PDF") + private String baseChanFilePdf; + + @ApiModelProperty("初验意见PDF") + private String baseInitialOpinionFilePdf; + + @ApiModelProperty("信息安全等级保护测评报告PDF") + private String baseInforLevelFilePdf; + + @ApiModelProperty("'商业密码应用评估报告'") + private String basePasswAssessFilePdf; + + @ApiModelProperty("第三方验收测试报告PDF") + private String baseThirdAcceptFilePdf; + + @ApiModelProperty("建设核查表PDF") + private String baseCheckFilePdf; + + @ApiModelProperty("财务审计报告PDF") + private String baseFinanlAuditFilePdf; + + @ApiModelProperty("用户使用报告PDF") + private String baseUserConsFilePdf; + + @ApiModelProperty("监理总结报告PDF") + private String baseEstaSummFilePdf; + + @ApiModelProperty("IRS应用试运行报告PDF") + private String baseIrsTestRunFilePdf; + + @ApiModelProperty("项目总结报告PDF") + private String baseSummReportFilePdf; + + @ApiModelProperty("终审意见PDF") + private String baseFinalExpertOpinionFilePdf; + + @ApiModelProperty("项目延期申请表PDF") + private String baseEngineerPostpoFilePdf; + + @ApiModelProperty("变更申请单PDF") + private String baseChangeFormFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java index 3676b42..12453b7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectMimplementVO.java @@ -98,4 +98,34 @@ public class GovBizProjectMimplementVO implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("信息安全等级保护测评报告PDF") + private String baseInforLevelFilePdf; + + @ApiModelProperty("商业密码应用评估报告PDF") + private String basePasswAssessFilePdf; + + @ApiModelProperty("第三方验收测试报告PDF") + private String baseThirdAcceptFilePdf; + + @ApiModelProperty("用户使用报告PDF") + private String baseUserConsFilePdf; + + @ApiModelProperty("监理总结报告PDF") + private String baseEstaSummFilePdf; + + @ApiModelProperty("运维总结报告PDF") + private String baseOperatMaintenSummFilePdf; + + @ApiModelProperty("终审意见PDF") + private String baseFinalExpertOpinionFilePdf; + + @ApiModelProperty("项目延期申请表PDF") + private String baseEngineerPostpoFilePdf; + + @ApiModelProperty("变更报告PDF") + private String baseEngineerAlterFilePdf; + + @ApiModelProperty("变更批复文件PDF") + private String baseChanFilePdf; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java index 9ff4798..fd90509 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectProcureVO.java @@ -99,4 +99,13 @@ public class GovBizProjectProcureVO implements Serializable { @ApiModelProperty("最后修改人") private String updateBy; + + @ApiModelProperty("招标(采购)文件PDF") + private String purchaseFilePdf; + + @ApiModelProperty("采购合同PDF") + private String purchaseContractPdf; + + @ApiModelProperty("中标(成交)通知书PDF") + private String biddingFilePdf; } From cc8e411de685d03d3646a4297401706a8a6f5fb6 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 15:19:40 +0800 Subject: [PATCH 20/22] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E5=90=8E=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectCollection/ProjectCollectionTest.java | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java new file mode 100644 index 0000000..e4c5398 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java @@ -0,0 +1,75 @@ +package com.ningdatech.pmapi.projectCollection; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; +import com.ningdatech.pmapi.gov.model.entity.*; +import com.ningdatech.pmapi.gov.service.*; +import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Classname ProjectCollectionTest + * @Description + * @Date 2023/9/7 15:08 + * @Author PoffyZhang + */ +public class ProjectCollectionTest extends AppTests { + + @Autowired + private IGovBizProjectBaseinfoService baseinfoService; + + @Autowired + private IGovBizProjectApplyService applyService; + + @Autowired + private IGovBizProjectApproveService approveService; + + @Autowired + private IGovBizProjectCimplementService cimplementService; + + @Autowired + private IGovBizProjectMimplementService mimplementService; + + @Autowired + private IGovBizProjectProcureService procureService; + + @Autowired + private GenerateProjectCodeUtil generateProjectCodeUtil; + + @Test + public void test(){ + String baseProjId = "33112500020210100003"; + GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId)); + GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjId, baseProjId)); + + GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); + saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); + saveDTO.setBaseinfo(BeanUtil.copyProperties(baseinfo, GovBizProjectBaseinfoDTO.class)); + String newProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); + + baseinfo.setBaseProjId(newProjId); + baseinfoService.updateById(baseinfo); + apply.setBaseProjId(newProjId); + applyService.updateById(apply); + approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId,baseProjId) + .set(GovBizProjectApprove::getBaseProjId,newProjId)); + cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjId,baseProjId) + .set(GovBizProjectCimplement::getBaseProjId,newProjId)); + mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjId,baseProjId) + .set(GovBizProjectMimplement::getBaseProjId,newProjId)); + procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjId,baseProjId) + .set(GovBizProjectProcure::getBaseProjId,newProjId)); + } + +} From c891eff615cc281506e527c1f471b435f26d2580 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 7 Sep 2023 16:21:43 +0800 Subject: [PATCH 21/22] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E5=90=8E=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java index d58fad1..db1f3b6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java @@ -125,6 +125,9 @@ public class ProjectConvert { private static ProjectMimplementReq convertMimplementVoWithConvertPdf(GovBizProjectMimplementVO mimplement) { ProjectMimplementReq req = BeanUtil.copyProperties(mimplement,ProjectMimplementReq.class); + if(Objects.isNull(req)){ + return req; + } req.setBaseUserConsFile(StringUtils.isNotBlank(mimplement.getBaseUserConsFilePdf()) ? mimplement.getBaseUserConsFilePdf() : mimplement.getBaseUserConsFile()); req.setBaseChanFile(StringUtils.isNotBlank(mimplement.getBaseChanFilePdf()) ? mimplement.getBaseChanFilePdf() : @@ -160,6 +163,9 @@ public class ProjectConvert { public static ProjectCimplementReq convertCimplementVoWithConvertPdf(GovBizProjectCimplementVO cimplement) { ProjectCimplementReq req = BeanUtil.copyProperties(cimplement,ProjectCimplementReq.class); + if(Objects.isNull(req)){ + return req; + } req.setBaseChangeFormFile(StringUtils.isNotBlank(cimplement.getBaseChangeFormFilePdf()) ? cimplement.getBaseChangeFormFilePdf() : cimplement.getBaseChangeFormFile()); req.setBaseUserConsFile(StringUtils.isNotBlank(cimplement.getBaseUserConsFilePdf()) ? cimplement.getBaseUserConsFilePdf() : From bc676e1342a26c822b835955a1f24512f050143e Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 8 Sep 2023 10:04:57 +0800 Subject: [PATCH 22/22] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E9=A1=B9=E7=9B=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/gov/contants/BizProjectContant.java | 1 + .../controller/GovProjectCollectionController.java | 7 + .../gov/manage/GovProjectCollectionManage.java | 76 +++---- .../scheduler/task/SynProjectCollectionTask.java | 249 +++++++++++++++++++++ .../pmapi/wps/manage/WpsConvertManage.java | 7 +- 5 files changed, 301 insertions(+), 39 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java index ef45497..90b1b25 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java @@ -23,6 +23,7 @@ public interface BizProjectContant { public static final String OP_INSERT = "insert"; public static final String OP_UPDATE = "update"; public static final String OP_DELETE = "delete"; + public static final String PDF_SUFFIX = ".pdf"; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java index f1bf99c..eb0a8ba 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java @@ -104,4 +104,11 @@ public class GovProjectCollectionController { public void pushTask() throws UnknownHostException { collectionTask.doTask(); } + + @PostMapping("/staging-convert-pdf") + @ApiOperation("把库存的项目归集的文件 都转换成PDF文件存入字段") + @WebLog("主动转换库存的文件都为PDF文件") + public void stagingConvertPdf() { + collectionTask.stagingConvertPdf(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 4505ef1..2078498 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -818,23 +818,23 @@ public class GovProjectCollectionManage { */ private void uploadFileToProvincialOssApply(GovBizProjectApplyDTO apply, GovBizProjectApply oldApply,GovBizProjectApply saveApply) { - if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ + if(checkFieldNotPdf(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjBasisFile()); saveApply.setBaseProjBasisFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ + if(checkFieldNotPdf(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjApplyFile()); saveApply.setBaseProjApplyFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ + if(checkFieldNotPdf(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ StringJoiner sj = convertAndUpload(apply.getBaseOperatMaintenFile()); saveApply.setBaseOperatMaintenFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ + if(checkFieldNotPdf(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ StringJoiner sj = convertAndUpload(apply.getBaseResearchReportFile()); saveApply.setBaseResearchReportFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ + if(checkFieldNotPdf(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjOtherFile()); saveApply.setBaseProjOtherFilePdf(sj.toString()); } @@ -842,15 +842,15 @@ public class GovProjectCollectionManage { } private void uploadFileToProvincialOssApprove(GovBizProjectApproveDTO approve, GovBizProjectApprove oldApprove, GovBizProjectApprove saveApprove) { - if(checkFieldHas(approve.getApprovalFile(),oldApprove,"approvalFile")){ + if(checkFieldNotPdf(approve.getApprovalFile(),oldApprove,"approvalFile")){ StringJoiner sj = convertAndUpload(approve.getApprovalFile()); saveApprove.setApprovalFilePdf(sj.toString()); } - if(checkFieldHas(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ + if(checkFieldNotPdf(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ StringJoiner sj = convertAndUpload(approve.getBaseReviewCommentsFile()); saveApprove.setBaseReviewCommentsFilePdf(sj.toString()); } - if(checkFieldHas(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ + if(checkFieldNotPdf(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ StringJoiner sj = convertAndUpload(approve.getPreliminaryDesignFile()); saveApprove.setPreliminaryDesignFilePdf(sj.toString()); } @@ -859,63 +859,63 @@ public class GovProjectCollectionManage { private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { - if(checkFieldHas(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ + if(checkFieldNotPdf(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); saveCimplement.setBaseChanFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ + if(checkFieldNotPdf(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseCheckFile()); saveCimplement.setBaseCheckFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ + if(checkFieldNotPdf(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseInforLevelFile()); saveCimplement.setBaseInforLevelFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ + if(checkFieldNotPdf(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseChangeFormFile()); saveCimplement.setBaseChangeFormFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ + if(checkFieldNotPdf(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEstaSummFile()); saveCimplement.setBaseEstaSummFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ + if(checkFieldNotPdf(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); saveCimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ + if(checkFieldNotPdf(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseThirdAcceptFile()); saveCimplement.setBaseThirdAcceptFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ + if(checkFieldNotPdf(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseUserConsFile()); saveCimplement.setBaseUserConsFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ + if(checkFieldNotPdf(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseFinanlAuditFile()); saveCimplement.setBaseFinanlAuditFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ + if(checkFieldNotPdf(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseInitialOpinionFile()); saveCimplement.setBaseInitialOpinionFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ + if(checkFieldNotPdf(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ StringJoiner sj = convertAndUpload(cimplement.getBasePasswAssessFile()); saveCimplement.setBasePasswAssessFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ + if(checkFieldNotPdf(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseSummReportFile()); saveCimplement.setBaseSummReportFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ + if(checkFieldNotPdf(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseIrsTestRunFile()); saveCimplement.setBaseIrsTestRunFilePdf(sj.toString()); } @@ -923,43 +923,43 @@ public class GovProjectCollectionManage { } private void uploadFileToProvincialOssMimplement(GovBizProjectMimplementDTO mimplement, GovBizProjectMimplement oldMimplement, GovBizProjectMimplement saveMimplement) { - if(checkFieldHas(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ + if(checkFieldNotPdf(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseChanFile()); saveMimplement.setBaseChanFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ + if(checkFieldNotPdf(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseInforLevelFile()); saveMimplement.setBaseInforLevelFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ + if(checkFieldNotPdf(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ StringJoiner sj = convertAndUpload(mimplement.getBasePasswAssessFile()); saveMimplement.setBasePasswAssessFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ + if(checkFieldNotPdf(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseThirdAcceptFile()); saveMimplement.setBaseThirdAcceptFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ + if(checkFieldNotPdf(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEstaSummFile()); saveMimplement.setBaseEstaSummFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ + if(checkFieldNotPdf(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseUserConsFile()); saveMimplement.setBaseUserConsFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ + if(checkFieldNotPdf(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); saveMimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ + if(checkFieldNotPdf(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); saveMimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerPostpoFile()); saveMimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEngineerAlterFile(),oldMimplement,"baseEngineerAlterFile")){ + if(checkFieldNotPdf(mimplement.getBaseEngineerAlterFile(),oldMimplement,"baseEngineerAlterFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerAlterFile()); saveMimplement.setBaseEngineerAlterFilePdf(sj.toString()); } @@ -973,22 +973,22 @@ public class GovProjectCollectionManage { * @param saveProcure */ private void uploadFileToProvincialOssProcure(GovBizProjectProcureDTO procure, Object o, GovBizProjectProcure saveProcure) { - if(checkFieldHas(procure.getPurchaseFile(),o,"purchaseFile")){ + if(checkFieldNotPdf(procure.getPurchaseFile(),o,"purchaseFile")){ StringJoiner sj = convertAndUpload(procure.getPurchaseFile()); saveProcure.setPurchaseFilePdf(sj.toString()); } - if(checkFieldHas(procure.getBiddingFile(),o,"biddingFile")){ + if(checkFieldNotPdf(procure.getBiddingFile(),o,"biddingFile")){ StringJoiner sj = convertAndUpload(procure.getBiddingFile()); saveProcure.setBiddingFilePdf(sj.toString()); } - if(checkFieldHas(procure.getPurchaseContract(),o,"purchaseContract")){ + if(checkFieldNotPdf(procure.getPurchaseContract(),o,"purchaseContract")){ StringJoiner sj = convertAndUpload(procure.getPurchaseContract()); saveProcure.setPurchaseContractPdf(sj.toString()); } procureService.updateById(saveProcure); } - private StringJoiner convertAndUpload(String baseProjBasisFile) { + public StringJoiner convertAndUpload(String baseProjBasisFile) { String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); StringJoiner sj = new StringJoiner(";"); for(String bpb : baseProjBasisFileArr){ @@ -1009,7 +1009,7 @@ public class GovProjectCollectionManage { return sj; } - private Boolean checkFieldHas(String field, Object record, String fieldName){ + private Boolean checkFieldNotPdf(String field, Object record, String fieldName){ if(StringUtils.isBlank(field)){ return Boolean.FALSE; } 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 4c672ad..4af974e 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 @@ -1,20 +1,29 @@ package com.ningdatech.pmapi.scheduler.task; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.StopWatch; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.gov.manage.GovProjectCollectionManage; +import com.ningdatech.pmapi.gov.model.entity.*; import com.ningdatech.pmapi.gov.model.vo.GovBizProjectDetailVO; import com.ningdatech.pmapi.gov.model.vo.GovBizProjectListVO; +import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; /** * @author ZPF @@ -34,6 +43,20 @@ public class SynProjectCollectionTask { @Autowired private GovProjectCollectionManage collectionManage; + @Autowired + private IGovBizProjectApplyService applyService; + @Autowired + private IGovBizProjectApproveService approveService; + + @Autowired + private IGovBizProjectCimplementService cimplementService; + + @Autowired + private IGovBizProjectMimplementService mimplementService; + + @Autowired + private IGovBizProjectProcureService procureService; + private final Integer PAGE_NUMBER = 1; /** @@ -78,4 +101,230 @@ public class SynProjectCollectionTask { stopWatch.stop(); log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds()); } + + /** + * 把库存的项目归集里 没有转换PDF文件的 都转换一遍 存入数据库 + */ + public void stagingConvertPdf() { + log.info("项目归集库存转换PDF任务开始====="); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + ProjectListReq req = new ProjectListReq(); + req.setPageNumber(1); + req.setPageSize(BizConst.MAX_EXPORT_COUNT); + PageVo pageRes = collectionManage.list(req); + + if(CollUtil.isEmpty(pageRes.getRecords())){ + log.info("没有项目归集 任务终止"); + return; + } + + Collection records = pageRes.getRecords(); + for(GovBizProjectListVO project : records){ + //开始转换PDF + convertPdfVo(project.getBaseProjId()); + } + + stopWatch.stop(); + log.info("项目归集库存转换PDF任务结束====={}s",stopWatch.getTotalTimeSeconds()); + } + + //开始转换PDF + private void convertPdfVo(String baseProjId) { + convertPdfApply(baseProjId); + convertPdfApprove(baseProjId); + convertPdfCimplement(baseProjId); + convertPdfMimplement(baseProjId); + convertPdfAProcure(baseProjId); + } + + private void convertPdfApply(String baseProjId) { + GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(apply)){ + return; + } + if(StringUtils.isBlank(apply.getBaseProjApplyFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjApplyFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjApplyFile()); + apply.setBaseProjApplyFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseProjBasisFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjBasisFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjBasisFile()); + apply.setBaseProjBasisFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseProjOtherFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjOtherFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjOtherFile()); + apply.setBaseProjOtherFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseResearchReportFilePdf()) && StringUtils.isNotBlank(apply.getBaseResearchReportFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseResearchReportFile()); + apply.setBaseResearchReportFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseOperatMaintenFilePdf()) && StringUtils.isNotBlank(apply.getBaseOperatMaintenFilePdf())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseOperatMaintenFile()); + apply.setBaseOperatMaintenFilePdf(sj.toString()); + } + applyService.updateById(apply); + } + + private void convertPdfApprove(String baseProjId) { + GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(approve)){ + return; + } + if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile()); + approve.setApprovalFile(sj.toString()); + } + if(StringUtils.isBlank(approve.getPreliminaryDesignFilePdf()) && StringUtils.isNotBlank(approve.getPreliminaryDesignFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getPreliminaryDesignFile()); + approve.setPreliminaryDesignFilePdf(sj.toString()); + } + if(StringUtils.isBlank(approve.getBaseReviewCommentsFilePdf()) && StringUtils.isNotBlank(approve.getBaseReviewCommentsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getBaseReviewCommentsFile()); + approve.setBaseReviewCommentsFilePdf(sj.toString()); + } + approveService.updateById(approve); + } + + private void convertPdfCimplement(String baseProjId) { + GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(cimplement)){ + return; + } + if(StringUtils.isBlank(cimplement.getBaseCheckFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseCheckFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseCheckFile()); + cimplement.setBaseCheckFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChanFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChanFile()); + cimplement.setBaseChanFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseChangeFormFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChangeFormFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChangeFormFile()); + cimplement.setBaseChangeFormFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseUserConsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseUserConsFile()); + cimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEstaSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEstaSummFile()); + cimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEngineerPostpoFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEngineerPostpoFile()); + cimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(cimplement.getBasePasswAssessFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBasePasswAssessFile()); + cimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile()); + cimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseFinanlAuditFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinanlAuditFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinanlAuditFile()); + cimplement.setBaseFinanlAuditFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseInitialOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseInitialOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseInitialOpinionFile()); + cimplement.setBaseInitialOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile()); + cimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseSummReportFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseSummReportFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseSummReportFile()); + cimplement.setBaseSummReportFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinalExpertOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); + cimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseIrsTestRunFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseIrsTestRunFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseIrsTestRunFile()); + cimplement.setBaseIrsTestRunFilePdf(sj.toString()); + } + cimplementService.updateById(cimplement); + } + + private void convertPdfMimplement(String baseProjId) { + GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(mimplement)){ + return; + } + if(StringUtils.isBlank(mimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseChanFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseChanFile()); + mimplement.setBaseChanFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseUserConsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseUserConsFile()); + mimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEstaSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEstaSummFile()); + mimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerPostpoFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerPostpoFile()); + mimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(mimplement.getBasePasswAssessFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBasePasswAssessFile()); + mimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile()); + mimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile()); + mimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseFinalExpertOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); + mimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEngineerAlterFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerAlterFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerAlterFile()); + mimplement.setBaseEngineerAlterFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseOperatMaintenSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseOperatMaintenSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); + mimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); + } + mimplementService.updateById(mimplement); + } + + private void convertPdfAProcure(String baseProjId) { + List procures = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjId, baseProjId)); + for(GovBizProjectProcure procure : procures){ + if(StringUtils.isBlank(procure.getPurchaseContractPdf()) && StringUtils.isNotBlank(procure.getPurchaseContract())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseContract()); + procure.setPurchaseContractPdf(sj.toString()); + } + if(StringUtils.isBlank(procure.getPurchaseFilePdf()) && StringUtils.isNotBlank(procure.getPurchaseFile())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseContract()); + procure.setPurchaseContractPdf(sj.toString()); + } + if(StringUtils.isBlank(procure.getBiddingFilePdf()) && StringUtils.isNotBlank(procure.getBiddingFile())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getBiddingFile()); + procure.setBiddingFilePdf(sj.toString()); + } + procureService.updateById(procure); + } + } + + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java index 2c399db..c5de710 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java @@ -8,6 +8,7 @@ import com.aliyun.oss.model.ObjectMetadata; import com.ningdatech.file.properties.FileServerProperties; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.gov.contants.BizProjectContant; import com.ningdatech.pmapi.wps.contants.WpsContant; import com.suwell.ofd.custom.agent.AtomAgent; import lombok.RequiredArgsConstructor; @@ -91,7 +92,9 @@ public class WpsConvertManage { byte[] bytes = new byte[4096]; int read; //测试环境 转不了PDF 请求不了 WPS转换服务器 - if(BizConst.DEV.equals(active)){ + // 或者 已经是PDF文件 也不用转PDF + if(BizConst.DEV.equals(active) || + file.getOriginalFileName().endsWith(BizProjectContant.ProjectCollection.PDF_SUFFIX)){ ObjectMetadata metadata = ossObject.getObjectMetadata(); response.setContentType(metadata.getContentType()); fileName = URLEncoder.encode(file.getOriginalFileName(), CharsetUtil.UTF_8); @@ -125,6 +128,8 @@ public class WpsConvertManage { //用完就删 f.deleteOnExit(); } + }else{ + log.info("都不满足条件 并且 没有转换文件!"); } outputStream.flush(); }catch (Exception e){