bug: 政策资料修改
This commit is contained in:
+4
-4
@@ -45,7 +45,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
|
||||
* 一级资料类别名称
|
||||
*/
|
||||
@ApiModelProperty(value = "一级资料类别名称")
|
||||
@TableField(exist = false)
|
||||
// @TableField(exist = false)
|
||||
@Excel(name = "一级资料类别", orderNum = "0")
|
||||
private String firstTypeName;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
|
||||
* 二级资料类别名称
|
||||
*/
|
||||
@ApiModelProperty(value = "二级资料类别名称")
|
||||
@TableField(exist = false)
|
||||
// @TableField(exist = false)
|
||||
@Excel(name = "二级资料类别", orderNum = "1")
|
||||
private String secondTypeName;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
|
||||
* 三级资料类别名称
|
||||
*/
|
||||
@ApiModelProperty(value = "三级资料类别名称")
|
||||
@TableField(exist = false)
|
||||
// @TableField(exist = false)
|
||||
@Excel(name = "三级资料类别", orderNum = "2")
|
||||
private String thirdTypeName;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
|
||||
* 四级资料类别名称
|
||||
*/
|
||||
@ApiModelProperty(value = "四级资料类别名称")
|
||||
@TableField(exist = false)
|
||||
// @TableField(exist = false)
|
||||
@Excel(name = "四级资料类别", orderNum = "3")
|
||||
private String fourthTypeName;
|
||||
|
||||
|
||||
+128
-78
@@ -80,7 +80,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
public SarLawsInformation getLawsInformationInfo(String id) {
|
||||
SarLawsInformation sarLawsInformation = this.baseMapper.selectById(id);
|
||||
// 将字典编号变更为字典值
|
||||
convertCodeToName(sarLawsInformation);
|
||||
// convertCodeToName(sarLawsInformation);
|
||||
// 查询资料文件信息
|
||||
if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) {
|
||||
String[] split = sarLawsInformation.getInformationFile().split(",");
|
||||
@@ -113,21 +113,21 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
if (list1.size() > 0) {
|
||||
List<String> viewableBy = new ArrayList<>();
|
||||
list1.forEach(item -> {
|
||||
String userName = userService.userIdByName(userId);
|
||||
viewableBy.add(userName);
|
||||
String userName = userService.userIdByName(item.getUserId());
|
||||
viewableBy.add(userName + "(" + item.getUserId() + ")");
|
||||
});
|
||||
sarLawsInformation.setViewableBy(String.join(",", viewableBy));
|
||||
}
|
||||
LambdaQueryWrapper<SarLawsInformationAuth> wrapper2 = new LambdaQueryWrapper<>();
|
||||
wrapper2.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId());
|
||||
wrapper2.eq(SarLawsInformationAuth::getAuthType, "viewableBy");
|
||||
wrapper2.eq(SarLawsInformationAuth::getAuthType, "downloadableBy");
|
||||
wrapper2.select(SarLawsInformationAuth::getUserId);
|
||||
List<SarLawsInformationAuth> list2 = authService.list(wrapper1);
|
||||
List<SarLawsInformationAuth> list2 = authService.list(wrapper2);
|
||||
if (list2.size() > 0) {
|
||||
List<String> downloadableBy = new ArrayList<>();
|
||||
list2.forEach(item -> {
|
||||
String userName = userService.userIdByName(userId);
|
||||
downloadableBy.add(userName);
|
||||
String userName = userService.userIdByName(item.getUserId());
|
||||
downloadableBy.add(userName + "(" + item.getUserId() + ")");
|
||||
// 判断是否可下载
|
||||
if (item.getUserId().equals(userId)) {
|
||||
sarLawsInformation.setDownloadable(true);
|
||||
@@ -154,13 +154,16 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
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();
|
||||
page.setSortField(sortField);
|
||||
}
|
||||
if (StringUtils.isBlank(page.getSortField())) {
|
||||
page.setSortField("ID");
|
||||
page.setSortMode("asc");
|
||||
} else {
|
||||
page.setSortField("ID");
|
||||
page.setSortMode("asc");
|
||||
}
|
||||
// 查询树节点及其子节点
|
||||
if (StringUtils.isNotBlank(page.getTreeNodeId())) {
|
||||
@@ -172,7 +175,6 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
page.getPager().setRowCount(rowCount);
|
||||
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.queryByPage(page);
|
||||
// 对一级类别或二级类别做排序
|
||||
// TODO 对类别做排序
|
||||
// if (page.getSortField().contains("_"))
|
||||
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
|
||||
// 将字典编号变更为字典值
|
||||
@@ -207,18 +209,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
SarLawsInformationCenterTree one = treeService.getOne(wrapper);
|
||||
sarLawsInformation.setTreeNodeId(one.getId());
|
||||
}
|
||||
convertCodeToName(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 {
|
||||
if (StringUtils.isNotBlank(sarLawsInformation.getViewableBy())) {
|
||||
List<String> viewableByList = extractContentInParentheses(sarLawsInformation.getViewableBy());
|
||||
if (!viewableByList.contains(userId)) {
|
||||
viewableByList.add(userId);
|
||||
@@ -231,13 +228,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
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 {
|
||||
if (StringUtils.isNotBlank(sarLawsInformation.getDownloadableBy())) {
|
||||
List<String> downloadableByList = extractContentInParentheses(sarLawsInformation.getDownloadableBy());
|
||||
if (!downloadableByList.contains(userId)) {
|
||||
downloadableByList.add(userId);
|
||||
@@ -256,16 +247,17 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
SarLawsInformationAuth auth = new SarLawsInformationAuth();
|
||||
auth.setLawsInformationId(sarLawsInformation.getId());
|
||||
auth.setAuthType("createAndApproveBy");
|
||||
auth.setUserId(userId);
|
||||
auth.setUserId(userIdBy);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -295,6 +287,36 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
List<String> compareResult = compareSarLawsInformation(oldLawsInformation, lawsInformation);
|
||||
if (compareResult.size() > 0) {
|
||||
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();
|
||||
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
|
||||
@@ -313,19 +335,29 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
LambdaQueryWrapper<SarLawsInformation> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(SarLawsInformation::getId, idList);
|
||||
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.selectList(wrapper);
|
||||
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
|
||||
// 将字典编号变更为字典值
|
||||
convertCodeToName(sarLawsInformation);
|
||||
}
|
||||
// for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
|
||||
// // 将字典编号变更为字典值
|
||||
// convertCodeToName(sarLawsInformation);
|
||||
// }
|
||||
return sarLawsInformationList;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
for (SarLawsInformation lawsInformation : sarLawsInformationList) {
|
||||
// 将字典编号变更为字典值
|
||||
convertCodeToName(lawsInformation);
|
||||
// convertCodeToName(lawsInformation);
|
||||
// 查询文件信息
|
||||
if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) {
|
||||
String[] split = lawsInformation.getInformationFile().split(",");
|
||||
@@ -547,7 +579,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
List<String> changes = new ArrayList<>();
|
||||
// 需要比较的字段
|
||||
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);
|
||||
// 获取SarLawsInformation类的所有字段
|
||||
Field[] fields = SarLawsInformation.class.getDeclaredFields();
|
||||
@@ -558,49 +590,57 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
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));
|
||||
switch (field.getName()) {
|
||||
// case "firstType":
|
||||
// case "secondType":
|
||||
// case "thirdType":
|
||||
// case "fourthType": {
|
||||
// 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);
|
||||
// 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);
|
||||
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) + "\"");
|
||||
} 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 + "List");
|
||||
List<?> oldFileList = (List) method.invoke(oldInfo);
|
||||
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) + "\"");
|
||||
break;
|
||||
}
|
||||
// 获取资料类型名称
|
||||
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
|
||||
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "List");
|
||||
List<?> oldFileList = (List)method.invoke(oldInfo);
|
||||
List<String> oldFileNameList = new ArrayList<>();
|
||||
if (oldFileList != null && oldFileList.size() > 0) {
|
||||
for (Object oldFile : oldFileList) {
|
||||
AttFileEO oldFile1 = (AttFileEO) oldFile;
|
||||
oldFileNameList.add(oldFile1.getOldFileName());
|
||||
}
|
||||
default: {
|
||||
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
|
||||
changes.add(annotationsByType.value() + "由\"" + oldValue + "\"改为\"" + newValue + "\"");
|
||||
break;
|
||||
}
|
||||
// 获取字段名称
|
||||
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) {
|
||||
@@ -643,6 +683,16 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-5
@@ -20,10 +20,8 @@
|
||||
<result property="uploadTime" column="UPLOAD_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="description" column="DESCRIPTION" 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="viewableBy" column="VALID_FLAG" jdbcType="TINYINT"/>
|
||||
<result property="validFlag" column="VALID_FLAG" jdbcType="TINYINT"/>
|
||||
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="modifyTime" column="MODIFY_TIME" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
@@ -40,8 +38,6 @@
|
||||
UPLOAD_TIME,
|
||||
`DESCRIPTION`,
|
||||
INFORMATION_FILE,
|
||||
VIEWABLE_BY,
|
||||
DOWNLOADABLE_BY,
|
||||
VALID_FLAG,
|
||||
CREATE_TIME,
|
||||
MODIFY_TIME
|
||||
|
||||
Reference in New Issue
Block a user