Browse Source

clear

tags/V1.3.3^2
wanjing 1 year ago
parent
commit
24ae6e0e9d
41 changed files with 178 additions and 150 deletions
  1. +8
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java
  2. +11
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/DataPermissionEnum.java
  3. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/AddUserCodeEnum.java
  4. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserCodeEnum.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/workorder/DistributionWorkorderCodeEnum.java
  6. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java
  7. +2
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java
  8. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java
  9. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeService.java
  10. +20
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataService.java
  11. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java
  12. +5
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java
  13. +5
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java
  14. +1
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/EditHandle.java
  15. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ExecuteHandle.java
  16. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java
  17. +7
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java
  18. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileDistributionListService.java
  19. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListByWorkOrderIdService.java
  20. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListService.java
  21. +5
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/RoadInformationServiceImpl.java
  22. +6
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/SectionServiceImpl.java
  23. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/structure/StructureServiceImpl.java
  24. +1
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ExecuteTaskService.java
  25. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/StartAIService.java
  26. +2
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/AddOidcTenantService.java
  27. +4
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java
  28. +2
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserListByDeptIdService.java
  29. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserPageListService.java
  30. +4
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserService.java
  31. +7
    -15
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/distribution/DistributionWorkorderService.java
  32. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java
  33. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java
  34. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/user/UserInfoVo.java
  35. +4
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/user/UserPageListVo.java
  36. +6
    -4
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml
  37. +4
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java
  38. +5
    -5
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DataPermissionEnum.java
  39. +4
    -4
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java
  40. +4
    -4
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  41. +12
    -13
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java

+ 8
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java View File

@NoArgsConstructor @NoArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("th_oauth_user")
@TableName("th_user")
public class User implements Serializable { public class User implements Serializable {


private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 角色ID * 角色ID
*/ */
@TableField(exist = false)
private String[] roleIds;
// @TableField(exist = false)
// private String[] roleIds;


/** /**
* 城市集合 * 城市集合
* 标识id 小程序,pc * 标识id 小程序,pc
*/ */
private String clientId; private String clientId;

/**
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据;
*/
private Integer dataPermission;
} }

+ 11
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/DataPermissionEnum.java View File

* @team tuoheng * @team tuoheng
* @date 2022-11-25 * @date 2022-11-25
*/ */
public enum RoleEnum {
public enum DataPermissionEnum {


SUPER_ADMIN(1,"超级管理员"),
ADMIN(2,"管理员"),
ORDINARY_USER(3,"普通用户");
ALL(1,"查看所有部门数据"),
DEPT_AND_SUB_DEPT(2,"查看本部门及子部门数据"),
DEPT(3,"查看本部门数据");


RoleEnum(int code, String description){
// ADMIN(2,"管理员"),
// ORDINARY_USER(3,"普通用户");

DataPermissionEnum(int code, String description){
this.code = code; this.code = code;
this.description = description; this.description = description;
} }
@Getter @Getter
private String description; private String description;


private static Map<Integer, RoleEnum> data = new HashMap<>();
private static Map<Integer, DataPermissionEnum> data = new HashMap<>();


static { static {
for (RoleEnum type : RoleEnum.values()) {
for (DataPermissionEnum type : DataPermissionEnum.values()) {
data.put(type.code, type); data.put(type.code, type);
} }
} }


public static RoleEnum parse(int code) {
public static DataPermissionEnum parse(int code) {
if (data.containsKey(code)) { if (data.containsKey(code)) {
return data.get(code); return data.get(code);
} }

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/AddUserCodeEnum.java View File

TYPE_ID_IS_NOT_EXISTS(1100108, "用户类型不存在"), TYPE_ID_IS_NOT_EXISTS(1100108, "用户类型不存在"),
PHONE_NOT_IMATCH(1100109, "手机号不匹配"), PHONE_NOT_IMATCH(1100109, "手机号不匹配"),
USERNAME_ALREADY_EXISTS(1100110, "系统中已经存在该账号"), USERNAME_ALREADY_EXISTS(1100110, "系统中已经存在该账号"),
ROLE_IS_NOT_EXISTS(1100111, "该角色不存在");
ROLE_IS_NOT_EXISTS(1100111, "该角色不存在"),
DATA_PERMISSION_IS_NULL(1100112, "数据权限不能为空");


/** /**
* 错误码 * 错误码

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserCodeEnum.java View File

PHONE_NOT_IMATCH(1100307, "手机号不匹配"), PHONE_NOT_IMATCH(1100307, "手机号不匹配"),
USER_IS_NOT_EXIST(1100308, "用户不存在"), USER_IS_NOT_EXIST(1100308, "用户不存在"),
USERNAME_ALREADY_EXISTS(1100309, "系统中已经存在该用户名"), USERNAME_ALREADY_EXISTS(1100309, "系统中已经存在该用户名"),
ROLE_IS_NOT_EXISTS(1100310, "该角色不存在");;
ROLE_IS_NOT_EXISTS(1100310, "该角色不存在"),
DATA_PERMISSION_IS_NULL(1100311, "数据权限不能为空"),;


/** /**
* 错误码 * 错误码

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/workorder/DistributionWorkorderCodeEnum.java View File

ASSIGN_DEPT_ID_IS_NULL(1260403, "指派部门ID为空"), ASSIGN_DEPT_ID_IS_NULL(1260403, "指派部门ID为空"),
ASSIGN_USER_ID_IS_NULL(1260404, "指派负责人为空"), ASSIGN_USER_ID_IS_NULL(1260404, "指派负责人为空"),
ASSIGN_USER_ID_IS_NOT_EXIST(1260405, "指派负责人不存在"), ASSIGN_USER_ID_IS_NOT_EXIST(1260405, "指派负责人不存在"),
SUPER_ADMIN_NOT_DISTRIBUTION(1260406, "超级管理员不能分配工单"),
ALL_NOT_DISTRIBUTION(1260406, "超级管理员不能分配工单"),
ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER(1260407, "管理员不能分配子部门工单"), ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER(1260407, "管理员不能分配子部门工单"),
ORDINARY_USER_NOT_DISTRIBUTION(1260408, "普通用户不能分配工单"); ORDINARY_USER_NOT_DISTRIBUTION(1260408, "普通用户不能分配工单");



+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java View File

import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentEnum; import com.tuoheng.admin.enums.AccidentEnum;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.SectionMapper; import com.tuoheng.admin.mapper.SectionMapper;
} }
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getDeptId, accident.getDeptId()) .eq(User::getDeptId, accident.getDeptId())
.eq(User::getRoleId, RoleEnum.ADMIN.getCode())
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())
.eq(User::getMark, MarkEnum.VALID.getCode())); .eq(User::getMark, MarkEnum.VALID.getCode()));
if(ObjectUtils.isEmpty(user)){ if(ObjectUtils.isEmpty(user)){
throw new ServiceException("登录用户对应的部门没有管理员账户"); throw new ServiceException("登录用户对应的部门没有管理员账户");

+ 2
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java View File

import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.conver.AccidentConverMapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList());
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.in(User::getDeptId, deptIdList) .in(User::getDeptId, deptIdList)
.eq(User::getRoleId, RoleEnum.ADMIN.getCode()));
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()));
Map<String, User> userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); Map<String, User> userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll);
return userMap; return userMap;
} }

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java View File

import com.tuoheng.admin.enums.AccidentEnum; import com.tuoheng.admin.enums.AccidentEnum;
import com.tuoheng.admin.enums.FlagEnum; import com.tuoheng.admin.enums.FlagEnum;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.UserMapper; import com.tuoheng.admin.mapper.UserMapper;
List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList());
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.in(User::getDeptId, deptIdList) .in(User::getDeptId, deptIdList)
.eq(User::getRoleId, RoleEnum.ADMIN.getCode()));
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()));
Map<String, User> userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); Map<String, User> userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll);
return userMap; return userMap;
} }

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeService.java View File



if (CollectionUtil.isEmpty(deptList)) { if (CollectionUtil.isEmpty(deptList)) {
log.info("获取部门列表为空"); log.info("获取部门列表为空");
return JsonResult.error(QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getMsg());
return JsonResult.success(deptTreeVoList);
} }


List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList); List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList);

+ 20
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFindFlightDataService.java View File

package com.tuoheng.admin.service.flightdata.query; package com.tuoheng.admin.service.flightdata.query;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.FlightData; import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum;
import com.tuoheng.admin.mapper.FlightDataMapper; import com.tuoheng.admin.mapper.FlightDataMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class QueryFindFlightDataService { public class QueryFindFlightDataService {


@Autowired
private InspectionMapper inspectionMapper;

@Autowired @Autowired
private FlightDataMapper flightDataMapper; private FlightDataMapper flightDataMapper;


if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
} }
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(inspection)) {
log.info("没有该任务记录, id={}", id);
throw new ServiceException("没有该任务记录");
}
if (2 == inspection.getType() && StringUtils.isNotEmpty(inspection.getEmergencyDataInspectionId())) {
id = inspection.getEmergencyDataInspectionId();
}

//根据任务id查询对应的云盒遥测数据 //根据任务id查询对应的云盒遥测数据
List<FlightData> listData = flightDataMapper.selectListByInspectionId(id); List<FlightData> listData = flightDataMapper.selectListByInspectionId(id);



+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/delete/DeleteInspectionService.java View File

import com.tuoheng.admin.entity.InspectionFile; import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionStatusEnum; import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.DeleteInspectionCodeEnum; import com.tuoheng.admin.enums.code.inspection.DeleteInspectionCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
.eq(User::getTenantId, tenantId) .eq(User::getTenantId, tenantId)
.eq(User::getId, userId) .eq(User::getId, userId)
.eq(User::getMark, 1)); .eq(User::getMark, 1));
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return JsonResult.success(); return JsonResult.success();
} else if (RoleEnum.ADMIN.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
if (user.getDeptId().equals(inspection.getDeptId())) { if (user.getDeptId().equals(inspection.getDeptId())) {
return JsonResult.success(); return JsonResult.success();
} }
return JsonResult.error(DeleteInspectionCodeEnum.ADMIN_NOT_DELETE_CHILD_INSPECTION.getCode(), DeleteInspectionCodeEnum.ADMIN_NOT_DELETE_CHILD_INSPECTION.getMsg()); return JsonResult.error(DeleteInspectionCodeEnum.ADMIN_NOT_DELETE_CHILD_INSPECTION.getCode(), DeleteInspectionCodeEnum.ADMIN_NOT_DELETE_CHILD_INSPECTION.getMsg());
} else if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(DeleteInspectionCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_DELETE.getCode(), DeleteInspectionCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_DELETE.getMsg()); return JsonResult.error(DeleteInspectionCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_DELETE.getCode(), DeleteInspectionCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_DELETE.getMsg());
} }
return JsonResult.error(); return JsonResult.error();

+ 5
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java View File

import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;


public JsonResult getPageList(QueryInspectionPageListRequest request) { public JsonResult getPageList(QueryInspectionPageListRequest request) {
// log.info("进入查询巡检任务分页列表业务"); // log.info("进入查询巡检任务分页列表业务");

String userId = CurrentUserUtil.getUserId(); String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId(); String tenantId = CurrentUserUtil.getTenantId();
request.setTenantId(tenantId); request.setTenantId(tenantId);
.eq(Dept::getMark, 1)); .eq(Dept::getMark, 1));


IPage<Inspection> pageData = null; IPage<Inspection> pageData = null;
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
pageData = this.getAllList(request); pageData = this.getAllList(request);
} else if (RoleEnum.ADMIN.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
pageData = this.getListByDept(request, user); pageData = this.getListByDept(request, user);
} else if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
pageData = this.getListByDept(request, user); pageData = this.getListByDept(request, user);
} }


if (null == pageData || pageData.getTotal() == 0) { if (null == pageData || pageData.getTotal() == 0) {
log.info("获取任务分页列表为空"); log.info("获取任务分页列表为空");
return JsonResult.success(null, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
return JsonResult.success(pageData);
} }


// 构造返回结果对象 // 构造返回结果对象

+ 5
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java View File

import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionListServiceEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionListServiceEnum;
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
} }


//判断用户角色 1超级管理员 2部门管理员 3普通用户 //判断用户角色 1超级管理员 2部门管理员 3普通用户
if (null == user.getRoleId()) {
if (null == user.getDataPermission()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//若角色为超级管理员,查询任务表最新五条数据 //若角色为超级管理员,查询任务表最新五条数据
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId) .eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) .eq(Inspection::getMark, MarkEnum.VALID.getCode())
if (CollectionUtil.isEmpty(inspectionList)) { if (CollectionUtil.isEmpty(inspectionList)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList); Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList);
return JsonResult.success(inspections); return JsonResult.success(inspections);
} }
} }


//若角色为部门管理员或普通用户,查询最新五条数据 //若角色为部门管理员或普通用户,查询最新五条数据
if (RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)) { if (StringUtils.isEmpty(deptId)) {
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(), QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg()); JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(), QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg());

+ 1
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/EditHandle.java View File

import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.*; import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.enums.code.inspection.EditInspectionCodeEnum;
import com.tuoheng.admin.mapper.UserMapper; import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.vo.inspection.InspectionVo; import com.tuoheng.admin.vo.inspection.InspectionVo;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
// 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改 // 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改
User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>() User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getDeptId, user.getDeptId()) .eq(User::getDeptId, user.getDeptId())
.eq(User::getRoleId, RoleEnum.ADMIN.getCode())
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())
.eq(User::getMark, MarkEnum.VALID.getCode())); .eq(User::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(userTmp)) { if (ObjectUtil.isNull(userTmp)) {
if (null != handler) { if (null != handler) {

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ExecuteHandle.java View File

import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionStatusEnum; import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.InspectionTypeEnum; import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.vo.inspection.InspectionVo; import com.tuoheng.admin.vo.inspection.InspectionVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
return; return;
} }


if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
// 超级管理员不能执行任务操作 // 超级管理员不能执行任务操作
inspectionVo.setExecute(false); inspectionVo.setExecute(false);
} else if (RoleEnum.ADMIN.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
// 管理员可对本部门的任务执行此操作 // 管理员可对本部门的任务执行此操作
if (user.getDeptId().equals(inspectionVo.getDeptId())) { if (user.getDeptId().equals(inspectionVo.getDeptId())) {
if (1 == inspectionVo.getExecutionStatus()) { if (1 == inspectionVo.getExecutionStatus()) {
inspectionVo.setExecute(true); inspectionVo.setExecute(true);
} }
} }
} else if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
// 普通用户可对自己创建的任务执行此操作 // 普通用户可对自己创建的任务执行此操作
if (user.getId().equals(inspectionVo.getCreateUser())) { if (user.getId().equals(inspectionVo.getCreateUser())) {
inspectionVo.setExecute(true); inspectionVo.setExecute(true);

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/UpdateInspectionService.java View File

import com.tuoheng.admin.enums.InspectionExecutionStatusEnum; import com.tuoheng.admin.enums.InspectionExecutionStatusEnum;
import com.tuoheng.admin.enums.InspectionStatusEnum; import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.EditInspectionCodeEnum; import com.tuoheng.admin.enums.code.inspection.EditInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.RoadInformationMapper; import com.tuoheng.admin.mapper.RoadInformationMapper;
// 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改 // 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改
User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>() User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getDeptId, user.getDeptId()) .eq(User::getDeptId, user.getDeptId())
.eq(User::getRoleId, RoleEnum.ADMIN.getCode())
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())
.eq(User::getMark, MarkEnum.VALID.getCode())); .eq(User::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(userTmp)) { if (ObjectUtil.isNull(userTmp)) {
return JsonResult.error(EditInspectionCodeEnum.NON_DEPT_ADMIN_NOT_EDIT.getCode(), EditInspectionCodeEnum.NON_DEPT_ADMIN_NOT_EDIT.getMsg()); return JsonResult.error(EditInspectionCodeEnum.NON_DEPT_ADMIN_NOT_EDIT.getCode(), EditInspectionCodeEnum.NON_DEPT_ADMIN_NOT_EDIT.getMsg());

+ 7
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java View File

import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile; import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.QuestionType; import com.tuoheng.admin.entity.QuestionType;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum;
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.query.InspectionFileQuery; import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.admin.request.inspectionfile.*; import com.tuoheng.admin.request.inspectionfile.*;
import com.tuoheng.admin.service.inspectionfile.IInspectionFileService;
import com.tuoheng.admin.service.inspectionfile.confirm.InspectionFileConfirmService; import com.tuoheng.admin.service.inspectionfile.confirm.InspectionFileConfirmService;
import com.tuoheng.admin.service.inspectionfile.handle.QueryInspectionFileHandleByInspectionFileIdService; import com.tuoheng.admin.service.inspectionfile.handle.QueryInspectionFileHandleByInspectionFileIdService;
import com.tuoheng.admin.service.inspectionfile.ignore.InspectionFileIgnoreService; import com.tuoheng.admin.service.inspectionfile.ignore.InspectionFileIgnoreService;
import com.tuoheng.common.core.enums.ServiceExceptionEnum; import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.SecurityUserUtils;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
//获取当前登录人信息 //获取当前登录人信息
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
//获取用户角色 //获取用户角色
Integer roleId = user.getRoleId();
Integer roleId = user.getDataPermission();
if(roleId ==null){ if(roleId ==null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//查询区域范范围问题 //查询区域范范围问题
List<InspectionFile> inspectionFileLists = new ArrayList<>(); List<InspectionFile> inspectionFileLists = new ArrayList<>();
//超级管理员 //超级管理员
if(RoleEnum.SUPER_ADMIN.getCode()==roleId){
if(DataPermissionEnum.ALL.getCode()==roleId){
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getMark, 1) .eq(InspectionFile::getMark, 1)
.eq(InspectionFile::getTenantId, tenantId)); .eq(InspectionFile::getTenantId, tenantId));
} }
} }
//部门管理员及普通用户 本部门的问题 //部门管理员及普通用户 本部门的问题
if(RoleEnum.ADMIN.getCode()== user.getRoleId() || RoleEnum.ORDINARY_USER.getCode()== user.getRoleId()){
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()== user.getDataPermission() || DataPermissionEnum.DEPT.getCode()== user.getDataPermission()){
//根据用户查询对应的巡检任务id //根据用户查询对应的巡检任务id
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>() List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId) .eq(Inspection::getTenantId, tenantId)
public JsonResult getListByDeptUserType(InspectionFileQuery query) { public JsonResult getListByDeptUserType(InspectionFileQuery query) {
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
//用户角色判断 1超级管理员 2部门管理员 3普通用户 //用户角色判断 1超级管理员 2部门管理员 3普通用户
if(null == user.getRoleId()){
if(null == user.getDataPermission()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
List<ListByDeptUserTypeVo> list = new ArrayList<>(); List<ListByDeptUserTypeVo> list = new ArrayList<>();
//5块状裂纹 //5块状裂纹
Integer massiveCrack = 0; Integer massiveCrack = 0;
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 //若角色为超级管理员,查看状态为已生成工单和和问题已处理
if(RoleEnum.SUPER_ADMIN.getCode()==user.getRoleId()){
if(DataPermissionEnum.ALL.getCode()==user.getDataPermission()){
//直接查问题列表 //直接查问题列表
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getMark, 1) .eq(InspectionFile::getMark, 1)
Collections.addAll(list,vo,vo1,vo2,vo3,vo4,vo5); Collections.addAll(list,vo,vo1,vo2,vo3,vo4,vo5);
} }
//若角色为部门管理员或普通用户 //若角色为部门管理员或普通用户
if(RoleEnum.ADMIN.getCode()== user.getRoleId() || RoleEnum.ORDINARY_USER.getCode()== user.getRoleId()){
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()== user.getDataPermission() || DataPermissionEnum.DEPT.getCode()== user.getDataPermission()){
//获取用户对应的部门 //获取用户对应的部门
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if(StringUtils.isEmpty(deptId)){ if(StringUtils.isEmpty(deptId)){

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileDistributionListService.java View File

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.conver.InspectionFileConverMapper; import com.tuoheng.admin.conver.InspectionFileConverMapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFileDistributionListRequest; import com.tuoheng.admin.request.inspectionfile.QueryInspectionFileDistributionListRequest;
List<InspectionFileDistribution> inspectionFileDistributionList = inspectionFileMapper.selectDistributionList(request); List<InspectionFileDistribution> inspectionFileDistributionList = inspectionFileMapper.selectDistributionList(request);
if (null == inspectionFileDistributionList || inspectionFileDistributionList.size() == 0) { if (null == inspectionFileDistributionList || inspectionFileDistributionList.size() == 0) {
log.info("获取任务问题分布列表为空"); log.info("获取任务问题分布列表为空");
return JsonResult.success(null, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
return JsonResult.success(inspectionFileDistributionList, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
} }


// 构造返回结果对象 // 构造返回结果对象
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getId, userId) .eq(User::getId, userId)
.eq(User::getMark, 1)); .eq(User::getMark, 1));
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null; return null;
} else { } else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); deptIdList = deptMapper.selectAllChildListById(user.getDeptId());

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListByWorkOrderIdService.java View File



if (null == pageData || pageData.getTotal() == 0) { if (null == pageData || pageData.getTotal() == 0) {
log.info("根据工单ID查询工单问题列表业务:获取任务分页列表为空"); log.info("根据工单ID查询工单问题列表业务:获取任务分页列表为空");
return JsonResult.success(null, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
return JsonResult.success(pageData, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
} }


List<WorkOrderFile> workOrderFileList = pageData.getRecords(); List<WorkOrderFile> workOrderFileList = pageData.getRecords();

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListService.java View File

import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.conver.InspectionFileConverMapper; import com.tuoheng.admin.conver.InspectionFileConverMapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListRequest; import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListRequest;
.eq(User::getId, userId) .eq(User::getId, userId)
.eq(User::getTenantId, tenantId) .eq(User::getTenantId, tenantId)
.eq(User::getMark, 1)); .eq(User::getMark, 1));
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null; return null;
} else { } else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); deptIdList = deptMapper.selectAllChildListById(user.getDeptId());

+ 5
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/RoadInformationServiceImpl.java View File

import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.query.RoadInformationQuery; import com.tuoheng.admin.query.RoadInformationQuery;
import com.tuoheng.admin.service.road.RoadInformationService;
import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService; import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.common.BaseServiceImpl; import com.tuoheng.common.core.common.BaseServiceImpl;
public JsonResult getListByUserType() { public JsonResult getListByUserType() {
//获取当前登录人信息 登录用户名 //获取当前登录人信息 登录用户名
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
if(null == user){
return JsonResult.error("用户不存在");
}
//获取租户id //获取租户id
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
//用户类型角色判断 1超级管理员 2 部门管理员 3普通用户 //用户类型角色判断 1超级管理员 2 部门管理员 3普通用户
if(null == user.getRoleId()){
if(null == user.getDataPermission()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//登录用户若为部门管理员或普通用户需要查询所在部门 //登录用户若为部门管理员或普通用户需要查询所在部门
//获取公路列表 //获取公路列表
List<RoadInformation> roadInformationList = new ArrayList<>(); List<RoadInformation> roadInformationList = new ArrayList<>();
//超级管理员 //超级管理员
if(RoleEnum.SUPER_ADMIN.getCode()== user.getRoleId()){
if(DataPermissionEnum.ALL.getCode()== user.getDataPermission()){
roadInformationList = this.getAllRoadInformationList(tenantId); roadInformationList = this.getAllRoadInformationList(tenantId);
} }
//部门管理员 //部门管理员
if(RoleEnum.ADMIN.getCode() == user.getRoleId()){
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()){
//根据当前用户对应的部门id获取该部门及子部门的id集合 //根据当前用户对应的部门id获取该部门及子部门的id集合
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); List<String> deptIdList = deptMapper.selectAllChildListById(deptId);
if(CollectionUtil.isEmpty(deptIdList)){ if(CollectionUtil.isEmpty(deptIdList)){
roadInformationList = this.getRoadInformationList(tenantId, list); roadInformationList = this.getRoadInformationList(tenantId, list);
} }
//普通用户 //普通用户
if(RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()){
if(DataPermissionEnum.DEPT.getCode() == user.getDataPermission()){
List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>() List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>()
.eq(RoadDept::getTenantId, tenantId) .eq(RoadDept::getTenantId, tenantId)
.eq(RoadDept::getDeptId, deptId)); .eq(RoadDept::getDeptId, deptId));

+ 6
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/SectionServiceImpl.java View File

import com.tuoheng.admin.entity.SectionDept; import com.tuoheng.admin.entity.SectionDept;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.SectionEnum; import com.tuoheng.admin.enums.SectionEnum;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.RoadInformationMapper; import com.tuoheng.admin.mapper.RoadInformationMapper;
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
IPage<Section> pageData = new Page<>(query.getPage(), query.getLimit()); IPage<Section> pageData = new Page<>(query.getPage(), query.getLimit());
//数据权限 超级管理员可以查看全部路段 //数据权限 超级管理员可以查看全部路段
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
//获取分页数据 //获取分页数据
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); IPage<Section> page = new Page<>(query.getPage(), query.getLimit());
pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery() pageData = sectionMapper.selectPage(page, Wrappers.<Section>lambdaQuery()
pageData.setRecords(list); pageData.setRecords(list);
} }
//部门管理员和普通用户 查看本部门及下属部门 //部门管理员和普通用户 查看本部门及下属部门
if (RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
//获取分页数据 //获取分页数据
IPage<Section> page = new Page<>(query.getPage(), query.getLimit()); IPage<Section> page = new Page<>(query.getPage(), query.getLimit());
//获取当前部门及其子部门列表 //获取当前部门及其子部门列表
} }
String tenantId = CurrentUserUtil.getTenantId(); String tenantId = CurrentUserUtil.getTenantId();
//超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和 //超级管理员获取当前租户下全部公路,部门管理员和普通用户显示用户所属部门监管范围路段之和
if(null == user.getRoleId()){
if(null == user.getDataPermission()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//登录用户若为部门管理员或普通用户需要查询所在部门 //登录用户若为部门管理员或普通用户需要查询所在部门
List<RoadInformation> roadInformationList = new ArrayList<>(); List<RoadInformation> roadInformationList = new ArrayList<>();


//超级管理员 //超级管理员
if(RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()){
if(DataPermissionEnum.ALL.getCode() == user.getDataPermission()){
roadInformationList = this.getAllRoadInformationList(tenantId); roadInformationList = this.getAllRoadInformationList(tenantId);
return JsonResult.success(roadInformationList); return JsonResult.success(roadInformationList);
} }


//部门管理员和普通用户 //部门管理员和普通用户
if(RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()){
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()){
//对应部门下的路段列表 //对应部门下的路段列表
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>() List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>()
.eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId)); .eq(SectionDept::getDeptId, deptId).eq(SectionDept::getTenantId, tenantId));

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/structure/StructureServiceImpl.java View File

import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.SectionEnum; import com.tuoheng.admin.enums.SectionEnum;
import com.tuoheng.admin.enums.StructureEnum; import com.tuoheng.admin.enums.StructureEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
query.setTenantId(tenantId); query.setTenantId(tenantId);


//获取用户角色 //获取用户角色
Integer roleId = user.getRoleId();
Integer roleId = user.getDataPermission();
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); IPage<Structure> page = new Page<>(query.getPage(), query.getLimit());
IPage<StructureInfoVo> pageData = null; IPage<StructureInfoVo> pageData = null;
//如果是超级管理员,查看所有构造物 //如果是超级管理员,查看所有构造物
if (RoleEnum.SUPER_ADMIN.getCode() == roleId) {
if (DataPermissionEnum.ALL.getCode() == roleId) {
//数据分页 //数据分页
pageData = structureMapper.queryPage(page, query); pageData = structureMapper.queryPage(page, query);
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> {


} }
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 //如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物
if (RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == roleId || DataPermissionEnum.DEPT.getCode() == roleId) {
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)) { if (StringUtils.isEmpty(deptId)) {
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(), StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(), StructureEnum.DEPT_IS_NOT_EXIST.getMsg());

+ 1
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ExecuteTaskService.java View File

JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", inspection.getInspectionLine()); jsonObject.put("taskId", inspection.getInspectionLine());
jsonObject.put("requestId", inspection.getId()); jsonObject.put("requestId", inspection.getId());
jsonObject.put("requestName", inspection.getName());
jsonObject.put("code", "gs"); // 与机场平台约定好的 jsonObject.put("code", "gs"); // 与机场平台约定好的
jsonObject.put("tenantCode", tenant.getCode()); jsonObject.put("tenantCode", tenant.getCode());



+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/StartAIService.java View File

* @return * @return
*/ */
public JsonResult startAI(MissionStatusRequest missionStatusRequest) { public JsonResult startAI(MissionStatusRequest missionStatusRequest) {
log.info("进入调用DSP接口方法");
log.info("进入调用DSP接口方法, missionStatusRequest={}", missionStatusRequest.getId());
log.info("进入调用DSP接口方法, dspServiceInstId={}", dspServiceInstId);
JSONObject request = new JSONObject(); JSONObject request = new JSONObject();
JSONArray configList = new JSONArray(); JSONArray configList = new JSONArray();
JSONObject instConfigMode = new JSONObject(); JSONObject instConfigMode = new JSONObject();

+ 2
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/AddOidcTenantService.java View File

import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.dto.ClientRoleDto; import com.tuoheng.admin.dto.ClientRoleDto;
import com.tuoheng.admin.entity.Role; import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.entity.Tenant; import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.ClientEnum; import com.tuoheng.admin.enums.ClientEnum;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.RoleMapper; import com.tuoheng.admin.mapper.RoleMapper;
import com.tuoheng.admin.mapper.TenantMapper; import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.mapper.UserMapper; import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.request.third.oidc.CreateOidcTenantRequest; import com.tuoheng.admin.request.third.oidc.CreateOidcTenantRequest;
import com.tuoheng.admin.request.user.UserInitRequest;
import com.tuoheng.common.core.utils.CommonUtils; import com.tuoheng.common.core.utils.CommonUtils;
import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;


@Slf4j @Slf4j
@Service @Service
return JsonResult.error(400, "系统中已经存在该用户名"); return JsonResult.error(400, "系统中已经存在该用户名");
} }
count = roleMapper.selectCount(new LambdaQueryWrapper<Role>() count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getId, RoleEnum.SUPER_ADMIN.getCode())
.eq(Role::getId, DataPermissionEnum.ALL.getCode())
.eq(Role::getMark, MarkEnum.VALID.getCode())); .eq(Role::getMark, MarkEnum.VALID.getCode()));
if (count <= 0) { if (count <= 0) {
return JsonResult.error(400, "角色不存在"); return JsonResult.error(400, "角色不存在");

+ 4
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java View File

if (ObjectUtil.isNull(user.getRoleId()) || 0 == user.getRoleId()) { if (ObjectUtil.isNull(user.getRoleId()) || 0 == user.getRoleId()) {
return JsonResult.error(AddUserCodeEnum.ROLE_ID_IS_NULL.getCode(), AddUserCodeEnum.ROLE_ID_IS_NULL.getMsg()); return JsonResult.error(AddUserCodeEnum.ROLE_ID_IS_NULL.getCode(), AddUserCodeEnum.ROLE_ID_IS_NULL.getMsg());
} }
if (ObjectUtil.isNull(user.getDataPermission()) || 0 == user.getDataPermission()) {
return JsonResult.error(AddUserCodeEnum.DATA_PERMISSION_IS_NULL.getCode(), AddUserCodeEnum.DATA_PERMISSION_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(user.getDeptId())) { if (StringUtils.isEmpty(user.getDeptId())) {
return JsonResult.error(AddUserCodeEnum.DEPT_ID_IS_NULL.getCode(), AddUserCodeEnum.DEPT_ID_IS_NULL.getMsg()); return JsonResult.error(AddUserCodeEnum.DEPT_ID_IS_NULL.getCode(), AddUserCodeEnum.DEPT_ID_IS_NULL.getMsg());
} }
return JsonResult.error(AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getCode(), AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getMsg()); return JsonResult.error(AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getCode(), AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getMsg());
} }
count = roleMapper.selectCount(new LambdaQueryWrapper<Role>() count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getId, user.getRoleId())
.eq(Role::getId, user.getDataPermission())
.eq(Role::getMark, 1)); .eq(Role::getMark, 1));
if (count < 0) { if (count < 0) {
return JsonResult.error(AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg()); return JsonResult.error(AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg());

+ 2
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserListByDeptIdService.java View File

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.user.QueryUserListByDeptIdCodeEnum; import com.tuoheng.admin.enums.code.user.QueryUserListByDeptIdCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.UserMapper; import com.tuoheng.admin.mapper.UserMapper;
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId) .eq(User::getTenantId, tenantId)
.eq(User::getDeptId, deptId) .eq(User::getDeptId, deptId)
.ne(User::getRoleId, RoleEnum.SUPER_ADMIN.getCode())
.ne(User::getRoleId, DataPermissionEnum.ALL.getCode())
.eq(User::getMark, 1)); .eq(User::getMark, 1));


if (CollectionUtil.isEmpty(userList)) { if (CollectionUtil.isEmpty(userList)) {

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserPageListService.java View File

import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.conver.UserConverMapper; import com.tuoheng.admin.conver.UserConverMapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.user.QueryUserPageListCodeEnum; import com.tuoheng.admin.enums.code.user.QueryUserPageListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.RoleMapper; import com.tuoheng.admin.mapper.RoleMapper;


if (null == pageData || pageData.getTotal() == 0) { if (null == pageData || pageData.getTotal() == 0) {
log.info("获取任务分页列表为空"); log.info("获取任务分页列表为空");
return JsonResult.success();
return JsonResult.success(pageData);
} }


// 构造返回结果对象 // 构造返回结果对象
* @return * @return
*/ */
private JsonResult check(User user) { private JsonResult check(User user) {
if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getCode(), QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getMsg()); return JsonResult.error(QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getCode(), QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getMsg());
} }
return JsonResult.success(); return JsonResult.success();
*/ */
private List<String> getDeptIdList(User user) { private List<String> getDeptIdList(User user) {
List<String> deptIdList; List<String> deptIdList;
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null; return null;
} else { } else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); deptIdList = deptMapper.selectAllChildListById(user.getDeptId());

+ 4
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserService.java View File

if (ObjectUtil.isNull(user.getRoleId()) || 0 == user.getRoleId()) { if (ObjectUtil.isNull(user.getRoleId()) || 0 == user.getRoleId()) {
return JsonResult.error(EditUserCodeEnum.ROLE_ID_IS_NULL.getCode(), EditUserCodeEnum.ROLE_ID_IS_NULL.getMsg()); return JsonResult.error(EditUserCodeEnum.ROLE_ID_IS_NULL.getCode(), EditUserCodeEnum.ROLE_ID_IS_NULL.getMsg());
} }
if (ObjectUtil.isNull(user.getDataPermission()) || 0 == user.getDataPermission()) {
return JsonResult.error(EditUserCodeEnum.DATA_PERMISSION_IS_NULL.getCode(), EditUserCodeEnum.DATA_PERMISSION_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(user.getClientId())) { if (StringUtils.isEmpty(user.getClientId())) {
return JsonResult.error(EditUserCodeEnum.CLIENT_ID_IS_NULL.getCode(), EditUserCodeEnum.CLIENT_ID_IS_NULL.getMsg()); return JsonResult.error(EditUserCodeEnum.CLIENT_ID_IS_NULL.getCode(), EditUserCodeEnum.CLIENT_ID_IS_NULL.getMsg());
} }
} }
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>() Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getTenantId, tenantId) .eq(Role::getTenantId, tenantId)
.eq(Role::getId, user.getRoleId())
.eq(Role::getId, user.getDataPermission())
.eq(Role::getMark, 1)); .eq(Role::getMark, 1));
if (count <= 0) { if (count <= 0) {
// return JsonResult.error(EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg()); // return JsonResult.error(EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg());

+ 7
- 15
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/distribution/DistributionWorkorderService.java View File

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.entity.WorkOrder; import com.tuoheng.admin.entity.WorkOrder;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum; import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.workorder.DistributionWorkorderCodeEnum; import com.tuoheng.admin.enums.code.workorder.DistributionWorkorderCodeEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum; import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
log.info("进入分配工单业务:校验失败:{}", result.getMsg()); log.info("进入分配工单业务:校验失败:{}", result.getMsg());
return result; return result;
} }
WorkOrder workOrder = (WorkOrder) result.getData();

User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
String userId = user.getId(); String userId = user.getId();
String tenantId = user.getTenantId();

// 检查权限
result = checkPermission(userId, tenantId, workOrder);
if (0 != result.getCode()) {
log.info("进入分配工单:校验权限失败:{}", result.getMsg());
return result;
}
result = this.distributionWorkOrder(userId, request); result = this.distributionWorkOrder(userId, request);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("进入分配工单:分配工单失败:{}", result.getMsg()); log.info("进入分配工单:分配工单失败:{}", result.getMsg());
* 2)、部门管理员仅可分配本部门工单,无法分配子部门工单 * 2)、部门管理员仅可分配本部门工单,无法分配子部门工单
* 3)、普通用户不能分配工单 * 3)、普通用户不能分配工单
* *
* 2023-05-11 角色权限功能改造为子定义,去除该检验
*
* @param userId * @param userId
* @param workOrder * @param workOrder
* @return * @return
.eq(User::getId, userId) .eq(User::getId, userId)
.eq(User::getTenantId, tenantId) .eq(User::getTenantId, tenantId)
.eq(User::getMark, 1)); .eq(User::getMark, 1));
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
return JsonResult.error(DistributionWorkorderCodeEnum.SUPER_ADMIN_NOT_DISTRIBUTION.getCode(), DistributionWorkorderCodeEnum.SUPER_ADMIN_NOT_DISTRIBUTION.getMsg());
} else if (RoleEnum.ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return JsonResult.error(DistributionWorkorderCodeEnum.ALL_NOT_DISTRIBUTION.getCode(), DistributionWorkorderCodeEnum.ALL_NOT_DISTRIBUTION.getMsg());
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
if (!user.getDeptId().equals(workOrder.getDeptId())) { if (!user.getDeptId().equals(workOrder.getDeptId())) {
return JsonResult.error(DistributionWorkorderCodeEnum.ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER.getCode(), DistributionWorkorderCodeEnum.ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER.getMsg()); return JsonResult.error(DistributionWorkorderCodeEnum.ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER.getCode(), DistributionWorkorderCodeEnum.ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER.getMsg());
} }
return JsonResult.success(user); return JsonResult.success(user);
} else if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(DistributionWorkorderCodeEnum.ORDINARY_USER_NOT_DISTRIBUTION.getCode(), DistributionWorkorderCodeEnum.ORDINARY_USER_NOT_DISTRIBUTION.getMsg()); return JsonResult.error(DistributionWorkorderCodeEnum.ORDINARY_USER_NOT_DISTRIBUTION.getCode(), DistributionWorkorderCodeEnum.ORDINARY_USER_NOT_DISTRIBUTION.getMsg());
} }
return JsonResult.error(); return JsonResult.error();

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java View File

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum; import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum; import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum; import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
* @return * @return
*/ */
private JsonResult checkPermission(User user, List<Inspection> inspectionList) { private JsonResult checkPermission(User user, List<Inspection> inspectionList) {
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return JsonResult.success(user); return JsonResult.success(user);
} else if (RoleEnum.ADMIN.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
for (Inspection inspection : inspectionList) { for (Inspection inspection : inspectionList) {
if (!user.getDeptId().equals(inspection.getDeptId())) { if (!user.getDeptId().equals(inspection.getDeptId())) {
return JsonResult.error(GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getCode(), GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getMsg()); return JsonResult.error(GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getCode(), GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getMsg());
} }
} }
return JsonResult.success(user); return JsonResult.success(user);
} else if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
return JsonResult.error(GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getCode(), GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getMsg()); return JsonResult.error(GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getCode(), GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getMsg());
} }
return JsonResult.error(); return JsonResult.error();

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java View File

import com.tuoheng.admin.conver.WorkOrderConverMapper; import com.tuoheng.admin.conver.WorkOrderConverMapper;
import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum; import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.RoleEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest; import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
return result; return result;
} }
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
if (RoleEnum.SUPER_ADMIN.getCode() != user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() != user.getDataPermission()) {
request.setUserDeptId(user.getDeptId()); request.setUserDeptId(user.getDeptId());
} }
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
IPage<WorkOrder> pageData = workOrderMapper.selectPageList(page, request); IPage<WorkOrder> pageData = workOrderMapper.selectPageList(page, request);
if (null == pageData || pageData.getTotal() == 0) { if (null == pageData || pageData.getTotal() == 0) {
log.info("获取任务分页列表为空"); log.info("获取任务分页列表为空");
return JsonResult.success(null, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
return JsonResult.success(pageData, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
} }


// 构造返回结果对象 // 构造返回结果对象
deptIdList.add(deptId); deptIdList.add(deptId);
return deptIdList; return deptIdList;
} }
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null; return null;
} else { } else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); deptIdList = deptMapper.selectAllChildListById(user.getDeptId());

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/user/UserInfoVo.java View File

*/ */
private String clientId; private String clientId;


/**
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据;
*/
private Integer dataPermission;

} }

+ 4
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/user/UserPageListVo.java View File

*/ */
private String clientId; private String clientId;


/**
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据;
*/
private Integer dataPermission;
} }

+ 6
- 4
tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml View File

<result property="streetCode" column="street_code" /> <result property="streetCode" column="street_code" />
<result property="address" column="address" /> <result property="address" column="address" />
<result property="cityName" column="city_name" /> <result property="cityName" column="city_name" />
<result property="dataPermission" column="data_permission" />
<result property="username" column="username" /> <result property="username" column="username" />
<result property="password" column="password" /> <result property="password" column="password" />
<result property="driverType" column="driver_type" /> <result property="driverType" column="driver_type" />
</resultMap> </resultMap>


<sql id="selectUserVo"> <sql id="selectUserVo">
id, tenant_id, code, realname, nickname, gender, avatar, mobile, email, birthday, dept_id, province_code, city_code, district_code, street_code, address, city_name, username, password, driver_type, driver_code, salt, intro, status, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time, role_id, client_id, mark
id, tenant_id, code, realname, nickname, gender, avatar, mobile, email, birthday, dept_id, province_code, city_code, district_code, street_code, address, city_name, data_permission,
username, password, driver_type, driver_code, salt, intro, status, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time, role_id, client_id, mark
</sql> </sql>


<update id="updateByIdList" parameterType="hashmap"> <update id="updateByIdList" parameterType="hashmap">
update th_oauth_user
update th_user
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="mark != null"> mark = #{mark}, </if> <if test="mark != null"> mark = #{mark}, </if>
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if> <if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
</update> </update>


<update id="updateDeptIdByIdList" parameterType="hashmap"> <update id="updateDeptIdByIdList" parameterType="hashmap">
update th_oauth_user
update th_user
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="deptId != null"> dept_id = #{deptId}, </if> <if test="deptId != null"> dept_id = #{deptId}, </if>
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if> <if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>


<select id="selectPageList" parameterType="com.tuoheng.admin.request.user.QueryUserPageListRequest" resultMap="UserResult"> <select id="selectPageList" parameterType="com.tuoheng.admin.request.user.QueryUserPageListRequest" resultMap="UserResult">
select <include refid="selectUserVo"/> select <include refid="selectUserVo"/>
from th_oauth_user
from th_user
<where> <where>
<if test="1 == 1"> and mark = 1 and role_id != 1 </if> <if test="1 == 1"> and mark = 1 and role_id != 1 </if>
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> <if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>

+ 4
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java View File

*/ */
private Integer roleId; private Integer roleId;


/**
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据;
*/
private Integer dataPermission;
} }

+ 5
- 5
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DataPermissionEnum.java View File

* @team tuoheng * @team tuoheng
* @date 2022-11-25 * @date 2022-11-25
*/ */
public enum RoleEnum {
public enum DataPermissionEnum {


ALL(1,"超级管理员"),
ADMIN(2,"管理员"),
ORDINARY_USER(3,"普通用户");
ALL(1,"查看所有部门数据"),
DEPT_AND_SUB_DEPT(2,"查看本部门及子部门数据"),
DEPT(3,"查看本部门数据");


RoleEnum(int code, String description){
DataPermissionEnum(int code, String description){
this.code = code; this.code = code;
this.description = description; this.description = description;
} }

+ 4
- 4
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java View File

import com.tuoheng.miniprogram.entity.dto.QuestionIdentificationDto; import com.tuoheng.miniprogram.entity.dto.QuestionIdentificationDto;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery; import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;
import com.tuoheng.miniprogram.enums.InspectionFileEnum; import com.tuoheng.miniprogram.enums.InspectionFileEnum;
import com.tuoheng.miniprogram.enums.RoleEnum;
import com.tuoheng.miniprogram.enums.DataPermissionEnum;
import com.tuoheng.miniprogram.service.IInspectionFileService; import com.tuoheng.miniprogram.service.IInspectionFileService;
import com.tuoheng.miniprogram.utils.CurrentUserUtil; import com.tuoheng.miniprogram.utils.CurrentUserUtil;
import com.tuoheng.miniprogram.vo.InspectionFileCountVo; import com.tuoheng.miniprogram.vo.InspectionFileCountVo;
if (StringUtils.isEmpty(user.getId())) { if (StringUtils.isEmpty(user.getId())) {
return JsonResult.error(InspectionFileEnum.USER_ID_IS_NULL.getCode(), InspectionFileEnum.USER_ID_IS_NULL.getMsg()); return JsonResult.error(InspectionFileEnum.USER_ID_IS_NULL.getCode(), InspectionFileEnum.USER_ID_IS_NULL.getMsg());
} }
if (null == user.getRoleId()) {
if (null == user.getDataPermission()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//获取当前租户id //获取当前租户id
DateTime startTime = DateUtil.offset(DateUtil.beginOfDay(DateUtil.date()), DateField.DAY_OF_WEEK, -4); DateTime startTime = DateUtil.offset(DateUtil.beginOfDay(DateUtil.date()), DateField.DAY_OF_WEEK, -4);
List<InspectionFileCountVo> result = new ArrayList<>(); List<InspectionFileCountVo> result = new ArrayList<>();
//判断角色 1超级管理员 2部门管理员 3普通用户 //判断角色 1超级管理员 2部门管理员 3普通用户
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
try { try {
List<String> list = findDates(startTime, endTime); List<String> list = findDates(startTime, endTime);
for (String s : list) { for (String s : list) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if (RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
try { try {
List<String> list = findDates(startTime, endTime); List<String> list = findDates(startTime, endTime);
for (String s : list) { for (String s : list) {

+ 4
- 4
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java View File

import com.tuoheng.miniprogram.dao.*; import com.tuoheng.miniprogram.dao.*;
import com.tuoheng.miniprogram.entity.*; import com.tuoheng.miniprogram.entity.*;
import com.tuoheng.miniprogram.entity.query.InspectionQuery; import com.tuoheng.miniprogram.entity.query.InspectionQuery;
import com.tuoheng.miniprogram.enums.RoleEnum;
import com.tuoheng.miniprogram.enums.DataPermissionEnum;
import com.tuoheng.miniprogram.service.IInspectionService; import com.tuoheng.miniprogram.service.IInspectionService;
import com.tuoheng.miniprogram.utils.CurrentUserUtil; import com.tuoheng.miniprogram.utils.CurrentUserUtil;
import com.tuoheng.miniprogram.vo.*; import com.tuoheng.miniprogram.vo.*;
} }
query.setStartTimeDate(startTime); query.setStartTimeDate(startTime);
query.setEndTimeDate(endTime); query.setEndTimeDate(endTime);
Integer type = user.getRoleId();
Integer type = user.getDataPermission();
if(null == type){ if(null == type){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>(); List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>();
//用户角色判断 1超级管理员 2部门管理员 3普通用户 //用户角色判断 1超级管理员 2部门管理员 3普通用户
if(RoleEnum.SUPER_ADMIN.getCode()==type){
if(DataPermissionEnum.ALL.getCode()==type){
IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query); IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query);
IPageData.getRecords().stream().forEach(x->{ IPageData.getRecords().stream().forEach(x->{
//修改执行人属性 //修改执行人属性


} }
//登录用户角色为部门管理员或普通用户 //登录用户角色为部门管理员或普通用户
if(RoleEnum.ADMIN.getCode()==type || RoleEnum.ORDINARY_USER.getCode()==type){
if(DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()==type || DataPermissionEnum.DEPT.getCode()==type){
// 根据部门id获取此部门id和所有下级部门id封装list集合 // 根据部门id获取此部门id和所有下级部门id封装list集合
List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId()); List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId());
if (StringUtils.isEmpty(deptLists)){ if (StringUtils.isEmpty(deptLists)){

+ 12
- 13
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java View File

package com.tuoheng.miniprogram.service.impl; package com.tuoheng.miniprogram.service.impl;


import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
query.setOrderStartTime(startTime); query.setOrderStartTime(startTime);
query.setOrderEndTime(endTime); query.setOrderEndTime(endTime);
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 //根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户
Integer type = user.getRoleId();
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
Integer type = user.getDataPermission();
if (DataPermissionEnum.ALL.getCode() == type) {


return JsonResult.success(null,"超级管理员代办工单不显示数据"); return JsonResult.success(null,"超级管理员代办工单不显示数据");
} }


//用户角色为2部门管理员 3普通用户 //用户角色为2部门管理员 3普通用户
if (RoleEnum.ADMIN.getCode() == type || RoleEnum.ORDINARY_USER.getCode() == type) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) {
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)) { if (StringUtils.isEmpty(deptId)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
query.setTenantId(tenantId); query.setTenantId(tenantId);
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 //根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户
Integer type = user.getRoleId();
Integer type = user.getDataPermission();
//获取分页数据 //获取分页数据
IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit()); IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit());
IPage<WorkOrderInfoVo> pageData = new Page<>(query.getPage(), query.getLimit()); IPage<WorkOrderInfoVo> pageData = new Page<>(query.getPage(), query.getLimit());
query.setOrderStartTime(startTime); query.setOrderStartTime(startTime);
query.setOrderEndTime(endTime); query.setOrderEndTime(endTime);
//用户角色为2部门管理员 3普通用户 //用户角色为2部门管理员 3普通用户
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
if (DataPermissionEnum.ALL.getCode() == type) {
//超级管理员可查看系统内所有已处理工单 //超级管理员可查看系统内所有已处理工单
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>() IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>()
.eq(WorkOrder::getStatus, 15) .eq(WorkOrder::getStatus, 15)
return JsonResult.success(pageData); return JsonResult.success(pageData);
} }
//用户角色为2部门管理员 3普通用户 //用户角色为2部门管理员 3普通用户
if (RoleEnum.ADMIN.getCode() == user.getRoleId() || RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
//获取部门 //获取部门
String deptId = user.getDeptId(); String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)) { if (StringUtils.isEmpty(deptId)) {
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg());
} }
//用户角色 //用户角色
Integer type = user.getRoleId();
Integer type = user.getDataPermission();
if (null == type) { if (null == type) {
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg());
} }
return null; return null;
} }
//根据用户角色判断 1超级管理员 2部门管理员 3普通用户 //根据用户角色判断 1超级管理员 2部门管理员 3普通用户
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
if (DataPermissionEnum.ALL.getCode() == type) {
//获取当前登录用户(超级管理员)已完成工单列表 //获取当前登录用户(超级管理员)已完成工单列表
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getMark, 1) .eq(WorkOrder::getMark, 1)
} }
} }
//部门管理员 普通用户 //部门管理员 普通用户
if (RoleEnum.ADMIN.getCode() == type || RoleEnum.ORDINARY_USER.getCode() == type) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) {
//获取部门id //获取部门id
if (StringUtils.isEmpty(user.getDeptId())) { if (StringUtils.isEmpty(user.getDeptId())) {
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg());
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg());
} }
//用户角色 //用户角色
Integer type = user.getRoleId();
Integer type = user.getDataPermission();
if (null == type) { if (null == type) {
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg());
} }
return null; return null;
} }
//根据用户角色判断 1超级管理员 2部门管理员 3普通用户 //根据用户角色判断 1超级管理员 2部门管理员 3普通用户
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
if (DataPermissionEnum.ALL.getCode() == type) {
//获取当前登录用户(超级管理员)已完成工单列表 //获取当前登录用户(超级管理员)已完成工单列表
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getMark, 1) .eq(WorkOrder::getMark, 1)
} }
} }
//部门管理员 普通用户 //部门管理员 普通用户
if (RoleEnum.ADMIN.getCode() == type || RoleEnum.ORDINARY_USER.getCode() == type) {
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) {
//获取部门id //获取部门id
if (StringUtils.isEmpty(user.getDeptId())) { if (StringUtils.isEmpty(user.getDeptId())) {
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg());

Loading…
Cancel
Save