|
|
@@ -279,7 +279,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
costProjectDocumentFile.setDataValue(whNo);
|
|
|
break;
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(costProjectDocumentFile.getTableName())){
|
|
|
+ if (StringUtils.isNotBlank(costProjectDocumentFile.getTableName()) && StringUtil.isEmpty(costProjectDocumentFile.getDataValue())){
|
|
|
if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue()) && StringUtil.isNotEmpty(costProjectDocumentFile.getWhereName())){
|
|
|
costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
|
|
|
} else if (costProjectDocument.getDocumentAlias().equals("cbjsgzdg")
|
|
|
@@ -357,8 +357,6 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
//costProjectDocumentFile.setProjectId(costProjectDocument.getProjectId());
|
|
|
switch (f.getPinyin()) {
|
|
|
case "JiaGeZhuGuanBuMenHuoChengBenDiaoChaJiGou":
|
|
|
- costProjectDocumentFile.setDataValue(org.getName());
|
|
|
- break;
|
|
|
case "JiaGeZhuGuanBuMenHuoChengBenJianShenJiGou":
|
|
|
costProjectDocumentFile.setDataValue(org.getName());
|
|
|
break;
|
|
|
@@ -555,71 +553,73 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
@Override
|
|
|
public String createDocument(String id) {
|
|
|
CostProjectDocument costProjectDocument = this.getDetail(id);
|
|
|
- List<CostProjectDocumentFile> list = costProjectDocumentFileManager.getCostProjectDocumentFiles(costProjectDocument.getProjectId(),costProjectDocument.getDocumentId());
|
|
|
- CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(costProjectDocument.getDocumentId());
|
|
|
- //生成文书
|
|
|
- Map<String,String> map = new HashMap<>();
|
|
|
- list.stream().forEach(p->{
|
|
|
- map.put("{"+p.getOriginalText()+"}", HtmlUtils.stripHtmlFast(p.getDataValue()) );
|
|
|
- });
|
|
|
- //先处理一种文件
|
|
|
- String templatePath = costDocumentTemplate.getFileUrl().replace(BaseConstant.RESOURCE_PREFIX,"");
|
|
|
- templatePath = EipConfig.getProfile()+templatePath;
|
|
|
-
|
|
|
- String fileExtension = FileUploadUtil.getFileExtension(costDocumentTemplate.getFileUrl());
|
|
|
- String fileName = FileUploadUtil.generateFileName(costDocumentTemplate.getDocumentName()+"."+fileExtension);
|
|
|
- String outputPath = FileUploadUtil.generateSavePath(EipConfig.getUploadPath(), fileName, fileExtension);
|
|
|
- try (FileInputStream fis = new FileInputStream(templatePath);
|
|
|
- XWPFDocument document = new XWPFDocument(fis);
|
|
|
- FileOutputStream fos = FileUtils.createFileOutputStream(outputPath);) {
|
|
|
-
|
|
|
-
|
|
|
- if (costProjectDocument.getDocumentAlias().equals("cbjstqzldjb")) {
|
|
|
- List<CostProjectTaskEvidence> costProjectTaskEvidences= costProjectTaskEvidenceManager.findEvidenceListByTaskIds(costProjectDocument.getProjectId(),costProjectDocument.getEnterpriseId());
|
|
|
- if (!costProjectTaskEvidences.isEmpty()) {
|
|
|
- List<CompleteTemplateProcessor.TableRowData> mapList = costProjectTaskEvidences.stream().map(c -> {
|
|
|
- CompleteTemplateProcessor.TableRowData tableRowData = new CompleteTemplateProcessor.TableRowData();
|
|
|
-
|
|
|
- tableRowData.setDocumentName(c.getMaterialName());
|
|
|
- tableRowData.setRemark(c.getRemark());
|
|
|
- tableRowData.setPageCount(c.getPageCount());
|
|
|
- return tableRowData;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- AuditedUnit auditedUnit = auditedUnitManager.get(costProjectDocument.getEnterpriseId());
|
|
|
-
|
|
|
- CompleteTemplateProcessor.processTemplateComplete(document,auditedUnit.getUnitName(),mapList,DateUtils.format(new Date(),ISO8601_DATE_PATTERN));
|
|
|
+ if (StringUtil.isEmpty(costProjectDocument.getActUrl())) {
|
|
|
+ List<CostProjectDocumentFile> list = costProjectDocumentFileManager.getCostProjectDocumentFiles(costProjectDocument.getProjectId(),costProjectDocument.getDocumentId());
|
|
|
+ CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(costProjectDocument.getDocumentId());
|
|
|
+ //生成文书
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ list.stream().forEach(p->{
|
|
|
+ map.put("{"+p.getOriginalText()+"}", HtmlUtils.stripHtmlFast(p.getDataValue()) );
|
|
|
+ });
|
|
|
+ //先处理一种文件
|
|
|
+ String templatePath = costDocumentTemplate.getFileUrl().replace(BaseConstant.RESOURCE_PREFIX,"");
|
|
|
+ templatePath = EipConfig.getProfile()+templatePath;
|
|
|
+
|
|
|
+ String fileExtension = FileUploadUtil.getFileExtension(costDocumentTemplate.getFileUrl());
|
|
|
+ String fileName = FileUploadUtil.generateFileName(costDocumentTemplate.getDocumentName()+"."+fileExtension);
|
|
|
+ String outputPath = FileUploadUtil.generateSavePath(EipConfig.getUploadPath(), fileName, fileExtension);
|
|
|
+ try (FileInputStream fis = new FileInputStream(templatePath);
|
|
|
+ XWPFDocument document = new XWPFDocument(fis);
|
|
|
+ FileOutputStream fos = FileUtils.createFileOutputStream(outputPath);) {
|
|
|
+
|
|
|
+
|
|
|
+ if (costProjectDocument.getDocumentAlias().equals("cbjstqzldjb")) {
|
|
|
+ List<CostProjectTaskEvidence> costProjectTaskEvidences= costProjectTaskEvidenceManager.findEvidenceListByTaskIds(costProjectDocument.getProjectId(),costProjectDocument.getEnterpriseId());
|
|
|
+ if (!costProjectTaskEvidences.isEmpty()) {
|
|
|
+ List<CompleteTemplateProcessor.TableRowData> mapList = costProjectTaskEvidences.stream().map(c -> {
|
|
|
+ CompleteTemplateProcessor.TableRowData tableRowData = new CompleteTemplateProcessor.TableRowData();
|
|
|
+
|
|
|
+ tableRowData.setDocumentName(c.getMaterialName());
|
|
|
+ tableRowData.setRemark(c.getRemark());
|
|
|
+ tableRowData.setPageCount(c.getPageCount());
|
|
|
+ return tableRowData;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ AuditedUnit auditedUnit = auditedUnitManager.get(costProjectDocument.getEnterpriseId());
|
|
|
+
|
|
|
+ CompleteTemplateProcessor.processTemplateComplete(document,auditedUnit.getUnitName(),mapList,DateUtils.format(new Date(),ISO8601_DATE_PATTERN));
|
|
|
+ }
|
|
|
+ } else if (costProjectDocument.getDocumentAlias().equals("zfdjcbjsjlbg")) {
|
|
|
+ CostProjectApproval costProjectApproval = costProjectApprovalManager.get(costProjectDocument.getProjectId());
|
|
|
+
|
|
|
+ List<CostProjectTask> taskByProjectId = costProjectTaskManager.findTaskByProjectId(costProjectApproval.getProjectId(), costProjectDocument.getEnterpriseId());
|
|
|
+
|
|
|
+ List<Map<String,Object>> maps= costTemplateFileManager.getSurveyTemplate(taskByProjectId.get(0).getId());
|
|
|
+
|
|
|
+ CostDataUtil costDataUtil = new CostDataUtil();
|
|
|
+ Map<String, Object> map1 = costDataUtil.convertToCostFormat(maps);
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<String> years = (List<String>)map1.get("years");
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Map<String, Object>> costItems = (List<Map<String, Object>>) map1.get("costItems");
|
|
|
+
|
|
|
+ // 处理文档
|
|
|
+ RobustComplexDocumentProcessor.processDocumentWithMaps(
|
|
|
+ document,
|
|
|
+ map,
|
|
|
+ years,
|
|
|
+ costItems
|
|
|
+ );
|
|
|
+
|
|
|
+ } else {
|
|
|
+ SmartTemplateWriter.writeToTemplate(document,map);
|
|
|
}
|
|
|
- } else if (costProjectDocument.getDocumentAlias().equals("zfdjcbjsjlbg")) {
|
|
|
- CostProjectApproval costProjectApproval = costProjectApprovalManager.get(costProjectDocument.getProjectId());
|
|
|
-
|
|
|
- List<CostProjectTask> taskByProjectId = costProjectTaskManager.findTaskByProjectId(costProjectApproval.getProjectId(), costProjectDocument.getEnterpriseId());
|
|
|
-
|
|
|
- List<Map<String,Object>> maps= costTemplateFileManager.getSurveyTemplate(taskByProjectId.get(0).getId());
|
|
|
-
|
|
|
- CostDataUtil costDataUtil = new CostDataUtil();
|
|
|
- Map<String, Object> map1 = costDataUtil.convertToCostFormat(maps);
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<String> years = (List<String>)map1.get("years");
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Map<String, Object>> costItems = (List<Map<String, Object>>) map1.get("costItems");
|
|
|
-
|
|
|
- // 处理文档
|
|
|
- RobustComplexDocumentProcessor.processDocumentWithMaps(
|
|
|
- document,
|
|
|
- map,
|
|
|
- years,
|
|
|
- costItems
|
|
|
- );
|
|
|
-
|
|
|
- } else {
|
|
|
- SmartTemplateWriter.writeToTemplate(document,map);
|
|
|
+ document.write(fos);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException("处理Word文档时出错", e);
|
|
|
}
|
|
|
- document.write(fos);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException("处理Word文档时出错", e);
|
|
|
+ costProjectDocument.setActUrl(EipConfig.getImgUrl() + FileUploadUtil.getPathFileName(outputPath, fileName));
|
|
|
}
|
|
|
-
|
|
|
- return EipConfig.getImgUrl()+FileUploadUtil.getPathFileName(outputPath,fileName);
|
|
|
+ return costProjectDocument.getActUrl() ;
|
|
|
}
|
|
|
|
|
|
|