feat(本地工具): UNECE拆分
This commit is contained in:
+7
@@ -58,6 +58,13 @@ public class SplitFileInfo {
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 标准类别 (数据字典 海外标准法规:standard_type_overseas 国内标准法规:standard_type) (全部传空)
|
||||
*/
|
||||
@ApiModelProperty(value = "标准类别")
|
||||
@TableField(exist = false)
|
||||
private String standardClass;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "来源")
|
||||
@Dict(dicCode = "standard_source")
|
||||
|
||||
+8
-4
@@ -208,7 +208,7 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryDocumentSplitDetailById" resultType="java.util.Map">
|
||||
select *
|
||||
from laws_document_split
|
||||
@@ -217,13 +217,17 @@
|
||||
|
||||
<select id="querySplitFileInfoByPage" resultType="com.jero.modules.laws.documenttool.entity.SplitFileInfo">
|
||||
select standard.*, o.id id, o.file_name, o.standard_file_type, o.url
|
||||
from (select id standardId, standard_number, standard_number standardNo, standard_name, standard_state, release_date, 1 origin, create_time, create_by, update_by, update_time
|
||||
from (select id standardId, standard_number, standard_number standardNo, standard_class, standard_name, standard_state, release_date, 1 origin, create_time, create_by, update_by, update_time
|
||||
from laws_domestic_standard
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id standardId, standard_number, standard_number standardNo, standard_name, standard_state, release_date, 3 origin, create_time, create_by, update_by, update_time
|
||||
select id standardId, standard_number, standard_number standardNo, standard_class, standard_name, standard_state, release_date, 3 origin, create_time, create_by, update_by, update_time
|
||||
from laws_enterprise_standard
|
||||
where del_flag = 0) standard left join oss_file o on standardId = o.standard_id
|
||||
where del_flag = 0
|
||||
union all
|
||||
select id standardId, standard_number, standard_number standardNo, standard_class, standard_name, standard_state, release_date, 2 origin, create_time, create_by, update_by, update_time
|
||||
from laws_overseas_standard
|
||||
where del_flag = 0 AND standard_class = 'UNECE') standard left join oss_file o on standardId = o.standard_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
+9
-2
@@ -387,11 +387,17 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
// 企标权限校验
|
||||
enterpriseCheck(sarFileSplitInfoEO);
|
||||
// 唯一校验
|
||||
// uniqueCheck(sarFileSplitInfoEO);
|
||||
uniqueCheck(sarFileSplitInfoEO);
|
||||
// 保存文本拆分数据
|
||||
saveDocumentSplitInfo(sarFileSplitInfoEO);
|
||||
int count;
|
||||
|
||||
//拆分
|
||||
int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT);
|
||||
if (SplitFileTypeTypeEnum.EU.getValue().equals(sarFileSplitInfoEO.getStandardClass())){
|
||||
count = fileSpiltService.fileEU(sarFileSplitInfoEO, SplitFileTypeTypeEnum.EU);
|
||||
}else {
|
||||
count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT);
|
||||
}
|
||||
|
||||
if(count == -1){
|
||||
if(LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) {
|
||||
@@ -1389,6 +1395,7 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
sarFileSplitInfoEO.setSerialNumber(fileInfo.getStandardNumber());
|
||||
sarFileSplitInfoEO.setStandardId(fileInfo.getStandardId());
|
||||
sarFileSplitInfoEO.setTitle(fileInfo.getStandardName());
|
||||
sarFileSplitInfoEO.setStandardClass(fileInfo.getStandardClass());
|
||||
try {
|
||||
add(sarFileSplitInfoEO);
|
||||
// 提交事务
|
||||
|
||||
@@ -150,4 +150,10 @@ public class SarFileSplitInfoEO implements Serializable {
|
||||
@ApiModelProperty("ids")
|
||||
@TableField(exist = false)
|
||||
private String ids;
|
||||
/**
|
||||
* 标准类别 (数据字典 海外标准法规:standard_type_overseas 国内标准法规:standard_type) (全部传空)
|
||||
*/
|
||||
@ApiModelProperty(value = "标准类别")
|
||||
@TableField(exist = false)
|
||||
private String standardClass;
|
||||
}
|
||||
|
||||
@@ -1298,4 +1298,308 @@ public class FileSpiltService {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public int fileEU(SarFileSplitInfoEO sarFileSplitInfoEO, SplitFileTypeTypeEnum enumByValue) {
|
||||
if (sarFileSplitInfoEO.getStopNumber() <= 0) {
|
||||
sarFileSplitInfoEO.setStopNumber(200);
|
||||
}
|
||||
if (sarFileSplitInfoEO.getStartNumber() <= 0) {
|
||||
sarFileSplitInfoEO.setStartNumber(1);
|
||||
}
|
||||
|
||||
// 拆分文件条款表中最终插入数据
|
||||
List<SarFileSplitItemsEO> messageList = new ArrayList<>();
|
||||
int messageNumber = 0;
|
||||
// 拆分文件目录表中最终插入数据
|
||||
List<SarFileSplitMenuEO> treeList = new ArrayList<>();
|
||||
// 拆分文件条款详情表中最终插入数据
|
||||
List<SarFileSplitItemsValEO> itemValList = new ArrayList<>();
|
||||
Long treeListDisplay = 1L;
|
||||
|
||||
String generalCatalogueId = UUIDUtils.randomUUID20();
|
||||
SarFileSplitMenuEO documentTreeEO = new SarFileSplitMenuEO();
|
||||
// SarFileSplitMenuEO documentTreeEO = new SarFileSplitMenuEO(generalCatalogueId,"General Catalogue","",sarFileSplitInfoEO.getId(),treeListDisplay++,"");
|
||||
documentTreeEO.setId(generalCatalogueId);
|
||||
documentTreeEO.setName("General Catalogue");
|
||||
documentTreeEO.setInfoId(sarFileSplitInfoEO.getId());
|
||||
documentTreeEO.setDisplaySeq(1L);
|
||||
documentTreeEO.setDisplaySeq(treeListDisplay++);
|
||||
documentTreeEO.setValidFlag(0);
|
||||
treeList.add(documentTreeEO);
|
||||
|
||||
List<String> nowStart = new ArrayList<>();
|
||||
nowStart.add("1");
|
||||
// if (sarFileSplitInfoEO.getStartNumber()<4){
|
||||
// } else {
|
||||
// nowStart.add(String.valueOf(sarFileSplitInfoEO.getStartNumber()));
|
||||
// }
|
||||
//获取文件地址
|
||||
// String connectId = sarFileSplitInfoEO.getConnectId();
|
||||
// String fileName = sarFileSplitInfoEO.getFileName();
|
||||
// if (org.apache.commons.lang.StringUtils.isEmpty(connectId) || org.apache.commons.lang.StringUtils.isEmpty(fileName)) {
|
||||
// throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||
// }
|
||||
// LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper();
|
||||
// queryWrapper.eq(OSSFile::getConnectId, connectId);
|
||||
// queryWrapper.eq(OSSFile::getFileName, fileName);
|
||||
// queryWrapper.orderByDesc(OSSFile::getCreateTime);
|
||||
// List<OSSFile> ossFileList = iossFileService.list(queryWrapper);
|
||||
// if (CollectionUtils.isEmpty(ossFileList)) {
|
||||
// throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||
// }
|
||||
String fileId = sarFileSplitInfoEO.getFileId();
|
||||
LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(OSSFile::getId, fileId);
|
||||
queryWrapper.orderByDesc(OSSFile::getCreateTime);
|
||||
List<OSSFile> ossFileList = iossFileService.list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(ossFileList)) {
|
||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||
}
|
||||
OSSFile ossFile = ossFileList.get(0);
|
||||
String readFilePath = ossFile.getUrl();
|
||||
if (org.apache.commons.lang.StringUtils.isEmpty(readFilePath) || !MinioUtil.doesObjectExist(readFilePath)) {
|
||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||
}
|
||||
try (InputStream is = MinioUtil.download(readFilePath)) {
|
||||
|
||||
// InputStream is = new FileInputStream(readFilePath); //需要将文件路更改为word文档所在路径。
|
||||
XWPFDocument doc = new XWPFDocument(is);
|
||||
|
||||
Pattern ptest = Pattern.compile("^[\\d.]*$");
|
||||
// Matcher matcher;
|
||||
|
||||
// 记录拆分后的每一段文字
|
||||
List<IBodyElement> elements = doc.getBodyElements();
|
||||
// 记录word自动生成的编号数据
|
||||
Map numberMap = new HashMap<String, Integer>();
|
||||
boolean menuCanAdd = false; // 判断当前目录下是否可以正常填写数据
|
||||
List<String> startDigitList = getStartDigit(elements, enumByValue);
|
||||
List<String> newStartDigitList = new ArrayList<>();
|
||||
for (String startDigit : startDigitList) {
|
||||
if(startDigit.endsWith(".")) {
|
||||
startDigit = startDigit.substring(0, startDigit.lastIndexOf("."));
|
||||
}
|
||||
newStartDigitList.add(startDigit);
|
||||
}
|
||||
String regex = "^[0-9]*$";
|
||||
boolean firstFlag = true;
|
||||
String preName = "";
|
||||
int preNameNum = 0;
|
||||
// for (IBodyElement element : elements) {
|
||||
for (int g=0; g< elements.size(); g++) {
|
||||
IBodyElement element = elements.get(g);
|
||||
// 段落
|
||||
if (element instanceof XWPFParagraph) {
|
||||
XWPFParagraph p = (XWPFParagraph) element;
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (XWPFRun xwrun : p.getRuns()) {
|
||||
VerticalAlign subscript = xwrun.getSubscript();
|
||||
String smalltext = xwrun.getText(0);
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(smalltext)){
|
||||
smalltext = smalltext.replace("<", "<").replace(">", ">");
|
||||
}
|
||||
if (smalltext==null){
|
||||
continue;
|
||||
}
|
||||
switch (subscript) {
|
||||
case BASELINE:
|
||||
stringBuilder.append(smalltext);
|
||||
break;
|
||||
case SUBSCRIPT:
|
||||
stringBuilder.append("<sub>").append(smalltext).append("</sub>");
|
||||
break;
|
||||
case SUPERSCRIPT:
|
||||
stringBuilder.append("<sup>").append(smalltext).append("</sup>");
|
||||
break;
|
||||
default:
|
||||
stringBuilder.append(smalltext);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理段落生成编号不识别问题
|
||||
String paragraphString = stringBuilder.toString();
|
||||
if (!org.apache.commons.lang.StringUtils.isEmpty(paragraphString)) {
|
||||
paragraphString = paragraphString.replace((char) 12288, ' ');
|
||||
paragraphString = paragraphString.replaceAll("\r\n","");
|
||||
paragraphString = paragraphString.replaceAll("\n","");
|
||||
paragraphString = paragraphString.trim();
|
||||
}
|
||||
if(org.apache.commons.lang.StringUtils.isEmpty(paragraphString)){
|
||||
// 处理当前段落仅为图片的情况
|
||||
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||
if (messageList.size() > 0) {
|
||||
addItermsConditionsImage(messageList.get(messageList.size() - 1), itemValList, p, imageBundleList);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (paragraphString.toLowerCase().contains("scope")) {
|
||||
String pp = paragraphString.replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "");
|
||||
if (!pp.substring(pp.length()-1).matches(regex)) {
|
||||
firstFlag = false;
|
||||
}
|
||||
}
|
||||
if (firstFlag) {
|
||||
continue;
|
||||
}
|
||||
// if (StringUtils.isNotEmpty(p.getNumLevelText())&& p.getNumLevelText().indexOf(".")>0) {
|
||||
// String numberParent = p.getNumLevelText().substring(0,p.getNumLevelText().lastIndexOf("."));
|
||||
// if (numberMap.containsKey(numberParent)){
|
||||
// Integer numbernow =(Integer)numberMap.get(numberParent)+1;
|
||||
// if (messageList != null && !messageList.isEmpty() && messageList.get(messageList.size()-1).getItemsNum().equals(numberParent + "." + String.valueOf(numbernow))){
|
||||
// numberMap.put(numberParent,numbernow+1);
|
||||
// paragraphString = numberParent + "." + String.valueOf(numbernow+1)+ p.getText();
|
||||
// } else {
|
||||
// numberMap.put(numberParent,numbernow);
|
||||
// paragraphString = numberParent + "." + String.valueOf(numbernow)+ p.getText();
|
||||
// }
|
||||
// } else {
|
||||
// numberMap.put(numberParent,1);
|
||||
// paragraphString = numberParent+".1"+ p.getText();
|
||||
// }
|
||||
// }
|
||||
//^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$
|
||||
ptest = Pattern.compile("^[\\d.]*$");
|
||||
//定义查看是否有编号,没有编号则按照上一个编号放置数据
|
||||
boolean hasGoIf = false;
|
||||
String startDigit = getOneStartDigit(paragraphString, enumByValue);
|
||||
for (int i = 0; i < nowStart.size(); i++) {
|
||||
// if (paragraphString.startsWith(nowStart.get(i))) {
|
||||
if (startDigit.equals(nowStart.get(i)) || startDigit.equals(nowStart.get(i)+ ".") || startDigit.equals(nowStart.get(i)+ "-") ) {
|
||||
// 判断一级 真的是标题还是干扰项 TODO
|
||||
if (startDigit.matches("^[0-9]*.$") || startDigit.matches("^[0-9]*-$")) {
|
||||
if(startDigit.endsWith(".")) {
|
||||
boolean result = fileSplitPdfService.judge(preName, preNameNum, startDigit.substring(0, startDigit.lastIndexOf(".")), g, newStartDigitList, ".");
|
||||
if (result) {
|
||||
continue;
|
||||
}
|
||||
} else if(startDigit.endsWith("-")) {
|
||||
boolean result = fileSplitPdfService.judge(preName, preNameNum, startDigit.substring(0, startDigit.lastIndexOf("-")), g, newStartDigitList, ".");
|
||||
if (result) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
boolean result = fileSplitPdfService.judge(preName, preNameNum, startDigit, g, newStartDigitList, ".");
|
||||
if (result) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断名称,如果大于10位,取十位,
|
||||
// String itemName = paragraphString.substring(nowStart.get(i).length()).length()>10?paragraphString.substring(nowStart.get(i).length(),nowStart.get(i).length()+10):paragraphString.substring(nowStart.get(i).length());
|
||||
String itemName = FileSplitUtils.getItemName(paragraphString, startDigit);
|
||||
List<String> clauseContent = new ArrayList<>();
|
||||
clauseContent.add(paragraphString);
|
||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), startDigit, itemName, clauseContent);
|
||||
|
||||
String[] numberStr = nowStart.get(i).split("\\.");
|
||||
// String numberStrTemp = numberStr[0].replace("S", "");
|
||||
|
||||
if (Integer.valueOf(numberStr[0]) > sarFileSplitInfoEO.getStopNumber()) {
|
||||
menuCanAdd = false;
|
||||
} else {
|
||||
// 增加一条数据,需要在数结构中加一条数据
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList(nowStart.get(i), treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, itemName, enumByValue);
|
||||
treeList.add(sarFileSplitMenuEO);
|
||||
preName = nowStart.get(i);
|
||||
preNameNum = g;
|
||||
message.setMenuId(sarFileSplitMenuEO.getId());
|
||||
// addItermsConditionsText(message, itemValList, paragraphString.substring(nowStart.get(i).length()));
|
||||
if(!org.apache.commons.lang.StringUtils.isEmpty(itemName) && !message.getItemsCondi().get(message.getItemsCondi().size() - 1).equals(paragraphString)){
|
||||
addItermsConditionsText(message, itemValList, paragraphString.substring(startDigit.length()), p.getAlignment());
|
||||
}
|
||||
messageList.add(message);
|
||||
nowStart = getNewNowStart(nowStart.get(i));
|
||||
menuCanAdd = true;
|
||||
}
|
||||
hasGoIf = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (!hasGoIf && menuCanAdd) {
|
||||
if (("annex1".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", ""))
|
||||
|| "annex1a".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "")))
|
||||
&& !messageList.get(messageList.size() - 1).getItemNum().equals("annex")) {
|
||||
|
||||
String appendixNum = messageList.get(messageList.size() - 1).getItemNum().split("\\.")[0];
|
||||
if (Integer.valueOf(appendixNum) + 1 <= sarFileSplitInfoEO.getStopNumber()) {
|
||||
String itemName = "annex";
|
||||
List<String> clauseContent = new ArrayList<>();
|
||||
clauseContent.add(paragraphString);
|
||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "annex", itemName, clauseContent);
|
||||
// 增加一条数据,需要在数结构中加一条数据
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList("annex", treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, "", enumByValue);
|
||||
addItermsConditionsText(message, itemValList, paragraphString, p.getAlignment());
|
||||
treeList.add(sarFileSplitMenuEO);
|
||||
message.setMenuId(sarFileSplitMenuEO.getId());
|
||||
messageList.add(message);
|
||||
nowStart = new ArrayList<>();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!p.getText().equals("")) {
|
||||
addItermsConditionsText(messageList.get(messageList.size() - 1), itemValList, p.getText(), p.getAlignment());
|
||||
}
|
||||
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||
addItermsConditionsImage(messageList.get(messageList.size() - 1), itemValList, p, imageBundleList);
|
||||
}
|
||||
}
|
||||
// }
|
||||
hasGoIf = true;
|
||||
}
|
||||
|
||||
// 判断是否直接跳出所有循环
|
||||
if (!menuCanAdd && messageList.size() > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (element instanceof XWPFTable) {
|
||||
if (messageList != null && !messageList.isEmpty()) {
|
||||
addItermsConditionsOfTable(messageList.get(messageList.size() - 1), itemValList, (XWPFTable) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
if (treeList.size() > 0 && messageList.size() > 0) {
|
||||
sarFileSplitMenuEOMapper.insertForeach(treeList);
|
||||
for (int i = 0; i < messageList.size(); i++) {
|
||||
messageList.get(i).setZhan3Shi4Shun4Xu4(String.valueOf(i+1));
|
||||
}
|
||||
iSarFileSplitItemsEOService.insertForeach(messageList);
|
||||
iSarFileSplitItemsValEOService.insertForeach(itemValList);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return treeList.size();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String paragraphString = "Article 1";
|
||||
String regex = "^[0-9]*$";
|
||||
if (paragraphString.toLowerCase().contains("article")) {
|
||||
String pp = paragraphString.replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "");
|
||||
if (pp.substring(pp.length()-1).matches(regex)) {
|
||||
System.out.println("ok");
|
||||
}
|
||||
}
|
||||
|
||||
FileSpiltService fileSpiltService = new FileSpiltService();
|
||||
System.out.println(fileSpiltService.getOneStartDigit(paragraphString, SplitFileTypeTypeEnum.EU));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ enterpriseDetailRoleCode: JTGLBZCXJS
|
||||
|
||||
# 文件下载加解密
|
||||
download:
|
||||
enable: true
|
||||
enable: false
|
||||
# 文件下载、预览拦截路径,多个以逗号分隔
|
||||
download_url: /sys/common/download/
|
||||
view_url: /sys/common/view/
|
||||
|
||||
Reference in New Issue
Block a user