bug: 政策资料修改

This commit is contained in:
wxyclub
2023-11-12 13:02:46 +08:00
parent 45a6e34185
commit d23cef196d
3 changed files with 133 additions and 87 deletions
@@ -45,7 +45,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
* 一级资料类别名称 * 一级资料类别名称
*/ */
@ApiModelProperty(value = "一级资料类别名称") @ApiModelProperty(value = "一级资料类别名称")
@TableField(exist = false) // @TableField(exist = false)
@Excel(name = "一级资料类别", orderNum = "0") @Excel(name = "一级资料类别", orderNum = "0")
private String firstTypeName; private String firstTypeName;
@@ -60,7 +60,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
* 二级资料类别名称 * 二级资料类别名称
*/ */
@ApiModelProperty(value = "二级资料类别名称") @ApiModelProperty(value = "二级资料类别名称")
@TableField(exist = false) // @TableField(exist = false)
@Excel(name = "二级资料类别", orderNum = "1") @Excel(name = "二级资料类别", orderNum = "1")
private String secondTypeName; private String secondTypeName;
@@ -75,7 +75,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
* 三级资料类别名称 * 三级资料类别名称
*/ */
@ApiModelProperty(value = "三级资料类别名称") @ApiModelProperty(value = "三级资料类别名称")
@TableField(exist = false) // @TableField(exist = false)
@Excel(name = "三级资料类别", orderNum = "2") @Excel(name = "三级资料类别", orderNum = "2")
private String thirdTypeName; private String thirdTypeName;
@@ -90,7 +90,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
* 四级资料类别名称 * 四级资料类别名称
*/ */
@ApiModelProperty(value = "四级资料类别名称") @ApiModelProperty(value = "四级资料类别名称")
@TableField(exist = false) // @TableField(exist = false)
@Excel(name = "四级资料类别", orderNum = "3") @Excel(name = "四级资料类别", orderNum = "3")
private String fourthTypeName; private String fourthTypeName;
@@ -80,7 +80,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
public SarLawsInformation getLawsInformationInfo(String id) { public SarLawsInformation getLawsInformationInfo(String id) {
SarLawsInformation sarLawsInformation = this.baseMapper.selectById(id); SarLawsInformation sarLawsInformation = this.baseMapper.selectById(id);
// 将字典编号变更为字典值 // 将字典编号变更为字典值
convertCodeToName(sarLawsInformation); // convertCodeToName(sarLawsInformation);
// 查询资料文件信息 // 查询资料文件信息
if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) { if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) {
String[] split = sarLawsInformation.getInformationFile().split(","); String[] split = sarLawsInformation.getInformationFile().split(",");
@@ -113,21 +113,21 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
if (list1.size() > 0) { if (list1.size() > 0) {
List<String> viewableBy = new ArrayList<>(); List<String> viewableBy = new ArrayList<>();
list1.forEach(item -> { list1.forEach(item -> {
String userName = userService.userIdByName(userId); String userName = userService.userIdByName(item.getUserId());
viewableBy.add(userName); viewableBy.add(userName + "(" + item.getUserId() + ")");
}); });
sarLawsInformation.setViewableBy(String.join(",", viewableBy)); sarLawsInformation.setViewableBy(String.join(",", viewableBy));
} }
LambdaQueryWrapper<SarLawsInformationAuth> wrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SarLawsInformationAuth> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId()); wrapper2.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId());
wrapper2.eq(SarLawsInformationAuth::getAuthType, "viewableBy"); wrapper2.eq(SarLawsInformationAuth::getAuthType, "downloadableBy");
wrapper2.select(SarLawsInformationAuth::getUserId); wrapper2.select(SarLawsInformationAuth::getUserId);
List<SarLawsInformationAuth> list2 = authService.list(wrapper1); List<SarLawsInformationAuth> list2 = authService.list(wrapper2);
if (list2.size() > 0) { if (list2.size() > 0) {
List<String> downloadableBy = new ArrayList<>(); List<String> downloadableBy = new ArrayList<>();
list2.forEach(item -> { list2.forEach(item -> {
String userName = userService.userIdByName(userId); String userName = userService.userIdByName(item.getUserId());
downloadableBy.add(userName); downloadableBy.add(userName + "(" + item.getUserId() + ")");
// 判断是否可下载 // 判断是否可下载
if (item.getUserId().equals(userId)) { if (item.getUserId().equals(userId)) {
sarLawsInformation.setDownloadable(true); sarLawsInformation.setDownloadable(true);
@@ -154,13 +154,16 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
page.setInformationIdList(informationIdList); page.setInformationIdList(informationIdList);
} }
// 设置排序字段 // 设置排序字段
if("name".equals(page.getSortField()) || "uploadTime".equals(page.getSortField())) { // if("name".equals(page.getSortField()) || "uploadTime".equals(page.getSortField())) {
// String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
// page.setSortField(sortField);
// }
if (StringUtils.isNotBlank(page.getSortField())) {
String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase(); String sortField = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(page.getSortField()),"_").toUpperCase();
page.setSortField(sortField); page.setSortField(sortField);
} } else {
if (StringUtils.isBlank(page.getSortField())) { page.setSortField("ID");
page.setSortField("ID"); page.setSortMode("asc");
page.setSortMode("asc");
} }
// 查询树节点及其子节点 // 查询树节点及其子节点
if (StringUtils.isNotBlank(page.getTreeNodeId())) { if (StringUtils.isNotBlank(page.getTreeNodeId())) {
@@ -172,7 +175,6 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
page.getPager().setRowCount(rowCount); page.getPager().setRowCount(rowCount);
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.queryByPage(page); List<SarLawsInformation> sarLawsInformationList = this.baseMapper.queryByPage(page);
// 对一级类别或二级类别做排序 // 对一级类别或二级类别做排序
// TODO 对类别做排序
// if (page.getSortField().contains("_")) // if (page.getSortField().contains("_"))
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值 // 将字典编号变更为字典值
@@ -207,18 +209,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
SarLawsInformationCenterTree one = treeService.getOne(wrapper); SarLawsInformationCenterTree one = treeService.getOne(wrapper);
sarLawsInformation.setTreeNodeId(one.getId()); sarLawsInformation.setTreeNodeId(one.getId());
} }
convertCodeToName(sarLawsInformation);
int insert = this.baseMapper.insert(sarLawsInformation); int insert = this.baseMapper.insert(sarLawsInformation);
if (insert <= 0) { if (insert <= 0) {
return false; return false;
} }
// 设置可见人和下载人 // 设置可见人和下载人
if (StringUtils.isBlank(sarLawsInformation.getViewableBy())) { if (StringUtils.isNotBlank(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()); List<String> viewableByList = extractContentInParentheses(sarLawsInformation.getViewableBy());
if (!viewableByList.contains(userId)) { if (!viewableByList.contains(userId)) {
viewableByList.add(userId); viewableByList.add(userId);
@@ -231,13 +228,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
authService.save(auth); authService.save(auth);
}); });
} }
if (StringUtils.isBlank(sarLawsInformation.getDownloadableBy())) { if (StringUtils.isNotBlank(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()); List<String> downloadableByList = extractContentInParentheses(sarLawsInformation.getDownloadableBy());
if (!downloadableByList.contains(userId)) { if (!downloadableByList.contains(userId)) {
downloadableByList.add(userId); downloadableByList.add(userId);
@@ -256,16 +247,17 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
SarLawsInformationAuth auth = new SarLawsInformationAuth(); SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(sarLawsInformation.getId()); auth.setLawsInformationId(sarLawsInformation.getId());
auth.setAuthType("createAndApproveBy"); auth.setAuthType("createAndApproveBy");
auth.setUserId(userId); auth.setUserId(userIdBy);
authService.save(auth); authService.save(auth);
} }
} else {
// 配置初始人员权限
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; return true;
} }
@@ -295,6 +287,36 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
List<String> compareResult = compareSarLawsInformation(oldLawsInformation, lawsInformation); List<String> compareResult = compareSarLawsInformation(oldLawsInformation, lawsInformation);
if (compareResult.size() > 0) { if (compareResult.size() > 0) {
int update = this.baseMapper.updateById(lawsInformation); int update = this.baseMapper.updateById(lawsInformation);
for (String compareItem : compareResult) {
if (compareItem.contains("可查看者")) {
LambdaQueryWrapper<SarLawsInformationAuth> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SarLawsInformationAuth::getLawsInformationId, lawsInformation.getId());
wrapper.eq(SarLawsInformationAuth::getAuthType, "viewableBy");
authService.remove(wrapper);
List<String> viewableByList = extractContentInParentheses(lawsInformation.getViewableBy());
viewableByList.forEach(viewableBy -> {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(lawsInformation.getId());
auth.setAuthType("viewableBy");
auth.setUserId(viewableBy);
authService.save(auth);
});
}
if (compareItem.contains("可下载者")) {
LambdaQueryWrapper<SarLawsInformationAuth> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SarLawsInformationAuth::getLawsInformationId, lawsInformation.getId());
wrapper.eq(SarLawsInformationAuth::getAuthType, "downloadableBy");
authService.remove(wrapper);
List<String> downloadableByList = extractContentInParentheses(lawsInformation.getDownloadableBy());
downloadableByList.forEach(downloadableBy -> {
SarLawsInformationAuth auth = new SarLawsInformationAuth();
auth.setLawsInformationId(lawsInformation.getId());
auth.setAuthType("downloadableBy");
auth.setUserId(downloadableBy);
authService.save(auth);
});
}
}
// 添加修改记录 // 添加修改记录
SarUpdLog sarUpdLogEO = new SarUpdLog(); SarUpdLog sarUpdLogEO = new SarUpdLog();
sarUpdLogEO.setId(UUIDUtils.randomUUID20()); sarUpdLogEO.setId(UUIDUtils.randomUUID20());
@@ -313,19 +335,29 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
LambdaQueryWrapper<SarLawsInformation> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SarLawsInformation> wrapper = new LambdaQueryWrapper<>();
wrapper.in(SarLawsInformation::getId, idList); wrapper.in(SarLawsInformation::getId, idList);
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.selectList(wrapper); List<SarLawsInformation> sarLawsInformationList = this.baseMapper.selectList(wrapper);
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { // for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值 // // 将字典编号变更为字典值
convertCodeToName(sarLawsInformation); // convertCodeToName(sarLawsInformation);
} // }
return sarLawsInformationList; return sarLawsInformationList;
} }
@Override @Override
public List<SarLawsInformation> getAllLawsInformation(SarLawsInformation sarLawsInformation) { public List<SarLawsInformation> getAllLawsInformation(SarLawsInformation sarLawsInformation) {
String userId = LoginUserUtil.getUserId();
// 查询有权限的资料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());
sarLawsInformation.setInformationIdList(informationIdList);
}
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.getAllLawsInformation(sarLawsInformation); List<SarLawsInformation> sarLawsInformationList = this.baseMapper.getAllLawsInformation(sarLawsInformation);
for (SarLawsInformation lawsInformation : sarLawsInformationList) { for (SarLawsInformation lawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值 // 将字典编号变更为字典值
convertCodeToName(lawsInformation); // convertCodeToName(lawsInformation);
// 查询文件信息 // 查询文件信息
if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) { if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) {
String[] split = lawsInformation.getInformationFile().split(","); String[] split = lawsInformation.getInformationFile().split(",");
@@ -547,7 +579,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
List<String> changes = new ArrayList<>(); List<String> changes = new ArrayList<>();
// 需要比较的字段 // 需要比较的字段
String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name", String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name",
"department","author","description","informationFile","treeNodeId"}; "department","author","description","informationFile","treeNodeId","viewableBy","downloadableBy"};
List<String> fieldList = Arrays.asList(fieldArr); List<String> fieldList = Arrays.asList(fieldArr);
// 获取SarLawsInformation类的所有字段 // 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields(); Field[] fields = SarLawsInformation.class.getDeclaredFields();
@@ -558,49 +590,57 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
String oldValue = String.valueOf(field.get(oldInfo)); String oldValue = String.valueOf(field.get(oldInfo));
String newValue = String.valueOf(field.get(newInfo)); String newValue = String.valueOf(field.get(newInfo));
if (!Objects.equals(oldValue, newValue)) { if (!Objects.equals(oldValue, newValue)) {
if ("firstType".equals(field.getName()) || "secondType".equals(field.getName()) || "thirdType".equals(field.getName()) || switch (field.getName()) {
"fourthType".equals(field.getName())) { // case "firstType":
List<String> typeNameList = new ArrayList<>(); // case "secondType":
if (StringUtils.isNotBlank(newValue)) { // case "thirdType":
for (String type : newValue.split(",")) { // case "fourthType": {
if (StringUtils.isNotBlank(type)) { // List<String> typeNameList = new ArrayList<>();
typeNameList.add(dicTypeService.getDicTypeNameByDicCode(type)); // 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);
// ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
// changes.add(annotationsByType.value() + "由\"" + oldTypeName + "\"改为\"" + String.join(",", typeNameList) + "\"");
// break;
// }
case "informationFile": {
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);
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); Method method = SarLawsInformation.class.getMethod("get" + fieldName + "List");
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name"); List<?> oldFileList = (List) method.invoke(oldInfo);
Object oldTypeName = method.invoke(oldInfo); List<String> oldFileNameList = new ArrayList<>();
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0]; if (oldFileList != null && oldFileList.size() > 0) {
changes.add(annotationsByType.value() + "由\"" + oldTypeName + "\"改为\"" + String.join(",",typeNameList) + "\""); for (Object oldFile : oldFileList) {
} else if ("informationFile".equals(field.getName())) { AttFileEO oldFile1 = (AttFileEO) oldFile;
List<String> fileNameList = new ArrayList<>(); oldFileNameList.add(oldFile1.getOldFileName());
if (StringUtils.isNotBlank(newValue)) { }
String[] split = newValue.split(",");
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo.getOldFileName());
} }
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "由\"" + String.join(",", oldFileNameList) + "\"改为\"" + String.join(",", fileNameList) + "\"");
break;
} }
// 获取资料类型名称 default: {
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "List"); changes.add(annotationsByType.value() + "由\"" + oldValue + "\"改为\"" + newValue + "\"");
List<?> oldFileList = (List)method.invoke(oldInfo); break;
List<String> oldFileNameList = new ArrayList<>();
if (oldFileList != null && oldFileList.size() > 0) {
for (Object oldFile : oldFileList) {
AttFileEO oldFile1 = (AttFileEO) oldFile;
oldFileNameList.add(oldFile1.getOldFileName());
}
} }
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "由\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
}
else {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "由\"" + oldValue + "\"改为\"" + newValue + "\"");
} }
} }
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
@@ -643,6 +683,16 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
} }
return results; return results;
} }
public boolean equalsSet(Set<?> set1, Set<?> set2){
if(set1 == null || set2 ==null){//null就直接不比了
return false;
}
if(set1.size()!=set2.size()){//大小不同也不用比了
return false;
}
return set1.containsAll(set2);//最后比containsAll
}
} }
@@ -20,10 +20,8 @@
<result property="uploadTime" column="UPLOAD_TIME" jdbcType="TIMESTAMP"/> <result property="uploadTime" column="UPLOAD_TIME" jdbcType="TIMESTAMP"/>
<result property="description" column="DESCRIPTION" jdbcType="VARCHAR"/> <result property="description" column="DESCRIPTION" jdbcType="VARCHAR"/>
<result property="informationFile" column="INFORMATION_FILE" jdbcType="VARCHAR"/> <result property="informationFile" column="INFORMATION_FILE" jdbcType="VARCHAR"/>
<result property="viewableBy" column="VIEWABLE_BY" jdbcType="VARCHAR"/>
<result property="downloadableBy" column="DOWNLOADABLE_BY" jdbcType="VARCHAR"/>
<result property="treeNodeId" column="TREE_NODE_ID" jdbcType="VARCHAR"/> <result property="treeNodeId" column="TREE_NODE_ID" jdbcType="VARCHAR"/>
<result property="viewableBy" column="VALID_FLAG" jdbcType="TINYINT"/> <result property="validFlag" column="VALID_FLAG" jdbcType="TINYINT"/>
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/> <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="MODIFY_TIME" jdbcType="TIMESTAMP"/> <result property="modifyTime" column="MODIFY_TIME" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
@@ -40,8 +38,6 @@
UPLOAD_TIME, UPLOAD_TIME,
`DESCRIPTION`, `DESCRIPTION`,
INFORMATION_FILE, INFORMATION_FILE,
VIEWABLE_BY,
DOWNLOADABLE_BY,
VALID_FLAG, VALID_FLAG,
CREATE_TIME, CREATE_TIME,
MODIFY_TIME MODIFY_TIME