@@ -84,6 +84,11 @@ public class DingInfoPullController { | |||||
organizationBatchGetTask.batchGetOrganizationTask(); | organizationBatchGetTask.batchGetOrganizationTask(); | ||||
} | } | ||||
@GetMapping("/organization/{orgCode}") | |||||
public void organizationGetSubs(@PathVariable String orgCode) { | |||||
organizationBatchGetTask.organizationGetSubs(orgCode); | |||||
} | |||||
@GetMapping("/employeeByRegionCode/{regionCode}") | @GetMapping("/employeeByRegionCode/{regionCode}") | ||||
public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { | public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { | ||||
employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); | employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); | ||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
import com.ningdatech.basic.model.GenericResult; | import com.ningdatech.basic.model.GenericResult; | ||||
import com.ningdatech.pmapi.common.constant.BizConst; | |||||
import com.ningdatech.pmapi.ding.model.DingOrgInfoTreeDTO; | import com.ningdatech.pmapi.ding.model.DingOrgInfoTreeDTO; | ||||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | ||||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | ||||
@@ -21,6 +22,7 @@ import org.springframework.scheduling.annotation.Scheduled; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import java.time.LocalDateTime; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Objects; | import java.util.Objects; | ||||
@@ -103,6 +105,50 @@ public class OrganizationBatchGetTask { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* 更新 其 子单位 | |||||
* @param orgCode | |||||
*/ | |||||
public void organizationGetSubs(String orgCode) { | |||||
log.info("----拉取浙政钉组织子单位开始---,顶级code:" + orgCode); | |||||
DingOrganization topOrg = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, orgCode) | |||||
.last(BizConst.LIMIT_1)); | |||||
// 顶级组织code | |||||
List<String> topOrgCodes = Lists.newArrayList(orgCode); | |||||
GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient.listOrganizationsByCodes(topOrgCodes); | |||||
log.info("listGenericResult: {}" + JSON.toJSONString(listGenericResult)); | |||||
List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData(); | |||||
for(DingOrgInfoDTO dingOrgInfo : dingOrgInfoDtos){ | |||||
DingOrganization old = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, dingOrgInfo.getOrganizationCode()) | |||||
.last(BizConst.LIMIT_1)); | |||||
if(Objects.nonNull(old)){ | |||||
log.info("该单位已经存在 :{}",old.getOrganizationName()); | |||||
continue; | |||||
} | |||||
DingOrganization organization = new DingOrganization(); | |||||
organization.setOrganizationCode(dingOrgInfo.getOrganizationCode()); | |||||
organization.setOrganizationName(dingOrgInfo.getOrganizationName()); | |||||
//和顶级单位一个区域 | |||||
organization.setDivisionCode(topOrg.getDivisionCode()); | |||||
organization.setParentCode(dingOrgInfo.getParentCode()); | |||||
organization.setTypeName(dingOrgInfo.getTypeName()); | |||||
organization.setAddress(dingOrgInfo.getAddress()); | |||||
organization.setBusinessStripCodes(dingOrgInfo.getBusinessStripCodes()); | |||||
organization.setDisplayOrder(dingOrgInfo.getDisplayOrder()); | |||||
organization.setGmtCreate(LocalDateTime.now()); | |||||
organization.setInstitutionLevelCode(dingOrgInfo.getInstitutionLevelCode()); | |||||
organization.setParentName(dingOrgInfo.getParentName()); | |||||
iDingOrganizationService.save(organization); | |||||
} | |||||
log.info("----拉取浙政钉组织子单位结束---,顶级code:" + orgCode); | |||||
} | |||||
private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) { | private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) { | ||||
if (CollectionUtils.isEmpty(treeDTOList)) { | if (CollectionUtils.isEmpty(treeDTOList)) { | ||||
return; | return; | ||||
@@ -167,7 +213,6 @@ public class OrganizationBatchGetTask { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -796,14 +796,20 @@ public class GovProjectCollectionManage { | |||||
private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, | private void uploadFileToProvincialOss(GovBizProjectApplyDTO apply, | ||||
GovBizProjectApply oldApply,GovBizProjectApply saveApply) { | GovBizProjectApply oldApply,GovBizProjectApply saveApply) { | ||||
if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ | if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ | ||||
JSONArray fileArray = JSON.parseArray(apply.getBaseProjBasisFile()); | |||||
String[] baseProjBasisFileArr = apply.getBaseProjBasisFile().split(";"); | |||||
StringJoiner sj = new StringJoiner(";"); | StringJoiner sj = new StringJoiner(";"); | ||||
fileArray.forEach(j -> { | |||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); | |||||
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); | |||||
String oss = ProvincialManage.uploadToOss(btyes, jsonObject.getString("originalFileName")); | |||||
sj.add(oss); | |||||
}); | |||||
for(String baseProjBasisFile : baseProjBasisFileArr){ | |||||
JSONArray fileArray = JSON.parseArray(baseProjBasisFile); | |||||
fileArray.forEach(j -> { | |||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); | |||||
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); | |||||
String suffix = jsonObject.getString("suffix"); | |||||
String originalFileName = jsonObject.getString("originalFileName"); | |||||
String pdfName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); | |||||
String oss = ProvincialManage.uploadToOss(btyes, pdfName); | |||||
sj.add(oss); | |||||
}); | |||||
} | |||||
saveApply.setBaseProjBasisFilePdf(sj.toString()); | saveApply.setBaseProjBasisFilePdf(sj.toString()); | ||||
} | } | ||||
projectApplyService.updateById(saveApply); | projectApplyService.updateById(saveApply); | ||||
@@ -13,15 +13,12 @@ import com.suwell.ofd.custom.agent.AtomAgent; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
import javax.servlet.ServletOutputStream; | import javax.servlet.ServletOutputStream; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.io.*; | import java.io.*; | ||||
import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
import java.nio.file.Path; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -44,13 +41,11 @@ public class WpsConvertManage { | |||||
@Value("${spring.profiles.active}") | @Value("${spring.profiles.active}") | ||||
private String active; | private String active; | ||||
// HTTPAgent ha = new HTTPAgent("http://127.0.0.1:8090"); | |||||
//2、定义方法实现 多个文件合并转为1个pdf文件 | //2、定义方法实现 多个文件合并转为1个pdf文件 | ||||
public String offs2Pdf() { | public String offs2Pdf() { | ||||
AtomAgent ha = new AtomAgent("http://10.53.157.47"); | |||||
AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); | |||||
try { | try { | ||||
//2-1、传参文件对象转换输出PDF文件 | //2-1、传参文件对象转换输出PDF文件 | ||||
//1)、定义集合,存储待转换的原文件 | //1)、定义集合,存储待转换的原文件 | ||||
List<File> fileList =new ArrayList<File>(); | List<File> fileList =new ArrayList<File>(); | ||||
@@ -58,25 +53,10 @@ public class WpsConvertManage { | |||||
OutputStream out = null; | OutputStream out = null; | ||||
//3)、添加原文件到集合 | //3)、添加原文件到集合 | ||||
fileList.add(new File("/temp/111.xlsx")); | 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文件输出流 | //4)、赋值转换后的pdf文件输出流 | ||||
out=new FileOutputStream(new File("/temp/offices2_pdf.pdf")); | out=new FileOutputStream(new File("/temp/offices2_pdf.pdf")); | ||||
//5)、调用方法,执行将多个文件转为pdf文件 | //5)、调用方法,执行将多个文件转为pdf文件 | ||||
ha.OFDToPDF(fileList, out); | 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 "转换成功"; | return "转换成功"; | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error(e.getMessage()); | log.error(e.getMessage()); | ||||
@@ -164,8 +144,6 @@ public class WpsConvertManage { | |||||
AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); | AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); | ||||
try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath()); | try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath()); | ||||
InputStream stream = ossObject.getObjectContent();) { | InputStream stream = ossObject.getObjectContent();) { | ||||
String fileName = null; | |||||
byte[] bytes = new byte[4096]; | |||||
int read; | int read; | ||||
//测试环境 转不了PDF 请求不了 WPS转换服务器 | //测试环境 转不了PDF 请求不了 WPS转换服务器 | ||||
if(BizConst.DEV.equals(active)){ | if(BizConst.DEV.equals(active)){ | ||||
@@ -188,7 +166,6 @@ public class WpsConvertManage { | |||||
//5)、调用方法,执行将多个文件转为pdf文件 | //5)、调用方法,执行将多个文件转为pdf文件 | ||||
ha.OFDToPDF(fileList, out); | ha.OFDToPDF(fileList, out); | ||||
FileInputStream fileInputStream = new FileInputStream(pdfFile); | FileInputStream fileInputStream = new FileInputStream(pdfFile); | ||||
fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8); | |||||
for(File f : fileList){ | for(File f : fileList){ | ||||
//用完就删 | //用完就删 | ||||
f.deleteOnExit(); | f.deleteOnExit(); | ||||