文档生成合并 11.22

master
zhc077 11 hours ago
parent 5a4276219f
commit 603e4c7f06
  1. 3
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/controller/ProjectController.java
  2. 57
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java
  3. 1
      jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml
  4. 4
      jeecgboot-vue3/src/views/projectApplication/kejigongguan/xiangmushu/ZhengWenDemo.vue
  5. 4
      jeecgboot-vue3/src/views/projectFile/zhengwen/ProjectFile4ZhengWen.data.ts

@ -608,6 +608,9 @@ public class ProjectController extends JeecgController<Project, IProjectService>
log.setProjectStatus("6");
log.setBudgetStatus("6");
log.setOperationMark("申请人提交项目书,申请人提交预算书");
//提交项目时,生成项目书pdf文件
iProject4WordService.createXiangMuShu4Word(project);
}
//申请单位审核通过,并向上级提交->科技主管部门待提交(区/县管理员)
if ("faren_admin".equals(loginUser.getRoleCode())) {

@ -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.mapper.ProjectMapper;
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.service.IProjectMemberService;
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.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@ -46,9 +47,11 @@ import java.util.List;
import java.util.Map;
/**
* @Description: 项目表
* @Description: 根据模板填充数据生成word文件
* 合并正文意见文件
* 生成pdf文件
* @Author: jeecg-boot
* @Date: 2024-10-17
* @Date: 2024-11-19
* @Version: V1.0
*/
@Service
@ -72,12 +75,18 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
@Autowired
private IProjectTypeService iProjectTypeService;
@Autowired
private IProjectMemberService iProjectMemberService;
@Autowired
private IProjectFileService iProjectFileService;
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;
ProjectDto dto = new ProjectDto();
@ -241,23 +250,25 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
return dto;
}
@Autowired
private ResourceLoader resourceLoader;
@Value("${jeecg.path.model4word}")
private String model4wordPath;
/* @Value("${jeecg.path.upload}")
private String uploadPath;*/
@Override
public Object createXiangMuShu4Word(Project obj) {
ProjectDto dto = getData4Xiangmushu(obj);
if (ObjectUtil.isEmpty(dto)) {
return null;
}
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);
String basePath = file.getPath() + File.separator;
// String modelFilePath = basePath + "baseInfoModel.docx";
// String modelFilePath = basePath + "model2v.doc";
String modelFilePath = "C:\\Users\\YX\\Documents\\model3v.docx";
log.info("the baseInfoModel path:{}", modelFilePath);
log.info("---------------------the basePath:{}", basePath);
String modelFilePath = basePath + "baseInfoModel.docx";
log.info("---------------------the baseInfoModel path:{}", modelFilePath);
String mergeWordFileName = dto.getProjectName() + ".docx";
File outDir = new File(basePath + "pdf");
if (!outDir.exists()) {
@ -269,9 +280,25 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
List<XWPFDocument> wordList = new ArrayList<>();
// 文件第一部分
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));
} else { //若正文为空则拼接正文模板
FileInputStream fis = new FileInputStream(basePath + "shenqingshu.docx");
wordList.add(new XWPFDocument(fis));
}
// 意见部分 文件第三部分
FileInputStream fis2 = new FileInputStream(basePath + "yiJianModel.docx");
wordList.add(new XWPFDocument(fis2));
@ -279,8 +306,8 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
XWPFDocument mergeWordObj = WordUtils.mergeWord(wordList);
FileOutputStream fos = new FileOutputStream(new File(outDir, mergeWordFileName));
//已合并过的文件,删除
File oldMergeWord = new File(outDir + File.separator + dto.getProjectName()+".docx");
File oldPdf = new File(outDir + File.separator + dto.getProjectName()+".pdf");
File oldMergeWord = new File(outDir + File.separator + dto.getProjectName() + ".docx");
File oldPdf = new File(outDir + File.separator + dto.getProjectName() + ".pdf");
if (oldMergeWord != null && oldMergeWord.isFile() && oldMergeWord.exists()) {
oldMergeWord.delete();
}

@ -216,6 +216,7 @@ jeecg:
path:
#文件上传根目录 设置
upload: /opt/kjj/upload
model4word: /opt/kjj/upload
#webapp文件路径
webapp: /opt/kjj/webapp
shiro:

@ -2,7 +2,7 @@
<div class="p-1">
<div class="p-1 bg-white">
<a-button :ghost="true" type="primary" preIcon="ant-design:download-outlined"
@click="downloadFile('temp/shenqingshu.doc')">下载模板
@click="downloadFile('temp/shenqingshu.docx')">下载模板
</a-button>
<BasicForm @register="register2" />
</div>
@ -101,7 +101,7 @@ const schemas2: FormSchema[] = [
},
// label: '',
defaultValue: '上传主表信息\n' +
'第一步:下载项目申请书word模板(shenqingshu.doc)。\n' +
'第一步:下载项目申请书word模板(shenqingshu.docx)。\n' +
'第二步:打开项目申请书模板,在word中填写项目申请书。\n' +
'第三步:将填写完整无误,不再修改的项目申请书(word)上传。',
dynamicDisabled: true,

@ -42,9 +42,9 @@ export const formSchema: FormSchema[] = [
field: 'fileUrl',
labelLength: 100,
component: 'JUpload',
helpMessage: '1次最多上传1个文件,可多次上传',
helpMessage: '只能上传一个申请书模板正文,且格式必须为.docx',
componentProps: {
fileType: UploadTypeEnum.all,
fileType: UploadTypeEnum.file,
maxCount: 1,
},
},

Loading…
Cancel
Save