From d23cef196d8b4571999b0e93f41dd378bc1ab5e1 Mon Sep 17 00:00:00 2001 From: wxyclub Date: Sun, 12 Nov 2023 13:02:46 +0800 Subject: [PATCH] =?UTF-8?q?bug:=20=E6=94=BF=E7=AD=96=E8=B5=84=E6=96=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/SarLawsInformation.java | 8 +- .../impl/SarLawsInformationServiceImpl.java | 206 +++++++++++------- .../SarLawsInformationMapper.xml | 6 +- 3 files changed, 133 insertions(+), 87 deletions(-) diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/entity/SarLawsInformation.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/entity/SarLawsInformation.java index e44c6f47..20ea8e57 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/entity/SarLawsInformation.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/entity/SarLawsInformation.java @@ -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; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java index c4afb771..b5cef826 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/service/impl/SarLawsInformationServiceImpl.java @@ -80,7 +80,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl 0) { List 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 wrapper2 = new LambdaQueryWrapper<>(); wrapper2.eq(SarLawsInformationAuth::getLawsInformationId, sarLawsInformation.getId()); - wrapper2.eq(SarLawsInformationAuth::getAuthType, "viewableBy"); + wrapper2.eq(SarLawsInformationAuth::getAuthType, "downloadableBy"); wrapper2.select(SarLawsInformationAuth::getUserId); - List list2 = authService.list(wrapper1); + List list2 = authService.list(wrapper2); if (list2.size() > 0) { List 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 sarLawsInformationList = this.baseMapper.queryByPage(page); // 对一级类别或二级类别做排序 - // TODO 对类别做排序 // if (page.getSortField().contains("_")) for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { // 将字典编号变更为字典值 @@ -207,18 +209,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl viewableByList = extractContentInParentheses(sarLawsInformation.getViewableBy()); if (!viewableByList.contains(userId)) { viewableByList.add(userId); @@ -231,13 +228,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl downloadableByList = extractContentInParentheses(sarLawsInformation.getDownloadableBy()); if (!downloadableByList.contains(userId)) { downloadableByList.add(userId); @@ -256,16 +247,17 @@ public class SarLawsInformationServiceImpl extends ServiceImpl compareResult = compareSarLawsInformation(oldLawsInformation, lawsInformation); if (compareResult.size() > 0) { int update = this.baseMapper.updateById(lawsInformation); + for (String compareItem : compareResult) { + if (compareItem.contains("可查看者")) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarLawsInformationAuth::getLawsInformationId, lawsInformation.getId()); + wrapper.eq(SarLawsInformationAuth::getAuthType, "viewableBy"); + authService.remove(wrapper); + List 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 wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarLawsInformationAuth::getLawsInformationId, lawsInformation.getId()); + wrapper.eq(SarLawsInformationAuth::getAuthType, "downloadableBy"); + authService.remove(wrapper); + List 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 wrapper = new LambdaQueryWrapper<>(); wrapper.in(SarLawsInformation::getId, idList); List sarLawsInformationList = this.baseMapper.selectList(wrapper); - for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { - // 将字典编号变更为字典值 - convertCodeToName(sarLawsInformation); - } +// for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { +// // 将字典编号变更为字典值 +// convertCodeToName(sarLawsInformation); +// } return sarLawsInformationList; } @Override public List getAllLawsInformation(SarLawsInformation sarLawsInformation) { + String userId = LoginUserUtil.getUserId(); + // 查询有权限的资料ID + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SarLawsInformationAuth::getUserId, userId); + wrapper.select(SarLawsInformationAuth::getLawsInformationId); + List informationAuthList = authService.list(wrapper); + if (informationAuthList.size() > 0) { + List informationIdList = informationAuthList.stream().map(SarLawsInformationAuth::getLawsInformationId).collect(Collectors.toList()); + sarLawsInformation.setInformationIdList(informationIdList); + } List 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 changes = new ArrayList<>(); // 需要比较的字段 String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name", - "department","author","description","informationFile","treeNodeId"}; + "department","author","description","informationFile","treeNodeId","viewableBy","downloadableBy"}; List fieldList = Arrays.asList(fieldArr); // 获取SarLawsInformation类的所有字段 Field[] fields = SarLawsInformation.class.getDeclaredFields(); @@ -558,49 +590,57 @@ public class SarLawsInformationServiceImpl extends ServiceImpl 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 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 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 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 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 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 set1, Set set2){ + if(set1 == null || set2 ==null){//null就直接不比了 + return false; + } + if(set1.size()!=set2.size()){//大小不同也不用比了 + return false; + } + return set1.containsAll(set2);//最后比containsAll + } } diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml index 8a04eebc..6457df92 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInformation/SarLawsInformationMapper.xml @@ -20,10 +20,8 @@ - - - + @@ -40,8 +38,6 @@ UPLOAD_TIME, `DESCRIPTION`, INFORMATION_FILE, - VIEWABLE_BY, - DOWNLOADABLE_BY, VALID_FLAG, CREATE_TIME, MODIFY_TIME