feat: 标准重新拆分2

This commit is contained in:
2024-09-16 15:37:34 +08:00
parent c893dd565c
commit 1ce85ca16d
3 changed files with 225 additions and 211 deletions
@@ -496,6 +496,7 @@ public class DocumentSplitController {
@ApiOperation(value = "标准拆分详情-查询所有拆分错误的标准") @ApiOperation(value = "标准拆分详情-查询所有拆分错误的标准")
@GetMapping("/fixAllBadSplit") @GetMapping("/fixAllBadSplit")
public Result<String> fixAllBadSplit() { public Result<String> fixAllBadSplit() {
return Result.OK(MessageUtils.getMessage(ResultCommon.OK), documentSplitService.fixAllBadSplit()); documentSplitService.fixAllBadSplit();
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
} }
} }
@@ -246,5 +246,5 @@ public interface IDocumentSplitService extends IService<LawsDocumentSplit> {
*/ */
void deleteBatchTitle(String ids); void deleteBatchTitle(String ids);
String fixAllBadSplit(); void fixAllBadSplit();
} }
@@ -106,6 +106,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -158,6 +159,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
private static final String MENU_ID = "menu_id"; private static final String MENU_ID = "menu_id";
private static final String CREATE_TIME = "create_time"; private static final String CREATE_TIME = "create_time";
private static final String SPLIT_STATUS = "split_status"; private static final String SPLIT_STATUS = "split_status";
public DocumentSplitServiceImpl(DocumentSplitMapper documentSplitMapper, public DocumentSplitServiceImpl(DocumentSplitMapper documentSplitMapper,
ISarFileSplitInfoService sarFileSplitInfoService, ISarFileSplitInfoService sarFileSplitInfoService,
LawsCommonMapper lawsCommonMapper, LawsCommonMapper lawsCommonMapper,
@@ -223,7 +225,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
private void setData(List<DocumentSplitInfo> data) { private void setData(List<DocumentSplitInfo> data) {
if (CollectionUtils.isEmpty(data)){ if (CollectionUtils.isEmpty(data)) {
return; return;
} }
// 获取标准信息 // 获取标准信息
@@ -238,7 +240,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
List<String> authorList = data.stream().map(DocumentSplitInfo::getAuthor).distinct().collect(Collectors.toList()); List<String> authorList = data.stream().map(DocumentSplitInfo::getAuthor).distinct().collect(Collectors.toList());
List<String> createByList = data.stream().map(DocumentSplitInfo::getCreateBy).distinct().collect(Collectors.toList()); List<String> createByList = data.stream().map(DocumentSplitInfo::getCreateBy).distinct().collect(Collectors.toList());
List<SysUser> sysUserList = new ArrayList<>(); List<SysUser> sysUserList = new ArrayList<>();
if (!CollectionUtils.isEmpty(authorList) || !CollectionUtils.isEmpty(createByList)){ if (!CollectionUtils.isEmpty(authorList) || !CollectionUtils.isEmpty(createByList)) {
sysUserList = sysUserService.list( sysUserList = sysUserService.list(
new LambdaQueryWrapper<SysUser>() new LambdaQueryWrapper<SysUser>()
.in(!CollectionUtils.isEmpty(authorList), SysUser::getId, authorList) .in(!CollectionUtils.isEmpty(authorList), SysUser::getId, authorList)
@@ -247,16 +249,16 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
for (DocumentSplitInfo documentSplitInfo : data) { for (DocumentSplitInfo documentSplitInfo : data) {
String standardId = documentSplitInfo.getStandardId(); String standardId = documentSplitInfo.getStandardId();
if (StringUtils.isNotBlank(standardId)){ if (StringUtils.isNotBlank(standardId)) {
if (domesticMap.containsKey(documentSplitInfo.getStandardId())){ if (domesticMap.containsKey(documentSplitInfo.getStandardId())) {
if (!CollectionUtils.isEmpty(domesticMap.get(standardId))){ if (!CollectionUtils.isEmpty(domesticMap.get(standardId))) {
LawsDomesticStandard lawsDomesticStandard = domesticMap.get(standardId).get(0); LawsDomesticStandard lawsDomesticStandard = domesticMap.get(standardId).get(0);
documentSplitInfo.setSerialNumber(lawsDomesticStandard.getStandardNumber()); documentSplitInfo.setSerialNumber(lawsDomesticStandard.getStandardNumber());
documentSplitInfo.setTitle(lawsDomesticStandard.getStandardName()); documentSplitInfo.setTitle(lawsDomesticStandard.getStandardName());
} }
documentSplitInfo.setSplitStandardSource("1"); documentSplitInfo.setSplitStandardSource("1");
}else if (enterpriseMap.containsKey(documentSplitInfo.getStandardId())){ } else if (enterpriseMap.containsKey(documentSplitInfo.getStandardId())) {
if (!CollectionUtils.isEmpty(enterpriseMap.get(standardId))){ if (!CollectionUtils.isEmpty(enterpriseMap.get(standardId))) {
LawsEnterpriseStandard lawsEnterpriseStandard = enterpriseMap.get(standardId).get(0); LawsEnterpriseStandard lawsEnterpriseStandard = enterpriseMap.get(standardId).get(0);
documentSplitInfo.setSerialNumber(lawsEnterpriseStandard.getStandardNumber()); documentSplitInfo.setSerialNumber(lawsEnterpriseStandard.getStandardNumber());
documentSplitInfo.setTitle(lawsEnterpriseStandard.getStandardName()); documentSplitInfo.setTitle(lawsEnterpriseStandard.getStandardName());
@@ -264,7 +266,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
documentSplitInfo.setSplitStandardSource("3"); documentSplitInfo.setSplitStandardSource("3");
} }
} }
if (!CollectionUtils.isEmpty(sysUserList)){ if (!CollectionUtils.isEmpty(sysUserList)) {
Optional<SysUser> first = sysUserList.stream() Optional<SysUser> first = sysUserList.stream()
.filter(v -> v.getUsername().equals(documentSplitInfo.getCreateBy())).findFirst(); .filter(v -> v.getUsername().equals(documentSplitInfo.getCreateBy())).findFirst();
first.ifPresent(v -> documentSplitInfo.setCreateBy(v.getId())); first.ifPresent(v -> documentSplitInfo.setCreateBy(v.getId()));
@@ -272,7 +274,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
Optional<SysUser> optionalSysUser = sysUserList.stream() Optional<SysUser> optionalSysUser = sysUserList.stream()
.filter(v -> v.getId().equals(documentSplitInfo.getAuthor())).findFirst(); .filter(v -> v.getId().equals(documentSplitInfo.getAuthor())).findFirst();
optionalSysUser.ifPresent(v -> { optionalSysUser.ifPresent(v -> {
if (!"云平台".equals(documentSplitInfo.getAuthor())){ if (!"云平台".equals(documentSplitInfo.getAuthor())) {
documentSplitInfo.setAuthor(v.calcNameWorkNo()); documentSplitInfo.setAuthor(v.calcNameWorkNo());
} }
}); });
@@ -295,9 +297,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
LambdaUpdateWrapper<SarFileSplitInfoEO> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<SarFileSplitInfoEO> updateWrapper = new LambdaUpdateWrapper<>();
List<String> ids; List<String> ids;
// 获取id集合 // 获取id集合
if (StringUtils.isNotBlank(documentSplitInfo.getIds())){ if (StringUtils.isNotBlank(documentSplitInfo.getIds())) {
ids = Arrays.asList(documentSplitInfo.getIds().split(",")); ids = Arrays.asList(documentSplitInfo.getIds().split(","));
}else { } else {
List<DocumentSplitInfo> documentSplitInfos = queryByList(documentSplitInfo); List<DocumentSplitInfo> documentSplitInfos = queryByList(documentSplitInfo);
ids = documentSplitInfos.stream().map(DocumentSplitInfo::getId).collect(Collectors.toList()); ids = documentSplitInfos.stream().map(DocumentSplitInfo::getId).collect(Collectors.toList());
} }
@@ -314,23 +316,24 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
/** /**
* 判断操作权限 * 判断操作权限
*
* @param ids * @param ids
*/ */
@Override @Override
public void checkOutOperation(List<String> ids) { public void checkOutOperation(List<String> ids) {
// 登陆人信息 // 登陆人信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser.getRoleIds().contains("admin")){ if (sysUser.getRoleIds().contains("admin")) {
return; return;
} }
List<SarFileSplitInfoEO> sarFileSplitInfoEOS = sarFileSplitInfoService.listByIds(ids); List<SarFileSplitInfoEO> sarFileSplitInfoEOS = sarFileSplitInfoService.listByIds(ids);
for (SarFileSplitInfoEO sarFileSplitInfoEO : sarFileSplitInfoEOS) { for (SarFileSplitInfoEO sarFileSplitInfoEO : sarFileSplitInfoEOS) {
String createBy = sarFileSplitInfoEO.getCreateBy(); String createBy = sarFileSplitInfoEO.getCreateBy();
String author = sarFileSplitInfoEO.getAuthor(); String author = sarFileSplitInfoEO.getAuthor();
if (!sysUser.getUsername().equals(createBy) || !sysUser.getId().equals(author)){ if (!sysUser.getUsername().equals(createBy) || !sysUser.getId().equals(author)) {
if(LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) { if (LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) {
throw new JeroBootException("只能删除有操作权限的数据!"); throw new JeroBootException("只能删除有操作权限的数据!");
}else{ } else {
throw new JeroBootException("You can delete only the data that you have permission to operate!"); throw new JeroBootException("You can delete only the data that you have permission to operate!");
} }
} }
@@ -343,7 +346,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
isHorizontalOverstep(parameter.get(INFO_ID).toString()); isHorizontalOverstep(parameter.get(INFO_ID).toString());
} }
// 企标权限校验 // 企标权限校验
if (parameter.containsKey("serialNumber")){ if (parameter.containsKey("serialNumber")) {
SarFileSplitInfoEO sarFileSplitInfoEO = new SarFileSplitInfoEO(); SarFileSplitInfoEO sarFileSplitInfoEO = new SarFileSplitInfoEO();
sarFileSplitInfoEO.setSerialNumber((String) parameter.get("serialNumber")); sarFileSplitInfoEO.setSerialNumber((String) parameter.get("serialNumber"));
enterpriseCheck(sarFileSplitInfoEO); enterpriseCheck(sarFileSplitInfoEO);
@@ -377,7 +380,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
private String orderBy(Map<String, Object> parameter, String selectCondition, List<LawsTag> fieldListSelect) { private String orderBy(Map<String, Object> parameter, String selectCondition, List<LawsTag> fieldListSelect) {
StringBuilder sb = new StringBuilder(selectCondition); StringBuilder sb = new StringBuilder(selectCondition);
if (parameter.containsKey("column")){ if (parameter.containsKey("column")) {
sb.append(" order by "); sb.append(" order by ");
String column = (String) parameter.get("column"); String column = (String) parameter.get("column");
String order = (String) parameter.get("order"); String order = (String) parameter.get("order");
@@ -385,15 +388,15 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
Optional<LawsTag> lawsTag = fieldListSelect.stream().filter(o -> column.equals(o.getDbFieldName())).findFirst(); Optional<LawsTag> lawsTag = fieldListSelect.stream().filter(o -> column.equals(o.getDbFieldName())).findFirst();
lawsTag.ifPresent(l -> { lawsTag.ifPresent(l -> {
// 多日期特殊处理 // 多日期特殊处理
if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){ if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())) {
sb.append(DocumentSplitCommon.STR_TO_DATE_BEGIN + "substring_index(") sb.append(DocumentSplitCommon.STR_TO_DATE_BEGIN + "substring_index(")
.append(l.getDbFieldName()).append(", ',', -1)").append(",'%Y-%m-%d')"); .append(l.getDbFieldName()).append(", ',', -1)").append(",'%Y-%m-%d')");
}else { } else {
sb.append(column); sb.append(column);
} }
}); });
sb.append(" ").append(order); sb.append(" ").append(order);
}else { } else {
// 默认排序 // 默认排序
sb.append(" order by display_seq asc, sort_number is null, sort_number asc"); sb.append(" order by display_seq asc, sort_number is null, sort_number asc");
} }
@@ -430,10 +433,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
for (Map<String, Object> map : records) { for (Map<String, Object> map : records) {
for (LawsTag lawsTag : lawsTags) { for (LawsTag lawsTag : lawsTags) {
String dbFieldName = lawsTag.getDbFieldName(); String dbFieldName = lawsTag.getDbFieldName();
if (map.containsKey(dbFieldName)){ if (map.containsKey(dbFieldName)) {
// 字典查找 // 字典查找
SysDict sysDict = sysDictService.getById(lawsTag.getDictId()); SysDict sysDict = sysDictService.getById(lawsTag.getDictId());
if (!Objects.isNull(sysDict)){ if (!Objects.isNull(sysDict)) {
setDicText(map, dbFieldName, sysDict); setDicText(map, dbFieldName, sysDict);
} }
} }
@@ -445,13 +448,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
private void specialTranslate(Map<String, Object> map) { private void specialTranslate(Map<String, Object> map) {
// 零部件翻译 // 零部件翻译
if (map.containsKey("applicable_components")){ if (map.containsKey("applicable_components")) {
String applicableComponents = (String) map.get("applicable_components"); String applicableComponents = (String) map.get("applicable_components");
List<PartName> partNames = partNameService.queryEcho(applicableComponents); List<PartName> partNames = partNameService.queryEcho(applicableComponents);
map.put("applicable_components_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(","))); map.put("applicable_components_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(",")));
} }
// 属性标识翻译 // 属性标识翻译
if (map.containsKey("property_tag")){ if (map.containsKey("property_tag")) {
String propertyTag = (String) map.get("property_tag"); String propertyTag = (String) map.get("property_tag");
List<LawsLabelDatabase> lawsLabelDatabases = lawsLabelDatabaseService.queryByCodes(propertyTag); List<LawsLabelDatabase> lawsLabelDatabases = lawsLabelDatabaseService.queryByCodes(propertyTag);
map.put("property_tag_dictText", lawsLabelDatabases.stream().map(LawsLabelDatabase::getName).collect(Collectors.joining(","))); map.put("property_tag_dictText", lawsLabelDatabases.stream().map(LawsLabelDatabase::getName).collect(Collectors.joining(",")));
@@ -464,7 +467,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
.in(SysDictItem::getItemValue, Arrays.asList(map.get(dbFieldName).toString().split(","))); .in(SysDictItem::getItemValue, Arrays.asList(map.get(dbFieldName).toString().split(",")));
// 字典值查询 // 字典值查询
List<SysDictItem> list = sysDictItemService.list(queryWrapper); List<SysDictItem> list = sysDictItemService.list(queryWrapper);
if(!list.isEmpty()){ if (!list.isEmpty()) {
List<String> itemTextList = list.stream().map(SysDictItem::getItemText).collect(Collectors.toList()); List<String> itemTextList = list.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
map.put(dbFieldName + DocumentSplitCommon.DIC_TEXT, String.join(",", itemTextList)); map.put(dbFieldName + DocumentSplitCommon.DIC_TEXT, String.join(",", itemTextList));
} }
@@ -481,10 +484,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
//拆分 //拆分
int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT); int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT);
if(count == -1){ if (count == -1) {
if(LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) { if (LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) {
throw new JeroBootException("文档格式错误,请检查文档内容!"); throw new JeroBootException("文档格式错误,请检查文档内容!");
}else{ } else {
throw new JeroBootException("The document format is wrong. Please check the document content!"); throw new JeroBootException("The document format is wrong. Please check the document content!");
} }
} }
@@ -497,7 +500,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 管理员有所有企标的权限 // 管理员有所有企标的权限
List<String> roleIdList = Arrays.asList(sysUser.getRoleIds().split(",")); List<String> roleIdList = Arrays.asList(sysUser.getRoleIds().split(","));
Collection<String> intersection = CollectionUtils.intersection(adminRoleCodeList, roleIdList); Collection<String> intersection = CollectionUtils.intersection(adminRoleCodeList, roleIdList);
if (!intersection.isEmpty()){ if (!intersection.isEmpty()) {
// 有权限 // 有权限
return; return;
} }
@@ -505,9 +508,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
LawsEnterpriseStandard lawsEnterpriseStandard = lawsEnterpriseStandardService.getOne( LawsEnterpriseStandard lawsEnterpriseStandard = lawsEnterpriseStandardService.getOne(
new LambdaQueryWrapper<LawsEnterpriseStandard>() new LambdaQueryWrapper<LawsEnterpriseStandard>()
.eq(LawsEnterpriseStandard::getStandardNumber, sarFileSplitInfoEO.getSerialNumber())); .eq(LawsEnterpriseStandard::getStandardNumber, sarFileSplitInfoEO.getSerialNumber()));
if (!Objects.isNull(lawsEnterpriseStandard)){ if (!Objects.isNull(lawsEnterpriseStandard)) {
String id = lawsEnterpriseStandard.getId(); String id = lawsEnterpriseStandard.getId();
if (StringUtils.isBlank(sarFileSplitInfoEO.getStandardId())){ if (StringUtils.isBlank(sarFileSplitInfoEO.getStandardId())) {
sarFileSplitInfoEO.setStandardId(id); sarFileSplitInfoEO.setStandardId(id);
} }
// 登陆人所在部门 // 登陆人所在部门
@@ -530,13 +533,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthExpireDate); tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthExpireDate);
tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthDept); tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthDept);
List<EnterpriseStandardAuthDept> tempAuthDeptList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper); List<EnterpriseStandardAuthDept> tempAuthDeptList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper);
if (!tempAuthDeptList.isEmpty()){ if (!tempAuthDeptList.isEmpty()) {
// 有权限 // 有权限
return; return;
} }
tempAuthDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date); tempAuthDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date);
List<EnterpriseStandardAuthDept> authDeptExpireDateList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper); List<EnterpriseStandardAuthDept> authDeptExpireDateList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper);
if (!authDeptExpireDateList.isEmpty()){ if (!authDeptExpireDateList.isEmpty()) {
// 有权限 // 有权限
return; return;
} }
@@ -564,7 +567,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 临时权限 // 临时权限
if (authUserList.stream().map(EnterpriseStandardAuthUser::getStandardId).collect(Collectors.toList()).contains(id)) { if (authUserList.stream().map(EnterpriseStandardAuthUser::getStandardId).collect(Collectors.toList()).contains(id)) {
// 有权限 // 有权限
return; return;
} }
// 等级分类 // 等级分类
String gradeClassification = lawsEnterpriseStandard.getGradeClassification(); String gradeClassification = lawsEnterpriseStandard.getGradeClassification();
@@ -601,9 +604,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
private void noAccess() { private void noAccess() {
if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) { if (LanguageEnum.CN.equals(MessageUtils.getLanguage())) {
throw new JeroBootException("无权限!"); throw new JeroBootException("无权限!");
}else{ } else {
throw new JeroBootException("No access!"); throw new JeroBootException("No access!");
} }
} }
@@ -629,18 +632,18 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
List<SarFileSplitItemsValEO> articlesList = JSON.parseArray(JSON.toJSONString(parameter.get(INTERPRETATION_ARTICLES_LIST)), SarFileSplitItemsValEO.class); List<SarFileSplitItemsValEO> articlesList = JSON.parseArray(JSON.toJSONString(parameter.get(INTERPRETATION_ARTICLES_LIST)), SarFileSplitItemsValEO.class);
parameter.remove(INTERPRETATION_ARTICLES_LIST); parameter.remove(INTERPRETATION_ARTICLES_LIST);
parameter.putIfAbsent(INTERPRETATION_ARTICLES, ""); parameter.putIfAbsent(INTERPRETATION_ARTICLES, "");
parameter.forEach((k, v) ->{ parameter.forEach((k, v) -> {
// 条文内容拼接 // 条文内容拼接
if (ITEM_CONTENT.equals(k)){ if (ITEM_CONTENT.equals(k)) {
v = itemContentJoin(valList, (String) parameter.get(ID)); v = itemContentJoin(valList, (String) parameter.get(ID));
} }
// 条文解读 // 条文解读
if (INTERPRETATION_ARTICLES.equals(k)){ if (INTERPRETATION_ARTICLES.equals(k)) {
v = articlesJoin(articlesList, (String) parameter.get(ID)); v = articlesJoin(articlesList, (String) parameter.get(ID));
} }
// 修改字段 // 修改字段
String updateValue = getUpdateValue(finalFieldList, k, (String) v); String updateValue = getUpdateValue(finalFieldList, k, (String) v);
if (StringUtils.isNotBlank(updateValue)){ if (StringUtils.isNotBlank(updateValue)) {
updateSet.append(updateValue).append(","); updateSet.append(updateValue).append(",");
} }
}); });
@@ -655,7 +658,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
//条文解读更新 //条文解读更新
// 删除旧数据 // 删除旧数据
documentSplitMapper.deleteItemsValByItemId((String) parameter.get(ID), DocumentSplitCommon.INTERPRETATION); documentSplitMapper.deleteItemsValByItemId((String) parameter.get(ID), DocumentSplitCommon.INTERPRETATION);
if (!Objects.isNull(articlesList) && !articlesList.isEmpty()){ if (!Objects.isNull(articlesList) && !articlesList.isEmpty()) {
// 添加新数据 // 添加新数据
documentSplitMapper.addBatchItemsVal(articlesList); documentSplitMapper.addBatchItemsVal(articlesList);
} }
@@ -663,16 +666,16 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 条目信息更新 // 条目信息更新
// 删除旧数据 // 删除旧数据
documentSplitMapper.deleteItemsValByItemId((String) parameter.get(ID), ""); documentSplitMapper.deleteItemsValByItemId((String) parameter.get(ID), "");
if (!Objects.isNull(valList) && !valList.isEmpty()){ if (!Objects.isNull(valList) && !valList.isEmpty()) {
// 添加新数据 // 添加新数据
documentSplitMapper.addBatchItemsVal(valList); documentSplitMapper.addBatchItemsVal(valList);
} }
} }
private void mapValueNullToString(Map<String, Object> parameter) { private void mapValueNullToString(Map<String, Object> parameter) {
if (parameter!= null){ if (parameter != null) {
parameter.forEach((k, v) ->{ parameter.forEach((k, v) -> {
if (Objects.isNull(v)){ if (Objects.isNull(v)) {
parameter.put(k, ""); parameter.put(k, "");
} }
}); });
@@ -683,9 +686,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
StringBuilder valContent = new StringBuilder(); StringBuilder valContent = new StringBuilder();
int index = 0; int index = 0;
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (!Objects.isNull(articlesList) && !articlesList.isEmpty()){ if (!Objects.isNull(articlesList) && !articlesList.isEmpty()) {
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : articlesList) { for (SarFileSplitItemsValEO sarFileSplitItemsValEO : articlesList) {
index ++; index++;
valContent.append("<p>").append(sarFileSplitItemsValEO.getItemContent()).append("</p>"); valContent.append("<p>").append(sarFileSplitItemsValEO.getItemContent()).append("</p>");
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20()); sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
sarFileSplitItemsValEO.setItemId(itemId); sarFileSplitItemsValEO.setItemId(itemId);
@@ -703,13 +706,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
private String itemContentJoin(List<SarFileSplitItemsValEO> valList, String itemId) { private String itemContentJoin(List<SarFileSplitItemsValEO> valList, String itemId) {
StringBuilder valContent = new StringBuilder(); StringBuilder valContent = new StringBuilder();
if (!Objects.isNull(valList) && !valList.isEmpty()){ if (!Objects.isNull(valList) && !valList.isEmpty()) {
int index = 0; int index = 0;
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : valList) { for (SarFileSplitItemsValEO sarFileSplitItemsValEO : valList) {
// 条文内容拼接 // 条文内容拼接
if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType())) { if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType())) {
if (StringUtils.isNotBlank(sarFileSplitItemsValEO.getItemContent())){ if (StringUtils.isNotBlank(sarFileSplitItemsValEO.getItemContent())) {
sarFileSplitItemsValEO.setItemContent(sarFileSplitItemsValEO.getItemContent() sarFileSplitItemsValEO.setItemContent(sarFileSplitItemsValEO.getItemContent()
.replace("<", "&lt;").replace(">", "&gt;")); .replace("<", "&lt;").replace(">", "&gt;"));
} }
@@ -743,10 +746,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
AtomicReference<String> sql = new AtomicReference<>(""); AtomicReference<String> sql = new AtomicReference<>("");
lawsTag.ifPresent(l -> { lawsTag.ifPresent(l -> {
// 构建修改字段 // 构建修改字段
if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){ if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())) {
// 多日期 // 多日期
sql.set(new DateManyConditionImpl().buildUpdate(l.getDbFieldName(), v)); sql.set(new DateManyConditionImpl().buildUpdate(l.getDbFieldName(), v));
}else { } else {
sql.set(new UniversalImpl().buildUpdate(l.getDbFieldName(), v)); sql.set(new UniversalImpl().buildUpdate(l.getDbFieldName(), v));
} }
}); });
@@ -775,12 +778,12 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
parameter.forEach((k, v) -> { parameter.forEach((k, v) -> {
// 条文解读 // 条文解读
if (INTERPRETATION_ARTICLES.equals(k)){ if (INTERPRETATION_ARTICLES.equals(k)) {
v = articlesJoin(articlesList, (String) parameter.get(ID)); v = articlesJoin(articlesList, (String) parameter.get(ID));
} }
// 修改字段 // 修改字段
String updateValue = getUpdateValue(finalFieldList, k, (String) v); String updateValue = getUpdateValue(finalFieldList, k, (String) v);
if (StringUtils.isNotBlank(updateValue)){ if (StringUtils.isNotBlank(updateValue)) {
updateSet.append(updateValue).append(","); updateSet.append(updateValue).append(",");
} }
}); });
@@ -790,11 +793,11 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
updateSet.deleteCharAt(updateSet.length() - 1); updateSet.deleteCharAt(updateSet.length() - 1);
// where条件 // where条件
String updateCondition = ""; String updateCondition = "";
if (parameter.containsKey("ids")){ if (parameter.containsKey("ids")) {
String ids = (String) parameter.get("ids"); String ids = (String) parameter.get("ids");
List<String> list = Arrays.asList(ids.split(",")); List<String> list = Arrays.asList(ids.split(","));
updateCondition = "id in ('" + String.join("','", list) + "')"; updateCondition = "id in ('" + String.join("','", list) + "')";
}else { } else {
String infoId = (String) parameter.get(INFO_ID); String infoId = (String) parameter.get(INFO_ID);
updateCondition = "info_id = " + "'" + infoId + "'"; updateCondition = "info_id = " + "'" + infoId + "'";
} }
@@ -803,7 +806,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 条文解读更新 // 条文解读更新
// 删除旧数据 // 删除旧数据
documentSplitMapper.deleteItemsValByItemIds((String) parameter.get("ids"), DocumentSplitCommon.INTERPRETATION); documentSplitMapper.deleteItemsValByItemIds((String) parameter.get("ids"), DocumentSplitCommon.INTERPRETATION);
if (!Objects.isNull(articlesList) && !articlesList.isEmpty()){ if (!Objects.isNull(articlesList) && !articlesList.isEmpty()) {
// 添加新数据 // 添加新数据
documentSplitMapper.addBatchItemsVal(articlesList); documentSplitMapper.addBatchItemsVal(articlesList);
} }
@@ -843,12 +846,12 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
String content = firstData.get(ITEM_CONTENT) + mergeData(listMap, ITEM_CONTENT); String content = firstData.get(ITEM_CONTENT) + mergeData(listMap, ITEM_CONTENT);
String updateByAndUpdateTime = new UniversalImpl().getUpdateByAndUpdateTime(); String updateByAndUpdateTime = new UniversalImpl().getUpdateByAndUpdateTime();
String updateSet = updateByAndUpdateTime + String updateSet = updateByAndUpdateTime +
"," + ITEM_TITLE + " = " + "' "+ title + "'" + "," + ITEM_TITLE + " = " + "' " + title + "'" +
"," + ITEM_CONTENT + " = " + "'" + content + "'"; "," + ITEM_CONTENT + " = " + "'" + content + "'";
String updateCondition = "id = " + "'" + firstData.get(ID) + "'"; String updateCondition = "id = " + "'" + firstData.get(ID) + "'";
// 修改数据 // 修改数据
documentSplitMapper.editDocumentSplitDetail(updateSet, updateCondition); documentSplitMapper.editDocumentSplitDetail(updateSet, updateCondition);
List<String> otherIds = listMap.stream().map(v -> (String)v.get(ID)).collect(Collectors.toList()); List<String> otherIds = listMap.stream().map(v -> (String) v.get(ID)).collect(Collectors.toList());
// 删除旧数据 // 删除旧数据
lawsDocumentSplitMapper.deleteBatchIds(otherIds); lawsDocumentSplitMapper.deleteBatchIds(otherIds);
@@ -859,14 +862,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!menuIdList.isEmpty()){ if (!menuIdList.isEmpty()) {
// 判断被合并条款之前有没有复制过,复制过则不删除相关目录 // 判断被合并条款之前有没有复制过,复制过则不删除相关目录
List<LawsDocumentSplit> lawsDocumentSplits = documentSplitMapper.queryLawsDocumentSplitInIds(Collections.singletonList((String) firstData.get(ID))); List<LawsDocumentSplit> lawsDocumentSplits = documentSplitMapper.queryLawsDocumentSplitInIds(Collections.singletonList((String) firstData.get(ID)));
List<String> menuIds = documentSplitMapper.queryLawsDocumentSplitGroupByMenuId(lawsDocumentSplits.get(0).getInfoId()); List<String> menuIds = documentSplitMapper.queryLawsDocumentSplitGroupByMenuId(lawsDocumentSplits.get(0).getInfoId());
if (CollectionUtils.isNotEmpty(menuIds)){ if (CollectionUtils.isNotEmpty(menuIds)) {
menuIdList = menuIdList.stream().filter(v -> !menuIds.contains(v)).collect(Collectors.toList()); menuIdList = menuIdList.stream().filter(v -> !menuIds.contains(v)).collect(Collectors.toList());
} }
if (!menuIdList.isEmpty()){ if (!menuIdList.isEmpty()) {
// 删除旧数据 // 删除旧数据
documentSplitMapper.sarFileSplitMenuDeleteByIdList(menuIdList); documentSplitMapper.sarFileSplitMenuDeleteByIdList(menuIdList);
} }
@@ -882,7 +885,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
List<SarFileSplitItemsValEO> sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId((String) firstData.get(ID), ""); List<SarFileSplitItemsValEO> sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId((String) firstData.get(ID), "");
// 第一条数据信息的最大的排序字段值 // 第一条数据信息的最大的排序字段值
Optional<SarFileSplitItemsValEO> sarFileSplitItemsValEOOptional = sarFileSplitItemsValEOS.stream().sorted(Comparator.comparing(v -> Integer.valueOf(String.valueOf(v.getDisplaySeq())))).findFirst(); Optional<SarFileSplitItemsValEO> sarFileSplitItemsValEOOptional = sarFileSplitItemsValEOS.stream().sorted(Comparator.comparing(v -> Integer.valueOf(String.valueOf(v.getDisplaySeq())))).findFirst();
sarFileSplitItemsValEOOptional.ifPresent(v ->{ sarFileSplitItemsValEOOptional.ifPresent(v -> {
// 排序字段 // 排序字段
Integer displaySeq = v.getDisplaySeq(); Integer displaySeq = v.getDisplaySeq();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -895,7 +898,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 修改数据 // 修改数据
sarFileSplitItemsValEOMapper.updateByPrimaryKeySelective(fileSplitItemsValEO); sarFileSplitItemsValEOMapper.updateByPrimaryKeySelective(fileSplitItemsValEO);
} }
} ); });
} }
@Override @Override
@@ -924,7 +927,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
@Override @Override
public void deleteBatchDocumentSplitDetail(Map<String, Object> parameter) { public void deleteBatchDocumentSplitDetail(Map<String, Object> parameter) {
if (parameter.containsKey(IDS)){ if (parameter.containsKey(IDS)) {
String ids = (String) parameter.get(IDS); String ids = (String) parameter.get(IDS);
String[] list = ids.split(","); String[] list = ids.split(",");
for (String id : list) { for (String id : list) {
@@ -981,14 +984,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
@Override @Override
public List<SarFileSplitItemsValEO> queryItemsValList(String itemId) { public List<SarFileSplitItemsValEO> queryItemsValList(String itemId) {
List<SarFileSplitItemsValEO> sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId(itemId, ""); List<SarFileSplitItemsValEO> sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId(itemId, "");
if (!Objects.isNull(sarFileSplitItemsValEOS) && !sarFileSplitItemsValEOS.isEmpty()){ if (!Objects.isNull(sarFileSplitItemsValEOS) && !sarFileSplitItemsValEOS.isEmpty()) {
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : sarFileSplitItemsValEOS) { for (SarFileSplitItemsValEO sarFileSplitItemsValEO : sarFileSplitItemsValEOS) {
String imgPath = sarFileSplitItemsValEO.getItemContent(); String imgPath = sarFileSplitItemsValEO.getItemContent();
if (DocumentSplitCommon.IMG.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)) { if (DocumentSplitCommon.IMG.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)) {
String imgName = imgPath.substring(imgPath.lastIndexOf("/") + 1); String imgName = imgPath.substring(imgPath.lastIndexOf("/") + 1);
sarFileSplitItemsValEO.setImgName(imgName); sarFileSplitItemsValEO.setImgName(imgName);
} }
if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)){ if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)) {
sarFileSplitItemsValEO.setItemContent(HtmlUtils.htmlUnescape(sarFileSplitItemsValEO.getItemContent())); sarFileSplitItemsValEO.setItemContent(HtmlUtils.htmlUnescape(sarFileSplitItemsValEO.getItemContent()));
} }
} }
@@ -1009,7 +1012,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 水平越权 // 水平越权
isHorizontalOverstep(request.getParameter("infoId")); isHorizontalOverstep(request.getParameter("infoId"));
try (Workbook workbook = new XSSFWorkbook()){ try (Workbook workbook = new XSSFWorkbook()) {
String fileName = "拆分导入模版下载.xlsx"; String fileName = "拆分导入模版下载.xlsx";
// sheet页 // sheet页
XSSFSheet sheet = (XSSFSheet) workbook.createSheet("拆分导入模版"); XSSFSheet sheet = (XSSFSheet) workbook.createSheet("拆分导入模版");
@@ -1063,37 +1066,36 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
//删除指定文件夹 //删除指定文件夹
FileUtils.deleteFolders(replacePath); FileUtils.deleteFolders(replacePath);
}catch (Exception e){ } catch (Exception e) {
throw new JeroBootException("下载文件失败!"); throw new JeroBootException("下载文件失败!");
} }
} }
/** /**
* private static void returnOutPutStream(HttpServletResponse response, String fileName, String zipPath) throws IOException { * private static void returnOutPutStream(HttpServletResponse response, String fileName, String zipPath) throws IOException {
* ServletOutputStream outputStream = null; * ServletOutputStream outputStream = null;
* try (InputStream in = Files.newInputStream(Paths.get(zipPath));){ * try (InputStream in = Files.newInputStream(Paths.get(zipPath));){
* response.reset(); * response.reset();
* response.setContentType("application/ostet-stream"); * response.setContentType("application/ostet-stream");
* response.setHeader("content-type", "application/octet-stream"); * response.setHeader("content-type", "application/octet-stream");
* response.setContentType("application/octet-stream"); * response.setContentType("application/octet-stream");
* response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + new String((fileName + ".zip").getBytes("GB2312"), StandardCharsets.ISO_8859_1)); * response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + new String((fileName + ".zip").getBytes("GB2312"), StandardCharsets.ISO_8859_1));
* response.setCharacterEncoding("UTF-8"); * response.setCharacterEncoding("UTF-8");
* outputStream = response.getOutputStream(); * outputStream = response.getOutputStream();
* //创建存放文件内容的数组 * //创建存放文件内容的数组
* byte[] buff = new byte[1024]; * byte[] buff = new byte[1024];
* //所读取的内容使用n来接收 * //所读取的内容使用n来接收
* int n; * int n;
* //当没有读取完时,继续读取,循环 * //当没有读取完时,继续读取,循环
* while ((n = in.read(buff)) != -1) { * while ((n = in.read(buff)) != -1) {
* //将字节数组的数据全部写入到输出流中 * //将字节数组的数据全部写入到输出流中
* outputStream.write(buff, 0, n); * outputStream.write(buff, 0, n);
* } * }
* //强制将缓存区的数据进行输出 * //强制将缓存区的数据进行输出
* outputStream.println(); * outputStream.println();
* } * }
* outputStream.close(); * outputStream.close();
* } * }
*
*/ */
private void generateExcel(Workbook workbook, String fileName, String replacePath) throws IOException { private void generateExcel(Workbook workbook, String fileName, String replacePath) throws IOException {
@@ -1105,9 +1107,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 生成excel文件路径 // 生成excel文件路径
String excelPath = replacePath + File.separator + fileName; String excelPath = replacePath + File.separator + fileName;
// 写出excel文件 // 写出excel文件
try (FileOutputStream fos = new FileOutputStream(excelPath)){ try (FileOutputStream fos = new FileOutputStream(excelPath)) {
workbook.write(fos); workbook.write(fos);
}catch (Exception e){ } catch (Exception e) {
throw new JeroBootException(e.getMessage()); throw new JeroBootException(e.getMessage());
} }
} }
@@ -1123,7 +1125,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
String id = (String) parameter.get(ID); String id = (String) parameter.get(ID);
boolean itemContent = false; boolean itemContent = false;
// 水平越权 // 水平越权
if (parameter.containsKey("horizontalOverstep")){ if (parameter.containsKey("horizontalOverstep")) {
isHorizontalOverstep(id); isHorizontalOverstep(id);
parameter.remove("horizontalOverstep"); parameter.remove("horizontalOverstep");
} }
@@ -1131,13 +1133,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 文档拆分信息 // 文档拆分信息
DocumentSplitInfo documentSplitInfo = new DocumentSplitInfo(); DocumentSplitInfo documentSplitInfo = new DocumentSplitInfo();
documentSplitInfo.setId(id); documentSplitInfo.setId(id);
if (parameter.containsKey("publishBeforeId")){ if (parameter.containsKey("publishBeforeId")) {
documentSplitInfo.setPublishBeforeId((String) parameter.get("publishBeforeId")); documentSplitInfo.setPublishBeforeId((String) parameter.get("publishBeforeId"));
} }
List<DocumentSplitInfo> documentSplitInfos = queryByList(documentSplitInfo); List<DocumentSplitInfo> documentSplitInfos = queryByList(documentSplitInfo);
lawsDocumentSplitView.setDocumentSplitInfo(documentSplitInfos.get(0)); lawsDocumentSplitView.setDocumentSplitInfo(documentSplitInfos.get(0));
if (parameter.containsKey("item_content")){ if (parameter.containsKey("item_content")) {
itemContent = true; itemContent = true;
} }
// 文档拆分详情 // 文档拆分详情
@@ -1151,14 +1153,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
splitMenuEOPage.setValidFlag("0"); splitMenuEOPage.setValidFlag("0");
splitMenuEOPage.setOrderBy("display_seq"); splitMenuEOPage.setOrderBy("display_seq");
splitMenuEOPage.setInfoId(id); splitMenuEOPage.setInfoId(id);
if (itemContent && CollectionUtils.isNotEmpty(documentSplitDetailByList)){ if (itemContent && CollectionUtils.isNotEmpty(documentSplitDetailByList)) {
List<String> menuId = documentSplitDetailByList.stream() List<String> menuId = documentSplitDetailByList.stream()
.map(v -> String.valueOf(v.get("menu_id"))).distinct() .map(v -> String.valueOf(v.get("menu_id"))).distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
splitMenuEOPage.setIdList(menuId); splitMenuEOPage.setIdList(menuId);
List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage);
lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS); lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS);
}else { } else {
List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage);
// 不需要总目录层级 // 不需要总目录层级
lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS.get(0).getChildren()); lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS.get(0).getChildren());
@@ -1166,6 +1168,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
return lawsDocumentSplitView; return lawsDocumentSplitView;
} }
@Override @Override
public List<ProcessProjectAssessTerm> processProjectAssessGetList(String ids) { public List<ProcessProjectAssessTerm> processProjectAssessGetList(String ids) {
List<ProcessProjectAssessTerm> processProjectAssessTermList = new ArrayList<>(); List<ProcessProjectAssessTerm> processProjectAssessTermList = new ArrayList<>();
@@ -1230,7 +1233,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
private void publishs(Map<String, Object> parameter, boolean b) { private void publishs(Map<String, Object> parameter, boolean b) {
long l = System.currentTimeMillis(); long l = System.currentTimeMillis();
String id = (String) parameter.get(ID); String id = (String) parameter.get(ID);
if (b){ if (b) {
// 水平越权 // 水平越权
isHorizontalOverstep(id); isHorizontalOverstep(id);
} }
@@ -1240,7 +1243,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
SarFileSplitInfoEO sarFileSplitInfoEO = sarFileSplitInfoService.getOne( SarFileSplitInfoEO sarFileSplitInfoEO = sarFileSplitInfoService.getOne(
new QueryWrapper<SarFileSplitInfoEO>().lambda() new QueryWrapper<SarFileSplitInfoEO>().lambda()
.eq(SarFileSplitInfoEO::getPublishBeforeId, id)); .eq(SarFileSplitInfoEO::getPublishBeforeId, id));
if (!Objects.isNull(sarFileSplitInfoEO)){ if (!Objects.isNull(sarFileSplitInfoEO)) {
// 删除旧发布数据 // 删除旧发布数据
sarFileSplitInfoService.deleteById(sarFileSplitInfoEO.getId()); sarFileSplitInfoService.deleteById(sarFileSplitInfoEO.getId());
} }
@@ -1304,7 +1307,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
}); });
List<String> keyList = new ArrayList<>(map.keySet()); List<String> keyList = new ArrayList<>(map.keySet());
List<String> valueList = map.values().stream().map(o ->(String.valueOf(o))).collect(Collectors.toList()); List<String> valueList = map.values().stream().map(o -> (String.valueOf(o))).collect(Collectors.toList());
String insertField = String.join(",", keyList); String insertField = String.join(",", keyList);
documentSplitMapper.insertLawsDocumentSplit(insertField, valueList); documentSplitMapper.insertLawsDocumentSplit(insertField, valueList);
} }
@@ -1317,12 +1320,12 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
fileSplitItemsVal.setItemId(oldNewMap.get(fileSplitItemsVal.getItemId())); fileSplitItemsVal.setItemId(oldNewMap.get(fileSplitItemsVal.getItemId()));
} }
batchSaveItemsVal(sarFileSplitItemsVal); batchSaveItemsVal(sarFileSplitItemsVal);
log.info("===================================耗时:"+(System.currentTimeMillis() - l)); log.info("===================================耗时:" + (System.currentTimeMillis() - l));
} }
private void batchSaveItemsVal(List<SarFileSplitItemsVal> allvItemsValList) { private void batchSaveItemsVal(List<SarFileSplitItemsVal> allvItemsValList) {
int size = allvItemsValList.size(); int size = allvItemsValList.size();
int count = (int)Math.ceil((double) size / NUMBER); int count = (int) Math.ceil((double) size / NUMBER);
for (int i = 1; i <= count; i++) { for (int i = 1; i <= count; i++) {
List<SarFileSplitItemsVal> list = allvItemsValList.stream() List<SarFileSplitItemsVal> list = allvItemsValList.stream()
.skip((long) (Math.max(i, 1) - 1) * NUMBER) .skip((long) (Math.max(i, 1) - 1) * NUMBER)
@@ -1348,7 +1351,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
@Override @Override
public void exportDocumentSplitDetail(Map<String, Object> parameter, HttpServletRequest request, HttpServletResponse response) { public void exportDocumentSplitDetail(Map<String, Object> parameter, HttpServletRequest request, HttpServletResponse response) {
try (Workbook workbook = new XSSFWorkbook()){ try (Workbook workbook = new XSSFWorkbook()) {
// 文档拆分详情数据 // 文档拆分详情数据
List<Map<String, Object>> mapList = queryDocumentSplitDetailByList(parameter); List<Map<String, Object>> mapList = queryDocumentSplitDetailByList(parameter);
// 创建工作簿 // 创建工作簿
@@ -1357,7 +1360,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
Sheet sheet = workbook.createSheet("条文内容"); Sheet sheet = workbook.createSheet("条文内容");
// 字段名 // 字段名
List<String> keyList = new ArrayList<>(); List<String> keyList = new ArrayList<>();
if(!Objects.isNull(mapList) && !mapList.isEmpty()){ if (!Objects.isNull(mapList) && !mapList.isEmpty()) {
Map<String, Object> map = mapList.get(0); Map<String, Object> map = mapList.get(0);
keyList = map.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList()); keyList = map.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList());
} }
@@ -1385,13 +1388,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
cell.setCellValue(new XSSFRichTextString(keyList.get(i))); cell.setCellValue(new XSSFRichTextString(keyList.get(i)));
cell.setCellStyle(cellStyleOne); cell.setCellStyle(cellStyleOne);
if("条文内容".equals(keyList.get(i))) { if ("条文内容".equals(keyList.get(i))) {
sheet.setColumnWidth(i, 80 * 256); sheet.setColumnWidth(i, 80 * 256);
} else { } else {
sheet.setColumnWidth(i, 20 * 256); sheet.setColumnWidth(i, 20 * 256);
} }
} }
}catch (Exception e){ } catch (Exception e) {
throw new JeroBootException("导出失败!"); throw new JeroBootException("导出失败!");
} }
} }
@@ -1407,10 +1410,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
queryWrapper.isNotNull("o.standard_id"); queryWrapper.isNotNull("o.standard_id");
queryWrapper.orderByDesc(CREATE_TIME); queryWrapper.orderByDesc(CREATE_TIME);
queryWrapper.eq(StringUtils.isNotBlank(splitFileInfo.getStandardSplitStatus()), "standard.standard_split_status", splitFileInfo.getStandardSplitStatus()); queryWrapper.eq(StringUtils.isNotBlank(splitFileInfo.getStandardSplitStatus()), "standard.standard_split_status", splitFileInfo.getStandardSplitStatus());
if (StringUtils.isNotBlank(splitFileInfo.getEsMainDraftUnit())){ if (StringUtils.isNotBlank(splitFileInfo.getEsMainDraftUnit())) {
queryWrapper.in("esMainDraftUnit", Arrays.asList(splitFileInfo.getEsMainDraftUnit().split(","))); queryWrapper.in("esMainDraftUnit", Arrays.asList(splitFileInfo.getEsMainDraftUnit().split(",")));
} }
if (StringUtils.isNotBlank(splitFileInfo.getIds())){ if (StringUtils.isNotBlank(splitFileInfo.getIds())) {
queryWrapper.in("o.id", Arrays.asList(splitFileInfo.getIds().split(","))); queryWrapper.in("o.id", Arrays.asList(splitFileInfo.getIds().split(",")));
} }
return documentSplitMapper.querySplitFileInfoByPage(queryWrapper, new Page<>(pageNo, pageSize)); return documentSplitMapper.querySplitFileInfoByPage(queryWrapper, new Page<>(pageNo, pageSize));
@@ -1427,7 +1430,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
splitMenuEOPage.setInfoId(infoId); splitMenuEOPage.setInfoId(infoId);
List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage);
if (!sarFileSplitMenuEOS.isEmpty() && !Objects.isNull(sarFileSplitMenuEOS.get(0).getChildren())){ if (!sarFileSplitMenuEOS.isEmpty() && !Objects.isNull(sarFileSplitMenuEOS.get(0).getChildren())) {
return sarFileSplitMenuEOS.get(0).getChildren(); return sarFileSplitMenuEOS.get(0).getChildren();
} }
return new ArrayList<>(); return new ArrayList<>();
@@ -1439,7 +1442,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 未发布的只有自己可见,发布的数据所有人可见 // 未发布的只有自己可见,发布的数据所有人可见
String roleIds = loginUser.getRoleIds(); String roleIds = loginUser.getRoleIds();
QueryWrapper<SarFileSplitInfoEO> queryWrapper = new QueryWrapper<>(); QueryWrapper<SarFileSplitInfoEO> queryWrapper = new QueryWrapper<>();
if (StringUtils.isBlank(ids)){ if (StringUtils.isBlank(ids)) {
return; return;
} }
List<String> idList = Arrays.asList(ids.split(",")); List<String> idList = Arrays.asList(ids.split(","));
@@ -1493,13 +1496,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
sarFileSplitInfoService.updateStandardSplitStatus(sarFileSplitInfoEO.getStandardId(), DocumentSplitCommon.STANDARD_SPLIT_STATUS1); sarFileSplitInfoService.updateStandardSplitStatus(sarFileSplitInfoEO.getStandardId(), DocumentSplitCommon.STANDARD_SPLIT_STATUS1);
// 提交事务 // 提交事务
dataSourceTransactionManager.commit(transaction); dataSourceTransactionManager.commit(transaction);
}catch (JeroBootException e){ } catch (JeroBootException e) {
// 回滚事务 // 回滚事务
dataSourceTransactionManager.rollback(transaction); dataSourceTransactionManager.rollback(transaction);
errorList.add("标准编号为:" + fileInfo.getStandardNumber() + " " + e.getMessage()); errorList.add("标准编号为:" + fileInfo.getStandardNumber() + " " + e.getMessage());
} }
} }
if (!errorList.isEmpty()){ if (!errorList.isEmpty()) {
throw new JeroBootException(String.join("<br/>", errorList)); throw new JeroBootException(String.join("<br/>", errorList));
} }
} }
@@ -1521,10 +1524,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
sarFileSplitItemsValEOMapper.deleteByitemId(lawsDocumentSplit.getId()); sarFileSplitItemsValEOMapper.deleteByitemId(lawsDocumentSplit.getId());
// 构建新条文详情 // 构建新条文详情
if (StringUtils.isNotBlank(lawsDocumentSplit.getItemContent())){ if (StringUtils.isNotBlank(lawsDocumentSplit.getItemContent())) {
Document document = Jsoup.parse(lawsDocumentSplit.getItemContent()); Document document = Jsoup.parse(lawsDocumentSplit.getItemContent());
Elements elements = document.select("p:not(table p):not(:empty), img, table"); Elements elements = document.select("p:not(table p):not(:empty), img, table");
if (elements.isEmpty() && StringUtils.isNotBlank(lawsDocumentSplit.getItemContent())){ if (elements.isEmpty() && StringUtils.isNotBlank(lawsDocumentSplit.getItemContent())) {
SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO(); SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO();
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20()); sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId()); sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId());
@@ -1537,17 +1540,17 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
for (int i = 0; i < elements.size(); i++) { for (int i = 0; i < elements.size(); i++) {
Element element = elements.get(i); Element element = elements.get(i);
if (StringUtils.isBlank(element.text()) && "p".equals(element.tagName())){ if (StringUtils.isBlank(element.text()) && "p".equals(element.tagName())) {
continue; continue;
} }
SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO(); SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO();
if ("table".equals(element.tagName())){ if ("table".equals(element.tagName())) {
sarFileSplitItemsValEO.setType("TABLE"); sarFileSplitItemsValEO.setType("TABLE");
sarFileSplitItemsValEO.setItemContent(element.outerHtml()); sarFileSplitItemsValEO.setItemContent(element.outerHtml());
}else if ("img".equals(element.tagName())){ } else if ("img".equals(element.tagName())) {
sarFileSplitItemsValEO.setType("IMG"); sarFileSplitItemsValEO.setType("IMG");
sarFileSplitItemsValEO.setItemContent(element.attr("src")); sarFileSplitItemsValEO.setItemContent(element.attr("src"));
}else if ("p".equals(element.tagName())){ } else if ("p".equals(element.tagName())) {
sarFileSplitItemsValEO.setType("TEXT"); sarFileSplitItemsValEO.setType("TEXT");
sarFileSplitItemsValEO.setItemContent(element.text()); sarFileSplitItemsValEO.setItemContent(element.text());
} }
@@ -1567,7 +1570,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
public String queryItemValueByMenuId(String menuId) { public String queryItemValueByMenuId(String menuId) {
LawsDocumentSplit lawsDocumentSplit = documentSplitMapper.selectOne(new LambdaQueryWrapper<LawsDocumentSplit>() LawsDocumentSplit lawsDocumentSplit = documentSplitMapper.selectOne(new LambdaQueryWrapper<LawsDocumentSplit>()
.eq(LawsDocumentSplit::getMenuId, menuId)); .eq(LawsDocumentSplit::getMenuId, menuId));
if (!Objects.isNull(lawsDocumentSplit)){ if (!Objects.isNull(lawsDocumentSplit)) {
SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO(); SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO();
sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId()); sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId());
sarFileSplitItemsValEO.setType("TEXT"); sarFileSplitItemsValEO.setType("TEXT");
@@ -1634,10 +1637,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
documentSplitInfo.setSerialNumber(sarFileSplitInfoEO.getSerialNumber()); documentSplitInfo.setSerialNumber(sarFileSplitInfoEO.getSerialNumber());
documentSplitInfo.setFileType(sarFileSplitInfoEO.getFileType()); documentSplitInfo.setFileType(sarFileSplitInfoEO.getFileType());
List<DocumentSplitInfo> list = queryByList(documentSplitInfo); List<DocumentSplitInfo> list = queryByList(documentSplitInfo);
if(!list.isEmpty()){ if (!list.isEmpty()) {
if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) { if (LanguageEnum.CN.equals(MessageUtils.getLanguage())) {
throw new JeroBootException("每个文件类型只能拆分一次!"); throw new JeroBootException("每个文件类型只能拆分一次!");
}else{ } else {
throw new JeroBootException("Each file type can only be split once!"); throw new JeroBootException("Each file type can only be split once!");
} }
} }
@@ -1651,11 +1654,11 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
selectColumn.append(","); selectColumn.append(",");
selectColumn.append(DocumentSplitCommon.IF_NULL_BEGIN); selectColumn.append(DocumentSplitCommon.IF_NULL_BEGIN);
// 日期字段需要格式化 // 日期字段需要格式化
if (LawsFieldTypeEnum.DATE_SINGLE.getValue().equals(lawsTag.getDbFieldName())){ if (LawsFieldTypeEnum.DATE_SINGLE.getValue().equals(lawsTag.getDbFieldName())) {
selectColumn.append(DocumentSplitCommon.DATE_FORMAT_BEGIN) selectColumn.append(DocumentSplitCommon.DATE_FORMAT_BEGIN)
.append(lawsTag.getDbFieldName()) .append(lawsTag.getDbFieldName())
.append(DocumentSplitCommon.DATE_FORMAT_END); .append(DocumentSplitCommon.DATE_FORMAT_END);
}else { } else {
// 普通字段直接拼接 // 普通字段直接拼接
selectColumn.append(lawsTag.getDbFieldName()); selectColumn.append(lawsTag.getDbFieldName());
} }
@@ -1689,36 +1692,36 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
private void defaultCondition(Map<String, Object> parameter, StringBuilder selectCondition) { private void defaultCondition(Map<String, Object> parameter, StringBuilder selectCondition) {
if (parameter.containsKey(ID)){ if (parameter.containsKey(ID)) {
selectCondition.append(" and s.id = '").append(parameter.get(ID)).append("'"); selectCondition.append(" and s.id = '").append(parameter.get(ID)).append("'");
parameter.remove(ID); parameter.remove(ID);
} }
if (parameter.containsKey(INFO_ID)){ if (parameter.containsKey(INFO_ID)) {
selectCondition.append(" and s.info_id = '").append(parameter.get(INFO_ID)).append("'"); selectCondition.append(" and s.info_id = '").append(parameter.get(INFO_ID)).append("'");
parameter.remove(INFO_ID); parameter.remove(INFO_ID);
} }
if (parameter.containsKey(ITEM_NUM)){ if (parameter.containsKey(ITEM_NUM)) {
selectCondition.append(" and item_num = '").append(parameter.get(ITEM_NUM)).append("'"); selectCondition.append(" and item_num = '").append(parameter.get(ITEM_NUM)).append("'");
parameter.remove(ITEM_NUM); parameter.remove(ITEM_NUM);
} }
if (parameter.containsKey(ITEM_TITLE)){ if (parameter.containsKey(ITEM_TITLE)) {
// 模糊匹配 // 模糊匹配
selectCondition.append(likeCondition(ITEM_TITLE, (String) parameter.get(ITEM_TITLE))); selectCondition.append(likeCondition(ITEM_TITLE, (String) parameter.get(ITEM_TITLE)));
parameter.remove(ITEM_TITLE); parameter.remove(ITEM_TITLE);
} }
if (parameter.containsKey(ITEM_CONTENT)){ if (parameter.containsKey(ITEM_CONTENT)) {
// 模糊匹配 // 模糊匹配
selectCondition.append(likeCondition(ITEM_CONTENT, (String) parameter.get(ITEM_CONTENT))); selectCondition.append(likeCondition(ITEM_CONTENT, (String) parameter.get(ITEM_CONTENT)));
parameter.remove(ITEM_CONTENT); parameter.remove(ITEM_CONTENT);
} }
// 树节点搜索 // 树节点搜索
if (parameter.containsKey(MENU_ID)){ if (parameter.containsKey(MENU_ID)) {
// 查询此节点下的所有子节点 // 查询此节点下的所有子节点
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO(); SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
sarFileSplitMenuEO.setId( (String) parameter.get(MENU_ID)); sarFileSplitMenuEO.setId((String) parameter.get(MENU_ID));
List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryAllChildrenById(sarFileSplitMenuEO); List<SarFileSplitMenuEO> sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryAllChildrenById(sarFileSplitMenuEO);
if (!sarFileSplitMenuEOS.isEmpty()){ if (!sarFileSplitMenuEOS.isEmpty()) {
String menuIds= sarFileSplitMenuEOS.stream() String menuIds = sarFileSplitMenuEOS.stream()
.map(SarFileSplitMenuEO::getId) .map(SarFileSplitMenuEO::getId)
.collect(Collectors.joining("','")); .collect(Collectors.joining("','"));
// in查询 // in查询
@@ -1730,13 +1733,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
/** /**
* 模糊查询 * 模糊查询
*
* @param fieldName * @param fieldName
* @param value * @param value
* @return 返回数据样例 and fieldName like '%value%' * @return 返回数据样例 and fieldName like '%value%'
*/ */
private String likeCondition(String fieldName, String value) { private String likeCondition(String fieldName, String value) {
return DocumentSplitCommon.AND + fieldName + DocumentSplitCommon.LIKE + return DocumentSplitCommon.AND + fieldName + DocumentSplitCommon.LIKE +
DocumentSplitCommon.CONCAT_LIKE_BEGIN + value + DocumentSplitCommon.CONCAT_LIKE_END; DocumentSplitCommon.CONCAT_LIKE_BEGIN + value + DocumentSplitCommon.CONCAT_LIKE_END;
} }
@NotNull @NotNull
@@ -1764,7 +1768,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
} }
// 标准编号 // 标准编号
if (StringUtils.isNotBlank(documentSplitInfo.getSerialNumber())){ if (StringUtils.isNotBlank(documentSplitInfo.getSerialNumber())) {
List<LawsDomesticStandard> lawsDomesticStandardList = lawsDomesticStandardService.list( List<LawsDomesticStandard> lawsDomesticStandardList = lawsDomesticStandardService.list(
new LambdaQueryWrapper<LawsDomesticStandard>() new LambdaQueryWrapper<LawsDomesticStandard>()
.like(LawsDomesticStandard::getStandardNumber, documentSplitInfo.getSerialNumber())); .like(LawsDomesticStandard::getStandardNumber, documentSplitInfo.getSerialNumber()));
@@ -1782,7 +1786,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
} }
// 标准名称 // 标准名称
if (StringUtils.isNotBlank(documentSplitInfo.getTitle())){ if (StringUtils.isNotBlank(documentSplitInfo.getTitle())) {
List<LawsDomesticStandard> lawsDomesticStandardList = lawsDomesticStandardService.list( List<LawsDomesticStandard> lawsDomesticStandardList = lawsDomesticStandardService.list(
new LambdaQueryWrapper<LawsDomesticStandard>() new LambdaQueryWrapper<LawsDomesticStandard>()
.like(LawsDomesticStandard::getStandardName, documentSplitInfo.getTitle())); .like(LawsDomesticStandard::getStandardName, documentSplitInfo.getTitle()));
@@ -1804,18 +1808,18 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
// 拆分状态 // 拆分状态
queryWrapper.eq(StringUtils.isNotBlank(documentSplitInfo.getSplitStatus()), SPLIT_STATUS, documentSplitInfo.getSplitStatus()); queryWrapper.eq(StringUtils.isNotBlank(documentSplitInfo.getSplitStatus()), SPLIT_STATUS, documentSplitInfo.getSplitStatus());
// 编辑人 // 编辑人
if (StringUtils.isNotBlank(documentSplitInfo.getAuthor())){ if (StringUtils.isNotBlank(documentSplitInfo.getAuthor())) {
List<SysUser> sysUserList = sysUserService.list(new LambdaQueryWrapper<SysUser>().like(SysUser::getRealname, documentSplitInfo.getAuthor())); List<SysUser> sysUserList = sysUserService.list(new LambdaQueryWrapper<SysUser>().like(SysUser::getRealname, documentSplitInfo.getAuthor()));
List<String> sysUserIdList = sysUserList.stream().map(SysUser::getId).collect(Collectors.toList()); List<String> sysUserIdList = sysUserList.stream().map(SysUser::getId).collect(Collectors.toList());
queryWrapper.and(qw -> queryWrapper.and(qw ->
qw.in("author", sysUserIdList) qw.in("author", sysUserIdList)
.or().eq("云平台".contains(documentSplitInfo.getAuthor()), "author", "云平台") .or().eq("云平台".contains(documentSplitInfo.getAuthor()), "author", "云平台")
); );
} }
// 发布前id // 发布前id
if (StringUtils.isNotBlank(documentSplitInfo.getPublishBeforeId())){ if (StringUtils.isNotBlank(documentSplitInfo.getPublishBeforeId())) {
queryWrapper.eq("publish_before_id", documentSplitInfo.getPublishBeforeId()); queryWrapper.eq("publish_before_id", documentSplitInfo.getPublishBeforeId());
}else { } else {
queryWrapper.isNull("publish_before_id"); queryWrapper.isNull("publish_before_id");
} }
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -1825,7 +1829,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
qw.and(qwi -> qwi.eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS1) qw.and(qwi -> qwi.eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS1)
.eq("author", loginUser.getId())) .eq("author", loginUser.getId()))
.or().eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS2) .or().eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS2)
.or().eq(roleIds.contains("admin"), "author", "云平台")); .or().eq(roleIds.contains("admin"), "author", "云平台"));
// 逻辑删除 // 逻辑删除
queryWrapper.eq("del_flag", 0); queryWrapper.eq("del_flag", 0);
// 排序 // 排序
@@ -1834,72 +1838,81 @@ public class DocumentSplitServiceImpl extends ServiceImpl<DocumentSplitMapper, L
} }
@Override @Override
public String fixAllBadSplit() { public void fixAllBadSplit() {
List<SarFileSplitItemsValEO> list = sarFileSplitItemsValEOService.list(); CompletableFuture.runAsync(() -> {
Map<String, List<SarFileSplitItemsValEO>> valMap = list.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getItemId)); List<SarFileSplitItemsValEO> list = sarFileSplitItemsValEOService.list();
List<SarFileSplitItemsValEO> imageOneList = list.stream().filter(val -> val.getItemContent().startsWith("图1")).collect(Collectors.toList()); Map<String, List<SarFileSplitItemsValEO>> valMap = list.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getItemId));
ConcurrentLinkedQueue<String> itemIdList = new ConcurrentLinkedQueue<>(); List<SarFileSplitItemsValEO> imageOneList = list.stream().filter(val -> val.getItemContent().startsWith("图1")).collect(Collectors.toList());
imageOneList.stream().parallel().forEach(one -> { ConcurrentLinkedQueue<String> itemIdList = new ConcurrentLinkedQueue<>();
List<SarFileSplitItemsValEO> vals = valMap.get(one.getItemId()); imageOneList.stream().parallel().forEach(one -> {
if (vals.isEmpty()) { List<SarFileSplitItemsValEO> vals = valMap.get(one.getItemId());
return; if (vals.isEmpty()) {
} return;
Map<Integer, List<SarFileSplitItemsValEO>> orderMap = vals.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getDisplaySeq)); }
List<SarFileSplitItemsValEO> imageList = orderMap.get(one.getDisplaySeq() - 1); Map<Integer, List<SarFileSplitItemsValEO>> orderMap = vals.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getDisplaySeq));
if (imageList == null || imageList.isEmpty()) { List<SarFileSplitItemsValEO> imageList = orderMap.get(one.getDisplaySeq() - 1);
itemIdList.add(one.getItemId()); if (imageList == null || imageList.isEmpty()) {
return; itemIdList.add(one.getItemId());
} return;
SarFileSplitItemsValEO image = imageList.get(0); }
if (!image.getType().equals("IMG")) { SarFileSplitItemsValEO image = imageList.get(0);
itemIdList.add(one.getItemId()); if (!image.getType().equals("IMG")) {
} itemIdList.add(one.getItemId());
}); }
});
// 找到所有infoId // 找到所有infoId
LambdaQueryWrapper<LawsDocumentSplit> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LawsDocumentSplit> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(LawsDocumentSplit::getId, itemIdList); lambdaQueryWrapper.in(LawsDocumentSplit::getId, itemIdList);
List<LawsDocumentSplit> documentSplistList = documentSplitService.list(lambdaQueryWrapper); List<LawsDocumentSplit> documentSplistList = documentSplitService.list(lambdaQueryWrapper);
Set<String> infoIdList = documentSplistList.stream() Set<String> infoIdList = documentSplistList.stream()
.map(LawsDocumentSplit::getInfoId).collect(Collectors.toSet()); .map(LawsDocumentSplit::getInfoId).collect(Collectors.toSet());
// 找到所有info 并打印所有标准编号 和splitId // 找到所有info 并打印所有标准编号 和splitId
List<LawsEnterpriseStandard> esList = esService.list(); List<LawsEnterpriseStandard> esList = esService.list();
List<String> esStandardNoList = esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()); List<String> esStandardNoList = esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList());
LambdaQueryWrapper<SarFileSplitInfoEO> infoEOLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SarFileSplitInfoEO> infoEOLambdaQueryWrapper = new LambdaQueryWrapper<>();
infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getSerialNumber, esStandardNoList); infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getSerialNumber, esStandardNoList);
infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getDelFlag, YesOrNoEnum.NO.getValue()); infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getDelFlag, YesOrNoEnum.NO.getValue());
infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitResult, "成功"); infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitResult, "成功");
infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitStatus, "2"); infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitStatus, "2");
infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getId, infoIdList); infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getId, infoIdList);
// infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getId, "19e6041480f8469bb9c2e09487ed8770"); // infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getId, "19e6041480f8469bb9c2e09487ed8770");
List<SarFileSplitInfoEO> infoList = sarFileSplitInfoService.list(infoEOLambdaQueryWrapper); List<SarFileSplitInfoEO> infoList = sarFileSplitInfoService.list(infoEOLambdaQueryWrapper);
log.info("共发现{}条没有拆出图片的企标", infoList.size()); // 根据fileId去重
// 开始重新拆分 long needSplit = infoList.stream().collect(Collectors.groupingBy(SarFileSplitInfoEO::getFileId)).entrySet().stream().count();
int count = 1; log.info("共发现{}条没有拆出图片的企标", needSplit);
List<String> failedList = new ArrayList<>(); // 开始重新拆分
for (SarFileSplitInfoEO info : infoList) { List<String> failedList = new ArrayList<>();
try { Map<String, String> alreadySplitMap = new HashMap<>();
log.info("正在处理第{}条,企标编号{}", count, info.getSerialNumber()); for (int i = 0; i < infoList.size(); i++) {
String fileId = info.getFileId(); SarFileSplitInfoEO info = infoList.get(i);
String infoId = info.getId(); try {
String author = info.getAuthor(); log.info("正在处理第{}条,企标编号{}", i, info.getSerialNumber());
// 删除拆分记录 String fileId = info.getFileId();
sarFileSplitInfoService.deleteByIds(Collections.singletonList(infoId)); String infoId = info.getId();
// 重新拆分 String author = info.getAuthor();
JSONObject jsonObject = new JSONObject(); // 删除拆分记录
jsonObject.put("ids", fileId); sarFileSplitInfoService.deleteByIds(Collections.singletonList(infoId));
documentSplitService.batchSplit(jsonObject, author); // 重新拆分
log.info("第{}条处理完毕", count++); JSONObject jsonObject = new JSONObject();
} catch (Exception e) { jsonObject.put("ids", fileId);
log.info("第{}条处理失败", count++); String s = alreadySplitMap.get(fileId);
failedList.add(info.getId()); if (s != null) {
log.info("该企标已经拆分过了,跳过{}", fileId);
continue;
}
alreadySplitMap.put(fileId, "split");
documentSplitService.batchSplit(jsonObject, author);
log.info("第{}条处理完毕", i);
} catch (Exception e) {
log.info("第{}条处理失败", i);
failedList.add(info.getId());
}
} }
} // 将失败的标准编号打印出来,逗号拼接
// 将失败的标准编号打印出来,逗号拼接 log.error("企标拆分失败企标编号:{}", StringUtils.join(failedList, ","));
log.error("企标拆分失败企标编号:{}", StringUtils.join(failedList, ",")); });
return failedList.size() + "条企标拆分失败";
} }
} }