bug: 政策资料修改

This commit is contained in:
wxyclub
2023-11-10 17:05:11 +08:00
parent 092a7132d8
commit 45a6e34185
10 changed files with 251 additions and 41 deletions
@@ -29,17 +29,16 @@ public class ActSarLawsInformationEOService {
SarLawsInformation sarLawsInformation = JSONObject.parseObject(lawsInformationInfo, SarLawsInformation.class);
JSONObject jsonObject = JSONObject.parseObject(lawsInformationInfo);
String applyUserId = jsonObject.getString("applyUserId");
String applyUserName = jsonObject.getString("applyUserName");
// String applyUserName = jsonObject.getString("applyUserName");
String approverId = jsonObject.getString("approverId");
String approverName = jsonObject.getString("approverName");
// String approverName = jsonObject.getString("approverName");
String createAndApproveBy = "";
// 判断发起人和审批人是否相同
if (approverId.equals(applyUserId)) {
createAndApproveBy = applyUserName + "(" + applyUserId + ")";
createAndApproveBy = applyUserId;
}else {
createAndApproveBy = applyUserName + "(" + applyUserId + ")," + approverName + "(" + approverId + ")";
createAndApproveBy = applyUserId + "," + approverId;
}
sarLawsInformation.setCreateAndApproveBy(createAndApproveBy);
sarLawsInformation.setDownloadableBy(createAndApproveBy);
sarLawsInformation.setViewableBy(createAndApproveBy);
logger.info("政策法规资料入库:" + sarLawsInformation);
@@ -69,6 +69,9 @@ public class SarLawsInformationController extends BaseController<SarLawsInformat
@GetMapping("/page")
public ResponseMessage<PageInfo<SarLawsInformation>> page(SarLawsInformation sarLawsInformation) {
List<SarLawsInformation> rows = informationService.queryByPage(sarLawsInformation);
if (rows == null) {
return Result.error("查询失败!");
}
return Result.success(getPageInfo(sarLawsInformation.getPager(), rows));
}
@@ -0,0 +1,14 @@
package com.adc.da.slrs.sarLawsInformation.dao;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformationAuth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tjzdw
* @description
* @date 2023/11/10
*/
@Mapper
public interface SarLawsInformationAuthDao extends BaseMapper<SarLawsInformationAuth> {
}
@@ -154,21 +154,21 @@ public class SarLawsInformation extends BasePage implements Serializable {
* 可查看者,若设置为空则所有用户均可查看,若设置人员后,仅有可查看者可以查看文件信息。
*/
@ApiModelProperty(value = "可查看者")
@TableField(value = "VIEWABLE_BY")
@TableField(exist = false)
private String viewableBy;
/**
* 可下载者,若设置为空则仅有上传人和审批人可以查看,若设置人员后,仅有可下载者可下载文件信息。
*/
@ApiModelProperty(value = "可下载者")
@TableField(value = "DOWNLOADABLE_BY")
@TableField(exist = false)
private String downloadableBy;
/**
* 创建人和审批人
*/
@ApiModelProperty(value = "创建人和审批人")
@TableField
@TableField(exist = false)
private String createAndApproveBy;
/**
@@ -245,10 +245,17 @@ public class SarLawsInformation extends BasePage implements Serializable {
// 上传时间查询字段
@TableField(exist = false)
private Date uploadTimeBegin;
private String uploadTimeBegin;
@TableField(exist = false)
private Date uploadTimeEnd;
private String uploadTimeEnd;
// 查询使用 所有子节点列表
@TableField(exist = false)
private List<String> treeNodeIdList;
@TableField(exist = false)
private List<String> informationIdList;
// 是否可下载
@TableField(exist = false)
private Boolean downloadable;
}
@@ -0,0 +1,41 @@
package com.adc.da.slrs.sarLawsInformation.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author tjzdw
* @description
* @date 2023/11/10
*/
@TableName(value ="sar_laws_information_auth")
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@Data
public class SarLawsInformationAuth extends BaseEntity implements Serializable {
@ApiModelProperty(value = "主键")
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
@ApiModelProperty(value = "权限类型")
@TableField(value = "AUTH_TYPE")
private String authType;
@ApiModelProperty(value = "政策资料ID")
@TableField(value = "LAWS_INFORMATION_ID")
private String lawsInformationId;
@ApiModelProperty(value = "用户ID")
@TableField(value = "USER_ID")
private String userId;
}
@@ -0,0 +1,12 @@
package com.adc.da.slrs.sarLawsInformation.service;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformationAuth;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author tjzdw
* @description
* @date 2023/11/10
*/
public interface SarLawsInformationAuthService extends IService<SarLawsInformationAuth> {
}
@@ -18,7 +18,7 @@ public interface SarLawsInformationService extends IService<SarLawsInformation>
List<SarLawsInformation> queryByPage(SarLawsInformation sarLawsInformation);
Integer addLawsInformation(SarLawsInformation sarLawsInformation);
Boolean addLawsInformation(SarLawsInformation sarLawsInformation);
Boolean deleteInformation(String id);
@@ -0,0 +1,18 @@
package com.adc.da.slrs.sarLawsInformation.service.impl;
import com.adc.da.slrs.sarLawsInformation.dao.SarLawsInformationAuthDao;
import com.adc.da.slrs.sarLawsInformation.dao.SarLawsInformationDao;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformationAuth;
import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationAuthService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author tjzdw
* @description
* @date 2023/11/10
*/
@Service
public class SarLawsInformationAuthServiceImpl extends ServiceImpl<SarLawsInformationAuthDao, SarLawsInformationAuth>
implements SarLawsInformationAuthService {
}
@@ -1,6 +1,5 @@
package com.adc.da.slrs.sarLawsInformation.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.adc.da.att.entity.AttFileEO;
@@ -10,11 +9,12 @@ import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.person.entity.TsPersonCollect;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformationAuth;
import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationAuthService;
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.sarUser.entity.TsUser;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
@@ -22,7 +22,6 @@ import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
@@ -47,6 +46,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -61,6 +62,8 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
@Resource
private SarLawsInformationCenterTreeService treeService;
@Resource
private SarLawsInformationAuthService authService;
@Resource
private IAttFileEOService attFileEOService;
@Resource
private ITsDicTypeService dicTypeService;
@@ -100,11 +103,56 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
if (list.size() > 0) {
sarLawsInformation.setCollectId(list.get(0).getId());
}
// 查询可查看用户和可下载用户
String userId = LoginUserUtil.getUserId();
LambdaQueryWrapper<SarLawsInformationAuth> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId());
wrapper1.eq(SarLawsInformationAuth::getAuthType, "viewableBy");
wrapper1.select(SarLawsInformationAuth::getUserId);
List<SarLawsInformationAuth> list1 = authService.list(wrapper1);
if (list1.size() > 0) {
List<String> viewableBy = new ArrayList<>();
list1.forEach(item -> {
String userName = userService.userIdByName(userId);
viewableBy.add(userName);
});
sarLawsInformation.setViewableBy(String.join(",", viewableBy));
}
LambdaQueryWrapper<SarLawsInformationAuth> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId());
wrapper2.eq(SarLawsInformationAuth::getAuthType, "viewableBy");
wrapper2.select(SarLawsInformationAuth::getUserId);
List<SarLawsInformationAuth> list2 = authService.list(wrapper1);
if (list2.size() > 0) {
List<String> downloadableBy = new ArrayList<>();
list2.forEach(item -> {
String userName = userService.userIdByName(userId);
downloadableBy.add(userName);
// 判断是否可下载
if (item.getUserId().equals(userId)) {
sarLawsInformation.setDownloadable(true);
}
});
sarLawsInformation.setDownloadableBy(String.join(",", downloadableBy));
}
return sarLawsInformation;
}
@Override
public List<SarLawsInformation> queryByPage(SarLawsInformation page) {
String userId = LoginUserUtil.getUserId();
if (StringUtils.isBlank(userId)) {
return null;
}
// 查询有权限的资料ID
LambdaQueryWrapper<SarLawsInformationAuth> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SarLawsInformationAuth::getUserId, userId);
wrapper.select(SarLawsInformationAuth::getLawsInformationId);
List<SarLawsInformationAuth> informationAuthList = authService.list(wrapper);
if (informationAuthList.size() > 0) {
List<String> informationIdList = informationAuthList.stream().map(SarLawsInformationAuth::getLawsInformationId).collect(Collectors.toList());
page.setInformationIdList(informationIdList);
}
// 设置排序字段
if("name".equals(page.getSortField()) || "uploadTime".equals(page.getSortField())) {
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
@@ -144,7 +192,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
@Override
public Integer addLawsInformation(SarLawsInformation sarLawsInformation) {
public Boolean addLawsInformation(SarLawsInformation sarLawsInformation) {
sarLawsInformation.setCreateTime(new Date());
sarLawsInformation.setModifyTime(new Date());
if (sarLawsInformation.getUploadTime() == null) {
@@ -152,23 +200,6 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
sarLawsInformation.setValidFlag(0);
String userId = LoginUserUtil.getUserId();
TsUser tsUser = userService.getById(userId);
String userInfo = tsUser.getUname() + "(" + userId + ")";
// 设置可见人和下载人
if (StringUtils.isBlank(sarLawsInformation.getViewableBy())) {
sarLawsInformation.setViewableBy(userInfo);
} else {
if (!sarLawsInformation.getViewableBy().contains(userInfo)) {
sarLawsInformation.setViewableBy(sarLawsInformation.getViewableBy() + "," + userInfo);
}
}
if (StringUtils.isBlank(sarLawsInformation.getDownloadableBy())) {
sarLawsInformation.setDownloadableBy(userInfo);
} else {
if (!sarLawsInformation.getDownloadableBy().contains(userInfo)) {
sarLawsInformation.setDownloadableBy(sarLawsInformation.getDownloadableBy() + "," + userInfo);
}
}
// 若体系类别不存在,则默认属于根节点
if (StringUtils.isBlank(sarLawsInformation.getTreeNodeId())) {
LambdaQueryWrapper<SarLawsInformationCenterTree> wrapper = new LambdaQueryWrapper<>();
@@ -176,7 +207,66 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
SarLawsInformationCenterTree one = treeService.getOne(wrapper);
sarLawsInformation.setTreeNodeId(one.getId());
}
return this.baseMapper.insert(sarLawsInformation);
int insert = this.baseMapper.insert(sarLawsInformation);
if (insert <= 0) {
return false;
}
// 设置可见人和下载人
if (StringUtils.isBlank(sarLawsInformation.getViewableBy())) {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("viewableBy");
auth.setUserId(userId);
authService.save(auth);
} else {
List<String> viewableByList = extractContentInParentheses(sarLawsInformation.getViewableBy());
if (!viewableByList.contains(userId)) {
viewableByList.add(userId);
}
viewableByList.forEach(viewableBy -> {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("viewableBy");
auth.setUserId(viewableBy);
authService.save(auth);
});
}
if (StringUtils.isBlank(sarLawsInformation.getDownloadableBy())) {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("downloadableBy");
auth.setUserId(userId);
authService.save(auth);
} else {
List<String> downloadableByList = extractContentInParentheses(sarLawsInformation.getDownloadableBy());
if (!downloadableByList.contains(userId)) {
downloadableByList.add(userId);
}
downloadableByList.forEach(viewableBy -> {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("downloadableBy");
auth.setUserId(viewableBy);
authService.save(auth);
});
}
// 流程入库审批人和创建人入库
if (sarLawsInformation.getCreateAndApproveBy() != null) {
for (String userIdBy : sarLawsInformation.getCreateAndApproveBy().split(",")) {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("createAndApproveBy");
auth.setUserId(userId);
authService.save(auth);
}
}
// 配置初始人员权限
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("createAndApproveBy");
auth.setUserId(userId);
authService.save(auth);
return true;
}
@Override
@@ -185,7 +275,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
wrapper.eq(SarLawsInformation::getId, id);
wrapper.set(SarLawsInformation::getValidFlag,1);
wrapper.set(SarLawsInformation::getModifyTime,new Date());
return update(wrapper);
boolean update = update(wrapper);
if (update) {
LambdaQueryWrapper<SarLawsInformationAuth> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(SarLawsInformationAuth::getLawsInformationId, id);
authService.remove(wrapper1);
}
return false;
}
@Override
@@ -449,15 +545,14 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
*/
public List<String> compareSarLawsInformation(SarLawsInformation oldInfo, SarLawsInformation newInfo) {
List<String> changes = new ArrayList<>();
// 需要比较的字段
String[] ignoreFields = {"id","firstTypeName","secondTypeName","thirdTypeName","fourthTypeName","uploadTime",
"informationFileList","createAndApproveBy","treeNodeId","treeNodeName","validFlag","createTime",
"modifyTime","sortField","sortMode","collectId","serialVersionUID","uploadTimeBegin","uploadTimeEnd"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 需要比较的字段
String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name",
"department","author","description","informationFile","treeNodeId"};
List<String> fieldList = Arrays.asList(fieldArr);
// 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields();
for (Field field : fields) {
if (!ignoreFieldList.contains(field.getName())) {
if (fieldList.contains(field.getName())) {
try {
field.setAccessible(true);
String oldValue = String.valueOf(field.get(oldInfo));
@@ -533,6 +628,21 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
return resultlist;
}
/**
* 获取括号内的内容转换成列表
* @param input 类似于 张兰英(zhanglanying),管理员(admin) 的字符串
* @return 括号内内容的List
*/
private static List<String> extractContentInParentheses(String input) {
List<String> results = new ArrayList<>();
Pattern pattern = Pattern.compile("\\(([^)]+)\\)");
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
results.add(matcher.group(1));
}
return results;
}
}
@@ -57,7 +57,7 @@
and `NAME` like concat('%',#{name},'%')
</if>
<if test="uploadTimeBegin != null and uploadTimeEnd != null">
and UPLOAD_TIME between #{uploadTimeBegin} and ${uploadTimeEnd}
and UPLOAD_TIME between DATE_FORMAT(#{uploadTimeBegin}, '%Y-%m-%d') and DATE_FORMAT(${uploadTimeEnd}, '%Y-%m-%d')
</if>
<if test="treeNodeIdList != null and treeNodeIdList.size() &gt; 0">
and TREE_NODE_ID in
@@ -65,6 +65,12 @@
#{treeNodeId}
</foreach>
</if>
<if test="informationIdList != null and informationIdList.size() &gt; 0">
and ID in
<foreach collection="informationIdList" item="informationId" index="index" separator="," open="(" close=")">
#{informationId}
</foreach>
</if>
</sql>
<select id="queryByPageCount" resultType="java.lang.Integer">
select count(1)