fix(文档拆分): 编辑问题修复
This commit is contained in:
+12
@@ -48,6 +48,18 @@ public class DocumentSplitCommon {
|
||||
* <=
|
||||
*/
|
||||
public static final String LT = " <= ";
|
||||
/**
|
||||
* 条目类型 TEXT:文本, IMG:图片, TABLE:表格
|
||||
*/
|
||||
public static final String TEXT = "TEXT";
|
||||
/**
|
||||
* 条目类型
|
||||
*/
|
||||
public static final String IMG = "IMG";
|
||||
/**
|
||||
* 条目类型
|
||||
*/
|
||||
public static final String TABLE = "TABLE";
|
||||
|
||||
public static final String MEG_DEL = "删除成功!";
|
||||
public static final String MEG_DEL_BATCH = "批量删除成功!";
|
||||
|
||||
+17
-4
@@ -130,7 +130,7 @@ public class DocumentSplitController {
|
||||
@PostMapping("/editDocumentSplitDetail")
|
||||
public Result<T> editDocumentSplitDetail(@RequestBody Map<String, Object> parameter) {
|
||||
documentSplitService.editDocumentSplitDetail(parameter);
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,6 +146,19 @@ public class DocumentSplitController {
|
||||
return Result.OK(DocumentSplitCommon.MEG_DEL_BATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档拆分详情-删除
|
||||
*
|
||||
* @return Result<T>
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-删除")
|
||||
@ApiOperation(value="文档拆分详情-删除", notes="文档拆分详情-删除")
|
||||
@PostMapping(value = "/deleteDocumentSplitDetail")
|
||||
public Result<T> deleteDocumentSplitDetail(@RequestBody Map<String, Object> parameter) {
|
||||
documentSplitService.deleteDocumentSplitDetail(parameter);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档拆分详情-批量删除
|
||||
*
|
||||
@@ -153,9 +166,9 @@ public class DocumentSplitController {
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-批量删除")
|
||||
@ApiOperation(value="文档拆分详情-批量删除", notes="文档拆分详情-批量删除")
|
||||
@PostMapping(value = "/deleteBatchBatchDocumentSplitDetail")
|
||||
public Result<T> deleteBatchBatchDocumentSplitDetail(@RequestBody Map<String, Object> parameter) {
|
||||
documentSplitService.deleteBatchBatchDocumentSplitDetail(parameter);
|
||||
@PostMapping(value = "/deleteBatchDocumentSplitDetail")
|
||||
public Result<T> deleteBatchDocumentSplitDetail(@RequestBody Map<String, Object> parameter) {
|
||||
documentSplitService.deleteBatchDocumentSplitDetail(parameter);
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class AbstractConditionBase {
|
||||
public String getUpdateByAndUpdateTime() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return " update_by = " + "'" + sysUser.getUsername() + "'" +
|
||||
return " update_by = " + "'" + sysUser.getUsername() + "'" + "," +
|
||||
"update_time = " + FieldCommon.STR_TO_DATE_PREFIX + dateFormat.format(new Date()) + "','%Y-%m-%d %H:%i:%s')";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jero.modules.laws.documenttool.handler.impl;
|
||||
|
||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||
import com.jero.modules.laws.documenttool.handler.AbstractConditionBase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -17,6 +16,6 @@ public class UniversalImpl extends AbstractConditionBase {
|
||||
|
||||
@Override
|
||||
public String buildUpdate(String fieldName, String value){
|
||||
return fieldName + " = " + "'" + FieldCommon.STR_TO_DATE_PREFIX + value + FieldCommon.STR_TO_DATE_SUFFIX +"'";
|
||||
return fieldName + " = " + "'" + value + "'";
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -56,7 +56,7 @@ public interface DocumentSplitMapper {
|
||||
* @param updateCondition
|
||||
* @return int
|
||||
*/
|
||||
int editDocumentSplitDetail(@Param("updateSet") String updateSet,@Param("updateCondition") String updateCondition);
|
||||
int editDocumentSplitDetail(@Param("updateSet") String updateSet, @Param("updateCondition") String updateCondition);
|
||||
|
||||
/**
|
||||
* 条目查询根据itemId集合
|
||||
@@ -83,11 +83,24 @@ public interface DocumentSplitMapper {
|
||||
* 目录删除根据menuId集合
|
||||
* @param menuIdList
|
||||
*/
|
||||
int sarFileSplitMenudeleteByIdList(@Param("menuIdList") List<String> menuIdList);
|
||||
int sarFileSplitMenuDeleteByIdList(@Param("menuIdList") List<String> menuIdList);
|
||||
|
||||
/**
|
||||
* 文档拆分详情-删除
|
||||
* @param id
|
||||
*/
|
||||
int deleteDocumentSplitDetail(@Param("id") String id);
|
||||
|
||||
/**
|
||||
* 文档拆分详情-批量删除
|
||||
* @param updateCondition
|
||||
*/
|
||||
int deleteBatchBatchDocumentSplitDetail(@Param("updateCondition") String updateCondition);
|
||||
int deleteBatchDocumentSplitDetail(@Param("updateCondition") String updateCondition);
|
||||
|
||||
/**
|
||||
* 条目批量新增
|
||||
* @param valList
|
||||
* @return
|
||||
*/
|
||||
int addBatchItemsVal(@Param("valList") List<SarFileSplitItemsValEO> valList);
|
||||
}
|
||||
|
||||
+24
-3
@@ -2,7 +2,23 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper">
|
||||
|
||||
<delete id="sarFileSplitMenudeleteByIdList">
|
||||
<insert id="addBatchItemsVal">
|
||||
insert into SAR_FILE_SPLIT_ITEMS_VAL
|
||||
(id, type, item_id, valid_flag, creation_user, creation_time, modify_time, modify_user, display_seq, img_name, item_content, index_item)
|
||||
values
|
||||
<foreach collection="valList" item="item" index="index" separator=",">(
|
||||
#{item.id, jdbcType=VARCHAR}, #{item.type, jdbcType=VARCHAR},
|
||||
#{item.itemId, jdbcType=VARCHAR},
|
||||
#{item.validFlag, jdbcType=INTEGER}, #{item.creationUser, jdbcType=VARCHAR},
|
||||
#{item.creationTime, jdbcType=TIMESTAMP}, #{item.modifyTime, jdbcType=TIMESTAMP},
|
||||
#{item.modifyUser, jdbcType=VARCHAR}, #{item.displaySeq, jdbcType=INTEGER},
|
||||
#{item.imgName, jdbcType=INTEGER},
|
||||
#{item.itemContent, jdbcType=CLOB},
|
||||
#{item.indexItem, jdbcType=INTEGER})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="sarFileSplitMenuDeleteByIdList">
|
||||
delete from SAR_FILE_SPLIT_MENU
|
||||
where id in
|
||||
<foreach collection="menuIdList" index="index" item="item" open="(" separator="," close=")">
|
||||
@@ -10,7 +26,12 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBatchBatchDocumentSplitDetail">
|
||||
<delete id="deleteDocumentSplitDetail">
|
||||
delete from laws_document_split
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBatchDocumentSplitDetail">
|
||||
delete from laws_document_split
|
||||
where #{updateCondition}
|
||||
</delete>
|
||||
@@ -73,6 +94,6 @@
|
||||
<update id="editDocumentSplitDetail">
|
||||
UPDATE laws_document_split
|
||||
SET ${updateSet}
|
||||
WHERE #{updateCondition}
|
||||
WHERE ${updateCondition}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
+7
-1
@@ -67,9 +67,15 @@ public interface IDocumentSplitService {
|
||||
*/
|
||||
void mergeDocumentSplitDetail(Map<String, Object> parameter);
|
||||
|
||||
/**
|
||||
* 文档拆分详情-删除
|
||||
* @param parameter
|
||||
*/
|
||||
void deleteDocumentSplitDetail(Map<String, Object> parameter);
|
||||
|
||||
/**
|
||||
* 文档拆分详情-批量删除
|
||||
* @param parameter
|
||||
*/
|
||||
void deleteBatchBatchDocumentSplitDetail(Map<String, Object> parameter);
|
||||
void deleteBatchDocumentSplitDetail(Map<String, Object> parameter);
|
||||
}
|
||||
|
||||
+73
-13
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.laws.documenttool.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -9,6 +10,7 @@ import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
import com.jero.modules.laws.common.mapper.LawsCommonMapper;
|
||||
import com.jero.modules.laws.documenttool.common.DocumentSplitCommon;
|
||||
import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||
@@ -37,6 +39,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -159,34 +162,81 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
.equals(v.getIsShowFormCreate())).collect(Collectors.toList());
|
||||
List<LawsTag> finalFieldList = fieldList;
|
||||
StringBuilder updateSet = new StringBuilder();
|
||||
parameter.forEach((k, v) ->
|
||||
List<SarFileSplitItemsValEO> valList = JSON.parseArray(JSON.toJSONString(parameter.get("itemValEOList")), SarFileSplitItemsValEO.class);
|
||||
parameter.remove("itemValEOList");
|
||||
// 计数
|
||||
parameter.forEach((k, v) ->{
|
||||
// 条文内容拼接
|
||||
if (ITEM_CONTENT.equals(k)){
|
||||
v = itemContentJoin(valList, (String) parameter.get(ID));
|
||||
}
|
||||
// 修改字段
|
||||
updateSet.append(getUpdateValue(finalFieldList, k, (String) v))
|
||||
);
|
||||
String updateValue = getUpdateValue(finalFieldList, k, (String) v);
|
||||
if (StringUtils.isNotBlank(updateValue)){
|
||||
updateSet.append(updateValue).append(",");
|
||||
}
|
||||
});
|
||||
// 更新人和更新时间
|
||||
String updateByAndUpdateTime = new UniversalImpl().getUpdateByAndUpdateTime();
|
||||
updateSet.insert(0, updateByAndUpdateTime + ",");
|
||||
updateSet.deleteCharAt(updateSet.length() - 1);
|
||||
// where条件
|
||||
String updateCondition = "id = '" + parameter.get("id") + "'";
|
||||
documentSplitMapper.editDocumentSplitDetail(updateSet.toString(), updateCondition);
|
||||
|
||||
// 条目信息更新
|
||||
// 删除旧数据
|
||||
documentSplitMapper.deleteItemsValByItemId((String) parameter.get("id"));
|
||||
// 添加新数据
|
||||
documentSplitMapper.addBatchItemsVal(valList);
|
||||
}
|
||||
|
||||
private String itemContentJoin(List<SarFileSplitItemsValEO> valList, String itemId) {
|
||||
StringBuilder valContent = new StringBuilder();
|
||||
if (!Objects.isNull(valList) && !valList.isEmpty()){
|
||||
int index = 0;
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : valList) {
|
||||
// 条文内容拼接
|
||||
if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType())) {
|
||||
valContent.append("<p>").append(sarFileSplitItemsValEO.getItemContent()).append("</p>");
|
||||
} else if (DocumentSplitCommon.IMG.equals(sarFileSplitItemsValEO.getType())) {
|
||||
valContent.append("<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"").append(sarFileSplitItemsValEO.getItemContent()).append("\">");
|
||||
} else if (DocumentSplitCommon.TABLE.equals(sarFileSplitItemsValEO.getType())) {
|
||||
valContent.append(sarFileSplitItemsValEO.getItemContent());
|
||||
}
|
||||
|
||||
// 条目信息
|
||||
index += 1;
|
||||
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
|
||||
sarFileSplitItemsValEO.setItemId(itemId);
|
||||
sarFileSplitItemsValEO.setDisplaySeq(index);
|
||||
sarFileSplitItemsValEO.setValidFlag(0);
|
||||
sarFileSplitItemsValEO.setCreationTime(new Date());
|
||||
sarFileSplitItemsValEO.setModifyTime(new Date());
|
||||
sarFileSplitItemsValEO.setCreationUser(sysUser.getId());
|
||||
sarFileSplitItemsValEO.setModifyUser(sysUser.getId());
|
||||
}
|
||||
}
|
||||
return valContent.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getUpdateValue(List<LawsTag> finalFieldList, String k, String v) {
|
||||
// 匹配参数和字段
|
||||
Optional<LawsTag> lawsTag = finalFieldList.stream().filter(o -> k.equals(o.getDbFieldName())).findFirst();
|
||||
ArrayList<String> sqlList = new ArrayList<>();
|
||||
AtomicReference<String> sql = new AtomicReference<>("");
|
||||
lawsTag.ifPresent(l -> {
|
||||
// 构建修改字段
|
||||
if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){
|
||||
// 多日期
|
||||
sqlList.add(new DateManyConditionImpl().buildUpdate(l.getDbFieldName(), v));
|
||||
sql.set(new DateManyConditionImpl().buildUpdate(l.getDbFieldName(), v));
|
||||
}else {
|
||||
sqlList.add(new UniversalImpl().buildUpdate(l.getDbFieldName(), v));
|
||||
sql.set(new UniversalImpl().buildUpdate(l.getDbFieldName(), v));
|
||||
}
|
||||
});
|
||||
// 修改数据
|
||||
return String.join(",", sqlList);
|
||||
return sql.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,13 +248,17 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
.equals(v.getIsShowFormCreate())).collect(Collectors.toList());
|
||||
List<LawsTag> finalFieldList = fieldList;
|
||||
StringBuilder updateSet = new StringBuilder();
|
||||
parameter.forEach((k, v) ->
|
||||
parameter.forEach((k, v) -> {
|
||||
// 修改字段
|
||||
updateSet.append(getUpdateValue(finalFieldList, k, (String) v))
|
||||
);
|
||||
String updateValue = getUpdateValue(finalFieldList, k, (String) v);
|
||||
if (StringUtils.isNotBlank(updateValue)){
|
||||
updateSet.append(updateValue).append(",");
|
||||
}
|
||||
});
|
||||
// 更新人和更新时间
|
||||
String updateByAndUpdateTime = new UniversalImpl().getUpdateByAndUpdateTime();
|
||||
updateSet.insert(0, updateByAndUpdateTime + ",");
|
||||
updateSet.deleteCharAt(updateSet.length() - 1);
|
||||
// where条件
|
||||
String updateCondition = "";
|
||||
if (parameter.containsKey("ids")){
|
||||
@@ -253,7 +307,7 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
// 目录更新
|
||||
List<String> menuIdList = listMap.stream().map(v -> (String) v.get(MENU_ID)).distinct().collect(Collectors.toList());
|
||||
// 删除旧数据
|
||||
documentSplitMapper.sarFileSplitMenudeleteByIdList(menuIdList);
|
||||
documentSplitMapper.sarFileSplitMenuDeleteByIdList(menuIdList);
|
||||
|
||||
// 修改条目
|
||||
ArrayList<SarFileSplitItemsValEO> sarFileSplitItemsValEOSList = new ArrayList<>();
|
||||
@@ -282,7 +336,13 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatchBatchDocumentSplitDetail(Map<String, Object> parameter) {
|
||||
public void deleteDocumentSplitDetail(Map<String, Object> parameter) {
|
||||
// 删除数据
|
||||
documentSplitMapper.deleteDocumentSplitDetail((String) parameter.get(ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatchDocumentSplitDetail(Map<String, Object> parameter) {
|
||||
// where条件
|
||||
String updateCondition = "";
|
||||
if (parameter.containsKey(ID)){
|
||||
@@ -294,7 +354,7 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
updateCondition = "info_id = " + "'" + infoId + "'";
|
||||
}
|
||||
// 删除数据
|
||||
documentSplitMapper.deleteBatchBatchDocumentSplitDetail(updateCondition);
|
||||
documentSplitMapper.deleteBatchDocumentSplitDetail(updateCondition);
|
||||
}
|
||||
|
||||
private String mergeData(List<Map<String, Object>> listMap) {
|
||||
|
||||
Reference in New Issue
Block a user