文档拆分修改成固定字段-导入功能

This commit is contained in:
wangzhijiang
2024-02-20 17:58:44 +08:00
parent 7524c7cdd7
commit 7b7b9c25b8
7 changed files with 224 additions and 175 deletions
@@ -1,11 +1,16 @@
package com.jero.modules.documenttool.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.*;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @Author: yjz
@@ -18,6 +23,12 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="laws_document_split对象", description="文档拆分")
public class LawsDocumentSplit extends BaseEntity {
/**
* 主键id
*/
@ApiModelProperty("主键id")
private String id;
/**
* 条文号
*/
@@ -36,6 +47,12 @@ public class LawsDocumentSplit extends BaseEntity {
@ApiModelProperty("条文内容")
private String itemContent;
/**
* 条文解读
*/
@ApiModelProperty("条文解读")
private String interpretationArticles;
/**
* 展示顺序
*/
@@ -48,93 +65,37 @@ public class LawsDocumentSplit extends BaseEntity {
@ApiModelProperty("拆分目录id")
private String menuId;
/**
* 技术领域
*/
@ApiModelProperty("技术领域")
private String technicalField;
/**
* 信息类别
*/
@ApiModelProperty("信息类别")
private String infoType;
/**
* 法规要求类型
*/
@ApiModelProperty("法规要求类型")
private String lawsRequireType;
/**
* 功能分类
*/
@ApiModelProperty("功能分类")
private String functionClassification;
/**
* 功能专业
*/
@ApiModelProperty("功能专业")
private String functionProfessional;
/**
* 功能分组编码
*/
@ApiModelProperty("功能分组编码")
private String functionGroupCode;
/**
* 功能分组名称
*/
@ApiModelProperty("功能分组名称")
private String functionGroupName;
/**
* 新认证实施时间
*/
@ApiModelProperty("新认证实施时间")
private String newCerImplementDate;
/**
* 已认证实施时间
*/
@ApiModelProperty("已认证实施时间")
private String cerImplementDate;
/**
* 新注册实施时间
*/
@ApiModelProperty("新注册实施时间")
private String newRegisterImplementDate;
/**
* 适用车型
*/
@ApiModelProperty("适用车型")
private String applications;
/**
* 动力类型
*/
@ApiModelProperty("动力类型")
private String dynamicType;
/**
* 适用零部件
*/
@ApiModelProperty("适用零部件")
private String applicableComponents;
/**
* 条文解读
*/
@ApiModelProperty("条文解读")
private String interpretationArticles;
/**
* 拆分信息记录id
*/
@ApiModelProperty("拆分信息记录id")
private String infoId;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**拆分时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "拆分时间")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**
* 逻辑删除标识 0未删 1已删
*/
@TableLogic
// @TableField(value = "del_flag")
@ApiModelProperty(value = "逻辑删除标识 0未删 1已删")
private Integer delFlag;
}
@@ -37,11 +37,10 @@ public interface DocumentSplitMapper {
/**
* 文档拆分详情-分页列表查询
* @param mapPage
* @param selectColumn
* @param selectCondition
* @param params
* @return
*/
IPage<Map<String, Object>> queryDocumentSplitDetail(Page<Map<String, Object>> mapPage, @Param("selectColumn") String selectColumn, @Param("selectCondition") String selectCondition);
IPage<Map<String, Object>> queryDocumentSplitDetail(Page<Map<String, Object>> mapPage, @Param("params") Map<String,Object> params);
/**
* 文档拆分详情-列表查询
@@ -2,6 +2,40 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.documenttool.mapper.DocumentSplitMapper">
<!-- 基础列 -->
<sql id="Base_Column_List">
id,
item_num,
item_title,
item_content,
interpretation_articles,
sort_number,
menu_id,
info_id,
create_by,
create_time,
update_by,
update_time,
del_flag
</sql>
<!-- 通用查询结果列 -->
<sql id="Query_Base_Column_List">
lds.id,
lds.item_num,
lds.item_title,
lds.item_content,
lds.interpretation_articles,
lds.sort_number,
lds.menu_id,
lds.info_id,
lds.create_by,
lds.create_time,
lds.update_by,
lds.update_time,
lds.del_flag
</sql>
<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)
@@ -132,12 +166,71 @@
<select id="queryDocumentSplitDetail" resultType="java.util.Map">
select
${selectColumn}
from laws_document_split s
left join SAR_FILE_SPLIT_MENU m on s.MENU_ID = m.id
${selectCondition}
<include refid="Query_Base_Column_List" />
from
laws_document_split lds
left join SAR_FILE_SPLIT_MENU m on lds.MENU_ID = m.id
<include refid="Base_Where_Clause"/>
order by lds.create_time desc
</select>
<!-- 查询条件 -->
<sql id="Base_Where_Clause">
where lds.del_flag = 0
<trim suffixOverrides="," >
<if test="params.info_id != null" >
and lds.info_id = #{params.info_id}
</if>
<if test="params.menu_id != null" >
and lds.menu_id = #{params.menu_id}
</if>
<!--<if test="standNumber != null" >
and ncl.STAND_NUMBER like concat(concat('%', #{standNumber}),'%')
</if>
<if test="standName != null" >
and ncl.STAND_NAME like concat(concat('%', #{standName}),'%')
</if>
<if test="suitabilityResult != null" >
and ncl.SUITABILITY_RESULT = #{suitabilityResult}
</if>
<if test="suitabilityCategory != null" >
and ncl.SUITABILITY_CATEGORY = #{suitabilityCategory}
</if>
<if test="whetherAuthenticationCorresponding != null" >
and ncl.WHETHER_AUTHENTICATION_CORRESPONDING = #{whetherAuthenticationCorresponding}
</if>
<if test="authenticationCorrespondingType != null" >
and (
ncl.AUTHENTICATION_CORRESPONDING_TYPE = #{authenticationCorrespondingType}
<foreach item="item" index="index" collection="authenticationCorrespondingType.split(',')">
or ncl.AUTHENTICATION_CORRESPONDING_TYPE like concat(concat('%',#{item}),'%')
</foreach>
)
</if>
<if test="closedState != null" >
and ncl.CLOSED_STATE = #{closedState}
</if>
<if test="ids != null and ids.size != 0">
and ncl.ID in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="standId != null" >
and ncl.STAND_ID = #{standId}
</if>
<if test="standIdList != null and standIdList.size != 0" >
and sl.STAND_ID in
<foreach collection="standIdList" item="standId" open="(" separator="," close=")">
#{standId}
</foreach>
</if>
<if test="projectLibraryId != null" >
and ncl.PROJECT_LIBRARY_ID = #{projectLibraryId}
</if>-->
</trim>
</sql>
<select id="queryItemsValByItemIds" resultType="com.jero.modules.split.entity.SarFileSplitItemsValEO">
select id, type, item_id, item_content, valid_flag, creation_user,
creation_time, modify_time, modify_user, display_seq,img_name,index_item
@@ -201,33 +201,14 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
@Override
public IPage<Map<String, Object>> queryDocumentSplitDetail(Map<String, Object> parameter) {
// isHorizontalOverstep(parameter.get(INFO_ID).toString());
// // 查询全部字段列表
// List<LawsTag> fieldList = lawsCommonMapper.getFieldList(TableNameEnum.DOCUMENT_SPLIT.getTableName());
// // 列表展示字段
// List<LawsTag> fieldListSelect = fieldList.stream().filter(v -> YesOrNoEnum.YES.getValue()
// .equals(String.valueOf(v.getIsShowList()))).collect(Collectors.toList());
// // 搜索条件展示字段
// List<LawsTag> fieldListCondition = fieldList.stream().filter(v -> YesOrNoEnum.YES.getValue()
// .equals(String.valueOf(v.getIsQuery()))).collect(Collectors.toList());
//
// 分页参数
int pageNo = Integer.parseInt((String) parameter.get("pageNo"));
int pageSize = Integer.parseInt((String) parameter.get("pageSize"));
//
// // sql查询列字段拼接
// String selectColumn = getSelectColumn(fieldListSelect);
// // sql where条件拼接
// String selectCondition = getSelectCondition(parameter, fieldListCondition);
// // 排序
// selectCondition = orderBy(parameter, selectCondition, fieldListSelect);
String selectColumn = "*";
String selectCondition = "order by create_time desc";
// String selectCondition = "order by create_time desc";
// 查询数据
IPage<Map<String, Object>> mapIPage = documentSplitMapper.queryDocumentSplitDetail(new Page<>(pageNo, pageSize), selectColumn, selectCondition);
IPage<Map<String, Object>> mapIPage = documentSplitMapper.queryDocumentSplitDetail(new Page<>(pageNo, pageSize), parameter);
// // 翻译
// dicTranslate(mapIPage.getRecords(), fieldListSelect);
// return mapIPage;
return mapIPage;
}
@@ -749,9 +730,6 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
@Override
public void deleteDocumentSplitDetail(Map<String, Object> parameter) {
String id = (String) parameter.get(ID);
// 水平越权
Map<String, Object> map = documentSplitMapper.queryLawsDocumentSplitInId(id);
isHorizontalOverstep(map.get(INFO_ID).toString());
// 删除文档拆分详情数据
documentSplitMapper.deleteDocumentSplitDetail(id);
@@ -841,9 +819,6 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
@Override
public void downloadImportTemplate(HttpServletRequest request, HttpServletResponse response) {
// 水平越权
isHorizontalOverstep(request.getParameter("infoId"));
try (Workbook workbook = new XSSFWorkbook()){
String fileName = "拆分导入模版下载.xlsx";
// sheet页
@@ -2,6 +2,7 @@ package com.jero.modules.split.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.documenttool.entity.LawsDocumentSplit;
import com.jero.modules.split.entity.SarFileSplitItemsEO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -79,4 +80,6 @@ public interface FileSplitItemsEOMapper extends BaseMapper<SarFileSplitItemsEO>
List<SarFileSplitItemsEO> selectByInfoId(String value);
void updateSarFileSplitItemsInfo(@Param("sarFileSplitItemsEO") SarFileSplitItemsEO sarFileSplitItemsEO);
void insertLawsDocumentSplit(LawsDocumentSplit lawsDocumentSplit);
}
@@ -144,4 +144,39 @@
</set>
where id = #{sarFileSplitItemsEO.id, jdbcType=VARCHAR}
</update>
<!--新增-->
<insert id="insertLawsDocumentSplit" parameterType="com.jero.modules.documenttool.entity.LawsDocumentSplit">
insert into laws_document_split
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >id,</if>
<if test="itemNum != null" >item_num,</if>
<if test="itemTitle != null" >item_title,</if>
<if test="itemContent != null" >item_content,</if>
<if test="interpretationArticles != null" >interpretation_articles,</if>
<if test="sortNumber != null" >sort_number,</if>
<if test="menuId != null" >menu_id,</if>
<if test="infoId != null" >info_id,</if>
<if test="createBy != null" >create_by,</if>
<if test="createTime != null" >create_time,</if>
<if test="updateBy != null" >update_by,</if>
<if test="updateTime != null" >update_time,</if>
<if test="delFlag != null" >del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >#{id, jdbcType=INTEGER},</if>
<if test="itemNum != null" >#{itemNum, jdbcType=VARCHAR},</if>
<if test="itemTitle != null" >#{itemTitle, jdbcType=VARCHAR},</if>
<if test="itemContent != null" >#{itemContent, jdbcType=VARCHAR},</if>
<if test="interpretationArticles != null" >#{interpretationArticles, jdbcType=VARCHAR},</if>
<if test="sortNumber != null" >#{sortNumber, jdbcType=VARCHAR},</if>
<if test="menuId != null" >#{menuId, jdbcType=VARCHAR},</if>
<if test="infoId != null" >#{infoId, jdbcType=VARCHAR},</if>
<if test="createBy != null" >#{createBy, jdbcType=VARCHAR},</if>
<if test="createTime != null" >#{createTime, jdbcType=TIMESTAMP},</if>
<if test="updateBy != null" >#{updateBy, jdbcType=VARCHAR},</if>
<if test="updateTime != null" >#{updateTime, jdbcType=TIMESTAMP},</if>
<if test="delFlag != null" >#{delFlag, jdbcType=INTEGER},</if>
</trim>
</insert>
</mapper>
@@ -22,6 +22,7 @@ import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
import com.jero.modules.document.enums.FieldTypeEnum;
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.documenttool.entity.LawsDocumentSplit;
import com.jero.modules.documenttool.service.IDocumentSplitService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
@@ -509,10 +510,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
private String getMustValues(String id) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String mustValue = "'" + id + "','" + sysUser.getUsername() + "',"
+ "str_to_date('" + sdf.format(new Date()) + "','%Y-%m-%d %H:%i:%s')" + ",'" + sysUser.getUsername() + "',"
+ "str_to_date('" + sdf.format(new Date()) + "','%Y-%m-%d %H:%i:%s')" + ",'" + sysUser.getOrgCode() + "'";
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userName = "";
String orgCode = "";
String mustValue = "'" + id + "','" + userName + "',"
+ "str_to_date('" + sdf.format(new Date()) + "','%Y-%m-%d %H:%i:%s')" + ",'" + userName + "',"
+ "str_to_date('" + sdf.format(new Date()) + "','%Y-%m-%d %H:%i:%s')" + ",'" + orgCode + "'";
return mustValue;
}
@@ -1446,8 +1449,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
List<Map<String, Object>> itemsEOList = new ArrayList<>(addItemsEOList);
List<SarFileSplitMenuTreeNode> treeList = buildTree(itemsEOList, treeListDisplay, menuId);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = "";
for (SarFileSplitMenuTreeNode treeNode : treeList) {
menuAndItemMap.put(treeNode.getItemId(), treeNode.getId());
}
@@ -1520,9 +1523,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
@Override
public Result<?> importSplitItems(MultipartFile file, String cut, String menuId, String infoId) throws IOException {
// 水平越权
documentSplitService.isHorizontalOverstep(infoId);
//验证文件名是否合格
/* 截取后缀名 */
int pos = file.getOriginalFilename().lastIndexOf(".");
@@ -1789,36 +1789,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//获得总列数
int cellLength = sheet.getRow(0).getPhysicalNumberOfCells();
// 验证模板表头是否正确
Row rowTitle = sheet.getRow(0);
// for (int i = 0; i < cellLength; i++) {
// if (rowTitle != null) {
// Cell cell = rowTitle.getCell(i);
// if(ObjectUtil.isNotNull(cell)){
// //设置单元格类型
// cell.setCellType(CellType.STRING);
// String cellValue = cell.getStringCellValue().substring(cell.getStringCellValue().indexOf("*")+1);
// if(!cellValue.equals(titles[i])){
// if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
// throw new JeroBootException("请导入正确模板!");
// } else {
// throw new JeroBootException("Please import the correct template");
// }
// }
// } else{
// if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
// throw new JeroBootException("请导入正确模板!");
// } else {
// throw new JeroBootException("Please import the correct template");
// }
// }
// }else{
// if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
// throw new JeroBootException("请导入正确模板!");
// } else {
// throw new JeroBootException("Please import the correct template");
// }
// }
// }
Row rowDescription= sheet.getRow(1);
if (rowDescription != null) {
Cell cell = rowDescription.getCell(0);
@@ -2486,8 +2456,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
private void createItemsInfo(Map<String, Object> sarFileSplitItemsEO, String menuId, String infoId){
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = "";
//创建菜单
// SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
// sarFileSplitMenuEO.setInfoId(infoId);
@@ -2539,7 +2509,23 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
sarFileSplitItemsEO.remove("id");
sarFileSplitItemsEO.remove("itemValEOList");
sarFileSplitItemsEO = filterMap(sarFileSplitItemsEO);
insertInfo(sarFileSplitItemsEO,id,"import"); // 添加条款
// insertInfo(sarFileSplitItemsEO,id,"import"); // 添加条款
LawsDocumentSplit lawsDocumentSplit = new LawsDocumentSplit();
lawsDocumentSplit.setId(UUID.randomUUID().toString().replace("-", ""));
lawsDocumentSplit.setItemNum(sarFileSplitItemsEO.get("item_num").toString());
lawsDocumentSplit.setItemTitle(sarFileSplitItemsEO.get("item_title").toString());
lawsDocumentSplit.setItemContent(sarFileSplitItemsEO.get("item_content").toString());
lawsDocumentSplit.setInterpretationArticles("");
lawsDocumentSplit.setSortNumber("");
lawsDocumentSplit.setMenuId(sarFileSplitItemsEO.get("menu_id").toString());
lawsDocumentSplit.setInfoId(sarFileSplitItemsEO.get("info_id").toString());
lawsDocumentSplit.setDelFlag(0);
lawsDocumentSplit.setCreateTime(new Date());
lawsDocumentSplit.setUpdateTime(new Date());
this.dao.insertLawsDocumentSplit(lawsDocumentSplit);
}
private List<SarFileSplitMenuTreeNode> buildTree(List<Map<String, Object>> addItemsEOList, Long treeListDisplay, String menuId){
@@ -3788,18 +3774,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
*/
@Override
public String[] getWorkbookTitleForExport(String cut) {
// 查询全部字段列表
// List<LawsTag> fieldList = lawsCommonMapper.getFieldList(TableNameEnum.DOCUMENT_SPLIT.getTableName());
List<LawsTag> fieldList = new ArrayList<>();
// 列表展示字段
List<LawsTag> fieldListSelect = fieldList.stream().filter(v -> YesOrNoEnum.YES.getValue()
.equals(String.valueOf(v.getIsShowList()))).collect(Collectors.toList());
List<String> fieldForExport = new ArrayList<>();
if (MessageUtils.getLanguage().getValue().equals(LanguageEnum.EN.getValue())){
fieldForExport = fieldListSelect.stream().map(LawsTag::getDbFieldEnName).collect(Collectors.toList());
} else {
fieldForExport = fieldListSelect.stream().map(LawsTag::getDbFieldTxt).collect(Collectors.toList());
}
fieldForExport.add("条款号");
fieldForExport.add("条款名称");
fieldForExport.add("条款内容");
return StringUtils.join(fieldForExport, ",").split(",");
}
@@ -3826,10 +3804,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 查询全部字段列表
// List<LawsTag> fieldList = lawsCommonMapper.getFieldList(TableNameEnum.DOCUMENT_SPLIT.getTableName());
List<LawsTag> fieldList = new ArrayList<>();
// 列表展示字段
List<String> fieldListSelect = fieldList.stream().filter(v -> YesOrNoEnum.YES.getValue()
.equals(String.valueOf(v.getIsShowList()))).map(LawsTag::getDbFieldName).collect(Collectors.toList());
// List<LawsTag> fieldList = new ArrayList<>();
// // 列表展示字段
// List<String> fieldListSelect = fieldList.stream().filter(v -> YesOrNoEnum.YES.getValue()
// .equals(String.valueOf(v.getIsShowList()))).map(LawsTag::getDbFieldName).collect(Collectors.toList());
List<String> fieldListSelect = new ArrayList<>();
fieldListSelect.add("item_num");
fieldListSelect.add("item_title");
fieldListSelect.add("item_content");
return StringUtils.join(fieldListSelect, ",");
}