|
@@ -34,15 +34,21 @@ import com.ningdatech.pmapi.wps.manage.WpsConvertManage; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.http.HttpEntity; |
|
|
import org.springframework.http.HttpEntity; |
|
|
import org.springframework.http.HttpHeaders; |
|
|
import org.springframework.http.HttpHeaders; |
|
|
import org.springframework.http.MediaType; |
|
|
import org.springframework.http.MediaType; |
|
|
import org.springframework.http.ResponseEntity; |
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.client.RestTemplate; |
|
|
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.lang.reflect.Field; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
@@ -80,6 +86,8 @@ public class GovProjectCollectionManage { |
|
|
|
|
|
|
|
|
private final WpsConvertManage wpsConvertManage; |
|
|
private final WpsConvertManage wpsConvertManage; |
|
|
|
|
|
|
|
|
|
|
|
private final ThreadPoolTaskExecutor threadPoolTaskExecutor; |
|
|
|
|
|
|
|
|
@Value("${project.push-url}") |
|
|
@Value("${project.push-url}") |
|
|
private String pushUrl; |
|
|
private String pushUrl; |
|
|
|
|
|
|
|
@@ -89,6 +97,9 @@ public class GovProjectCollectionManage { |
|
|
@Value("${project.delete-all-url}") |
|
|
@Value("${project.delete-all-url}") |
|
|
private String deleteAllUrl; |
|
|
private String deleteAllUrl; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${spring.profiles.active}") |
|
|
|
|
|
private String active; |
|
|
|
|
|
|
|
|
public List<GovProjectDictionaryVO> dictionary(String type) { |
|
|
public List<GovProjectDictionaryVO> dictionary(String type) { |
|
|
|
|
|
|
|
|
List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) |
|
|
List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) |
|
@@ -430,7 +441,7 @@ public class GovProjectCollectionManage { |
|
|
saveApply.setUpdateBy(user.getUsername()); |
|
|
saveApply.setUpdateBy(user.getUsername()); |
|
|
saveApply.setUpdateOn(LocalDateTime.now()); |
|
|
saveApply.setUpdateOn(LocalDateTime.now()); |
|
|
if(projectApplyService.saveOrUpdate(saveApply)){ |
|
|
if(projectApplyService.saveOrUpdate(saveApply)){ |
|
|
uploadFileToProvincialOss(apply,oldApply,saveApply); |
|
|
|
|
|
|
|
|
threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApply(apply,oldApply,saveApply)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -454,7 +465,9 @@ public class GovProjectCollectionManage { |
|
|
saveApprove.setAreaCode(RegionConst.RC_LS); |
|
|
saveApprove.setAreaCode(RegionConst.RC_LS); |
|
|
saveApprove.setUpdateBy(user.getUsername()); |
|
|
saveApprove.setUpdateBy(user.getUsername()); |
|
|
saveApprove.setUpdateOn(LocalDateTime.now()); |
|
|
saveApprove.setUpdateOn(LocalDateTime.now()); |
|
|
approveService.saveOrUpdate(saveApprove); |
|
|
|
|
|
|
|
|
if(approveService.saveOrUpdate(saveApprove)){ |
|
|
|
|
|
threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssApprove(approve,oldApprove,saveApprove)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 4.保存 建设项目 实施信息 |
|
|
// 4.保存 建设项目 实施信息 |
|
@@ -478,7 +491,9 @@ public class GovProjectCollectionManage { |
|
|
saveCimplement.setBizTime(LocalDateTime.now()); |
|
|
saveCimplement.setBizTime(LocalDateTime.now()); |
|
|
saveCimplement.setUpdateBy(user.getUsername()); |
|
|
saveCimplement.setUpdateBy(user.getUsername()); |
|
|
saveCimplement.setUpdateOn(LocalDateTime.now()); |
|
|
saveCimplement.setUpdateOn(LocalDateTime.now()); |
|
|
cimplementService.saveOrUpdate(saveCimplement); |
|
|
|
|
|
|
|
|
if(cimplementService.saveOrUpdate(saveCimplement)){ |
|
|
|
|
|
threadPoolTaskExecutor.execute(() -> uploadFileToProvincialOssCimplement(cimplement,oldCimplement,saveCimplement)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 5.保存 运维项目 实施信息 |
|
|
// 5.保存 运维项目 实施信息 |
|
@@ -793,45 +808,93 @@ public class GovProjectCollectionManage { |
|
|
* @param apply |
|
|
* @param apply |
|
|
* @param oldApply |
|
|
* @param oldApply |
|
|
*/ |
|
|
*/ |
|
|
private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, |
|
|
|
|
|
|
|
|
private void uploadFileToProvincialOssApply(GovBizProjectApplyDTO apply, |
|
|
GovBizProjectApply oldApply,GovBizProjectApply saveApply) { |
|
|
GovBizProjectApply oldApply,GovBizProjectApply saveApply) { |
|
|
if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ |
|
|
if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ |
|
|
String[] baseProjBasisFileArr = apply.getBaseProjBasisFile().split(";"); |
|
|
|
|
|
StringJoiner sj = new StringJoiner(";"); |
|
|
|
|
|
for(String baseProjBasisFile : baseProjBasisFileArr){ |
|
|
|
|
|
JSONArray fileArray = JSON.parseArray(baseProjBasisFile); |
|
|
|
|
|
fileArray.forEach(j -> { |
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); |
|
|
|
|
|
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); |
|
|
|
|
|
String suffix = jsonObject.getString("suffix"); |
|
|
|
|
|
String originalFileName = jsonObject.getString("originalFileName"); |
|
|
|
|
|
String pdfName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); |
|
|
|
|
|
String oss = ProvincialManage.uploadToOss(btyes, pdfName); |
|
|
|
|
|
sj.add(oss); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
StringJoiner sj = convertAndUpload(apply.getBaseProjBasisFile()); |
|
|
saveApply.setBaseProjBasisFilePdf(sj.toString()); |
|
|
saveApply.setBaseProjBasisFilePdf(sj.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
if(checkFieldHas(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(apply.getBaseProjApplyFile()); |
|
|
|
|
|
saveApply.setBaseProjApplyFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkFieldHas(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(apply.getBaseOperatMaintenFile()); |
|
|
|
|
|
saveApply.setBaseOperatMaintenFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkFieldHas(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(apply.getBaseResearchReportFile()); |
|
|
|
|
|
saveApply.setBaseResearchReportFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkFieldHas(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(apply.getBaseProjOtherFile()); |
|
|
|
|
|
saveApply.setBaseProjOtherFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
projectApplyService.updateById(saveApply); |
|
|
projectApplyService.updateById(saveApply); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Boolean checkFieldHas(String field,GovBizProjectApply oldApply,String fieldName){ |
|
|
|
|
|
|
|
|
private void uploadFileToProvincialOssApprove(GovBizProjectApproveDTO approve, GovBizProjectApprove oldApprove, GovBizProjectApprove saveApprove) { |
|
|
|
|
|
if(checkFieldHas(approve.getApprovalFile(),oldApprove,"approvalFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(approve.getApprovalFile()); |
|
|
|
|
|
saveApprove.setApprovalFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkFieldHas(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(approve.getBaseReviewCommentsFile()); |
|
|
|
|
|
saveApprove.setBaseReviewCommentsFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkFieldHas(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(approve.getPreliminaryDesignFile()); |
|
|
|
|
|
saveApprove.setPreliminaryDesignFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
approveService.updateById(saveApprove); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { |
|
|
|
|
|
if(checkFieldHas(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ |
|
|
|
|
|
StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); |
|
|
|
|
|
saveCimplement.setBaseChanFilePdf(sj.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
cimplementService.updateById(saveCimplement); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private StringJoiner convertAndUpload(String baseProjBasisFile) { |
|
|
|
|
|
String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); |
|
|
|
|
|
StringJoiner sj = new StringJoiner(";"); |
|
|
|
|
|
for(String bpb : baseProjBasisFileArr){ |
|
|
|
|
|
JSONArray fileArray = JSON.parseArray(bpb); |
|
|
|
|
|
fileArray.forEach(j -> { |
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); |
|
|
|
|
|
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); |
|
|
|
|
|
String suffix = jsonObject.getString("suffix"); |
|
|
|
|
|
String originalFileName = jsonObject.getString("originalFileName"); |
|
|
|
|
|
if(!BizConst.DEV.equals(active)){ |
|
|
|
|
|
originalFileName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); |
|
|
|
|
|
} |
|
|
|
|
|
// upload(btyes,"/temp",originalFileName); |
|
|
|
|
|
String oss = ProvincialManage.uploadToOss(btyes, originalFileName); |
|
|
|
|
|
sj.add(oss); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
return sj; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Boolean checkFieldHas(String field, Object record, String fieldName){ |
|
|
if(StringUtils.isBlank(field)){ |
|
|
if(StringUtils.isBlank(field)){ |
|
|
return Boolean.FALSE; |
|
|
return Boolean.FALSE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//如果没有老值 |
|
|
//如果没有老值 |
|
|
if(Objects.isNull(oldApply)){ |
|
|
|
|
|
|
|
|
if(Objects.isNull(record)){ |
|
|
return Boolean.TRUE; |
|
|
return Boolean.TRUE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//和老值做个对比 不一样则true |
|
|
//和老值做个对比 不一样则true |
|
|
Class<?> clazz = oldApply.getClass(); |
|
|
|
|
|
|
|
|
Class<?> clazz = record.getClass(); |
|
|
String oldFiled = StringUtils.EMPTY; |
|
|
String oldFiled = StringUtils.EMPTY; |
|
|
try { |
|
|
try { |
|
|
Field fieldDeclared = clazz.getDeclaredField(fieldName); |
|
|
Field fieldDeclared = clazz.getDeclaredField(fieldName); |
|
|
fieldDeclared.setAccessible(Boolean.TRUE); |
|
|
fieldDeclared.setAccessible(Boolean.TRUE); |
|
|
oldFiled = Objects.nonNull(fieldDeclared.get(oldApply)) ? String.valueOf(fieldDeclared.get(oldApply)) : null; |
|
|
|
|
|
|
|
|
oldFiled = Objects.nonNull(fieldDeclared.get(record)) ? String.valueOf(fieldDeclared.get(record)) : null; |
|
|
} catch (NoSuchFieldException e) { |
|
|
} catch (NoSuchFieldException e) { |
|
|
log.error("转换PDF文件出错" + e); |
|
|
log.error("转换PDF文件出错" + e); |
|
|
} catch (IllegalAccessException e) { |
|
|
} catch (IllegalAccessException e) { |
|
@@ -844,4 +907,24 @@ public class GovProjectCollectionManage { |
|
|
|
|
|
|
|
|
return Boolean.FALSE; |
|
|
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(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |