use tuoheng_freeway; | use tuoheng_freeway; | ||||
-- 用户表 | -- 用户表 | ||||
rename table th_oauth_user to th_user; | |||||
rename table th_oauth_user to th_user; | |||||
alter table tuoheng_freeway.th_user add data_permission tinyint(1) default 1 not null comment '数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据;' after role_id; |
package com.tuoheng.admin.conver; | |||||
import com.tuoheng.admin.entity.QuestionType; | |||||
import com.tuoheng.admin.vo.QuestionTypeVo; | |||||
import org.mapstruct.Mapper; | |||||
import org.mapstruct.factory.Mappers; | |||||
import java.util.List; | |||||
@Mapper | |||||
public interface QuestionTypeConverMapper { | |||||
QuestionTypeConverMapper INSTANCE = Mappers.getMapper(QuestionTypeConverMapper.class); | |||||
List<QuestionTypeVo> fromUListToVoList(List<QuestionType> questionTypeList); | |||||
} |
INSPECTION_LIST_IS_NULL(1100304, "任务列表为空"), | INSPECTION_LIST_IS_NULL(1100304, "任务列表为空"), | ||||
DEPT_ID_IS_NULL(1100305, "部门id为空"), | DEPT_ID_IS_NULL(1100305, "部门id为空"), | ||||
QUESTION_ID_IS_NULL(1100306, "问题列表为空"), | QUESTION_ID_IS_NULL(1100306, "问题列表为空"), | ||||
TENANT_ID_IS_NULL(1100307, "租户id为空"); | |||||
TENANT_ID_IS_NULL(1100307, "租户id为空"), | |||||
DEPT_LIST_IS_NULL(1100308, "部门列表为空"); | |||||
/** | /** | ||||
* 错误码 | * 错误码 |
import lombok.Data; | import lombok.Data; | ||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
*/ | */ | ||||
private String code; | private String code; | ||||
/** | |||||
* 部门ID | |||||
*/ | |||||
private String deptId; | |||||
/** | /** | ||||
*起始日期 | *起始日期 | ||||
*/ | */ | ||||
*/ | */ | ||||
private Date accidentEndTime; | private Date accidentEndTime; | ||||
/** | |||||
* 部门ID | |||||
*/ | |||||
private String deptId; | |||||
/** | |||||
* 部门集合 | |||||
*/ | |||||
private List<String> deptIdList; | |||||
} | } |
package com.tuoheng.admin.request.accident; | package com.tuoheng.admin.request.accident; | ||||
import com.fasterxml.jackson.annotation.JsonFormat; | |||||
import lombok.Data; | import lombok.Data; | ||||
import org.springframework.format.annotation.DateTimeFormat; | |||||
import java.util.Date; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** |
import com.tuoheng.common.core.common.BaseQuery; | import com.tuoheng.common.core.common.BaseQuery; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* 查询报告分页列表请求实体 | * 查询报告分页列表请求实体 | ||||
* | * | ||||
*/ | */ | ||||
private Integer airportId; | private Integer airportId; | ||||
/** | |||||
* 创建人 | |||||
*/ | |||||
private String createUser; | |||||
/** | /** | ||||
* 租户Id | * 租户Id | ||||
*/ | */ | ||||
private String tenantId; | private String tenantId; | ||||
/** | |||||
* 部门集合 | |||||
*/ | |||||
private List<String> deptIdList; | |||||
} | } |
*/ | */ | ||||
private Integer roleId; | private Integer roleId; | ||||
/** | |||||
* 部门ID | |||||
*/ | |||||
private String deptId; | |||||
/** | /** | ||||
* 部门及子部门Id列表 | * 部门及子部门Id列表 | ||||
*/ | */ |
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.tuoheng.admin.entity.Accident; | import com.tuoheng.admin.entity.Accident; | ||||
import com.tuoheng.admin.entity.AccidentRead; | import com.tuoheng.admin.entity.AccidentRead; | ||||
import com.tuoheng.admin.entity.User; | |||||
import com.tuoheng.admin.enums.AccidentStatusEnum; | import com.tuoheng.admin.enums.AccidentStatusEnum; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
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.mapper.AccidentMapper; | import com.tuoheng.admin.mapper.AccidentMapper; | ||||
import com.tuoheng.admin.mapper.AccidentReadMapper; | import com.tuoheng.admin.mapper.AccidentReadMapper; | ||||
import com.tuoheng.admin.mapper.DeptMapper; | |||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
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; | ||||
@Autowired | @Autowired | ||||
private AccidentReadMapper accidentReadMapper; | private AccidentReadMapper accidentReadMapper; | ||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
/** | /** | ||||
* 告警弹窗通知下发 | * 告警弹窗通知下发 | ||||
*/ | */ | ||||
public JsonResult notice() { | public JsonResult notice() { | ||||
//当前登录用户 | //当前登录用户 | ||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
String userId = CurrentUserUtil.getUserId(); | |||||
if(StringUtils.isEmpty(userId)){ | |||||
throw new ServiceException("当前用户id为空"); | |||||
} | |||||
if(StringUtils.isEmpty(tenantId)){ | |||||
throw new ServiceException("当前用户的租户id为空"); | |||||
} | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | |||||
String userId = user.getId(); | |||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
//查询应急表是否有应急数据 | //查询应急表是否有应急数据 | ||||
List<Accident> accidentList = accidentMapper.selectList(new LambdaQueryWrapper<Accident>() | List<Accident> accidentList = accidentMapper.selectList(new LambdaQueryWrapper<Accident>() | ||||
.eq(Accident::getTenantId, tenantId) | .eq(Accident::getTenantId, tenantId) | ||||
.in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) | |||||
.eq(Accident::getStatus, AccidentStatusEnum.UNTREATED.getCode()) | .eq(Accident::getStatus, AccidentStatusEnum.UNTREATED.getCode()) | ||||
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | .eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | ||||
.eq(Accident::getMark, MarkEnum.VALID.getCode()) | .eq(Accident::getMark, MarkEnum.VALID.getCode()) | ||||
.orderByAsc(Accident::getCreateTime)); | .orderByAsc(Accident::getCreateTime)); | ||||
if(CollectionUtils.isEmpty(accidentList) || accidentList.size() == 0){ | |||||
if(CollectionUtils.isEmpty(accidentList)){ | |||||
return JsonResult.success("巡检任务无应急记录产生"); | return JsonResult.success("巡检任务无应急记录产生"); | ||||
} | } | ||||
//当前用户对应的应急记为未读才出现弹窗 | //当前用户对应的应急记为未读才出现弹窗 | ||||
return JsonResult.success(accidentList); | return JsonResult.success(accidentList); | ||||
} | } | ||||
/** | |||||
* 根据用户自己的数据权限,查询对应部门的数据 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
return deptIdList; | |||||
} | |||||
} | } |
if (StringUtils.isNotEmpty(dept.getName())) { | if (StringUtils.isNotEmpty(dept.getName())) { | ||||
accidentTipsVo.setDeptName(dept.getName()); | accidentTipsVo.setDeptName(dept.getName()); | ||||
} | } | ||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(User::getDeptId, accident.getDeptId()) | |||||
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()) | |||||
.eq(User::getMark, MarkEnum.VALID.getCode())); | |||||
if(ObjectUtils.isEmpty(user)){ | |||||
throw new ServiceException("登录用户对应的部门没有管理员账户"); | |||||
} | |||||
if(StringUtils.isNotEmpty(user.getRealname())){ | |||||
accidentTipsVo.setRealName(user.getRealname()); | |||||
} | |||||
accidentTipsVo.setRealName(""); | |||||
return JsonResult.success(accidentTipsVo); | return JsonResult.success(accidentTipsVo); | ||||
} | } | ||||
} | } |
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
public JsonResult getList(QueryAccidentCardListRequest request) { | public JsonResult getList(QueryAccidentCardListRequest request) { | ||||
// log.info("进入查询事件列表业务"); | // log.info("进入查询事件列表业务"); | ||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
request.setTenantId(tenantId); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | |||||
JsonResult result = this.check(tenantId, request); | JsonResult result = this.check(tenantId, request); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg()); | log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg()); | ||||
return result; | return result; | ||||
} | } | ||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
request.setDeptIdList(deptIdList); | |||||
request.setTenantId(tenantId); | |||||
List<Accident> accidentList = accidentMapper.selectAccidentCardList(request); | List<Accident> accidentList = accidentMapper.selectAccidentCardList(request); | ||||
// 构造返回结果对象 | // 构造返回结果对象 | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
/** | |||||
* 根据用户自己的数据权限,查询对应部门的数据 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
return deptIdList; | |||||
} | |||||
/** | /** | ||||
* @param accidentList | * @param accidentList | ||||
* @return | * @return |
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.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||||
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.conver.AccidentConverMapper; | import com.tuoheng.admin.conver.AccidentConverMapper; | ||||
import com.tuoheng.admin.entity.Accident; | import com.tuoheng.admin.entity.Accident; | ||||
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.AccidentEnum; | |||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
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.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; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.*; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
} | } | ||||
/** | /** | ||||
* 设置列表中每一个的部门名称 | |||||
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||||
* 设置列表中每一个的部门名称 | |||||
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||||
* | * | ||||
* @param accidentList | * @param accidentList | ||||
* @return | * @return | ||||
} | } | ||||
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) | |||||
.eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())); | |||||
.in(User::getDeptId, deptIdList) | |||||
.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; | ||||
} | } | ||||
public JsonResult index(AccidentQuery query) { | public JsonResult index(AccidentQuery query) { | ||||
//校验 | //校验 | ||||
if(query.getLimit() == null && query.getPage() == null){ | |||||
if (query.getLimit() == null && query.getPage() == null) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//当前租户下 | //当前租户下 | ||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
if(tenantId == null){ | |||||
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(),AccidentEnum.TENANT_ID_IS_NULL.getMsg()); | |||||
} | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | |||||
List<String> deptIdList = this.getDeptIdList(user, query.getDeptId()); | |||||
query.setDeptIdList(deptIdList); | |||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
IPage<Accident> page = new Page<>(query.getPage(),query.getLimit()); | |||||
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(),query.getLimit()); | |||||
IPage<Accident> page = new Page<>(query.getPage(), query.getLimit()); | |||||
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(), query.getLimit()); | |||||
//搜索时间 | //搜索时间 | ||||
Date startTime = null; | Date startTime = null; | ||||
Date endTime = null; | Date endTime = null; | ||||
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){ | |||||
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00"); | |||||
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59"); | |||||
if (StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())) { | |||||
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getStartTime() + " 00:00:00"); | |||||
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getEndTime() + " 23:59:59"); | |||||
} | } | ||||
query.setAccidentStartTime(startTime); | query.setAccidentStartTime(startTime); | ||||
query.setAccidentEndTime(endTime); | query.setAccidentEndTime(endTime); | ||||
//获取分页数据 | //获取分页数据 | ||||
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery() | IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery() | ||||
.eq(null != query.getCode(),Accident::getRoadCode,query.getCode()) | |||||
.eq(null != query.getDeptId(),Accident::getDeptId,query.getDeptId()) | |||||
.eq(null != query.getCode(), Accident::getRoadCode, query.getCode()) | |||||
.in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) | |||||
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), | .between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), | ||||
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) | Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) | ||||
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | .eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | ||||
if (StringUtils.isNotEmpty(x.getDeptId())) { | if (StringUtils.isNotEmpty(x.getDeptId())) { | ||||
//根据当前部门id查询对应的部门名称 | //根据当前部门id查询对应的部门名称 | ||||
Dept dept = deptMapper.selectById(x.getDeptId()); | Dept dept = deptMapper.selectById(x.getDeptId()); | ||||
vo.setName(dept.getName() !=null?dept.getName():""); | |||||
vo.setName(dept.getName() != null ? dept.getName() : ""); | |||||
} | } | ||||
return vo; | return vo; | ||||
pageData.setCurrent(accidentPageData.getCurrent()); | pageData.setCurrent(accidentPageData.getCurrent()); | ||||
return JsonResult.success(pageData); | return JsonResult.success(pageData); | ||||
} | |||||
/** | |||||
* 根据用户自己的数据权限,查询对应部门的数据 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user, String deptId) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (StringUtils.isNotEmpty(deptId)) { | |||||
deptIdList.add(deptId); | |||||
return deptIdList; | |||||
} | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
return deptIdList; | |||||
} | } | ||||
} | } |
package com.tuoheng.admin.service.accident.query; | package com.tuoheng.admin.service.accident.query; | ||||
import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||||
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.Accident; | import com.tuoheng.admin.entity.Accident; | ||||
import com.tuoheng.admin.entity.Dept; | import com.tuoheng.admin.entity.Dept; | ||||
import com.tuoheng.admin.enums.AccidentEnum; | |||||
import com.tuoheng.admin.entity.User; | |||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
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.mapper.AccidentMapper; | import com.tuoheng.admin.mapper.AccidentMapper; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//当前租户下 | |||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
if (tenantId == null) { | |||||
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(), AccidentEnum.TENANT_ID_IS_NULL.getMsg()); | |||||
} | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | |||||
List<String> deptIdList = this.getDeptIdList(user, query.getDeptId()); | |||||
query.setDeptIdList(deptIdList); | |||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
IPage<Accident> page = new Page<>(query.getPage(), query.getLimit()); | IPage<Accident> page = new Page<>(query.getPage(), query.getLimit()); | ||||
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(), query.getLimit()); | IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(), query.getLimit()); | ||||
//搜索时间 | //搜索时间 | ||||
//获取分页数据 | //获取分页数据 | ||||
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery() | IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery() | ||||
.eq(Accident::getTenantId, tenantId) | .eq(Accident::getTenantId, tenantId) | ||||
.in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) | |||||
.eq(null != query.getCode(), Accident::getRoadCode, query.getCode()) | .eq(null != query.getCode(), Accident::getRoadCode, query.getCode()) | ||||
.eq(null != query.getDeptId(), Accident::getDeptId, query.getDeptId()) | |||||
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), | .between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), | ||||
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) | Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) | ||||
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | .eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) | ||||
pageData.setCurrent(accidentPageData.getCurrent()); | pageData.setCurrent(accidentPageData.getCurrent()); | ||||
return JsonResult.success(pageData); | return JsonResult.success(pageData); | ||||
} | |||||
/** | |||||
* 根据用户自己的数据权限,查询对应部门的数据 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user, String deptId) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (StringUtils.isNotEmpty(deptId)) { | |||||
deptIdList.add(deptId); | |||||
return deptIdList; | |||||
} | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
return deptIdList; | |||||
} | } | ||||
} | } |
package com.tuoheng.admin.service.accidentread; | package com.tuoheng.admin.service.accidentread; | ||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.tuoheng.admin.entity.AccidentRead; | import com.tuoheng.admin.entity.AccidentRead; | ||||
import com.tuoheng.admin.enums.AccidentEnum; | import com.tuoheng.admin.enums.AccidentEnum; | ||||
import com.tuoheng.admin.mapper.AccidentReadMapper; | import com.tuoheng.admin.mapper.AccidentReadMapper; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
* @Date 2023/3/2 | * @Date 2023/3/2 | ||||
} | } | ||||
//当前用户信息 | //当前用户信息 | ||||
String userId = CurrentUserUtil.getUserId(); | String userId = CurrentUserUtil.getUserId(); | ||||
if(StringUtils.isEmpty(userId)){ | |||||
throw new ServiceException("用户id为空"); | |||||
AccidentRead accidentReadOld = accidentReadMapper.selectOne(new LambdaQueryWrapper<AccidentRead>() | |||||
.eq(AccidentRead::getUserId, userId) | |||||
.eq(AccidentRead::getAccidentId, accidentId) | |||||
.last("limit 1")); | |||||
if (ObjectUtil.isNotEmpty(accidentReadOld)) { | |||||
log.info("应急记录已读已存在,userId={}, accidentId={}", userId, accidentId); | |||||
return JsonResult.success(); | |||||
} | } | ||||
AccidentRead accidentRead = new AccidentRead(); | AccidentRead accidentRead = new AccidentRead(); | ||||
accidentRead.setAccidentId(accidentId); | accidentRead.setAccidentId(accidentId); | ||||
if(result<=0){ | if(result<=0){ | ||||
return JsonResult.error(); | return JsonResult.error(); | ||||
} | } | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
package com.tuoheng.admin.service.dept.add; | package com.tuoheng.admin.service.dept.add; | ||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.tuoheng.admin.constant.SystemConstant; | import com.tuoheng.admin.constant.SystemConstant; | ||||
import com.tuoheng.admin.dto.RoadSectionDto; | import com.tuoheng.admin.dto.RoadSectionDto; | ||||
import com.tuoheng.admin.mapper.UserMapper; | import com.tuoheng.admin.mapper.UserMapper; | ||||
import com.tuoheng.admin.request.dept.AddDeptRequest; | import com.tuoheng.admin.request.dept.AddDeptRequest; | ||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
import com.tuoheng.common.core.exception.ServiceException; | |||||
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.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.transaction.annotation.Transactional; | |||||
import org.springframework.util.CollectionUtils; | import org.springframework.util.CollectionUtils; | ||||
import java.util.*; | import java.util.*; | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@Transactional | |||||
public JsonResult add(AddDeptRequest addDeptRequest) { | public JsonResult add(AddDeptRequest addDeptRequest) { | ||||
log.info("进入添加部门业务接口"); | log.info("进入添加部门业务接口"); | ||||
String userId = CurrentUserUtil.getUserId(); | |||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String userId = user.getId(); | |||||
String tenantId = user.getTenantId(); | |||||
JsonResult result = this.check(tenantId, addDeptRequest); | JsonResult result = this.check(tenantId, addDeptRequest); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
log.info("添加部门业务接口:校验失败:{}", result.getMsg()); | log.info("添加部门业务接口:校验失败:{}", result.getMsg()); | ||||
this.updateSuperAdminUser(userId, tenantId, dept); | this.updateSuperAdminUser(userId, tenantId, dept); | ||||
// 新增公路/路段与部门数据 | // 新增公路/路段与部门数据 | ||||
addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList()); | |||||
this.addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList()); | |||||
log.info("添加部门业务接口:添加部门成功:{}"); | log.info("添加部门业务接口:添加部门成功:{}"); | ||||
return JsonResult.success(dept); | return JsonResult.success(dept); | ||||
} | } | ||||
} | } | ||||
// 新增部门,公路和路段信息不能为空 | |||||
if (CollectionUtils.isEmpty(addDeptRequest.getRoadSectionDtoList())) { | |||||
return JsonResult.error(AddDeptCodeEnum.ROAD_IS_NULL.getCode(), AddDeptCodeEnum.ROAD_IS_NULL.getMsg()); | |||||
} | |||||
List<Section> sectionList; | |||||
List<RoadSectionDto> roadSectionDtoList = addDeptRequest.getRoadSectionDtoList(); | |||||
for (RoadSectionDto roadSectionDto : roadSectionDtoList) { | |||||
sectionList = roadSectionDto.getSectionList(); | |||||
if (CollectionUtils.isEmpty(sectionList)) { | |||||
return JsonResult.error(AddDeptCodeEnum.SECTION_IS_NULL.getCode(), AddDeptCodeEnum.SECTION_IS_NULL.getMsg()); | |||||
} | |||||
} | |||||
if (CollectionUtil.isNotEmpty(addDeptRequest.getRoadSectionDtoList())) { | |||||
List<Section> sectionList; | |||||
List<RoadSectionDto> roadSectionDtoList = addDeptRequest.getRoadSectionDtoList(); | |||||
for (RoadSectionDto roadSectionDto : roadSectionDtoList) { | |||||
sectionList = roadSectionDto.getSectionList(); | |||||
if (CollectionUtils.isEmpty(sectionList)) { | |||||
return JsonResult.error(AddDeptCodeEnum.SECTION_IS_NULL.getCode(), AddDeptCodeEnum.SECTION_IS_NULL.getMsg()); | |||||
} | |||||
} | |||||
} | |||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
* @return 结果 | * @return 结果 | ||||
*/ | */ | ||||
private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) { | private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) { | ||||
if (CollectionUtil.isEmpty(roadSectionDtoList)) { | |||||
log.info("新增部门公路/路段数据为空"); | |||||
return; | |||||
} | |||||
List<RoadInformation> roadInformationList = new ArrayList<>(); | List<RoadInformation> roadInformationList = new ArrayList<>(); | ||||
List<Section> sectionList = new ArrayList<>(); | List<Section> sectionList = new ArrayList<>(); | ||||
RoadInformation road; | RoadInformation road; |
import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||
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.enums.DataPermissionEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | import com.tuoheng.admin.enums.MarkEnum; | ||||
import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum; | import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum; | ||||
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
* @return | * @return | ||||
*/ | */ | ||||
public JsonResult getChildList(String deptId) { | public JsonResult getChildList(String deptId) { | ||||
log.info("进入查询子部门列表业务"); | |||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | |||||
JsonResult result = this.check(tenantId, deptId); | JsonResult result = this.check(tenantId, deptId); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg()); | log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg()); | ||||
return result; | return result; | ||||
} | } | ||||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||||
List<String> deptIdList; | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(deptId); | |||||
} else { | |||||
deptIdList = new ArrayList<>(); | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
if (CollectionUtil.isEmpty(deptIdList)) { | if (CollectionUtil.isEmpty(deptIdList)) { | ||||
log.info("获取部门列表为空"); | log.info("获取部门列表为空"); | ||||
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getMsg()); | |||||
return JsonResult.success(); | |||||
} | } | ||||
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); | List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); | ||||
return JsonResult.success(deptList); | return JsonResult.success(deptList); |
import com.tuoheng.admin.constant.SystemConstant; | import com.tuoheng.admin.constant.SystemConstant; | ||||
import com.tuoheng.admin.conver.DeptConverMapper; | import com.tuoheng.admin.conver.DeptConverMapper; | ||||
import com.tuoheng.admin.entity.Dept; | import com.tuoheng.admin.entity.Dept; | ||||
import com.tuoheng.admin.entity.RoadInformation; | |||||
import com.tuoheng.admin.entity.User; | import com.tuoheng.admin.entity.User; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.code.dept.QueryDeptTreeListCodeEnum; | import com.tuoheng.admin.enums.code.dept.QueryDeptTreeListCodeEnum; | ||||
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
public JsonResult getListTree(String deptId) { | public JsonResult getListTree(String deptId) { | ||||
List<DeptTreeVo> deptTreeVoList = new ArrayList<>(); | List<DeptTreeVo> deptTreeVoList = new ArrayList<>(); | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
// 查询当前部门下所有有效的部门数据 | |||||
List<String> deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); | |||||
// 找出当前部门 | |||||
Dept currentDept = deptList.stream() | |||||
.filter(item -> deptId.equals(item.getId())) | |||||
.findAny() | |||||
.orElse(null); | |||||
deptList.removeIf(item -> (item.getPid().equals(currentDept.getPid()) && !item.getId().equals(deptId))); | |||||
List<String> deptIdList; | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
deptIdList = null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else { | |||||
deptIdList = new ArrayList<>(); | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
// List<Dept> deptList = deptMapper.selectListByIdList(user.getTenantId(), deptIdList); | |||||
// // 找出当前部门 | |||||
// Dept currentDept = deptList.stream() | |||||
// .filter(item -> deptId.equals(item.getId())) | |||||
// .findAny() | |||||
// .orElse(null); | |||||
// deptList.removeIf(item -> (item.getPid().equals(currentDept.getPid()) && !item.getId().equals(deptId))); | |||||
List<Dept> deptList = deptMapper.selectList(new LambdaQueryWrapper<Dept>() | |||||
.eq(Dept::getTenantId, user.getTenantId()) | |||||
.in(CollectionUtil.isNotEmpty(deptIdList), Dept::getId, deptIdList) | |||||
.eq(Dept::getMark, MarkEnum.VALID.getCode()) | |||||
.orderByAsc(Dept::getCreateTime)); | |||||
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.error(QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getMsg()); | ||||
} | } | ||||
Dept currentDept = deptList.get(0); | |||||
List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList); | List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList); | ||||
Map<String, DeptTreeVo> deptVoMap = new HashMap<>(); | Map<String, DeptTreeVo> deptVoMap = new HashMap<>(); | ||||
for (DeptTreeVo deptTreeVo : deptTreeVoListTmp) { | for (DeptTreeVo deptTreeVo : deptTreeVoListTmp) { |
import com.tuoheng.admin.constant.SystemConstant; | import com.tuoheng.admin.constant.SystemConstant; | ||||
import com.tuoheng.admin.dto.RoadSectionDto; | import com.tuoheng.admin.dto.RoadSectionDto; | ||||
import com.tuoheng.admin.entity.*; | import com.tuoheng.admin.entity.*; | ||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.code.dept.EditDeptCodeEnum; | import com.tuoheng.admin.enums.code.dept.EditDeptCodeEnum; | ||||
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import com.tuoheng.admin.mapper.RoadDeptMapper; | import com.tuoheng.admin.mapper.RoadDeptMapper; | ||||
} | } | ||||
} | } | ||||
// 修改部门,公路和路段信息不能为空 | |||||
if (CollectionUtil.isEmpty(newEditDeptRequest.getRoadSectionDtoList())) { | |||||
return JsonResult.error(EditDeptCodeEnum.ROAD_IS_NULL.getCode(), EditDeptCodeEnum.ROAD_IS_NULL.getMsg()); | |||||
} | |||||
List<Section> sectionList; | |||||
List<RoadSectionDto> roadSectionDtoList = newEditDeptRequest.getRoadSectionDtoList(); | |||||
for (RoadSectionDto roadSectionDto : roadSectionDtoList) { | |||||
sectionList = roadSectionDto.getSectionList(); | |||||
if (CollectionUtil.isEmpty(sectionList)) { | |||||
return JsonResult.error(EditDeptCodeEnum.SECTION_IS_NULL.getCode(), EditDeptCodeEnum.SECTION_IS_NULL.getMsg()); | |||||
if (CollectionUtil.isNotEmpty(newEditDeptRequest.getRoadSectionDtoList())) { | |||||
List<Section> sectionList; | |||||
List<RoadSectionDto> roadSectionDtoList = newEditDeptRequest.getRoadSectionDtoList(); | |||||
for (RoadSectionDto roadSectionDto : roadSectionDtoList) { | |||||
sectionList = roadSectionDto.getSectionList(); | |||||
if (CollectionUtil.isEmpty(sectionList)) { | |||||
return JsonResult.error(EditDeptCodeEnum.SECTION_IS_NULL.getCode(), EditDeptCodeEnum.SECTION_IS_NULL.getMsg()); | |||||
} | |||||
} | } | ||||
} | } | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
// Collection<String> union = org.apache.commons.collections4.CollectionUtils.union(oldRoadIdList, newRoadIdList); | // Collection<String> union = org.apache.commons.collections4.CollectionUtils.union(oldRoadIdList, newRoadIdList); | ||||
// 差集:新增公路 | // 差集:新增公路 | ||||
Collection<String> addRoadIdList; | |||||
Collection<String> addRoadIdList = null; | |||||
if (CollectionUtil.isNotEmpty(oldRoadIdList)) { | if (CollectionUtil.isNotEmpty(oldRoadIdList)) { | ||||
addRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(newRoadIdList, oldRoadIdList); | |||||
if (CollectionUtil.isNotEmpty(newRoadIdList)) { | |||||
addRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(newRoadIdList, oldRoadIdList); | |||||
} | |||||
} else { | } else { | ||||
addRoadIdList = newRoadIdList; | addRoadIdList = newRoadIdList; | ||||
} | } | ||||
// 差集:删除公路 | // 差集:删除公路 | ||||
if (CollectionUtil.isNotEmpty(oldRoadIdList)) { | if (CollectionUtil.isNotEmpty(oldRoadIdList)) { | ||||
Collection<String> subRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(oldRoadIdList, newRoadIdList); | |||||
Collection<String> subRoadIdList; | |||||
if (CollectionUtil.isNotEmpty(newRoadIdList)) { | |||||
subRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(oldRoadIdList, newRoadIdList); | |||||
} else { | |||||
subRoadIdList = oldRoadIdList; | |||||
} | |||||
Map<String, Long> oldRoadIdMap = oldRoadIdList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting())); | Map<String, Long> oldRoadIdMap = oldRoadIdList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting())); | ||||
Map<String, Long> subRoadIdMap = subRoadIdList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting())); | Map<String, Long> subRoadIdMap = subRoadIdList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting())); | ||||
if (CollectionUtil.isNotEmpty(subRoadIdList)) { | if (CollectionUtil.isNotEmpty(subRoadIdList)) { | ||||
List<Dept> deptList = new ArrayList<>(); | List<Dept> deptList = new ArrayList<>(); | ||||
deptList.add(parentDept); | deptList.add(parentDept); | ||||
queryChildDeptList(deptList, parentDept); | |||||
this.queryChildDeptList(tenantId, deptList, parentDept); | |||||
List<String> deptIdList = deptList.stream().map(p -> p.getId()).collect(Collectors.toList());; | List<String> deptIdList = deptList.stream().map(p -> p.getId()).collect(Collectors.toList());; | ||||
for (String roadId : roadIdList) { | for (String roadId : roadIdList) { | ||||
List<RoadSectionDto> newRoadSectionList = newEditDeptRequest.getRoadSectionDtoList(); | List<RoadSectionDto> newRoadSectionList = newEditDeptRequest.getRoadSectionDtoList(); | ||||
List<Section> newSectionList = new ArrayList<>(); | List<Section> newSectionList = new ArrayList<>(); | ||||
for (RoadSectionDto roadSectionDto : newRoadSectionList) { | |||||
newSectionList.addAll(roadSectionDto.getSectionList()); | |||||
if (CollectionUtil.isNotEmpty(newRoadSectionList)) { | |||||
for (RoadSectionDto roadSectionDto : newRoadSectionList) { | |||||
newSectionList.addAll(roadSectionDto.getSectionList()); | |||||
} | |||||
} | } | ||||
List<String> newSectionIdList = newSectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | List<String> newSectionIdList = newSectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | ||||
* @param deptList | * @param deptList | ||||
* @param parentDept | * @param parentDept | ||||
*/ | */ | ||||
private void queryChildDeptList(List<Dept> deptList, Dept parentDept) { | |||||
private void queryChildDeptList(String tenantId, List<Dept> deptList, Dept parentDept) { | |||||
List<Dept> childDeptlist = deptMapper.selectList(new LambdaQueryWrapper<Dept>() | List<Dept> childDeptlist = deptMapper.selectList(new LambdaQueryWrapper<Dept>() | ||||
.eq(Dept::getTenantId, 0) | |||||
.eq(Dept::getTenantId, tenantId) | |||||
.eq(Dept::getPid, parentDept.getId()) | .eq(Dept::getPid, parentDept.getId()) | ||||
.eq(Dept::getMark, 1)); | |||||
.eq(Dept::getMark, MarkEnum.VALID.getCode())); | |||||
for (Dept dept : childDeptlist) { | for (Dept dept : childDeptlist) { | ||||
queryChildDeptList(deptList, dept); | |||||
queryChildDeptList(tenantId, deptList, dept); | |||||
} | } | ||||
deptList.addAll(childDeptlist); | deptList.addAll(childDeptlist); | ||||
} | } |
public JsonResult getPageList(QueryInspectionPageListRequest request) { | public JsonResult getPageList(QueryInspectionPageListRequest request) { | ||||
// log.info("进入查询巡检任务分页列表业务"); | // log.info("进入查询巡检任务分页列表业务"); | ||||
String userId = CurrentUserUtil.getUserId(); | |||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String userId = user.getId(); | |||||
String tenantId = user.getTenantId(); | |||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
// 不查应急任务 | // 不查应急任务 | ||||
return result; | return result; | ||||
} | } | ||||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||||
.eq(User::getTenantId, tenantId) | |||||
.eq(User::getId, userId) | |||||
.eq(User::getMark, 1)); | |||||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | ||||
.eq(Dept::getTenantId, tenantId) | .eq(Dept::getTenantId, tenantId) | ||||
.eq(Dept::getId, user.getDeptId()) | .eq(Dept::getId, user.getDeptId()) |
public JsonResult getList() { | public JsonResult getList() { | ||||
//获取登录用户信息 | //获取登录用户信息 | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
if (ObjectUtil.isNull(user)) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(), ListByDeptUserTypeEnum.USER_IS_NULL.getMsg()); | |||||
} | |||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
if (StringUtils.isEmpty(tenantId)) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//判断用户角色 1超级管理员 2部门管理员 3普通用户 | //判断用户角色 1超级管理员 2部门管理员 3普通用户 | ||||
if (null == user.getDataPermission()) { | if (null == user.getDataPermission()) { | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
.orderByDesc(Inspection::getCreateTime) | .orderByDesc(Inspection::getCreateTime) | ||||
.last("limit 5")); | .last("limit 5")); | ||||
if (CollectionUtil.isEmpty(inspectionList)) { | if (CollectionUtil.isEmpty(inspectionList)) { | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
return JsonResult.success(); | |||||
} | } | ||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | if (DataPermissionEnum.ALL.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | ||||
Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList); | Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList); | ||||
.orderByDesc(Inspection::getCreateTime) | .orderByDesc(Inspection::getCreateTime) | ||||
.last("limit 5")); | .last("limit 5")); | ||||
if (CollectionUtil.isEmpty(inspectionList)) { | if (CollectionUtil.isEmpty(inspectionList)) { | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
return JsonResult.success(); | |||||
} | } | ||||
Stream<InspectionListVo> inspectionListVoStream = this.getInspectionListVoStream(inspectionList); | Stream<InspectionListVo> inspectionListVoStream = this.getInspectionListVoStream(inspectionList); | ||||
return JsonResult.success(inspectionListVoStream); | return JsonResult.success(inspectionListVoStream); |
package com.tuoheng.admin.service.inspectionfile; | package com.tuoheng.admin.service.inspectionfile; | ||||
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.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.tuoheng.admin.entity.User; | import com.tuoheng.admin.entity.User; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | import com.tuoheng.admin.enums.DataPermissionEnum; | ||||
import com.tuoheng.admin.enums.SectionEnum; | import com.tuoheng.admin.enums.SectionEnum; | ||||
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; | |||||
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.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.admin.service.inspectionfile.processing.InspectionFileProcessingService; | import com.tuoheng.admin.service.inspectionfile.processing.InspectionFileProcessingService; | ||||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFileDistributionListService; | |||||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListByInspectionIdService; | |||||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListByWorkOrderIdService; | |||||
import com.tuoheng.admin.service.inspectionfile.query.QueryInspectionFilePageListService; | |||||
import com.tuoheng.admin.service.inspectionfile.query.*; | |||||
import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | import com.tuoheng.admin.service.inspectionfile.update.UpdateInspectionFileQuestionTypeService; | ||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | |||||
import com.tuoheng.admin.vo.inspection.InspectionFileVo; | import com.tuoheng.admin.vo.inspection.InspectionFileVo; | ||||
import com.tuoheng.common.core.config.common.CommonConfig; | import com.tuoheng.common.core.config.common.CommonConfig; | ||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||||
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; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
@Autowired | @Autowired | ||||
private UpdateInspectionFileQuestionTypeService updateInspectionFileQuestionTypeService; | private UpdateInspectionFileQuestionTypeService updateInspectionFileQuestionTypeService; | ||||
@Autowired | |||||
private QueryInspectionFileListByDeptUserTypeService queryInspectionFileListByDeptUserTypeService; | |||||
/** | /** | ||||
* 问题类型和任务名称 | * 问题类型和任务名称 | ||||
* | * | ||||
@Override | @Override | ||||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | public JsonResult getListByDeptUserType(InspectionFileQuery query) { | ||||
User user = CurrentUserUtil.getUserInfo(); | |||||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||||
if (null == user.getDataPermission()) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
List<ListByDeptUserTypeVo> list = new ArrayList<>(); | |||||
ListByDeptUserTypeVo vo = new ListByDeptUserTypeVo(); | |||||
ListByDeptUserTypeVo vo1 = new ListByDeptUserTypeVo(); | |||||
ListByDeptUserTypeVo vo2 = new ListByDeptUserTypeVo(); | |||||
ListByDeptUserTypeVo vo3 = new ListByDeptUserTypeVo(); | |||||
ListByDeptUserTypeVo vo4 = new ListByDeptUserTypeVo(); | |||||
ListByDeptUserTypeVo vo5 = new ListByDeptUserTypeVo(); | |||||
//坑槽 积水 裂缝 | |||||
//0纵向裂缝 | |||||
Integer longitudinalCrackNum = 0; | |||||
//4坑槽 | |||||
Integer pitGrooveNum = 0; | |||||
//6积水 | |||||
Integer ponDingNum = 0; | |||||
//1横向裂缝 | |||||
Integer abeamCrackNum = 0; | |||||
//3网状裂纹 | |||||
Integer reticularCrackNum = 0; | |||||
//5块状裂纹 | |||||
Integer massiveCrack = 0; | |||||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
//直接查问题列表 | |||||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||||
.eq(InspectionFile::getMark, 1) | |||||
.eq(InspectionFile::getTenantId, user.getTenantId()) | |||||
.in(InspectionFile::getStatus, 20, 25)); | |||||
//根据状态类型分类 | |||||
if (null == inspectionFileList) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||||
} | |||||
for (InspectionFile inspectionFile : inspectionFileList) { | |||||
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||||
} | |||||
//查找问题类型 | |||||
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | |||||
.eq(QuestionType::getMark, 1) | |||||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | |||||
if (ObjectUtil.isNull(questionType)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
Integer name = questionType.getName(); | |||||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
//1横向裂缝 | |||||
abeamCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||||
//3网状裂纹 | |||||
reticularCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||||
//4坑槽 | |||||
pitGrooveNum += 1; | |||||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||||
//5块状裂纹 | |||||
massiveCrack += 1; | |||||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||||
//6积水 | |||||
ponDingNum += 1; | |||||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||||
//0纵向裂缝 | |||||
longitudinalCrackNum += 1; | |||||
} | |||||
} | |||||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||||
vo.setNum(abeamCrackNum); | |||||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||||
vo1.setNum(reticularCrackNum); | |||||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||||
vo2.setNum(pitGrooveNum); | |||||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||||
vo3.setNum(massiveCrack); | |||||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||||
vo4.setNum(ponDingNum); | |||||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||||
vo5.setNum(longitudinalCrackNum); | |||||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||||
} | |||||
//若角色为部门管理员或普通用户 | |||||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
//获取用户对应的部门 | |||||
String deptId = user.getDeptId(); | |||||
if (StringUtils.isEmpty(deptId)) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//根据部门id获取部门id列表 | |||||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||||
if (CollectionUtil.isEmpty(deptIdList)) { | |||||
return null; | |||||
} | |||||
//根据部门id列表查多条任务 | |||||
List<Inspection> inspectionList = inspectionMapper.selectListByDeptIdList(deptIdList); | |||||
if (null == inspectionList) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_LIST_IS_NULL.getMsg()); | |||||
} | |||||
List<String> inspectionIdList = inspectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||||
//根据任务id列表查找多条问题 | |||||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectListByInspectIdList(inspectionIdList); | |||||
//根据状态类型分类 | |||||
if (null == inspectionFileList) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getCode(), ListByDeptUserTypeEnum.INSPECTION_TYPE_LIST_IS_NULL.getMsg()); | |||||
} | |||||
for (InspectionFile inspectionFile : inspectionFileList) { | |||||
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) { | |||||
JsonResult.error(ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getCode(), ListByDeptUserTypeEnum.QUESTION_ID_IS_NULL.getMsg()); | |||||
} | |||||
//查找问题类型 | |||||
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery() | |||||
.eq(QuestionType::getMark, 1) | |||||
.eq(QuestionType::getCode, inspectionFile.getQuestionCode())); | |||||
if (ObjectUtil.isNull(questionType)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
Integer name = questionType.getName(); | |||||
if (name == QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()) { | |||||
//1横向裂缝 | |||||
abeamCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()) { | |||||
//3网状裂纹 | |||||
reticularCrackNum += 1; | |||||
} else if (name == QuestionTypeEnum.PIT_GROOVE_NAME.getCode()) { | |||||
//4坑槽 | |||||
pitGrooveNum += 1; | |||||
} else if (name == QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()) { | |||||
//5块状裂纹 | |||||
massiveCrack += 1; | |||||
} else if (name == QuestionTypeEnum.PON_DING_NAME.getCode()) { | |||||
//6积水 | |||||
ponDingNum += 1; | |||||
} else if (name == QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()) { | |||||
//0纵向裂缝 | |||||
longitudinalCrackNum += 1; | |||||
} | |||||
} | |||||
vo.setType(QuestionTypeEnum.ABEAM_CRACK_NAME.getCode()); | |||||
vo.setNum(abeamCrackNum); | |||||
vo1.setType(QuestionTypeEnum.RETICULAR_CRACK_NAME.getCode()); | |||||
vo1.setNum(reticularCrackNum); | |||||
vo2.setType(QuestionTypeEnum.PIT_GROOVE_NAME.getCode()); | |||||
vo2.setNum(pitGrooveNum); | |||||
vo3.setType(QuestionTypeEnum.MASSIVE_CRACK_NAME.getCode()); | |||||
vo3.setNum(massiveCrack); | |||||
vo4.setType(QuestionTypeEnum.PON_DING_NAME.getCode()); | |||||
vo4.setNum(ponDingNum); | |||||
vo5.setType(QuestionTypeEnum.LONGITUDINAL_CRACK_NAME.getCode()); | |||||
vo5.setNum(longitudinalCrackNum); | |||||
Collections.addAll(list, vo, vo1, vo2, vo3, vo4, vo5); | |||||
} | |||||
return JsonResult.success(list); | |||||
return queryInspectionFileListByDeptUserTypeService.getListByDeptUserType(query); | |||||
} | } | ||||
/** | /** |
package com.tuoheng.admin.service.inspectionfile.query; | |||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.tuoheng.admin.conver.QuestionTypeConverMapper; | |||||
import com.tuoheng.admin.entity.Inspection; | |||||
import com.tuoheng.admin.entity.InspectionFile; | |||||
import com.tuoheng.admin.entity.QuestionType; | |||||
import com.tuoheng.admin.entity.User; | |||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | |||||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||||
import com.tuoheng.admin.mapper.DeptMapper; | |||||
import com.tuoheng.admin.mapper.InspectionFileMapper; | |||||
import com.tuoheng.admin.mapper.InspectionMapper; | |||||
import com.tuoheng.admin.mapper.QuestionTypeMapper; | |||||
import com.tuoheng.admin.query.InspectionFileQuery; | |||||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||||
import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | |||||
import com.tuoheng.admin.vo.QuestionTypeVo; | |||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||||
import com.tuoheng.common.core.exception.ServiceException; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 根据任务ID查询巡检任务问题分页列表业务层处理 | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-12-05 | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
public class QueryInspectionFileListByDeptUserTypeService { | |||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
@Autowired | |||||
private InspectionMapper inspectionMapper; | |||||
@Autowired | |||||
private InspectionFileMapper inspectionFileMapper; | |||||
@Autowired | |||||
private QuestionTypeMapper questionTypeMapper; | |||||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||||
if (null == user.getDataPermission()) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
List<QuestionType> questionTypeList = questionTypeMapper.selectList(new LambdaQueryWrapper<QuestionType>() | |||||
.eq(QuestionType::getMark, MarkEnum.VALID.getCode())); | |||||
if (CollectionUtil.isEmpty(questionTypeList)) { | |||||
log.info("问题类型为空"); | |||||
return JsonResult.success(); | |||||
} | |||||
List<InspectionFile> inspectionFileList = null; | |||||
//若角色为超级管理员,查看状态为已生成工单和和问题已处理 | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
//直接查问题列表 | |||||
inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||||
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode()) | |||||
.eq(InspectionFile::getTenantId, user.getTenantId()) | |||||
.in(InspectionFile::getStatus, 15, 20, 25)); | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
//若角色为部门管理员或普通用户 | |||||
//获取用户对应的部门 | |||||
String deptId = user.getDeptId(); | |||||
if (StringUtils.isEmpty(deptId)) { | |||||
log.info("部门id为空"); | |||||
return JsonResult.success(); | |||||
} | |||||
//根据部门id获取部门id列表 | |||||
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); | |||||
if (CollectionUtil.isEmpty(deptIdList)) { | |||||
log.info("部门列表为空"); | |||||
return JsonResult.success(); | |||||
} | |||||
//根据部门id列表查多条任务 | |||||
List<Inspection> inspectionList = inspectionMapper.selectListByDeptIdList(deptIdList); | |||||
if (CollectionUtil.isEmpty(inspectionList)) { | |||||
log.info("任务列表为空"); | |||||
return JsonResult.success(); | |||||
} | |||||
List<String> inspectionIdList = inspectionList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||||
//根据任务id列表查找多条问题 | |||||
inspectionFileList = inspectionFileMapper.selectListByInspectIdList(inspectionIdList); | |||||
} | |||||
if (CollectionUtil.isEmpty(inspectionFileList)) { | |||||
log.info("问题列表为空"); | |||||
return JsonResult.success(); | |||||
} | |||||
List<QuestionTypeVo> questionTypeVoList = QuestionTypeConverMapper.INSTANCE.fromUListToVoList(questionTypeList); | |||||
for (QuestionTypeVo questionTypeVo : questionTypeVoList) { | |||||
if (ObjectUtil.isEmpty(questionTypeVo.getNum())) { | |||||
questionTypeVo.setNum(0); | |||||
} | |||||
for (InspectionFile inspectionFile : inspectionFileList) { | |||||
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) { | |||||
log.info("问题类型为空"); | |||||
continue; | |||||
} | |||||
if (questionTypeVo.getCode().equals(inspectionFile.getQuestionCode())) { | |||||
questionTypeVo.setNum(questionTypeVo.getNum() + 1); | |||||
} | |||||
} | |||||
} | |||||
return JsonResult.success(questionTypeVoList); | |||||
} | |||||
} |
import com.tuoheng.admin.entity.InspectionFileHandle; | import com.tuoheng.admin.entity.InspectionFileHandle; | ||||
import com.tuoheng.admin.entity.Report; | import com.tuoheng.admin.entity.Report; | ||||
import com.tuoheng.admin.entity.User; | import com.tuoheng.admin.entity.User; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | import com.tuoheng.admin.enums.MarkEnum; | ||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.request.report.QueryReportPageListRequest; | import com.tuoheng.admin.request.report.QueryReportPageListRequest; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
public JsonResult getPageList(QueryReportPageListRequest request) { | public JsonResult getPageList(QueryReportPageListRequest request) { | ||||
// log.info("进入查询报告分页列表业务"); | // log.info("进入查询报告分页列表业务"); | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
String userId = user.getId(); | |||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
request.setTenantId(tenantId); | |||||
JsonResult result = this.check(tenantId, request); | JsonResult result = this.check(tenantId, request); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
return result; | return result; | ||||
} | } | ||||
// 设置分页参数 | |||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
request.setDeptIdList(deptIdList); | |||||
request.setTenantId(tenantId); | |||||
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); | IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); | ||||
// 用户只能查看自己生成的报告 | |||||
request.setCreateUser(userId); | |||||
// 查询结果 | |||||
IPage<Report> pageData = reportMapper.selectPageList(page, request); | IPage<Report> pageData = reportMapper.selectPageList(page, request); | ||||
// 构造返回结果对象 | // 构造返回结果对象 | ||||
*/ | */ | ||||
private JsonResult check(String tenantId, QueryReportPageListRequest request) { | private JsonResult check(String tenantId, QueryReportPageListRequest request) { | ||||
// 判断部门id是否为空 | // 判断部门id是否为空 | ||||
// if (StringUtils.isEmpty(queryInspectionRequest.getDeptId())) { | |||||
// return JsonResult.error(QueryInspectionPageListCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryInspectionPageListCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
// } | |||||
// | |||||
// // 判断部门是否存在 | |||||
// Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||||
// .eq(Dept::getTenantId, tenantId) | |||||
// .eq(Dept::getId, queryInspectionRequest.getDeptId()) | |||||
// .eq(Dept::getMark, 1)); | |||||
// if (null == dept) { | |||||
// return JsonResult.error(QueryInspectionPageListCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryInspectionPageListCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
// } | |||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
/** | |||||
* 根据用户自己的数据权限,查询对应部门的数据 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | |||||
return deptIdList; | |||||
} | |||||
/** | /** | ||||
* 构造返回的数据列表 | * 构造返回的数据列表 | ||||
* | * |
package com.tuoheng.admin.service.role; | package com.tuoheng.admin.service.role; | ||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import cn.hutool.core.convert.Convert; | import cn.hutool.core.convert.Convert; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
import com.tuoheng.admin.dto.RoleMenuDto; | import com.tuoheng.admin.dto.RoleMenuDto; | ||||
import com.tuoheng.admin.dto.RoleMenuPermissionDto; | import com.tuoheng.admin.dto.RoleMenuPermissionDto; | ||||
import com.tuoheng.admin.entity.*; | import com.tuoheng.admin.entity.*; | ||||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | import com.tuoheng.admin.enums.MarkEnum; | ||||
import com.tuoheng.admin.enums.code.role.RoleDeleteEnum; | import com.tuoheng.admin.enums.code.role.RoleDeleteEnum; | ||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
* @Date 2022/12/16 | * @Date 2022/12/16 | ||||
@Service | @Service | ||||
public class RoleServiceImpl implements IRoleService { | public class RoleServiceImpl implements IRoleService { | ||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
@Autowired | @Autowired | ||||
private RoleMapper roleMapper; | private RoleMapper roleMapper; | ||||
IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit()); | IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit()); | ||||
// 查询条件 | // 查询条件 | ||||
QueryWrapper<Role> queryWrapper = new QueryWrapper<>(); | QueryWrapper<Role> queryWrapper = new QueryWrapper<>(); | ||||
// 租户ID | |||||
// queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||||
// 角色名称 | // 角色名称 | ||||
if (!StringUtils.isEmpty(roleQuery.getRoleName())) { | |||||
if (StringUtils.isNotEmpty(roleQuery.getRoleName())) { | |||||
queryWrapper.like("role_name", roleQuery.getRoleName()); | queryWrapper.like("role_name", roleQuery.getRoleName()); | ||||
} | } | ||||
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||||
queryWrapper.eq("mark", MarkEnum.VALID.getCode()); | queryWrapper.eq("mark", MarkEnum.VALID.getCode()); | ||||
//queryWrapper.orderByAsc("sort"); | |||||
queryWrapper.orderByAsc("create_time"); | queryWrapper.orderByAsc("create_time"); | ||||
//queryWrapper.ne("id", "1"); | |||||
// 查询分页数据 | // 查询分页数据 | ||||
IPage<Role> pageData = roleMapper.selectPage(page, queryWrapper); | IPage<Role> pageData = roleMapper.selectPage(page, queryWrapper); | ||||
pageData.convert(x -> { | pageData.convert(x -> { | ||||
RoleListVo roleListVo = Convert.convert(RoleListVo.class, x); | RoleListVo roleListVo = Convert.convert(RoleListVo.class, x); | ||||
// TODO... | |||||
return roleListVo; | return roleListVo; | ||||
}); | }); | ||||
return JsonResult.success(pageData); | return JsonResult.success(pageData); | ||||
@Override | @Override | ||||
public JsonResult getRoleLists() { | public JsonResult getRoleLists() { | ||||
QueryWrapper<Role> queryWrapper = new QueryWrapper<>(); | QueryWrapper<Role> queryWrapper = new QueryWrapper<>(); | ||||
// 租户ID | |||||
//不展示超管 | |||||
queryWrapper.ne("code", "001"); | |||||
// queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||||
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||||
queryWrapper.eq("status", 1); | queryWrapper.eq("status", 1); | ||||
queryWrapper.eq("mark", MarkEnum.VALID.getCode()); | queryWrapper.eq("mark", MarkEnum.VALID.getCode()); | ||||
queryWrapper.orderByAsc("create_time"); | queryWrapper.orderByAsc("create_time"); | ||||
List<Role> rolesLists = roleMapper.selectList(queryWrapper); | List<Role> rolesLists = roleMapper.selectList(queryWrapper); | ||||
return JsonResult.success(rolesLists); | return JsonResult.success(rolesLists); | ||||
} | } | ||||
import com.tuoheng.admin.utils.CurrentUserUtil; | import com.tuoheng.admin.utils.CurrentUserUtil; | ||||
import com.tuoheng.admin.vo.user.UserPageListVo; | import com.tuoheng.admin.vo.user.UserPageListVo; | ||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
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.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.function.Function; | import java.util.function.Function; | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
List<String> deptIdList = this.getDeptIdList(user, request.getDeptId()); | |||||
request.setDeptIdList(deptIdList); | request.setDeptIdList(deptIdList); | ||||
// 查询分页数据 | // 查询分页数据 | ||||
* @return | * @return | ||||
*/ | */ | ||||
private JsonResult check(User user) { | private JsonResult check(User user) { | ||||
if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
return JsonResult.error(QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getCode(), QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getMsg()); | |||||
} | |||||
// if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
// return JsonResult.error(QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getCode(), QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getMsg()); | |||||
// } | |||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
* @param user | * @param user | ||||
* @return | * @return | ||||
*/ | */ | ||||
private List<String> getDeptIdList(User user) { | |||||
List<String> deptIdList; | |||||
private List<String> getDeptIdList(User user, String deptId) { | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (StringUtils.isNotEmpty(deptId)) { | |||||
deptIdList.add(deptId); | |||||
return deptIdList; | |||||
} | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | ||||
return null; | return null; | ||||
} else { | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | ||||
return deptIdList; | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList.add(user.getDeptId()); | |||||
} | } | ||||
return deptIdList; | |||||
} | } | ||||
/** | /** |
* @return | * @return | ||||
*/ | */ | ||||
private JsonResult checkPermission(User user, List<Inspection> inspectionList) { | private JsonResult checkPermission(User user, List<Inspection> inspectionList) { | ||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return JsonResult.success(user); | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
for (Inspection inspection : inspectionList) { | |||||
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.success(user); | |||||
} 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(); | |||||
// if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
// return JsonResult.success(user); | |||||
// } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
// for (Inspection inspection : inspectionList) { | |||||
// 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.success(user); | |||||
// } 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.success(); | |||||
} | } | ||||
/** | /** |
return result; | return result; | ||||
} | } | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
if (DataPermissionEnum.ALL.getCode() != user.getDataPermission()) { | |||||
request.setUserDeptId(user.getDeptId()); | |||||
} | |||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
// 获取部门Id的查询范围 | // 获取部门Id的查询范围 | ||||
/** | /** | ||||
* 获取部门Id的查询范围 | * 获取部门Id的查询范围 | ||||
* 1)、deptId:如果传了值,查该部门的任务 | |||||
* 2)、deptId:如果没有传值 | |||||
* 2.1)、管理员:可查全部确认问题 | |||||
* 2.2)、管理员/普通用户:本部门及子部门创建的工单 | |||||
* | * | ||||
* @param deptId | |||||
* @return | * @return | ||||
*/ | */ | ||||
private List<String> getDeptIdList(User user, String deptId) { | private List<String> getDeptIdList(User user, String deptId) { | ||||
List<String> deptIdList = new ArrayList<>(); | List<String> deptIdList = new ArrayList<>(); | ||||
if (!StringUtils.isEmpty(deptId)) { | |||||
if (StringUtils.isNotEmpty(deptId)) { | |||||
deptIdList.add(deptId); | deptIdList.add(deptId); | ||||
return deptIdList; | return deptIdList; | ||||
} | } | ||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | ||||
return null; | return null; | ||||
} else { | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | ||||
return deptIdList; | return deptIdList; | ||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = new ArrayList<>(); | |||||
deptIdList.add(user.getDeptId()); | |||||
return deptIdList; | |||||
} else { | |||||
return null; | |||||
} | } | ||||
} | } | ||||
package com.tuoheng.admin.vo; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import com.tuoheng.common.core.common.BaseEntity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.experimental.Accessors; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/29 | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = true) | |||||
@Accessors(chain = true) | |||||
public class QuestionTypeVo extends BaseEntity { | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* 编号 | |||||
*/ | |||||
private String code; | |||||
/** | |||||
* 类型名称:1坑槽 2积水 3裂纹 | |||||
*/ | |||||
private Integer name; | |||||
/** | |||||
* 巡检内容 | |||||
*/ | |||||
private String content; | |||||
/** | |||||
* 排序 | |||||
*/ | |||||
private Integer sort; | |||||
/** | |||||
* 事故问题:0:否;1:是 | |||||
*/ | |||||
private Integer accidentQuestion; | |||||
/** | |||||
* 是否展示问题 0:否;1是 | |||||
*/ | |||||
private Integer isShow; | |||||
/** | |||||
* 问题总数 | |||||
*/ | |||||
private Integer num; | |||||
} |
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | <if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | ||||
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | <if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | ||||
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> | <if test="request.type != null and request.type != 0"> and type = #{request.type} </if> | ||||
<if test="request.createUser != null and request.createUser != ''"> and create_user = #{request.createUser} </if> | |||||
<if test="request.deptIdList != null and request.deptIdList.size() > 0"> | |||||
and dept_id in | |||||
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")"> | |||||
#{deptId} | |||||
</foreach> | |||||
</if> | |||||
</where> | </where> | ||||
order by create_time desc | order by create_time desc | ||||
</select> | </select> |
select <include refid="selectUserVo"/> | select <include refid="selectUserVo"/> | ||||
from th_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 </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> | ||||
<if test="request.username != null and request.username != ''"> and username like concat('%', #{request.username}, '%') </if> | <if test="request.username != null and request.username != ''"> and username like concat('%', #{request.username}, '%') </if> | ||||
<if test="request.realname != null and request.realname != ''"> and realname like concat('%', #{request.realname}, '%') </if> | <if test="request.realname != null and request.realname != ''"> and realname like concat('%', #{request.realname}, '%') </if> |
package com.tuoheng.miniprogram.service.impl; | package com.tuoheng.miniprogram.service.impl; | ||||
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.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//登录用户信息 | //登录用户信息 | ||||
User userInfo = CurrentUserUtil.getUserInfo(); | |||||
String username = userInfo.getUsername(); | |||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(StringUtils.isNotEmpty(username), User::getUsername, username) | |||||
.eq(User::getStatus, 1).eq(User::getMark, 1)); | |||||
if (ObjectUtil.isNull(user)) { | |||||
return null; | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
Integer type = user.getDataPermission(); | |||||
if (null == type) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | } | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
if (StringUtils.isEmpty(tenantId)) { | |||||
return null; | |||||
} | |||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
query.setType(1); | query.setType(1); | ||||
//查询部门及下级部门列表 | |||||
List<Dept> list = deptMapper.selectList(Wrappers.<Dept>lambdaQuery() | |||||
.eq(Dept::getMark, 1)); | |||||
//初始部门id | //初始部门id | ||||
String deptIdInt = query.getDeptId(); | String deptIdInt = query.getDeptId(); | ||||
//获取当前部门对应的巡检任务 | //获取当前部门对应的巡检任务 | ||||
//获取分页数据 | //获取分页数据 | ||||
IPage<Inspection> page = new Page<>(query.getPage(), query.getLimit()); | IPage<Inspection> page = new Page<>(query.getPage(), query.getLimit()); | ||||
} | } | ||||
query.setStartTimeDate(startTime); | query.setStartTimeDate(startTime); | ||||
query.setEndTimeDate(endTime); | query.setEndTimeDate(endTime); | ||||
Integer type = user.getDataPermission(); | |||||
if (null == type) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>(); | List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>(); | ||||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | //用户角色判断 1超级管理员 2部门管理员 3普通用户 | ||||
if (DataPermissionEnum.ALL.getCode() == type) { | if (DataPermissionEnum.ALL.getCode() == type) { | ||||
query.setDeptId(""); // 要查所有部门的, 因此不通过deptId过滤 | |||||
IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query); | IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query); | ||||
IPageData.getRecords().stream().forEach(x -> { | IPageData.getRecords().stream().forEach(x -> { | ||||
//修改执行人属性 | //修改执行人属性 | ||||
long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | ||||
problemsFoundNum = (int) (count + count1 + count2); | problemsFoundNum = (int) (count + count1 + count2); | ||||
} | } | ||||
x.setFlag(0); | |||||
x.setFlag(1); | |||||
x.setProblemsFoundNum(problemsFoundNum); | x.setProblemsFoundNum(problemsFoundNum); | ||||
x.setProblemsVerifiedNum(problemsVerifiedNum); | x.setProblemsVerifiedNum(problemsVerifiedNum); | ||||
}); | }); | ||||
long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | ||||
problemsFoundNum = (int) (count + count1 + count2); | problemsFoundNum = (int) (count + count1 + count2); | ||||
} | } | ||||
//获取任务deptId1:1为部门任务 0为子部门任务 | |||||
if (deptIdInt.equals(deptId)) { | |||||
x.setFlag(1); | |||||
} else { | |||||
x.setFlag(0); | |||||
} | |||||
x.setFlag(1); | |||||
x.setProblemsFoundNum(problemsFoundNum); | x.setProblemsFoundNum(problemsFoundNum); | ||||
x.setProblemsVerifiedNum(problemsVerifiedNum); | x.setProblemsVerifiedNum(problemsVerifiedNum); | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
pageDataVo.setRecords(inspectionInfoVoList); | pageDataVo.setRecords(inspectionInfoVoList); | ||||
return JsonResult.success(pageDataVo); | return JsonResult.success(pageDataVo); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 递归获取部门的子集 | * 递归获取部门的子集 | ||||
* | * |
*/ | */ | ||||
@Override | @Override | ||||
public JsonResult getTodoList(WorkOrderQuery query) { | public JsonResult getTodoList(WorkOrderQuery query) { | ||||
log.info("获取代办工单列表,query={}", query); | |||||
if (query.getLimit() == null && query.getPage() == null) { | if (query.getLimit() == null && query.getPage() == null) { | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//登录用户信息 | //登录用户信息 | ||||
User userInfo1 = CurrentUserUtil.getUserInfo(); | |||||
String username = userInfo1.getUsername(); | |||||
if (null == username) { | |||||
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(), WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); | |||||
} | |||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(User::getMark, 1) | |||||
.eq(User::getUsername, username)); | |||||
if (ObjectUtil.isNull(user)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(), WorkOrderEnum.USER_IS_NOT_EXIST.getMsg()); | |||||
} | |||||
String tenantId = userInfo1.getTenantId(); | |||||
if (null == tenantId) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String deptId = user.getDeptId(); | |||||
if (StringUtils.isEmpty(deptId)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | } | ||||
String tenantId = user.getTenantId(); | |||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
//获取分页数据 | //获取分页数据 | ||||
IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit()); | IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit()); | ||||
} | } | ||||
query.setOrderStartTime(startTime); | query.setOrderStartTime(startTime); | ||||
query.setOrderEndTime(endTime); | query.setOrderEndTime(endTime); | ||||
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 | |||||
Integer type = user.getDataPermission(); | |||||
if (DataPermissionEnum.ALL.getCode() == type) { | |||||
return JsonResult.success(null,"超级管理员代办工单不显示数据"); | |||||
} | |||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
//用户角色为2部门管理员 3普通用户 | |||||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) { | |||||
String deptId = user.getDeptId(); | |||||
if (StringUtils.isEmpty(deptId)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
//获取当前分配人对应的工单分页数据 | |||||
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getAssignDeptId, deptId) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.like(StringUtils.isNotEmpty(user.getId()), WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) | |||||
.eq(WorkOrder::getMark, 1) | |||||
.orderByDesc(WorkOrder::getCreateTime)); | |||||
if (null == workPageData.getRecords()) { | |||||
return null; | |||||
} | |||||
List<WorkOrderInfoVo> WorkOrderInfoList = new ArrayList<>(); | |||||
//设置每条工单对应的各状态问题数量 | |||||
List<WorkOrderInfoVo> workOrderList = workPageData.getRecords().stream().map(x -> { | |||||
WorkOrderInfoVo vo = new WorkOrderInfoVo(); | |||||
BeanUtils.copyProperties(x, vo); | |||||
//获取当前分配人对应的工单分页数据 | |||||
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery() | |||||
.in(CollectionUtil.isNotEmpty(deptIdList), WorkOrder::getAssignDeptId, deptIdList) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.eq(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) | |||||
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) | |||||
.orderByDesc(WorkOrder::getCreateTime)); | |||||
if (null == workPageData.getRecords()) { | |||||
return null; | |||||
} | |||||
List<WorkOrderInfoVo> WorkOrderInfoList; | |||||
//设置每条工单对应的各状态问题数量 | |||||
List<WorkOrderInfoVo> workOrderList = workPageData.getRecords().stream().map(x -> { | |||||
WorkOrderInfoVo vo = new WorkOrderInfoVo(); | |||||
BeanUtils.copyProperties(x, vo); | |||||
// vo.setCode(x.getCode()); | // vo.setCode(x.getCode()); | ||||
// vo.setCreateTime(x.getCreateTime()); | // vo.setCreateTime(x.getCreateTime()); | ||||
//被分配人员对应id | |||||
String assignUser = x.getAssignUser(); | |||||
String[] assignUserId = assignUser.split(","); | |||||
if (StringUtils.isEmpty(assignUserId)) { | |||||
return null; | |||||
} | |||||
List<String> list = new ArrayList<>(); | |||||
for (String userId : assignUserId) { | |||||
User userInfo = userMapper.selectById(userId); | |||||
if (ObjectUtil.isNotNull(userInfo)) { | |||||
list.add(userInfo.getRealname()); | |||||
} | |||||
} | |||||
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、")); | |||||
vo.setAssignUserName(usernames); | |||||
//问题总数 | |||||
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() | |||||
.eq(WorkOrderFile::getWorkOrderId, x.getId())); | |||||
if (CollectionUtil.isEmpty(workOrderFiles)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
vo.setPromTotal(workOrderFiles.size()); | |||||
//对应的问题id集合 | |||||
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||||
if (CollectionUtil.isEmpty(inspectionFiledIds)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
//获取问题集合 | |||||
List<InspectionFile> inspectionFileList = new ArrayList<>(); | |||||
for (String inspectionFiledId : inspectionFiledIds) { | |||||
InspectionFile inspectionFile = inspectionFileMapper.selectById(inspectionFiledId); | |||||
inspectionFileList.add(inspectionFile); | |||||
//被分配人员对应id | |||||
String assignUser = x.getAssignUser(); | |||||
String[] assignUserId = assignUser.split(","); | |||||
if (StringUtils.isEmpty(assignUserId)) { | |||||
return null; | |||||
} | |||||
List<String> list = new ArrayList<>(); | |||||
for (String userId : assignUserId) { | |||||
User userInfo = userMapper.selectById(userId); | |||||
if (ObjectUtil.isNotNull(userInfo)) { | |||||
list.add(userInfo.getRealname()); | |||||
} | } | ||||
//待处理问题总数 | |||||
long count = inspectionFileList.stream().filter(t -> t.getStatus() == 20).count(); | |||||
vo.setPromTodo((int) count); | |||||
//已处理问题总数 | |||||
long count1 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | |||||
vo.setPromProcessed((int) count1); | |||||
} | |||||
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、")); | |||||
vo.setAssignUserName(usernames); | |||||
//问题总数 | |||||
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() | |||||
.eq(WorkOrderFile::getWorkOrderId, x.getId())); | |||||
if (CollectionUtil.isEmpty(workOrderFiles)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
vo.setPromTotal(workOrderFiles.size()); | |||||
//对应的问题id集合 | |||||
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||||
if (CollectionUtil.isEmpty(inspectionFiledIds)) { | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
//获取问题集合 | |||||
List<InspectionFile> inspectionFileList = new ArrayList<>(); | |||||
for (String inspectionFiledId : inspectionFiledIds) { | |||||
InspectionFile inspectionFile = inspectionFileMapper.selectById(inspectionFiledId); | |||||
inspectionFileList.add(inspectionFile); | |||||
} | |||||
//待处理问题总数 | |||||
long count = inspectionFileList.stream().filter(t -> t.getStatus() == 20).count(); | |||||
vo.setPromTodo((int) count); | |||||
//已处理问题总数 | |||||
long count1 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); | |||||
vo.setPromProcessed((int) count1); | |||||
return vo; | |||||
}).collect(Collectors.toList()); | |||||
//当待处理问题总数为0时,此工单不出现在代办工单列表并且工单状态修改为15已完成 | |||||
List<WorkOrderInfoVo> collect = workOrderList.stream().filter(f -> f.getPromTodo() == 0).collect(Collectors.toList()); | |||||
if (null != collect) { | |||||
for (WorkOrderInfoVo workOrderInfoVo : collect) { | |||||
//每一个工单对应的状态发生改变,一个工单id对应一个工单 | |||||
WorkOrder workOrder = workOrderMapper.selectById(workOrderInfoVo.getId()); | |||||
if (ObjectUtil.isNotNull(workOrder)) { | |||||
workOrder.setStatus(15); | |||||
workOrder.setUpdateTime(DateUtils.now()); | |||||
workOrder.setUpdateUser(user.getId()); | |||||
super.update(workOrder); | |||||
} | |||||
return vo; | |||||
}).collect(Collectors.toList()); | |||||
//当待处理问题总数为0时,此工单不出现在代办工单列表并且工单状态修改为15已完成 | |||||
List<WorkOrderInfoVo> collect = workOrderList.stream().filter(f -> f.getPromTodo() == 0).collect(Collectors.toList()); | |||||
if (null != collect) { | |||||
for (WorkOrderInfoVo workOrderInfoVo : collect) { | |||||
//每一个工单对应的状态发生改变,一个工单id对应一个工单 | |||||
WorkOrder workOrder = workOrderMapper.selectById(workOrderInfoVo.getId()); | |||||
if (ObjectUtil.isNotNull(workOrder)) { | |||||
workOrder.setStatus(15); | |||||
workOrder.setUpdateTime(DateUtils.now()); | |||||
workOrder.setUpdateUser(user.getId()); | |||||
super.update(workOrder); | |||||
} | } | ||||
} | } | ||||
//工单的待处理问题个数不为0时 重新返回 | |||||
WorkOrderInfoList = workOrderList.stream().filter(h -> h.getPromTodo() != 0).collect(Collectors.toList()); | |||||
pageData.setRecords(WorkOrderInfoList); | |||||
} | |||||
//工单的待处理问题个数不为0时 重新返回 | |||||
WorkOrderInfoList = workOrderList.stream().filter(h -> h.getPromTodo() != 0).collect(Collectors.toList()); | |||||
pageData.setRecords(WorkOrderInfoList); | |||||
return JsonResult.success(pageData); | |||||
return JsonResult.success(pageData); | |||||
} | |||||
/** | |||||
* 获取数据权限的查询范围 | |||||
* | |||||
* @param user | |||||
* @return | |||||
*/ | |||||
private List<String> getDeptIdList(User user) { | |||||
List<String> deptIdList = null; | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
return null; | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
deptIdList = new ArrayList<>(); | |||||
deptIdList.add(user.getDeptId()); | |||||
} | } | ||||
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg()); | |||||
return deptIdList; | |||||
} | } | ||||
/** | /** | ||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } | ||||
//获取登录用户信息 | //获取登录用户信息 | ||||
User userInfo1 = CurrentUserUtil.getUserInfo(); | |||||
String username = userInfo1.getUsername(); | |||||
if (null == username) { | |||||
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(), WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); | |||||
} | |||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(User::getMark, 1) | |||||
.eq(User::getUsername, username)); | |||||
if (ObjectUtil.isNull(user)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(), WorkOrderEnum.USER_IS_NOT_EXIST.getMsg()); | |||||
} | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
if (null == tenantId) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
query.setTenantId(tenantId); | query.setTenantId(tenantId); | ||||
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 | //根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 | ||||
Integer type = user.getDataPermission(); | Integer type = user.getDataPermission(); | ||||
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) | ||||
.eq(WorkOrder::getTenantId, tenantId) | .eq(WorkOrder::getTenantId, tenantId) | ||||
.eq(WorkOrder::getAssignUser, user.getId()) | |||||
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) | .between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) | ||||
.eq(WorkOrder::getMark, 1) | |||||
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) | |||||
.orderByDesc(WorkOrder::getCreateTime)); | .orderByDesc(WorkOrder::getCreateTime)); | ||||
//设置每条工单对应的已完成问题数量 问题状态为25问题已处理 | //设置每条工单对应的已完成问题数量 问题状态为25问题已处理 | ||||
List<WorkOrderInfoVo> collect = workPageData.getRecords().stream().map(s -> { | List<WorkOrderInfoVo> collect = workPageData.getRecords().stream().map(s -> { | ||||
@Override | @Override | ||||
public JsonResult weekCount() { | public JsonResult weekCount() { | ||||
//获取登录用户信息 | //获取登录用户信息 | ||||
User userInfo = CurrentUserUtil.getUserInfo(); | |||||
String username = userInfo.getUsername(); | |||||
if (StringUtils.isEmpty(username)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(), WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); | |||||
} | |||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(User::getMark, 1) | |||||
.eq(User::getUsername, username)); | |||||
if (ObjectUtil.isNull(user)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(), WorkOrderEnum.USER_IS_NOT_EXIST.getMsg()); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
//获取部门id | |||||
if (StringUtils.isEmpty(user.getDeptId())) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | } | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
if (StringUtils.isEmpty(tenantId)) { | |||||
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//用户角色 | //用户角色 | ||||
Integer type = user.getDataPermission(); | Integer type = user.getDataPermission(); | ||||
if (null == type) { | if (null == type) { | ||||
if (null == endTime || null == startTime) { | if (null == endTime || null == startTime) { | ||||
return null; | return null; | ||||
} | } | ||||
//根据用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||||
if (DataPermissionEnum.ALL.getCode() == type) { | |||||
//获取当前登录用户(超级管理员)已完成工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.between(WorkOrder::getUpdateTime, startTime, endTime)); | |||||
if (StringUtils.isNotEmpty(workOrders)) { | |||||
vo.setWeekWorkOrderFinishedSum(workOrders.size()); | |||||
} | |||||
} | |||||
//部门管理员 普通用户 | |||||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) { | |||||
//获取部门id | |||||
if (StringUtils.isEmpty(user.getDeptId())) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//获取当前登录用户(被分配人员)的待处理工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.like(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getAssignTime, startTime, endTime)); | |||||
if (StringUtils.isNotEmpty(workOrders)) { | |||||
vo.setWeekWorkOrderTodoSum(workOrders.size()); | |||||
} | |||||
//获取当前登录用户(被分配人员)的已完成工单列表 | |||||
List<WorkOrder> result = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.like(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getUpdateTime, startTime, endTime)); | |||||
if (StringUtils.isNotEmpty(result)) { | |||||
vo.setWeekWorkOrderFinishedSum(result.size()); | |||||
} | |||||
} | |||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
//获取当前登录用户(被分配人员)的待处理工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) | |||||
.eq(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.in(CollectionUtil.isNotEmpty(deptIdList), WorkOrder::getAssignDeptId, deptIdList) | |||||
.between(WorkOrder::getAssignTime, startTime, endTime)); | |||||
if (CollectionUtil.isNotEmpty(workOrders)) { | |||||
vo.setWeekWorkOrderTodoSum(workOrders.size()); | |||||
} else { | |||||
vo.setWeekWorkOrderTodoSum(0); | |||||
} | |||||
//获取当前登录用户(被分配人员)的已完成工单列表 | |||||
List<WorkOrder> result = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) | |||||
.eq(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getUpdateTime, startTime, endTime)); | |||||
if (CollectionUtil.isNotEmpty(result)) { | |||||
vo.setWeekWorkOrderFinishedSum(result.size()); | |||||
} else { | |||||
vo.setWeekWorkOrderFinishedSum(0); | |||||
} | |||||
return JsonResult.success(vo); | return JsonResult.success(vo); | ||||
} | } | ||||
@Override | @Override | ||||
public JsonResult mothCount() { | public JsonResult mothCount() { | ||||
//获取登录用户信息 | //获取登录用户信息 | ||||
User userInfo = CurrentUserUtil.getUserInfo(); | |||||
String username = userInfo.getUsername(); | |||||
if (StringUtils.isEmpty(username)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(), WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); | |||||
} | |||||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
.eq(User::getMark, 1) | |||||
.eq(User::getUsername, username)); | |||||
if (ObjectUtil.isNull(user)) { | |||||
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(), WorkOrderEnum.USER_IS_NOT_EXIST.getMsg()); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
//获取部门id | |||||
if (StringUtils.isEmpty(user.getDeptId())) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | } | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
if (StringUtils.isEmpty(tenantId)) { | |||||
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//用户角色 | //用户角色 | ||||
Integer type = user.getDataPermission(); | Integer type = user.getDataPermission(); | ||||
if (null == type) { | if (null == type) { | ||||
if (null == endTime || null == beginTime) { | if (null == endTime || null == beginTime) { | ||||
return null; | return null; | ||||
} | } | ||||
//根据用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||||
if (DataPermissionEnum.ALL.getCode() == type) { | |||||
//获取当前登录用户(超级管理员)已完成工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.between(WorkOrder::getUpdateTime, beginTime, endTime)); | |||||
if (StringUtils.isNotEmpty(workOrders)) { | |||||
vo.setMonthWorkOrderFinishedSum(workOrders.size()); | |||||
} | |||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
//获取当前登录用户(被分配人员)的待处理工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.eq(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.in(CollectionUtil.isNotEmpty(deptIdList), WorkOrder::getAssignDeptId, deptIdList) | |||||
.between(WorkOrder::getAssignTime, beginTime, endTime)); | |||||
if (CollectionUtil.isNotEmpty(workOrders)) { | |||||
vo.setMonthWorkOrderTodoSum(workOrders.size()); | |||||
} else { | |||||
vo.setMonthWorkOrderTodoSum(0); | |||||
} | |||||
//获取当前登录用户(被分配人员)的已完成工单列表 | |||||
List<WorkOrder> result = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.like(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getUpdateTime, beginTime, endTime)); | |||||
if (CollectionUtil.isNotEmpty(result)) { | |||||
vo.setMonthWorkOrderFinishedSum(result.size()); | |||||
} else { | |||||
vo.setMonthWorkOrderFinishedSum(0); | |||||
} | } | ||||
//部门管理员 普通用户 | |||||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) { | |||||
//获取部门id | |||||
if (StringUtils.isEmpty(user.getDeptId())) { | |||||
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
//获取当前登录用户(被分配人员)的待处理工单列表 | |||||
List<WorkOrder> workOrders = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.like(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 10) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getAssignTime, beginTime, endTime)); | |||||
if (StringUtils.isNotEmpty(workOrders)) { | |||||
vo.setMonthWorkOrderTodoSum(workOrders.size()); | |||||
} | |||||
//获取当前登录用户(被分配人员)的已完成工单列表 | |||||
List<WorkOrder> result = workOrderMapper.selectList(Wrappers.<WorkOrder>lambdaQuery() | |||||
.eq(WorkOrder::getMark, 1) | |||||
.like(WorkOrder::getAssignUser, user.getId()) | |||||
.eq(WorkOrder::getStatus, 15) | |||||
.eq(WorkOrder::getTenantId, tenantId) | |||||
.eq(WorkOrder::getDeptId, user.getDeptId()) | |||||
.between(WorkOrder::getUpdateTime, beginTime, endTime)); | |||||
if (StringUtils.isNotEmpty(result)) { | |||||
vo.setMonthWorkOrderFinishedSum(result.size()); | |||||
} | |||||
} | |||||
return JsonResult.success(vo); | return JsonResult.success(vo); | ||||
} | } | ||||
/** | /** | ||||
* 创建时间 | * 创建时间 | ||||
*/ | */ | ||||
@DateTimeFormat(pattern = "yyyy.MM.dd hh:mm") | |||||
@JsonFormat(pattern = "yyyy.MM.dd hh:mm", timezone = "GMT+8") | |||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") | |||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") | |||||
private Date createTime; | private Date createTime; | ||||
/** | /** |