@@ -375,7 +375,6 @@ | |||
<scope>system</scope> | |||
<systemPath>${project.basedir}/lib/dom4j-2.0.2.jar</systemPath> | |||
</dependency> | |||
</dependencies> | |||
<!-- 打包 --> | |||
<!--配置环境的profile--> | |||
@@ -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; | |||
/** | |||
@@ -24,11 +24,13 @@ 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_NAME = "开发区"; | |||
/** | |||
* 中国行政区划编码 | |||
@@ -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 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 | |||
* <code> | |||
* 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) | |||
* </code> | |||
* <p> | |||
* ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available() | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public long contentLength() { | |||
int estimate = length; | |||
return estimate == 0 ? 1 : estimate; | |||
} | |||
} |
@@ -19,6 +19,11 @@ 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"; | |||
public static final String PDF_SUFFIX = ".pdf"; | |||
} | |||
} |
@@ -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,10 +72,43 @@ public class GovProjectCollectionController { | |||
return collectionManage.remove(projId); | |||
} | |||
@GetMapping("/draft-list") | |||
@ApiOperation("项目归集草稿箱列表") | |||
public PageVo<GovBizProjectListVO> 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("主动调用定时器方法") | |||
public void pushTask() throws UnknownHostException { | |||
collectionTask.doTask(); | |||
} | |||
@PostMapping("/staging-convert-pdf") | |||
@ApiOperation("把库存的项目归集的文件 都转换成PDF文件存入字段") | |||
@WebLog("主动转换库存的文件都为PDF文件") | |||
public void stagingConvertPdf() { | |||
collectionTask.stagingConvertPdf(); | |||
} | |||
} |
@@ -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<ProjectProcureReq> convertProcures(List<GovBizProjectProcureDTO> procures) { | |||
if(CollUtil.isEmpty(procures)){ | |||
return Collections.emptyList(); | |||
@@ -81,6 +93,26 @@ public class ProjectConvert { | |||
return req; | |||
} | |||
private static List<ProjectProcureReq> convertProcuresVoWithConvertPdf(List<GovBizProjectProcureVO> procures) { | |||
if(CollUtil.isEmpty(procures)){ | |||
return Collections.emptyList(); | |||
} | |||
List<ProjectProcureReq> 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,34 @@ public class ProjectConvert { | |||
return req; | |||
} | |||
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() : | |||
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 +161,42 @@ public class ProjectConvert { | |||
return req; | |||
} | |||
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() : | |||
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 +247,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 +355,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); | |||
@@ -1,8 +1,11 @@ | |||
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.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; | |||
@@ -22,6 +25,13 @@ 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 io.swagger.annotations.ApiModelProperty; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -30,15 +40,17 @@ 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.ThreadPoolTaskScheduler; | |||
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.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -67,8 +79,14 @@ public class GovProjectCollectionManage { | |||
private final GenerateProjectCodeUtil generateProjectCodeUtil; | |||
private final IGovBizProjectDraftService draftService; | |||
private final RestTemplate restTemplate; | |||
private final WpsConvertManage wpsConvertManage; | |||
private final ThreadPoolTaskScheduler threadPoolTaskScheduler; | |||
@Value("${project.push-url}") | |||
private String pushUrl; | |||
@@ -78,6 +96,9 @@ public class GovProjectCollectionManage { | |||
@Value("${project.delete-all-url}") | |||
private String deleteAllUrl; | |||
@Value("${spring.profiles.active}") | |||
private String active; | |||
public List<GovProjectDictionaryVO> dictionary(String type) { | |||
List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) | |||
@@ -106,7 +127,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 +168,67 @@ public class GovProjectCollectionManage { | |||
return PageVo.of(res,page.getTotal()); | |||
} | |||
/** | |||
* 草稿箱列表 | |||
* @param req | |||
* @return | |||
*/ | |||
public PageVo<GovBizProjectListVO> draftList(ProjectListReq req) { | |||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||
Page<GovBizProjectDraft> page = req.page(); | |||
LambdaQueryWrapper<GovBizProjectDraft> 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<GovBizProjectListVO> 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 | |||
*/ | |||
private void permissions(LambdaQueryWrapper<GovBizProjectBaseinfo> wrapper) { | |||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||
List<Role> 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<GovBizProjectBaseinfo> wrapper = Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | |||
.like(StringUtils.isNotBlank(req.getProjectName()),GovBizProjectBaseinfo::getBaseProjName,req.getProjectName()) | |||
@@ -225,17 +309,86 @@ 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; | |||
} | |||
res.setDraftId(draftId); | |||
//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) { | |||
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); | |||
} | |||
@@ -258,12 +411,12 @@ public class GovProjectCollectionManage { | |||
saveBase.setId(oldBaseInfo.getId()); | |||
}else{ | |||
saveBase.setTongTime(LocalDateTime.now()); | |||
} | |||
if(Objects.nonNull(saveBase.getBaseAreaCode())){ | |||
saveBase.setBaseAreaCode(saveBase.getBaseAreaCode() + BizConst.NINE_AREA_CODE_LAST); | |||
saveBase.setBaseAreaCode(baseAreaCode); | |||
} | |||
saveBase.setAreaCode(RegionConst.RC_LS); | |||
saveBase.setBizTime(LocalDateTime.now()); | |||
saveBase.setUpdateBy(user.getUsername()); | |||
saveBase.setUpdateOn(LocalDateTime.now()); | |||
baseinfoService.saveOrUpdate(saveBase); | |||
// 2.保存 申报信息 | |||
@@ -284,7 +437,11 @@ public class GovProjectCollectionManage { | |||
} | |||
saveApply.setAreaCode(RegionConst.RC_LS); | |||
saveApply.setBizTime(LocalDateTime.now()); | |||
projectApplyService.saveOrUpdate(saveApply); | |||
saveApply.setUpdateBy(user.getUsername()); | |||
saveApply.setUpdateOn(LocalDateTime.now()); | |||
if(projectApplyService.saveOrUpdate(saveApply)){ | |||
threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); | |||
} | |||
} | |||
// 3.保存 审批信息 | |||
@@ -305,7 +462,11 @@ public class GovProjectCollectionManage { | |||
} | |||
saveApprove.setBizTime(LocalDateTime.now()); | |||
saveApprove.setAreaCode(RegionConst.RC_LS); | |||
approveService.saveOrUpdate(saveApprove); | |||
saveApprove.setUpdateBy(user.getUsername()); | |||
saveApprove.setUpdateOn(LocalDateTime.now()); | |||
if(approveService.saveOrUpdate(saveApprove)){ | |||
threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); | |||
} | |||
} | |||
// 4.保存 建设项目 实施信息 | |||
@@ -327,7 +488,11 @@ public class GovProjectCollectionManage { | |||
} | |||
saveCimplement.setAreaCode(RegionConst.RC_LS); | |||
saveCimplement.setBizTime(LocalDateTime.now()); | |||
cimplementService.saveOrUpdate(saveCimplement); | |||
saveCimplement.setUpdateBy(user.getUsername()); | |||
saveCimplement.setUpdateOn(LocalDateTime.now()); | |||
if(cimplementService.saveOrUpdate(saveCimplement)){ | |||
threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); | |||
} | |||
} | |||
// 5.保存 运维项目 实施信息 | |||
@@ -353,33 +518,153 @@ public class GovProjectCollectionManage { | |||
} | |||
saveMimplement.setAreaCode(RegionConst.RC_LS); | |||
saveMimplement.setBizTime(LocalDateTime.now()); | |||
mimplementService.saveOrUpdate(saveMimplement); | |||
saveMimplement.setUpdateBy(user.getUsername()); | |||
saveMimplement.setUpdateOn(LocalDateTime.now()); | |||
if(mimplementService.saveOrUpdate(saveMimplement)){ | |||
threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssMimplement(mimplement,oldMimplement,saveMimplement)); | |||
} | |||
} | |||
// 6.保存 采购信息 | |||
List<GovBizProjectProcureDTO> 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()); | |||
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. 推送数据(改为定时推送了) | |||
// pushProject(saveDTO); | |||
//如果是草稿箱来的 就要删除 | |||
if(Objects.nonNull(saveDTO.getDraftId())){ | |||
draftService.removeById(saveDTO.getDraftId()); | |||
} | |||
return BizConst.SAVE_SUCCESS; | |||
} | |||
/** | |||
* 暂存草稿箱 | |||
* @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; | |||
} | |||
// 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(); | |||
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(); | |||
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<GovBizProjectProcureDTO> procures = saveDTO.getProcures(); | |||
if(Objects.nonNull(procures)){ | |||
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; | |||
} | |||
@@ -390,30 +675,64 @@ public class GovProjectCollectionManage { | |||
* @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)); | |||
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); | |||
baseinfo.setUpdateBy(username); | |||
baseinfo.setUpdateOn(LocalDateTime.now()); | |||
baseinfoService.updateById(baseinfo); | |||
projectApplyService.update(Wrappers.lambdaUpdate(GovBizProjectApply.class) | |||
.eq(GovBizProjectApply::getBaseProjId,projId) | |||
.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::getUpdateOn,LocalDateTime.now()) | |||
.set(GovBizProjectApprove::getUpdateBy,username)); | |||
cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) | |||
.eq(GovBizProjectCimplement::getBaseProjId,projId) | |||
.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::getUpdateOn,LocalDateTime.now()) | |||
.set(GovBizProjectMimplement::getUpdateBy,username)); | |||
procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) | |||
.eq(GovBizProjectProcure::getBaseProjId,projId) | |||
.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) | |||
.eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) | |||
.ne(GovBizProjectBaseinfo::getBaseProjId,baseProjId)) > 0L) | |||
.throwMessage("项目名重复"); | |||
} | |||
@@ -431,7 +750,7 @@ public class GovProjectCollectionManage { | |||
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); | |||
headers.setContentType(type); | |||
headers.add("Accept", MediaType.APPLICATION_JSON.toString()); | |||
HttpEntity<ProjectPushReq> formEntity = new HttpEntity<ProjectPushReq>(req, headers); | |||
HttpEntity<ProjectPushReq> formEntity = new HttpEntity(req, headers); | |||
ResponseEntity<String> response = restTemplate.postForEntity(url, formEntity, String.class); | |||
log.info("推送结果 {} :{}",saveDTO.getBaseProjId(),response); | |||
}catch (Exception e){ | |||
@@ -440,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(); | |||
@@ -478,17 +797,265 @@ 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<String> formEntity = new HttpEntity<String>(null, headers); | |||
ResponseEntity<String> 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()); | |||
} | |||
} | |||
/** | |||
* 上传项目归集申报的文件到OSS 前提还要先转为PDF | |||
* @param apply | |||
* @param oldApply | |||
*/ | |||
private void uploadFileToProvincialOssApply(GovBizProjectApplyDTO apply, | |||
GovBizProjectApply oldApply,GovBizProjectApply saveApply) { | |||
if(checkFieldNotPdf(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ | |||
StringJoiner sj = convertAndUpload(apply.getBaseProjBasisFile()); | |||
saveApply.setBaseProjBasisFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ | |||
StringJoiner sj = convertAndUpload(apply.getBaseProjApplyFile()); | |||
saveApply.setBaseProjApplyFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ | |||
StringJoiner sj = convertAndUpload(apply.getBaseOperatMaintenFile()); | |||
saveApply.setBaseOperatMaintenFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ | |||
StringJoiner sj = convertAndUpload(apply.getBaseResearchReportFile()); | |||
saveApply.setBaseResearchReportFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ | |||
StringJoiner sj = convertAndUpload(apply.getBaseProjOtherFile()); | |||
saveApply.setBaseProjOtherFilePdf(sj.toString()); | |||
} | |||
projectApplyService.updateById(saveApply); | |||
} | |||
private void uploadFileToProvincialOssApprove(GovBizProjectApproveDTO approve, GovBizProjectApprove oldApprove, GovBizProjectApprove saveApprove) { | |||
if(checkFieldNotPdf(approve.getApprovalFile(),oldApprove,"approvalFile")){ | |||
StringJoiner sj = convertAndUpload(approve.getApprovalFile()); | |||
saveApprove.setApprovalFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ | |||
StringJoiner sj = convertAndUpload(approve.getBaseReviewCommentsFile()); | |||
saveApprove.setBaseReviewCommentsFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(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(checkFieldNotPdf(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); | |||
saveCimplement.setBaseChanFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseCheckFile()); | |||
saveCimplement.setBaseCheckFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseInforLevelFile()); | |||
saveCimplement.setBaseInforLevelFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseChangeFormFile()); | |||
saveCimplement.setBaseChangeFormFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseEstaSummFile()); | |||
saveCimplement.setBaseEstaSummFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); | |||
saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); | |||
saveCimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseThirdAcceptFile()); | |||
saveCimplement.setBaseThirdAcceptFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseUserConsFile()); | |||
saveCimplement.setBaseUserConsFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseFinanlAuditFile()); | |||
saveCimplement.setBaseFinanlAuditFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); | |||
saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseInitialOpinionFile()); | |||
saveCimplement.setBaseInitialOpinionFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBasePasswAssessFile()); | |||
saveCimplement.setBasePasswAssessFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseSummReportFile()); | |||
saveCimplement.setBaseSummReportFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ | |||
StringJoiner sj = convertAndUpload(cimplement.getBaseIrsTestRunFile()); | |||
saveCimplement.setBaseIrsTestRunFilePdf(sj.toString()); | |||
} | |||
cimplementService.updateById(saveCimplement); | |||
} | |||
private void uploadFileToProvincialOssMimplement(GovBizProjectMimplementDTO mimplement, GovBizProjectMimplement oldMimplement, GovBizProjectMimplement saveMimplement) { | |||
if(checkFieldNotPdf(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseChanFile()); | |||
saveMimplement.setBaseChanFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseInforLevelFile()); | |||
saveMimplement.setBaseInforLevelFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBasePasswAssessFile()); | |||
saveMimplement.setBasePasswAssessFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseThirdAcceptFile()); | |||
saveMimplement.setBaseThirdAcceptFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseEstaSummFile()); | |||
saveMimplement.setBaseEstaSummFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseUserConsFile()); | |||
saveMimplement.setBaseUserConsFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); | |||
saveMimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); | |||
saveMimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ | |||
StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerPostpoFile()); | |||
saveMimplement.setBaseEngineerPostpoFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(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(checkFieldNotPdf(procure.getPurchaseFile(),o,"purchaseFile")){ | |||
StringJoiner sj = convertAndUpload(procure.getPurchaseFile()); | |||
saveProcure.setPurchaseFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(procure.getBiddingFile(),o,"biddingFile")){ | |||
StringJoiner sj = convertAndUpload(procure.getBiddingFile()); | |||
saveProcure.setBiddingFilePdf(sj.toString()); | |||
} | |||
if(checkFieldNotPdf(procure.getPurchaseContract(),o,"purchaseContract")){ | |||
StringJoiner sj = convertAndUpload(procure.getPurchaseContract()); | |||
saveProcure.setPurchaseContractPdf(sj.toString()); | |||
} | |||
procureService.updateById(saveProcure); | |||
} | |||
public 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 checkFieldNotPdf(String field, Object record, String fieldName){ | |||
if(StringUtils.isBlank(field)){ | |||
return Boolean.FALSE; | |||
} | |||
//如果没有老值 | |||
if(Objects.isNull(record)){ | |||
return Boolean.TRUE; | |||
} | |||
//和老值做个对比 不一样则true | |||
Class<?> clazz = record.getClass(); | |||
String oldFiled = StringUtils.EMPTY; | |||
try { | |||
Field fieldDeclared = clazz.getDeclaredField(fieldName); | |||
fieldDeclared.setAccessible(Boolean.TRUE); | |||
oldFiled = Objects.nonNull(fieldDeclared.get(record)) ? String.valueOf(fieldDeclared.get(record)) : 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; | |||
} | |||
/** | |||
* @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(); | |||
} | |||
} | |||
} |
@@ -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; | |||
/** | |||
* <p> | |||
* Mapper 接口 | |||
* </p> | |||
* | |||
* @author zpf | |||
* @since 2023-08-23 | |||
*/ | |||
public interface GovBizProjectDraftMapper extends BaseMapper<GovBizProjectDraft> { | |||
} |
@@ -28,6 +28,9 @@ public class GovBizProjectSaveDTO implements Serializable { | |||
@ApiModelProperty("基本项目名称") | |||
private String baseProjName; | |||
@ApiModelProperty("草稿id") | |||
private Long draftId; | |||
@ApiModelProperty("项目基本信息") | |||
private GovBizProjectBaseinfoDTO baseinfo; | |||
@@ -140,4 +140,29 @@ public class GovBizProjectApply implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -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("立项批复文件") | |||
@@ -90,4 +90,22 @@ public class GovBizProjectApprove implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
@ApiModelProperty("立项批复文件") | |||
private String approvalFilePdf; | |||
@ApiModelProperty("评审意见附件PDF") | |||
private String baseReviewCommentsFilePdf; | |||
@ApiModelProperty("初步设计方案批复函PDF") | |||
private String preliminaryDesignFilePdf; | |||
} |
@@ -107,4 +107,13 @@ public class GovBizProjectBaseinfo implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
} |
@@ -106,4 +106,55 @@ public class GovBizProjectCimplement implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -0,0 +1,142 @@ | |||
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; | |||
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; | |||
@ApiModelProperty("主键") | |||
@TableId(type = IdType.AUTO) | |||
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; | |||
@ApiModelProperty("是否省级 1省级 2非省级") | |||
private Integer baseProvManDeprtType; | |||
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 baseBidName; | |||
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 LocalDateTime updateOn; | |||
private String updateBy; | |||
private Long createId; | |||
} |
@@ -94,4 +94,43 @@ public class GovBizProjectMimplement implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -95,4 +95,22 @@ public class GovBizProjectProcure implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
@ApiModelProperty("招标(采购)文件PDF") | |||
private String purchaseFilePdf; | |||
@ApiModelProperty("采购合同PDF") | |||
private String purchaseContractPdf; | |||
@ApiModelProperty("中标(成交)通知书PDF") | |||
private String biddingFilePdf; | |||
} |
@@ -135,4 +135,28 @@ public class GovBizProjectApplyVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -85,4 +85,22 @@ public class GovBizProjectApproveVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
@ApiModelProperty("立项批复文件") | |||
private String approvalFilePdf; | |||
@ApiModelProperty("评审意见附件PDF") | |||
private String baseReviewCommentsFilePdf; | |||
@ApiModelProperty("初步设计方案批复函PDF") | |||
private String preliminaryDesignFilePdf; | |||
} |
@@ -101,4 +101,13 @@ public class GovBizProjectBaseinfoVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
} |
@@ -101,4 +101,55 @@ public class GovBizProjectCimplementVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -26,6 +26,9 @@ public class GovBizProjectDetailVO implements Serializable { | |||
@ApiModelProperty("基本项目名称") | |||
private String baseProjName; | |||
@ApiModelProperty("草稿id") | |||
private Long draftId; | |||
@ApiModelProperty("项目基本信息") | |||
private GovBizProjectBaseinfoVO baseinfo; | |||
@@ -47,4 +47,7 @@ public class GovBizProjectListVO implements Serializable { | |||
@ApiModelProperty("申报年度预算") | |||
private BigDecimal baseProjDeclAmount; | |||
@ApiModelProperty("草稿编号") | |||
private Long draftId; | |||
} |
@@ -89,4 +89,43 @@ public class GovBizProjectMimplementVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@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; | |||
} |
@@ -90,4 +90,22 @@ public class GovBizProjectProcureVO implements Serializable { | |||
@ApiModelProperty("入库时间") | |||
private LocalDateTime tongTime; | |||
@ApiModelProperty("逻辑删除") | |||
private Boolean deleted; | |||
@ApiModelProperty("最后修改时间") | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("最后修改人") | |||
private String updateBy; | |||
@ApiModelProperty("招标(采购)文件PDF") | |||
private String purchaseFilePdf; | |||
@ApiModelProperty("采购合同PDF") | |||
private String purchaseContractPdf; | |||
@ApiModelProperty("中标(成交)通知书PDF") | |||
private String biddingFilePdf; | |||
} |
@@ -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; | |||
/** | |||
* <p> | |||
* 服务类 | |||
* </p> | |||
* | |||
* @author zpf | |||
* @since 2023-08-23 | |||
*/ | |||
public interface IGovBizProjectDraftService extends IService<GovBizProjectDraft> { | |||
} |
@@ -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; | |||
/** | |||
* <p> | |||
* 服务实现类 | |||
* </p> | |||
* | |||
* @author zpf | |||
* @since 2023-08-23 | |||
*/ | |||
@Service | |||
public class GovBizProjectDraftServiceImpl extends | |||
ServiceImpl<GovBizProjectDraftMapper, GovBizProjectDraft> implements IGovBizProjectDraftService { | |||
} |
@@ -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()); | |||
@@ -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"; | |||
} | |||
} |
@@ -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<String, Object> 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<MultiValueMap> formEntity = new HttpEntity(params, headers); | |||
ResponseEntity<OssApiResponse> 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(); | |||
} | |||
} |
@@ -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; | |||
/** | |||
* <p> | |||
* OssApiResponse - | |||
* </p> | |||
* | |||
* @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; | |||
} |
@@ -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; | |||
/** | |||
* <p> | |||
* OssApiResponse - | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 14:29 2022/9/29 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
public class OssApiResponse<T> 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 <T> OssApiResponse<T> of(Integer respCode, String respMsg, T data) { | |||
return new OssApiResponse<T>(respCode, respMsg, data); | |||
} | |||
/** | |||
* 构造一个成功且不带数据的API返回 | |||
* | |||
* @return ApiResponse | |||
*/ | |||
public static <T> OssApiResponse<T> ofSuccess() { | |||
return ofSuccess(null); | |||
} | |||
/** | |||
* 构造一个成功且带数据的API返回 | |||
* | |||
* @param data 返回数据 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> OssApiResponse<T> ofSuccess(T data) { | |||
return ofStatus(Status.OK, data); | |||
} | |||
/** | |||
* 构造一个成功且自定义消息的API返回 | |||
* | |||
* @param msg 返回内容 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> OssApiResponse<T> ofMessage(String msg) { | |||
return of(Status.OK.getCode(), msg, null); | |||
} | |||
/** | |||
* 构造一个有状态的API返回 | |||
* | |||
* @param status 状态 {@link Status} | |||
* @return ApiResponse | |||
*/ | |||
public static <T> OssApiResponse<T> ofStatus(ApiStatus status) { | |||
return ofStatus(status, null); | |||
} | |||
/** | |||
* 构造一个有状态且带数据的API返回 | |||
* | |||
* @param status 状态 {@link Status} | |||
* @param data 返回数据 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> OssApiResponse<T> ofStatus(ApiStatus status, T data) { | |||
return of(status.getCode(), status.getReasonPhrase(), data); | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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<GovBizProjectListVO> pageRes = collectionManage.list(req); | |||
if(CollUtil.isEmpty(pageRes.getRecords())){ | |||
log.info("没有项目归集 任务终止"); | |||
return; | |||
} | |||
Collection<GovBizProjectListVO> 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<GovBizProjectProcure> 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); | |||
} | |||
} | |||
} |
@@ -8,20 +8,18 @@ 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; | |||
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 +42,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<File> fileList =new ArrayList<File>(); | |||
@@ -58,25 +54,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()); | |||
@@ -96,6 +77,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); | |||
@@ -106,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); | |||
@@ -140,6 +128,8 @@ public class WpsConvertManage { | |||
//用完就删 | |||
f.deleteOnExit(); | |||
} | |||
}else{ | |||
log.info("都不满足条件 并且 没有转换文件!"); | |||
} | |||
outputStream.flush(); | |||
}catch (Exception e){ | |||
@@ -154,6 +144,54 @@ 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();) { | |||
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<File> fileList =new ArrayList<File>(); | |||
//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); | |||
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); | |||
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -0,0 +1,77 @@ | |||
package com.ningdatech.pmapi.file; | |||
import com.ningdatech.pmapi.common.util.CommonInputStreamResource; | |||
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 java.io.File; | |||
import java.io.FileInputStream; | |||
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<String,Object> 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<MultiValueMap> formEntity = new HttpEntity(params, headers); | |||
ResponseEntity<String> res = restTemplate.postForEntity(url, formEntity, String.class); | |||
System.out.println(res.getBody()); | |||
} | |||
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; | |||
} | |||
} |
@@ -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)); | |||
} | |||
} |