fix: 企标列表权限和批量删除权限不对应问题
This commit is contained in:
-8
@@ -1187,14 +1187,6 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
|||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String deleteByIdsAndModule(String ids, String module) {
|
public String deleteByIdsAndModule(String ids, String module) {
|
||||||
// 如果是企标的话 校验删除的ids是否有权限
|
|
||||||
if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)) {
|
|
||||||
boolean auth = esAuthUserService.verifyESDeleteAuth(ids, UserUtils.getUserId());
|
|
||||||
if (!auth) {
|
|
||||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.NO_AUTH));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取要操作的表名
|
// 获取要操作的表名
|
||||||
String tableName = TableNameEnum.getTableName(module);
|
String tableName = TableNameEnum.getTableName(module);
|
||||||
// 获取要删除的id集合
|
// 获取要删除的id集合
|
||||||
|
|||||||
+9
-14
@@ -585,21 +585,16 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
|||||||
if (StringUtils.isBlank(ids)) {
|
if (StringUtils.isBlank(ids)) {
|
||||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "ids不能为空");
|
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "ids不能为空");
|
||||||
}
|
}
|
||||||
List<String> idList = Arrays.asList(ids.split(","));
|
String[] idList = ids.split(",");
|
||||||
// 管理员有所有权限
|
List<Map<String, Object>> records = new ArrayList<>();
|
||||||
SysUser currentUser = sysUserService.getById(userId);
|
for (String id : idList) {
|
||||||
String username = currentUser.getUsername();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put(FieldCommon.ID, id);
|
||||||
// 获取当前用户的角色roleCode
|
records.add(map);
|
||||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
|
||||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
// 创建人可以删除
|
this.delFlagSet(records);
|
||||||
List<LawsEnterpriseStandard> list = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>().in(LawsEnterpriseStandard::getId, idList));
|
for (Map<String, Object> map : records) {
|
||||||
// 如果不是创建人,则直接返回false
|
if (!(boolean) map.get(FieldCommon.DEL_FLAG)) {
|
||||||
for (LawsEnterpriseStandard es : list) {
|
|
||||||
if (!es.getCreateBy().equals(username)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -150,7 +150,12 @@ public class LawsEnterpriseController {
|
|||||||
@PostMapping(value = "deleteByIdsAndModule")
|
@PostMapping(value = "deleteByIdsAndModule")
|
||||||
@ApiOperationSupport(order = 8)
|
@ApiOperationSupport(order = 8)
|
||||||
@RequiresPermissions("enterpriseStandard:search")
|
@RequiresPermissions("enterpriseStandard:search")
|
||||||
public Result<String> deleteByIdsAndModule(@RequestBody Map<String,Object> parameterMap) {
|
public Result<String> deleteByIdsAndModule(@RequestBody Map<String, Object> parameterMap) {
|
||||||
|
// 如果是企标的话 校验删除的ids是否有权限
|
||||||
|
boolean auth = esAuthUserService.verifyESDeleteAuth((String) parameterMap.get("ids"), UserUtils.getUserId());
|
||||||
|
if (!auth) {
|
||||||
|
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.NO_AUTH));
|
||||||
|
}
|
||||||
//删除标准时同步删除这个标准的收藏数据
|
//删除标准时同步删除这个标准的收藏数据
|
||||||
lawsStandardCollectionService.deleteByStandardId((String) parameterMap.get("ids"));
|
lawsStandardCollectionService.deleteByStandardId((String) parameterMap.get("ids"));
|
||||||
lawsStandardSharingService.deleteByStandardId((String) parameterMap.get("ids"));
|
lawsStandardSharingService.deleteByStandardId((String) parameterMap.get("ids"));
|
||||||
|
|||||||
+218
-5
@@ -14,11 +14,17 @@ import com.jero.common.util.MessageUtils;
|
|||||||
import com.jero.common.util.MinioUtil;
|
import com.jero.common.util.MinioUtil;
|
||||||
import com.jero.modules.activiti.util.ExcelUtils;
|
import com.jero.modules.activiti.util.ExcelUtils;
|
||||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||||
|
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser;
|
||||||
import com.jero.modules.laws.enterprise.entity.OldSystemImportDTO;
|
import com.jero.modules.laws.enterprise.entity.OldSystemImportDTO;
|
||||||
import com.jero.modules.laws.enterprise.service.ESSequenceNumberProvider;
|
import com.jero.modules.laws.enterprise.service.ESSequenceNumberProvider;
|
||||||
|
import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthDeptService;
|
||||||
|
import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthUserService;
|
||||||
import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil;
|
import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil;
|
||||||
import com.jero.modules.laws.home.common.LawsHomeSearchCommon;
|
import com.jero.modules.laws.home.common.LawsHomeSearchCommon;
|
||||||
import com.jero.modules.laws.home.service.ILawsHomeSearchService;
|
import com.jero.modules.laws.home.service.ILawsHomeSearchService;
|
||||||
|
import com.jero.modules.laws.oldSystem.entity.ESAuthAll;
|
||||||
|
import com.jero.modules.laws.oldSystem.entity.ESAuthDept;
|
||||||
|
import com.jero.modules.laws.oldSystem.entity.ESAuthUser;
|
||||||
import com.jero.modules.laws.oldSystem.entity.OldSystemDepartRelation;
|
import com.jero.modules.laws.oldSystem.entity.OldSystemDepartRelation;
|
||||||
import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService;
|
import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService;
|
||||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||||
@@ -99,6 +105,12 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
@Resource
|
@Resource
|
||||||
private IOSSFileService ossFileService;
|
private IOSSFileService ossFileService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseStandardAuthUserService esAuthUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseStandardAuthDeptService esAuthDeptService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ILawsHomeSearchService lawsHomeSearchService;
|
private ILawsHomeSearchService lawsHomeSearchService;
|
||||||
|
|
||||||
@@ -203,18 +215,218 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
this.oldSysGBImport(gbDatalist, errImportList);
|
this.oldSysGBImport(gbDatalist, errImportList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.exportWithExcel(response, errImportList);
|
this.exportWithExcel(response, errImportList, "OldSystemStandardErrorData.xls");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportWithExcel(HttpServletResponse response, List<OldSystemImportDTO> dtoList) {
|
@Override
|
||||||
|
public void importOldESAuthAllExcel(MultipartFile file, HttpServletResponse response) {
|
||||||
|
// 验证文件是否为压缩格式file.getContentType()).contains("xls")
|
||||||
|
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
||||||
|
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
||||||
|
}
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(0);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
List<ESAuthAll> datalist;
|
||||||
|
try {
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
@Cleanup
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
datalist = ExcelImportUtil.importExcel(inputStream, ESAuthAll.class, params);
|
||||||
|
// 删除空行
|
||||||
|
for (int i = 0; i < datalist.size(); i++) {
|
||||||
|
ESAuthAll data = datalist.get(i);
|
||||||
|
if (data.isEmptyRow()) {
|
||||||
|
datalist.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("获取数据成功,数据条数:{}", datalist.size());
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// 计算执行时间(毫秒)
|
||||||
|
long executionTime = endTime - startTime;
|
||||||
|
log.info("数据转换执行时间:" + executionTime + " 毫秒");
|
||||||
|
|
||||||
|
// 筛选有oldSystemId的数据
|
||||||
|
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<LawsEnterpriseStandard> esList = this.list(esWrapper.isNotNull(LawsEnterpriseStandard::getOldSystemId));
|
||||||
|
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getOldSystemId, o -> o));
|
||||||
|
|
||||||
|
// 遍历dataList 并且构造Update语句
|
||||||
|
List<LawsEnterpriseStandard> updateList = new ArrayList<>();
|
||||||
|
for (ESAuthAll data : datalist) {
|
||||||
|
LawsEnterpriseStandard es = esMap.get(data.getStandardId());
|
||||||
|
if (es != null) {
|
||||||
|
es.setGradeClassification("1");
|
||||||
|
updateList.add(es);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 批量更新
|
||||||
|
this.updateBatchById(updateList, updateList.size());
|
||||||
|
log.info("企标所有人权限导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("导入失败;{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importOldESAuthUserExcel(MultipartFile file, HttpServletResponse response) {
|
||||||
|
// 验证文件是否为压缩格式file.getContentType()).contains("xls")
|
||||||
|
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
||||||
|
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
||||||
|
}
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(0);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
List<ESAuthUser> datalist;
|
||||||
|
try {
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
@Cleanup
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
datalist = ExcelImportUtil.importExcel(inputStream, ESAuthUser.class, params);
|
||||||
|
// 删除空行
|
||||||
|
for (int i = 0; i < datalist.size(); i++) {
|
||||||
|
ESAuthUser data = datalist.get(i);
|
||||||
|
if (data.isEmptyRow()) {
|
||||||
|
datalist.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("获取数据成功,数据条数:{}", datalist.size());
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// 计算执行时间(毫秒)
|
||||||
|
long executionTime = endTime - startTime;
|
||||||
|
log.info("数据转换执行时间:" + executionTime + " 毫秒");
|
||||||
|
|
||||||
|
// 筛选有oldSystemId的数据
|
||||||
|
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<LawsEnterpriseStandard> esList = this.list(esWrapper.isNotNull(LawsEnterpriseStandard::getOldSystemId));
|
||||||
|
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getOldSystemId, o -> o));
|
||||||
|
Map<String, List<ESAuthUser>> auMap = datalist.stream().collect(Collectors.groupingBy(ESAuthUser::getStandardId));
|
||||||
|
List<SysUser> userlist = sysUserService.list();
|
||||||
|
Map<String, SysUser> userMap = userlist.stream().collect(Collectors.toMap(SysUser::getUsername, o -> o));
|
||||||
|
|
||||||
|
// 构造一个2099-12-31的Date时间
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
// 设置日期为2099年12月31日
|
||||||
|
calendar.set(Calendar.YEAR, 2099);
|
||||||
|
calendar.set(Calendar.MONTH, Calendar.DECEMBER); // 12月,注意月份是从0开始的,所以12表示12月
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 31);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 23); // 设置小时为23(表示23:59:59)
|
||||||
|
calendar.set(Calendar.MINUTE, 59); // 设置分钟为59
|
||||||
|
calendar.set(Calendar.SECOND, 59); // 设置秒钟为59
|
||||||
|
|
||||||
|
// 获取Date对象
|
||||||
|
Date date = calendar.getTime();
|
||||||
|
List<EnterpriseStandardAuthUser> authUserList = new ArrayList<>();
|
||||||
|
// 遍历esMap
|
||||||
|
for (Map.Entry<String, LawsEnterpriseStandard> entry : esMap.entrySet()) {
|
||||||
|
LawsEnterpriseStandard es = entry.getValue();
|
||||||
|
String standardId = es.getId();
|
||||||
|
List<ESAuthUser> auList = auMap.get(standardId);
|
||||||
|
if (auList != null) {
|
||||||
|
for (ESAuthUser au : auList) {
|
||||||
|
EnterpriseStandardAuthUser authUser = new EnterpriseStandardAuthUser();
|
||||||
|
authUser.setStandardId(es.getId());
|
||||||
|
String userId = userMap.get(au.getWorkNumber()).getId();
|
||||||
|
authUser.setAuthUser(userId);
|
||||||
|
authUser.setAuthExpireDate(date);
|
||||||
|
authUserList.add(authUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
esAuthUserService.saveBatch(authUserList, authUserList.size());
|
||||||
|
|
||||||
|
log.info("企标个人权限导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("导入失败;{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importOldESAuthDeptExcel(MultipartFile file, HttpServletResponse response) {
|
||||||
|
// 验证文件是否为压缩格式file.getContentType()).contains("xls")
|
||||||
|
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
||||||
|
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
||||||
|
}
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(0);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
List<ESAuthDept> datalist;
|
||||||
|
try {
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
@Cleanup
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
datalist = ExcelImportUtil.importExcel(inputStream, ESAuthDept.class, params);
|
||||||
|
// 删除空行
|
||||||
|
for (int i = 0; i < datalist.size(); i++) {
|
||||||
|
ESAuthDept data = datalist.get(i);
|
||||||
|
if (data.isEmptyRow()) {
|
||||||
|
datalist.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("获取数据成功,数据条数:{}", datalist.size());
|
||||||
|
// 获取当前时间戳(毫秒)
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// 计算执行时间(毫秒)
|
||||||
|
long executionTime = endTime - startTime;
|
||||||
|
log.info("数据转换执行时间:" + executionTime + " 毫秒");
|
||||||
|
|
||||||
|
// 筛选有oldSystemId的数据
|
||||||
|
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<LawsEnterpriseStandard> esList = this.list(esWrapper.isNotNull(LawsEnterpriseStandard::getOldSystemId));
|
||||||
|
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getOldSystemId, o -> o));
|
||||||
|
Map<String, List<ESAuthDept>> auMap = datalist.stream().collect(Collectors.groupingBy(ESAuthDept::getStandardId));
|
||||||
|
List<SysDepart> deptlist = departService.list();
|
||||||
|
// Map<String, SysDepart> deptMap = deptlist.stream().collect(Collectors.toMap(SysDepart::getUsername, o -> o));
|
||||||
|
//
|
||||||
|
// List<EnterpriseStandardAuthUser> authUserList = new ArrayList<>();
|
||||||
|
// // 遍历esMap
|
||||||
|
// for (Map.Entry<String, LawsEnterpriseStandard> entry : esMap.entrySet()) {
|
||||||
|
// LawsEnterpriseStandard es = entry.getValue();
|
||||||
|
// String standardId = es.getId();
|
||||||
|
// List<ESAuthUser> auList = auMap.get(standardId);
|
||||||
|
// if (auList != null) {
|
||||||
|
// for (ESAuthUser au : auList) {
|
||||||
|
// EnterpriseStandardAuthUser authUser = new EnterpriseStandardAuthUser();
|
||||||
|
// authUser.setStandardId(es.getId());
|
||||||
|
// String userId = userMap.get(au.getWorkNumber()).getId();
|
||||||
|
// authUser.setAuthUser(userId);
|
||||||
|
// authUser.setAuthExpireDate(date);
|
||||||
|
// authUserList.add(authUser);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// esAuthUserService.saveBatch(authUserList, authUserList.size());
|
||||||
|
|
||||||
|
log.info("企标所有人权限导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("导入失败;{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void exportWithExcel(HttpServletResponse response, List<T> dtoList, String fileName) {
|
||||||
try {
|
try {
|
||||||
// 设置导出参数
|
// 设置导出参数
|
||||||
ExportParams exportParams = new ExportParams(null, "ProblemOldStandard.xls"); // 可以为标题添加更多的配置
|
ExportParams exportParams = new ExportParams(null, fileName); // 可以为标题添加更多的配置
|
||||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, OldSystemImportDTO.class, dtoList);
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, dtoList.get(0).getClass(), dtoList);
|
||||||
|
|
||||||
// 设置响应头和内容类型
|
// 设置响应头和内容类型
|
||||||
response.setContentType("application/vnd.ms-excel");
|
response.setContentType("application/vnd.ms-excel");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=ProblemOldStandard.xls");
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
|
|
||||||
// 写出到响应流
|
// 写出到响应流
|
||||||
workbook.write(response.getOutputStream());
|
workbook.write(response.getOutputStream());
|
||||||
@@ -225,6 +437,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void oldSysGBImport(List<OldSystemImportDTO> gbDatalist, List<OldSystemImportDTO> errImportList) {
|
private void oldSysGBImport(List<OldSystemImportDTO> gbDatalist, List<OldSystemImportDTO> errImportList) {
|
||||||
// 找到所有人 并且用 姓名加工号做key
|
// 找到所有人 并且用 姓名加工号做key
|
||||||
Map<String, SysUser> allUserMap = sysUserService.list().stream().collect(Collectors.toMap(o -> o.getRealname() + o.getUsername(), o -> o));
|
Map<String, SysUser> allUserMap = sysUserService.list().stream().collect(Collectors.toMap(o -> o.getRealname() + o.getUsername(), o -> o));
|
||||||
|
|||||||
Reference in New Issue
Block a user