add:政策资料详情

This commit is contained in:
wxyclub
2023-10-26 13:57:50 +08:00
parent 5b04a8ac44
commit 58b20a75b3
3 changed files with 157 additions and 26 deletions
@@ -122,17 +122,23 @@ public class SarLawsInformation extends BasePage implements Serializable {
private String informationFileName;
/**
* 可查看者,若设置为空则仅有上传人和审批人可以查看,若设置人员后,仅有可查看者可查看文件信息。
* 可查看者,若设置为空则所有用户均可查看,若设置人员后,仅有可查看者可查看文件信息。
*/
@TableField(value = "VIEWABLE_BY")
private String viewableBy;
/**
* 可下载者,若设置为空则所有用户均可下载,若设置人员后,仅有可下载者可下载文件信息。
* 可下载者,若设置为空则仅有上传人和审批人可以查看,若设置人员后,仅有可下载者可下载文件信息。
*/
@TableField(value = "DOWNLOADABLE_BY")
private String downloadableBy;
/**
* 创建人和审批人
*/
@TableField
private String createAndApproveBy;
/**
* 树节点ID
*/
@@ -179,6 +185,12 @@ public class SarLawsInformation extends BasePage implements Serializable {
@TableField(exist = false)
private String sortMode = "asc";
/**
* 收藏ID
*/
@TableField(exist = false)
private String collectId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
@@ -2,9 +2,15 @@ package com.adc.da.slrs.sarLawsInformation.service.impl;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.person.entity.TsPersonCollect;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.slrs.sarLawsInformationCenterTree.entity.SarLawsInformationCenterTree;
import com.adc.da.slrs.sarLawsInformationCenterTree.service.SarLawsInformationCenterTreeService;
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,9 +21,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
/**
* @author tjzdw
@@ -34,23 +41,16 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
private IAttFileEOService attFileEOService;
@Resource
private ITsDicTypeService dicTypeService;
@Resource
private IPersonCollectEOService collectEOService;
@Resource
private ISarUpdLogService updLogService;
@Override
public SarLawsInformation getLawsInformationInfo(String id) {
SarLawsInformation sarLawsInformation = this.baseMapper.selectById(id);
// 根据类别Id查询类别名称
if (StringUtils.isNotBlank(sarLawsInformation.getFirstType())) {
sarLawsInformation.setFirstTypeName(dicTypeService.getDicTypeNameByDicCode(sarLawsInformation.getFirstType()));
}
if (StringUtils.isNotBlank(sarLawsInformation.getSecondType())) {
sarLawsInformation.setSecondTypeName(dicTypeService.getDicTypeNameByDicCode(sarLawsInformation.getSecondType()));
}
if (StringUtils.isNotBlank(sarLawsInformation.getThirdType())) {
sarLawsInformation.setThirdTypeName(dicTypeService.getDicTypeNameByDicCode(sarLawsInformation.getThirdType()));
}
if (StringUtils.isNotBlank(sarLawsInformation.getFourthType())) {
sarLawsInformation.setFourthTypeName(dicTypeService.getDicTypeNameByDicCode(sarLawsInformation.getFourthType()));
}
// 将字典编号变更为字典值
convertCodeToName(sarLawsInformation);
// 查询资料文件信息
if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) {
String[] split = sarLawsInformation.getInformationFile().split(",");
@@ -66,6 +66,14 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
SarLawsInformationCenterTree treeNode = treeService.getById(sarLawsInformation.getTreeNodeId());
sarLawsInformation.setTreeNodeName(treeNode.getName());
}
// 查询是否被收藏
LambdaQueryWrapper<TsPersonCollect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TsPersonCollect::getCollectResId, sarLawsInformation.getId());
wrapper.eq(TsPersonCollect::getValidFlag, 0);
List<TsPersonCollect> list = collectEOService.list();
if (list.size() > 0) {
sarLawsInformation.setCollectId(list.get(0).getId());
}
return sarLawsInformation;
}
@@ -81,7 +89,12 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
Integer rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount);
return this.baseMapper.queryByPage(page);
// 将字典编号变更为字典值
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.queryByPage(page);
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
convertCodeToName(sarLawsInformation);
}
return sarLawsInformationList;
}
@Override
@@ -114,10 +127,120 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
if (StringUtils.isBlank(lawsInformation.getId())) {
return false;
}
SarLawsInformation oldLawsInformation = getLawsInformationInfo(lawsInformation.getId());
lawsInformation.setModifyTime(new Date());
int update = this.baseMapper.updateById(lawsInformation);
// 比较修改前后的不同
List<String> compareResult = compareSarLawsInformation(oldLawsInformation, lawsInformation);
if (compareResult.size() > 0) {
int update = this.baseMapper.updateById(lawsInformation);
// 添加修改记录
SarUpdLog sarUpdLogEO = new SarUpdLog();
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
sarUpdLogEO.setSarId(oldLawsInformation.getId());
sarUpdLogEO.setSarType("LAWS_INFORMATION");
sarUpdLogEO.setCreationTime(new Date());
sarUpdLogEO.setCreationUser(LoginUserUtil.getUserId());
sarUpdLogEO.setContent(oldLawsInformation.getName() + "," + String.join(",",compareResult));
updLogService.save(sarUpdLogEO);
}
return true;
}
public void convertCodeToName(SarLawsInformation sarLawsInformation) {
List<String> firstTypeList = new ArrayList<>();
for (String type : sarLawsInformation.getFirstType().split(",")) {
if (StringUtils.isNotBlank(type)) {
firstTypeList.add(dicTypeService.getDicTypeNameByDicCode(type));
}
}
sarLawsInformation.setFirstTypeName(String.join(",",firstTypeList));
List<String> secondTypeList = new ArrayList<>();
for (String type : sarLawsInformation.getSecondType().split(",")) {
if (StringUtils.isNotBlank(type)) {
secondTypeList.add(dicTypeService.getDicTypeNameByDicCode(type));
}
}
sarLawsInformation.setSecondTypeName(String.join(",",secondTypeList));
List<String> thirdTypeList = new ArrayList<>();
for (String type : sarLawsInformation.getThirdType().split(",")) {
if (StringUtils.isNotBlank(type)) {
thirdTypeList.add(dicTypeService.getDicTypeNameByDicCode(type));
}
}
sarLawsInformation.setThirdTypeName(String.join(",",thirdTypeList));
List<String> fourthTypeList = new ArrayList<>();
for (String type : sarLawsInformation.getFourthType().split(",")) {
if (StringUtils.isNotBlank(type)) {
fourthTypeList.add(dicTypeService.getDicTypeNameByDicCode(type));
}
}
sarLawsInformation.setFirstTypeName(String.join(",",fourthTypeList));
}
/**
* 比较两个SarLawsInformation 对象
* @param oldInfo 数据库中存储的对象
* @param newInfo 更新后的对象
* @return 差异
*/
public List<String> compareSarLawsInformation(SarLawsInformation oldInfo, SarLawsInformation newInfo) {
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","firstTypeName","secondTypeName","thirdTypeName","fourthTypeName","uploadTime",
"informationFileName","createAndApproveBy","treeNodeId","treeNodeName","validFlag","createTime",
"modifyTime","sortField","sortMode","collectId","serialVersionUID"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields();
for (Field field : fields) {
if (!ignoreFieldList.contains(field.getName())) {
try {
field.setAccessible(true);
String oldValue = String.valueOf(field.get(oldInfo));
String newValue = String.valueOf(field.get(newInfo));
if (!Objects.equals(oldValue, newValue)) {
if ("firstType".equals(field.getName()) || "secondType".equals(field.getName()) || "thirdType".equals(field.getName()) ||
"fourthType".equals(field.getName())) {
List<String> typeNameList = new ArrayList<>();
if (StringUtils.isNotBlank(newValue)) {
for (String type : newValue.split(",")) {
if (StringUtils.isNotBlank(type)) {
typeNameList.add(dicTypeService.getDicTypeNameByDicCode(type));
}
}
}
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldInfo);
changes.add("\"" + field.getName() + "\"\"" + oldTypeName + "\"\"改为\"\"" + String.join(",",typeNameList) + "\"");
} else if ("informationFile".equals(field.getName())) {
List<String> fileNameList = new ArrayList<>();
if (StringUtils.isNotBlank(newValue)) {
String[] split = newValue.split(",");
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo.getOldFileName());
}
}
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldInfo);
changes.add(field.getName() + "\"" + oldTypeName + "\"\"改为\"\"" + String.join(",",fileNameList) + "\"");
}
else {
changes.add("\"" + field.getName() + "\"\"" + oldValue + "\"\"改为\"\"" + newValue + "\"");
}
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// 处理异常
e.printStackTrace();
}
}
}
return changes;
}
}
@@ -31,13 +31,9 @@
<sql id="Base_Column_List">
ID,
FIRST_TYPE,
(select DIC_TYPE_NAME from ts_dictype where DIC_ID = (SELECT ID FROM `ts_dictionary` where DICTIONARY_CODE = "firstMaterialType") and DIC_TYPE_CODE = FIRST_TYPE) firstTypeName,
SECOND_TYPE,
(select DIC_TYPE_NAME from ts_dictype where DIC_ID = (SELECT ID FROM `ts_dictionary` where DICTIONARY_CODE = "secondMaterialType") and DIC_TYPE_CODE = SECOND_TYPE) secondTypeName,
THIRD_TYPE,
(select DIC_TYPE_NAME from ts_dictype where DIC_ID = (SELECT ID FROM `ts_dictionary` where DICTIONARY_CODE = "thirdMaterialType") and DIC_TYPE_CODE = THIRD_TYPE) thirdTypeName,
FOURTH_TYPE,
(select DIC_TYPE_NAME from ts_dictype where DIC_ID = (SELECT ID FROM `ts_dictionary` where DICTIONARY_CODE = "fourthMaterialType") and DIC_TYPE_CODE = FOURTH_TYPE) fourthTypeName,
`NAME`,
DEPARTMENT,AUTHOR,UPLOAD_TIME,
`DESCRIPTION`,INFORMATION_FILE,VIEWABLE_BY,
@@ -46,10 +42,10 @@
</sql>
<sql id="Base_Where_Clause">
<if test="firstType != null and firstType != ''">
and FIRST_TYPE = #{firstType}
and FIRST_TYPE like concat('%',#{firstType},'%')
</if>
<if test="secondType != null and secondType != ''">
and SECOND_TYPE = #{secondType}
and SECOND_TYPE like concat('%',#{secondType},'%')
</if>
<if test="name != null and name != ''">
and `NAME` like concat('%',#{name},'%')