|
|
@ -18,6 +18,8 @@ import org.jeecg.modules.demo.project.dto.ProjectDto; |
|
|
|
import org.jeecg.modules.demo.project.entity.Project; |
|
|
|
import org.jeecg.modules.demo.project.entity.Project; |
|
|
|
import org.jeecg.modules.demo.project.mapper.ProjectMapper; |
|
|
|
import org.jeecg.modules.demo.project.mapper.ProjectMapper; |
|
|
|
import org.jeecg.modules.demo.project.service.IProject4WordService; |
|
|
|
import org.jeecg.modules.demo.project.service.IProject4WordService; |
|
|
|
|
|
|
|
import org.jeecg.modules.demo.projectFile.entity.ProjectFile; |
|
|
|
|
|
|
|
import org.jeecg.modules.demo.projectFile.service.IProjectFileService; |
|
|
|
import org.jeecg.modules.demo.projectMember.entity.ProjectMember; |
|
|
|
import org.jeecg.modules.demo.projectMember.entity.ProjectMember; |
|
|
|
import org.jeecg.modules.demo.projectMember.service.IProjectMemberService; |
|
|
|
import org.jeecg.modules.demo.projectMember.service.IProjectMemberService; |
|
|
|
import org.jeecg.modules.demo.projectType.entity.ProjectType; |
|
|
|
import org.jeecg.modules.demo.projectType.entity.ProjectType; |
|
|
@ -33,7 +35,6 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.core.io.ResourceLoader; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
@ -46,9 +47,11 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 项目表 |
|
|
|
* @Description: 根据模板填充数据生成word文件, |
|
|
|
|
|
|
|
* 合并正文、意见文件 |
|
|
|
|
|
|
|
* 生成pdf文件 |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Date: 2024-10-17 |
|
|
|
* @Date: 2024-11-19 |
|
|
|
* @Version: V1.0 |
|
|
|
* @Version: V1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
@ -72,12 +75,18 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project> |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IProjectTypeService iProjectTypeService; |
|
|
|
private IProjectTypeService iProjectTypeService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IProjectMemberService iProjectMemberService; |
|
|
|
private IProjectMemberService iProjectMemberService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private IProjectFileService iProjectFileService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProjectDto getData4Xiangmushu(Project req) { |
|
|
|
ProjectDto getData4Xiangmushu(Project req) { |
|
|
|
Project project = this.getById("1849284130146025473"); |
|
|
|
// Project project = this.getById("1849284130146025473");
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(req.getId())) return null; |
|
|
|
|
|
|
|
Project project = this.getById(req.getId()); |
|
|
|
if (ObjectUtils.isEmpty(project)) return null; |
|
|
|
if (ObjectUtils.isEmpty(project)) return null; |
|
|
|
|
|
|
|
|
|
|
|
ProjectDto dto = new ProjectDto(); |
|
|
|
ProjectDto dto = new ProjectDto(); |
|
|
@ -241,23 +250,25 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project> |
|
|
|
return dto; |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ResourceLoader resourceLoader; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${jeecg.path.model4word}") |
|
|
|
@Value("${jeecg.path.model4word}") |
|
|
|
private String model4wordPath; |
|
|
|
private String model4wordPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* @Value("${jeecg.path.upload}") |
|
|
|
|
|
|
|
private String uploadPath;*/ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object createXiangMuShu4Word(Project obj) { |
|
|
|
public Object createXiangMuShu4Word(Project obj) { |
|
|
|
ProjectDto dto = getData4Xiangmushu(obj); |
|
|
|
ProjectDto dto = getData4Xiangmushu(obj); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(dto)) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(dto); |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(dto); |
|
|
|
System.out.println("map = " + JSON.toJSONString(map)); |
|
|
|
log.info("--------项目模板填充数据:{}" + JSON.toJSONString(map)); |
|
|
|
File file = new File(model4wordPath + File.separator); |
|
|
|
File file = new File(model4wordPath + File.separator); |
|
|
|
String basePath = file.getPath() + File.separator; |
|
|
|
String basePath = file.getPath() + File.separator; |
|
|
|
// String modelFilePath = basePath + "baseInfoModel.docx";
|
|
|
|
log.info("---------------------the basePath:{}", basePath); |
|
|
|
// String modelFilePath = basePath + "model2v.doc";
|
|
|
|
String modelFilePath = basePath + "baseInfoModel.docx"; |
|
|
|
String modelFilePath = "C:\\Users\\YX\\Documents\\model3v.docx"; |
|
|
|
log.info("---------------------the baseInfoModel path:{}", modelFilePath); |
|
|
|
log.info("the baseInfoModel path:{}", modelFilePath); |
|
|
|
|
|
|
|
String mergeWordFileName = dto.getProjectName() + ".docx"; |
|
|
|
String mergeWordFileName = dto.getProjectName() + ".docx"; |
|
|
|
File outDir = new File(basePath + "pdf"); |
|
|
|
File outDir = new File(basePath + "pdf"); |
|
|
|
if (!outDir.exists()) { |
|
|
|
if (!outDir.exists()) { |
|
|
@ -269,9 +280,25 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project> |
|
|
|
List<XWPFDocument> wordList = new ArrayList<>(); |
|
|
|
List<XWPFDocument> wordList = new ArrayList<>(); |
|
|
|
// 文件第一部分
|
|
|
|
// 文件第一部分
|
|
|
|
wordList.add(doc); |
|
|
|
wordList.add(doc); |
|
|
|
|
|
|
|
|
|
|
|
//正文部门 文件第二部分
|
|
|
|
//正文部门 文件第二部分
|
|
|
|
FileInputStream fis = new FileInputStream(basePath + "正文.docx"); |
|
|
|
ProjectFile projectFile = iProjectFileService.getOne(new LambdaQueryWrapper<ProjectFile>() |
|
|
|
|
|
|
|
.eq(ProjectFile::getProjectId, dto.getId()) |
|
|
|
|
|
|
|
.eq(ProjectFile::getFileType, "docx") |
|
|
|
|
|
|
|
.orderByDesc(ProjectFile::getCreateTime)); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(projectFile)) { |
|
|
|
|
|
|
|
//windwos 下直接写回写路径
|
|
|
|
|
|
|
|
FileInputStream fis = new FileInputStream("F:\\opt\\upFiles\\temp\\" + projectFile.getFileName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//linux 环境下
|
|
|
|
|
|
|
|
// FileInputStream fis = new FileInputStream(basePath + projectFile.getFileName());
|
|
|
|
wordList.add(new XWPFDocument(fis)); |
|
|
|
wordList.add(new XWPFDocument(fis)); |
|
|
|
|
|
|
|
} else { //若正文为空则拼接正文模板
|
|
|
|
|
|
|
|
FileInputStream fis = new FileInputStream(basePath + "shenqingshu.docx"); |
|
|
|
|
|
|
|
wordList.add(new XWPFDocument(fis)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 意见部分 文件第三部分
|
|
|
|
// 意见部分 文件第三部分
|
|
|
|
FileInputStream fis2 = new FileInputStream(basePath + "yiJianModel.docx"); |
|
|
|
FileInputStream fis2 = new FileInputStream(basePath + "yiJianModel.docx"); |
|
|
|
wordList.add(new XWPFDocument(fis2)); |
|
|
|
wordList.add(new XWPFDocument(fis2)); |
|
|
|