CostProjectDocumentManagerImpl.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. package com.hotent.project.manager.impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.baomidou.mybatisplus.core.metadata.IPage;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.hotent.base.util.StringUtil;
  9. import com.hotent.base.util.UniqueIdUtil;
  10. import com.hotent.baseInfo.manager.AuditedUnitManager;
  11. import com.hotent.baseInfo.manager.CostDocumentTemplateFileManager;
  12. import com.hotent.baseInfo.manager.CostDocumentTemplateManager;
  13. import com.hotent.baseInfo.manager.CostDocumentWhManager;
  14. import com.hotent.baseInfo.model.AuditedUnit;
  15. import com.hotent.baseInfo.model.CostDocumentTemplate;
  16. import com.hotent.baseInfo.model.CostDocumentTemplateFile;
  17. import com.hotent.baseInfo.model.CostDocumentWh;
  18. import com.hotent.config.EipConfig;
  19. import com.hotent.constant.BaseConstant;
  20. import com.hotent.project.manager.CostProjectApprovalManager;
  21. import com.hotent.project.manager.CostProjectDocumentFileManager;
  22. import com.hotent.project.model.CostProjectApproval;
  23. import com.hotent.project.model.CostProjectDocument;
  24. import com.hotent.project.dao.CostProjectDocumentDao;
  25. import com.hotent.project.manager.CostProjectDocumentManager;
  26. import com.hotent.base.manager.impl.BaseManagerImpl;
  27. import com.hotent.project.model.CostProjectDocumentFile;
  28. import com.hotent.project.req.CostProjectDocumentPageReq;
  29. import com.hotent.project.req.CostProjectDocumentReq;
  30. import com.hotent.project.resp.CostProjectDocumentResp;
  31. import com.hotent.uc.api.model.IUser;
  32. import com.hotent.uc.exception.BaseException;
  33. import com.hotent.uc.manager.UserManager;
  34. import com.hotent.uc.model.User;
  35. import com.hotent.uc.util.ContextUtil;
  36. import com.hotent.util.wordexcelutils.DocumentProcessor;
  37. import org.apache.commons.lang.StringUtils;
  38. import org.apache.tools.ant.util.DateUtils;
  39. import org.springframework.beans.BeanUtils;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.stereotype.Service;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import java.time.LocalDateTime;
  44. import java.util.*;
  45. import java.util.stream.Collectors;
  46. import com.hotent.util.FileUploadUtil;
  47. /**
  48. * 监审项目文书表 服务实现类
  49. *
  50. * @author 超级管理员
  51. * @company 山西清众科技股份有限公司
  52. * @since 2025-09-26
  53. */
  54. @Service
  55. public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectDocumentDao, CostProjectDocument> implements CostProjectDocumentManager {
  56. @Autowired
  57. private CostProjectDocumentFileManager costProjectDocumentFileManager;
  58. @Autowired
  59. private CostDocumentTemplateManager costDocumentTemplateManager;
  60. @Autowired
  61. private AuditedUnitManager auditedUnitManager;
  62. @Autowired
  63. private CostDocumentTemplateFileManager costDocumentTemplateFileManager;
  64. @Autowired
  65. private CostDocumentWhManager costDocumentWhManager;
  66. @Autowired
  67. private CostProjectApprovalManager costProjectApprovalManager;
  68. @Autowired
  69. private UserManager userService;
  70. @Autowired
  71. private CostDocumentTemplateFileManager costTemplateFileManager;
  72. private static final HashMap<String, Boolean> whMap = new HashMap<>();
  73. @Override
  74. public CostProjectDocument getDetail(String id) {
  75. CostProjectDocument costProjectDocument = this.get(id);
  76. return costProjectDocument;
  77. }
  78. @Override
  79. public void deleteByIds(List<String> ids) {
  80. List<CostProjectDocument> costProjectDocuments = this.listByIds(ids);
  81. if (costProjectDocuments!=null){
  82. costProjectDocuments.forEach(item -> {
  83. //逻辑删除
  84. item.setIsDeleted( BaseConstant.DELETE_FLAG);
  85. });
  86. this.updateBatchById(costProjectDocuments);
  87. }
  88. }
  89. @Override
  90. @Transactional
  91. public void createOrUpdate(CostProjectDocument costProjectDocument) {
  92. //新建或更新
  93. this.saveOrUpdate(costProjectDocument);
  94. }
  95. @Override
  96. public IPage<CostProjectDocument> pageList(CostProjectDocumentPageReq req) {
  97. LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  98. if (req.getDocumentType() != null) {
  99. // LambdaQueryWrapper<CostDocumentTemplate> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  100. // lambdaQueryWrapper.eq(CostDocumentTemplate::getId, req.getDocumentType());
  101. // lambdaQueryWrapper.eq(CostDocumentTemplate::getIsWh, "0");
  102. qw.eq(CostProjectDocument::getDocumentType, req.getDocumentType());
  103. }
  104. qw.eq(CostProjectDocument::getProjectId, req.getProjectId());
  105. IPage<CostProjectDocument> page = new Page<>(req.getPageNum(), req.getPageSize());
  106. return this.page(page, qw);
  107. }
  108. // @Override
  109. // public void create(CostProjectDocument costProjectDocument) {
  110. // if (ObjectUtil.isEmpty(costProjectDocument.getDocumentId())) {
  111. // throw new BaseException("请选择文书模板");
  112. // }
  113. // if (ObjectUtil.isEmpty(costProjectDocument.getProjectId())) {
  114. // throw new BaseException("请选择项目");
  115. // }
  116. // if (ObjectUtil.isEmpty(costProjectDocument.getDocumentNumber())) {
  117. // throw new BaseException("请填写通知文号");
  118. // }
  119. // if (ObjectUtil.isEmpty(costProjectDocument.getEnterpriseId())) {
  120. // throw new BaseException("请选择监审单位");
  121. // }
  122. // costProjectDocument.setGenerateTime(LocalDateTime.now());
  123. // costProjectDocument.setIsPushed("1");
  124. //
  125. // CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(costProjectDocument.getDocumentId());
  126. // if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
  127. // throw new BaseException("文书模板不存在");
  128. // }
  129. // costProjectDocument.setDocumentAlias(costDocumentTemplate.getAlias());
  130. // AuditedUnit auditedUnit = auditedUnitManager.get(costProjectDocument.getEnterpriseId());
  131. // if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
  132. // throw new BaseException("被监审单位不存在");
  133. // }
  134. // CostDocumentWh costDocumentWh = costDocumentWhManager.get(costProjectDocument.getDocumentWhId());
  135. // if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
  136. // throw new BaseException("文书文号不存在");
  137. // }
  138. //
  139. // LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  140. // qw.eq(CostProjectDocument::getProjectId, costProjectDocument.getProjectId());
  141. // qw.eq(CostProjectDocument::getDocumentId, costProjectDocument.getDocumentId());
  142. // qw.eq(CostProjectDocument::getEnterpriseId, costProjectDocument.getEnterpriseId());
  143. // if (this.count(qw) > 0) {
  144. // throw new BaseException("该项目监审单位已存在此文书");
  145. // }
  146. // super.create(costProjectDocument);
  147. //
  148. //
  149. // }
  150. @Override
  151. @Transactional
  152. public void create(CostProjectDocumentReq req) throws Exception {
  153. if (ObjectUtil.isEmpty(req.getDocumentId())) {
  154. throw new BaseException("请选择文书模板");
  155. }
  156. if (ObjectUtil.isEmpty(req.getProjectId())) {
  157. throw new BaseException("请选择项目");
  158. }
  159. if (ObjectUtil.isEmpty(req.getDocumentNumber())) {
  160. throw new BaseException("请填写通知文号");
  161. }
  162. if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
  163. throw new BaseException("请选择监审单位");
  164. }
  165. req.setGenerateTime(LocalDateTime.now());
  166. req.setIsPushed("1");
  167. CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(req.getDocumentId());
  168. if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
  169. throw new BaseException("文书模板不存在");
  170. }
  171. req.setDocumentAlias(costDocumentTemplate.getAlias());
  172. AuditedUnit auditedUnit = auditedUnitManager.get(req.getEnterpriseId());
  173. if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
  174. throw new BaseException("被监审单位不存在");
  175. }
  176. CostDocumentWh costDocumentWh = costDocumentWhManager.get(req.getDocumentWhId());
  177. if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
  178. throw new BaseException("文书文号不存在");
  179. }
  180. //返回文号
  181. String whNo = this.getWH(costDocumentWh);
  182. //校验文号唯一性
  183. Boolean b = whMap.get(whNo);
  184. if (b==null || !b) {
  185. whMap.put(whNo,true);
  186. }else {
  187. throw new BaseException("【"+whNo+"】文号已存在请重新添加");
  188. }
  189. LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  190. qw.eq(CostProjectDocument::getProjectId, req.getProjectId());
  191. qw.eq(CostProjectDocument::getDocumentId, req.getDocumentId());
  192. qw.eq(CostProjectDocument::getEnterpriseId, req.getEnterpriseId());
  193. if (this.count(qw) > 0) {
  194. throw new BaseException("该项目监审单位已存在此文书");
  195. }
  196. CostProjectApproval costProjectApproval = costProjectApprovalManager.get(req.getProjectId());
  197. //类型转换
  198. CostProjectDocument costProjectDocument = new CostProjectDocument();
  199. BeanUtil.copyProperties(req, costProjectDocument);
  200. costProjectDocument.setDocumentNumber(whNo);
  201. costProjectDocument.setDocumentName(costDocumentTemplate.getDocumentName());
  202. costProjectDocument.setDocumentType(costDocumentTemplate.getType());
  203. costProjectDocument.setProjectId(costProjectApproval.getProjectId());
  204. super.create(costProjectDocument);
  205. /*if (costProjectDocument.getDocumentAlias().equals("cbjstzs")) {
  206. CostDocumentTemplate templateManagerById = costDocumentTemplateManager.getByAlias("sdhz");
  207. if (templateManagerById==null) {
  208. throw new BaseException("未查询到送达回证文书模板信息,请先添加");
  209. }
  210. IUser iUser = ContextUtil.getCurrentUser();
  211. User user = userService.getByAccount(iUser.getAccount());
  212. ArrayList<CostProjectDocumentFile> arrayList = new ArrayList<>();
  213. CostProjectDocument projectDocument = new CostProjectDocument();
  214. BeanUtil.copyProperties(costProjectDocument, projectDocument);
  215. projectDocument.setId(UniqueIdUtil.getSuid());
  216. projectDocument.setCreateBy(user.getAccount());
  217. projectDocument.setCreateTime(LocalDateTime.now());
  218. QueryWrapper<CostDocumentWh> wrapper = new QueryWrapper<>();
  219. wrapper.eq("wh_type","187");
  220. List<CostDocumentWh> list = costDocumentWhManager.list(wrapper);
  221. if (list == null || list.isEmpty()) {
  222. throw new BaseException("文书文号不存在");
  223. }
  224. CostDocumentWh costDocument = list.get(0);
  225. projectDocument.setDocumentNumber(costDocument.getRulePattern().replace("{prefixText}", costDocument.getPrefixText())
  226. .replace("{year}", costDocument.getYear()).replace("{currentValue}", costDocument.getCurrentValue().toString()));
  227. projectDocument.setElectronicDocumentUrl(templateManagerById.getFileUrl());
  228. projectDocument.setDocumentWhId(costDocument.getId());
  229. projectDocument.setDocumentId(String.valueOf(templateManagerById.getId()));
  230. projectDocument.setDocumentName(templateManagerById.getDocumentName());
  231. projectDocument.setDocumentType(templateManagerById.getType());
  232. projectDocument.setDocumentAlias(templateManagerById.getAlias());
  233. //super.create(projectDocument);
  234. this.save(projectDocument);
  235. List<CostDocumentTemplateFile> documentFileList = costDocumentTemplateFileManager.getDocumentFileList(String.valueOf(templateManagerById.getId()));
  236. documentFileList.forEach(f->{
  237. CostProjectDocumentFile costProjectDocumentFile = new CostProjectDocumentFile();
  238. BeanUtils.copyProperties(f,costProjectDocumentFile);
  239. costProjectDocumentFile.setId(UniqueIdUtil.getUId());
  240. costProjectDocumentFile.setCreateBy(user.getAccount());
  241. costProjectDocumentFile.setCreateTime(LocalDateTime.now());
  242. costProjectDocumentFile.setProjectId(costProjectApproval.getProjectId());
  243. costProjectDocumentFile.setProjectId(costProjectDocument.getProjectId());
  244. switch (f.getPinyin()) {
  245. case "SongDaWenShuWenHao":
  246. costProjectDocumentFile.setDataValue(projectDocument.getDocumentNumber());
  247. break;
  248. }
  249. if (StringUtils.isNotBlank(f.getTableName())){
  250. if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())){
  251. costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
  252. }else {
  253. String whereValue1 = costProjectDocumentFile.getWhereValue();
  254. String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
  255. costProjectDocumentFile.setWhereValue(replace);
  256. }
  257. String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
  258. //获取whereValue字段值
  259. costProjectDocumentFile.setDataValue(colValue);
  260. }
  261. arrayList.add(costProjectDocumentFile);
  262. });
  263. costProjectDocumentFileManager.saveBatch(arrayList);
  264. }*/
  265. //文件关联信息赋值
  266. req.getCostProjectDocumentFiles().forEach(costProjectDocumentFile -> {
  267. costProjectDocumentFile.setDocumentId(costProjectDocument.getDocumentId());
  268. costProjectDocumentFile.setProjectId(costProjectDocument.getProjectId());
  269. switch (costProjectDocumentFile.getPinyin()) {
  270. case "SongDaWenShuWenHao":
  271. costProjectDocumentFile.setDataValue(whNo);
  272. break;
  273. }
  274. if (StringUtils.isNotBlank(costProjectDocumentFile.getTableName())){
  275. if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())){
  276. costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
  277. }else {
  278. String whereValue1 = costProjectDocumentFile.getWhereValue();
  279. String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
  280. costProjectDocumentFile.setWhereValue(replace);
  281. }
  282. String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
  283. //获取whereValue字段值
  284. costProjectDocumentFile.setDataValue(colValue);
  285. }
  286. });
  287. //保存解析出的文件内容
  288. costProjectDocumentFileManager.saveBatch(req.getCostProjectDocumentFiles());
  289. //更新文号值
  290. costDocumentWhManager.updateCurrentValue(costDocumentWh.getId());
  291. whMap.remove(whNo);
  292. }
  293. public synchronized String getWH(CostDocumentWh costDocumentWh){
  294. return costDocumentWh.getRulePattern().replace("{prefixText}", costDocumentWh.getPrefixText())
  295. .replace("{year}", costDocumentWh.getYear()).replace("{currentValue}", costDocumentWh.getCurrentValue().toString());
  296. }
  297. @Override
  298. public List<CostProjectDocumentFile> getDocumentFileList(String id) {
  299. CostProjectDocument costProjectDocument = this.get(id);
  300. if(costProjectDocument == null){
  301. throw new BaseException("文书模板不存在");
  302. }
  303. return null;
  304. }
  305. @Override
  306. public void updateProjectDocument(CostProjectDocumentReq req) {
  307. if (ObjectUtil.isEmpty(req.getId())) {
  308. throw new BaseException("请选择要修改的文书");
  309. }
  310. if (ObjectUtil.isEmpty(req.getDocumentId())) {
  311. throw new BaseException("请选择文书模板");
  312. }
  313. if (ObjectUtil.isEmpty(req.getProjectId())) {
  314. throw new BaseException("请选择项目");
  315. }
  316. if (ObjectUtil.isEmpty(req.getDocumentNumber())) {
  317. throw new BaseException("请填写通知文号");
  318. }
  319. if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
  320. throw new BaseException("请选择监审单位");
  321. }
  322. CostProjectDocument selectCostProjectDocument = this.get(req.getId());
  323. if (selectCostProjectDocument == null) {
  324. throw new BaseException("请选择要修改的文书");
  325. }
  326. req.setIsPushed("1");
  327. CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(req.getDocumentId());
  328. if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
  329. throw new BaseException("文书模板不存在");
  330. }
  331. req.setDocumentAlias(costDocumentTemplate.getAlias());
  332. AuditedUnit auditedUnit = auditedUnitManager.get(req.getEnterpriseId());
  333. if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
  334. throw new BaseException("被监审单位不存在");
  335. }
  336. CostDocumentWh costDocumentWh = costDocumentWhManager.get(req.getDocumentWhId());
  337. if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
  338. throw new BaseException("文书文号不存在");
  339. }
  340. LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  341. qw.eq(CostProjectDocument::getProjectId, req.getProjectId());
  342. qw.eq(CostProjectDocument::getDocumentId, req.getDocumentId());
  343. qw.eq(CostProjectDocument::getEnterpriseId, req.getEnterpriseId());
  344. if (this.count(qw) > 0) {
  345. throw new BaseException("该项目监审单位已存在此文书");
  346. }
  347. selectCostProjectDocument.setDocumentWhId(req.getDocumentWhId());
  348. selectCostProjectDocument.setDocumentId(req.getDocumentId());
  349. selectCostProjectDocument.setEnterpriseId(req.getEnterpriseId());
  350. selectCostProjectDocument.setElectronicDocumentUrl("");
  351. // 类型转换
  352. BeanUtil.copyProperties(req,selectCostProjectDocument);
  353. super.update(selectCostProjectDocument);
  354. costProjectDocumentFileManager.remove(new LambdaQueryWrapper<CostProjectDocumentFile>().eq(CostProjectDocumentFile::getProjectId,selectCostProjectDocument.getProjectId()));
  355. List<CostProjectDocumentFile> costProjectDocumentFiles = req.getCostProjectDocumentFiles();
  356. if (costProjectDocumentFiles != null){
  357. for (CostProjectDocumentFile costProjectDocumentFile : costProjectDocumentFiles) {
  358. costProjectDocumentFile.setDocumentId(selectCostProjectDocument.getDocumentId());
  359. costProjectDocumentFile.setProjectId(selectCostProjectDocument.getProjectId());
  360. }
  361. }
  362. costProjectDocumentFileManager.saveBatch(req.getCostProjectDocumentFiles());
  363. }
  364. @Override
  365. public List<CostProjectDocument> getListByProjectId(String projectId) {
  366. LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  367. qw.eq(CostProjectDocument::getProjectId, projectId);
  368. qw.eq(CostProjectDocument::getIsDeleted, BaseConstant.NORMAL_STATUS);
  369. List<CostProjectDocument> list = this.list(qw);
  370. if (ObjectUtil.isEmpty(list)) {
  371. return new ArrayList<>();
  372. }
  373. return list;
  374. }
  375. @Override
  376. public CostProjectDocumentResp getByProjectId(String projectId){
  377. //查询监审文书
  378. LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
  379. qw.eq(CostProjectDocument::getProjectId, projectId);
  380. qw.eq(CostProjectDocument::getIsDeleted, BaseConstant.NORMAL_STATUS);
  381. CostProjectDocument costProjectDocument = this.getOne(qw);
  382. //转换为返回类型
  383. CostProjectDocumentResp costProjectDocumentResp = BeanUtil.copyProperties(costProjectDocument, CostProjectDocumentResp.class);
  384. //查询文书下的文书内容
  385. LambdaQueryWrapper<CostProjectDocumentFile> wrapper = new LambdaQueryWrapper<>();
  386. wrapper.eq(CostProjectDocumentFile::getProjectId, costProjectDocument.getProjectId());
  387. //获取文件内容返回
  388. costProjectDocumentResp.setCostProjectDocumentFiles(costProjectDocumentFileManager.list(wrapper));
  389. CostDocumentTemplate costDocumentTemplate = costDocumentTemplateManager.get(costProjectDocument.getDocumentId());
  390. costProjectDocumentResp.setFullPath(EipConfig.getImgUrl()+costDocumentTemplate.getFileUrl());
  391. return costProjectDocumentResp;
  392. }
  393. @Override
  394. public String createDocument(String id) {
  395. CostProjectDocument costProjectDocument = this.getDetail(id);
  396. List<CostProjectDocumentFile> list = costProjectDocumentFileManager.getCostProjectDocumentFiles(costProjectDocument.getProjectId(),costProjectDocument.getDocumentId());
  397. CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(costProjectDocument.getDocumentId());
  398. //生成文书
  399. Map<String,String> map = new HashMap<>();
  400. list.stream().forEach(p->{
  401. map.put("{"+p.getOriginalText()+"}",p.getDataValue());
  402. });
  403. //先处理一种文件
  404. String templatePath = costDocumentTemplate.getFileUrl().replace(BaseConstant.RESOURCE_PREFIX,"");
  405. templatePath = EipConfig.getProfile()+templatePath;
  406. String fileExtension = FileUploadUtil.getFileExtension(costDocumentTemplate.getFileUrl());
  407. String fileName = FileUploadUtil.generateFileName(costDocumentTemplate.getDocumentName()+"."+fileExtension);
  408. String outputPath = FileUploadUtil.generateSavePath(EipConfig.getUploadPath(), fileName, fileExtension);
  409. DocumentProcessor.processWordDocument(templatePath,outputPath,map,new LinkedHashMap<>());
  410. return EipConfig.getImgUrl()+FileUploadUtil.getPathFileName(outputPath,fileName);
  411. }
  412. }