Commit fede74aa authored by wangqiang's avatar wangqiang

生成卷内目录物理文档

parent a46e17c8
......@@ -42,6 +42,13 @@ public interface ExtFilesService<V extends ExtFilesVO> extends ExtFilesServiceSh
void generatFilesDirectory(Long id);
/**
* 生成卷内目录
* @param id
*/
void generateJNDirectory(Long id);
List<Long> getChildList(Long partId, List<Long> list);
}
......@@ -12,6 +12,7 @@ import com.inet.dcs.document.core.service.ExtFilesService;
import com.inet.dcs.document.core.util.SearchUtil;
import com.inet.dcs.document.core.util.WordUtils;
import com.inet.dcs.document.entity.po.ExtFiles;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
......@@ -28,12 +29,16 @@ import com.yonde.dex.dfs.objfilelink.enums.FileTypeEnum;
import com.yonde.dex.dfs.objfilelink.plugin.core.util.DxObjFileUtils;
import com.yonde.dex.dfs.vo.RepoFileVO;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import com.yonde.dex.feign.applink.DxAppModelDefLinkFeignService;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.vo.info.DxApplicationVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
......@@ -69,7 +74,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
private ExtFilesDocLinkService extFilesDocLinkService;
@Autowired
private DictDataFeignService dictDataService;
private DictDataFeignService dictDataFeignService;
@Autowired
private ExtDocService extDocService;
......@@ -80,6 +85,9 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
@Autowired
private FileManagerFeignService fileManagerFeignService;
@Autowired
private DxUserInfoFeign userService;
@Override
public void beforeSave(Collection<V> target) {
// 全宗号+项目号+项目代号+类别代号+盒号(三位流水号)+后缀“-(两位数字流水号)例如:2-20114272031-QH03-JS01-001-(01)
......@@ -268,6 +276,8 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
extDxContextProjectServiceFeign.saveRecursion(dxContextProjectVO);
}
public String categoryNumber(String categoryNumber,int zhNumber,int jjNumber,int sbNumber,int jsNumber,int countNumber){
if (categoryNumber.contains("ZH")){
categoryNumber = "综合";
......@@ -318,6 +328,107 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
}
return list;
}
/**
* 生成卷内目录
* @param id
*/
@Override
public void generateJNDirectory(Long id) {
//查询项目群下所有案卷
SearchQueryCondition searchProgram = SearchUtil.buildQuery("dxContextId", SearchItem.Operator.EQ, id);
List<V> content = this.findRecursion(searchProgram).getContent();
List<Long> extFilesIdList = content.stream().map(v -> v.getId()).collect(Collectors.toList());
//查询案卷下文件清单
for(Long filesId : extFilesIdList){
SearchQueryCondition searchQueryCondition = SearchQueryBuilder.openBuild().openFilterBuilder()
.setItem("targetId", SearchItem.Operator.EQ,filesId).closeFilterBuilder()
.setPropName("target").setPropName("source").build();
List<ExtFilesDocLinkVO> extFilesDocLinkVOList = extFilesDocLinkService.findRecursion(searchQueryCondition).getContent();
ExtFilesVO extFilesVO = extFilesDocLinkVOList.get(0).getTarget();
//获取案卷下所有的档案数据 -- 填充模板数据
Map<String,Object> wordFillData = getJNDirectoryFillData(extFilesDocLinkVOList,extFilesVO);
//文档转pdf
String string = convertPdf("卷内目录模板.docx", wordFillData);
//上传文件
MultipartFile multipartFile = DxObjFileUtils.createFile(string);
DxApplicationVO modelApp = dxAppModelDefLinkFeignService.findAppByModelName("ExtFiles");
Assert.notNull(modelApp.getBucketId(), String.format("当前应用%s未绑定桶!", modelApp.getName()));
RepoFileVO fileVo = fileManagerFeignService.uploadFile(multipartFile, Long.parseLong(modelApp.getBucketId()));
//将生成的文件挂载到案卷上
DxObjFileUtils.replaceFile(extFilesVO, fileVo, FileTypeEnum.MASTER_FILE);
extFilesVO.setOperator(OperatorType.MODIFY);
extDxContextProjectServiceFeign.saveRecursion(extFilesVO);
}
}
public Map<String,Object> getJNDirectoryFillData(List<ExtFilesDocLinkVO> extFilesDocLinkVOList,ExtFilesVO extFilesVO){
List<Map<String, Object>> extFilesMap = new ArrayList<>();
Map<String, Object> resultDatas = new HashMap<>();
int serialNumber = 1;
for (ExtFilesDocLinkVO extFilesDocLinkVO:extFilesDocLinkVOList){
//文档对象
DxDocumentVO source = extFilesDocLinkVO.getSource();
Map<String, Object> datas = new HashMap<>();
//档号
datas.put("DH",extFilesVO.getVolumeNumber());
//序号
datas.put("serialNumber",serialNumber);
//责任责 ---文件创建部门
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(source.getCreatorId());
datas.put("author",userVO.getDxOrganization().getName());
//文件题目 -- 文件名称
datas.put("fileName",source.getName());
//日期 -- 文件发布日期,有流程的文件取流程结束时间,无流程的文件取文件创建时间
datas.put("date",source.getCreateTime());
//页数 --文件页数
datas.put("pageNumber",extFilesDocLinkVO.getSource().getAttachPages());
//密级 --文件密级
datas.put("secret",searchDictDataValueByDictCode(Constants.SECRET_CODE,extFilesDocLinkVO.getSource().getSecretCode()));
//备注 -- 文件本身的备注
datas.put("note",source.getNote());
//档号 -- 文件档号
datas.put("fileDH","");
serialNumber++;
}
resultDatas.put("data", extFilesMap);
return resultDatas;
}
/**
* 根据字典code获取字典code和字典项的值获取key(英文转中文,key是英文,value是中文)
*
* @param dictCode
* @return
*/
public String searchDictDataValueByDictCode(String dictCode, String dictKey) {
if (!StringUtils.isEmpty(dictKey)) {
//字典type 项目代号 ProjectCode
List<DictDataVO> dictDatasByDictCode = dictDataFeignService.getDictDatas(dictCode);
if (org.springframework.util.CollectionUtils.isEmpty(dictDatasByDictCode)) {
log.error("所查字典为空!字典code为:" + dictCode);
return "";
} else {
for (DictDataVO dictDataVO : dictDatasByDictCode) {
if (dictKey.equals(dictDataVO.getDictKey())) {
return dictDataVO.getDictValue();
}
}
log.error("所查字典数据项为空!字典code为:" + dictCode);
return "";
}
}
log.error("所查字典Key为空!字典code为:" + dictCode);
return "";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment