Преглед изворни кода

Merge remote-tracking branch 'origin/develop' into develop

tags/V1.3.3^2
xiaoying пре 11 месеци
родитељ
комит
c41b883317
32 измењених фајлова са 723 додато и 620 уклоњено
  1. +3
    -1
      tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.2.sql
  2. +17
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/QuestionTypeConverMapper.java
  3. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspectionfile/ListByDeptUserTypeEnum.java
  4. +10
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/AccidentQuery.java
  5. +0
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java
  6. +6
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/report/QueryReportPageListRequest.java
  7. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/user/QueryUserPageListRequest.java
  8. +31
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java
  9. +1
    -11
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java
  10. +25
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java
  11. +41
    -24
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java
  12. +32
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java
  13. +11
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java
  14. +22
    -16
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java
  15. +13
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java
  16. +28
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeByDeptIdService.java
  17. +29
    -21
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/update/UpdateDeptService.java
  18. +3
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java
  19. +2
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java
  20. +5
    -166
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java
  21. +129
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileListByDeptUserTypeService.java
  22. +24
    -18
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryReportPageListService.java
  23. +8
    -12
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java
  24. +16
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserPageListService.java
  25. +13
    -13
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java
  26. +8
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java
  27. +54
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/QuestionTypeVo.java
  28. +6
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/ReportMapper.xml
  29. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml
  30. +11
    -29
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  31. +165
    -222
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java
  32. +2
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/WorkOrderInfoVo.java

+ 3
- 1
tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.2.sql Прегледај датотеку

@@ -4,4 +4,6 @@
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;

+ 17
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/QuestionTypeConverMapper.java Прегледај датотеку

@@ -0,0 +1,17 @@
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);

}

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspectionfile/ListByDeptUserTypeEnum.java Прегледај датотеку

@@ -13,7 +13,8 @@ public enum ListByDeptUserTypeEnum {
INSPECTION_LIST_IS_NULL(1100304, "任务列表为空"),
DEPT_ID_IS_NULL(1100305, "部门id为空"),
QUESTION_ID_IS_NULL(1100306, "问题列表为空"),
TENANT_ID_IS_NULL(1100307, "租户id为空");
TENANT_ID_IS_NULL(1100307, "租户id为空"),
DEPT_LIST_IS_NULL(1100308, "部门列表为空");

/**
* 错误码

+ 10
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/AccidentQuery.java Прегледај датотеку

@@ -4,6 +4,7 @@ import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
* @Author ChengWang
@@ -22,11 +23,6 @@ public class AccidentQuery extends BaseQuery {
*/
private String code;

/**
* 部门ID
*/
private String deptId;

/**
*起始日期
*/
@@ -47,4 +43,13 @@ public class AccidentQuery extends BaseQuery {
*/
private Date accidentEndTime;

/**
* 部门ID
*/
private String deptId;

/**
* 部门集合
*/
private List<String> deptIdList;
}

+ 0
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java Прегледај датотеку

@@ -1,10 +1,7 @@
package com.tuoheng.admin.request.accident;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**

+ 6
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/report/QueryReportPageListRequest.java Прегледај датотеку

@@ -3,6 +3,8 @@ package com.tuoheng.admin.request.report;
import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

import java.util.List;

/**
* 查询报告分页列表请求实体
*
@@ -28,15 +30,14 @@ public class QueryReportPageListRequest extends BaseQuery {
*/
private Integer airportId;

/**
* 创建人
*/
private String createUser;

/**
* 租户Id
*/
private String tenantId;

/**
* 部门集合
*/
private List<String> deptIdList;

}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/user/QueryUserPageListRequest.java Прегледај датотеку

@@ -31,6 +31,11 @@ public class QueryUserPageListRequest extends BaseQuery {
*/
private Integer roleId;

/**
* 部门ID
*/
private String deptId;

/**
* 部门及子部门Id列表
*/

+ 31
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java Прегледај датотеку

@@ -5,11 +5,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.AccidentRead;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.AccidentStatusEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.FlagEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.AccidentReadMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
@@ -37,6 +40,8 @@ public class AccidentNoticeService {
@Autowired
private AccidentReadMapper accidentReadMapper;

@Autowired
private DeptMapper deptMapper;

/**
* 告警弹窗通知下发
@@ -44,22 +49,21 @@ public class AccidentNoticeService {
*/
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>()
.eq(Accident::getTenantId, tenantId)
.in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList)
.eq(Accident::getStatus, AccidentStatusEnum.UNTREATED.getCode())
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode())
.eq(Accident::getMark, MarkEnum.VALID.getCode())
.orderByAsc(Accident::getCreateTime));
if(CollectionUtils.isEmpty(accidentList) || accidentList.size() == 0){
if(CollectionUtils.isEmpty(accidentList)){
return JsonResult.success("巡检任务无应急记录产生");
}
//当前用户对应的应急记为未读才出现弹窗
@@ -103,4 +107,22 @@ public class AccidentNoticeService {

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;
}
}

+ 1
- 11
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java Прегледај датотеку

@@ -75,17 +75,7 @@ public class AccidentTipsService {
if (StringUtils.isNotEmpty(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);
}
}

+ 25
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java Прегледај датотеку

@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,14 +52,18 @@ public class QueryAccidentCardListService {

public JsonResult getList(QueryAccidentCardListRequest request) {
// log.info("进入查询事件列表业务");
String tenantId = CurrentUserUtil.getTenantId();
request.setTenantId(tenantId);
User user = CurrentUserUtil.getUserInfo();
String tenantId = user.getTenantId();

JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg());
return result;
}

List<String> deptIdList = this.getDeptIdList(user);
request.setDeptIdList(deptIdList);
request.setTenantId(tenantId);
List<Accident> accidentList = accidentMapper.selectAccidentCardList(request);

// 构造返回结果对象
@@ -78,6 +83,24 @@ public class QueryAccidentCardListService {
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
* @return

+ 41
- 24
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java Прегледај датотеку

@@ -3,16 +3,16 @@ package com.tuoheng.admin.service.accident.query;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.extension.plugins.pagination.Page;
import com.tuoheng.admin.conver.AccidentConverMapper;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.entity.Dept;
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.MarkEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.UserMapper;
@@ -31,10 +31,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
@@ -122,8 +119,8 @@ public class QueryAccidentCardPageListService {
}

/**
* 设置列表中每一个的部门名称
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
* 设置列表中每一个的部门名称
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
*
* @param accidentList
* @return
@@ -141,39 +138,39 @@ public class QueryAccidentCardPageListService {
}
List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList());
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);
return userMap;
}

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);
}

//当前租户下
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);
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 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.setAccidentEndTime(endTime);
//获取分页数据
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(),
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime())
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode())
@@ -191,7 +188,7 @@ public class QueryAccidentCardPageListService {
if (StringUtils.isNotEmpty(x.getDeptId())) {
//根据当前部门id查询对应的部门名称
Dept dept = deptMapper.selectById(x.getDeptId());
vo.setName(dept.getName() !=null?dept.getName():"");
vo.setName(dept.getName() != null ? dept.getName() : "");
}

return vo;
@@ -202,7 +199,27 @@ public class QueryAccidentCardPageListService {
pageData.setCurrent(accidentPageData.getCurrent());

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;
}
}

+ 32
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java Прегледај датотеку

@@ -1,11 +1,13 @@
package com.tuoheng.admin.service.accident.query;

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.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.Accident;
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.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
@@ -24,6 +26,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -54,12 +57,13 @@ public class QueryAccidentPageListService {
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);

IPage<Accident> page = new Page<>(query.getPage(), query.getLimit());
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(), query.getLimit());
//搜索时间
@@ -74,8 +78,8 @@ public class QueryAccidentPageListService {
//获取分页数据
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery()
.eq(Accident::getTenantId, tenantId)
.in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList)
.eq(null != query.getCode(), Accident::getRoadCode, query.getCode())
.eq(null != query.getDeptId(), Accident::getDeptId, query.getDeptId())
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(),
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime())
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode())
@@ -104,7 +108,27 @@ public class QueryAccidentPageListService {
pageData.setCurrent(accidentPageData.getCurrent());

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;
}
}

+ 11
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java Прегледај датотеку

@@ -1,5 +1,7 @@
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.enums.AccidentEnum;
import com.tuoheng.admin.mapper.AccidentReadMapper;
@@ -14,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Author ChengWang
* @Date 2023/3/2
@@ -38,8 +42,13 @@ public class AccidentReadServiceImpl implements IAccidentReadService {
}
//当前用户信息
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.setAccidentId(accidentId);
@@ -51,7 +60,6 @@ public class AccidentReadServiceImpl implements IAccidentReadService {
if(result<=0){
return JsonResult.error();
}

return JsonResult.success();
}


+ 22
- 16
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java Прегледај датотеку

@@ -1,5 +1,6 @@
package com.tuoheng.admin.service.dept.add;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.dto.RoadSectionDto;
@@ -12,12 +13,14 @@ import com.tuoheng.admin.mapper.SectionDeptMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
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.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 org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.*;
@@ -51,10 +54,12 @@ public class AddDeptService {
*
* @return
*/
@Transactional
public JsonResult add(AddDeptRequest addDeptRequest) {
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);
if (0 != result.getCode()) {
log.info("添加部门业务接口:校验失败:{}", result.getMsg());
@@ -78,7 +83,7 @@ public class AddDeptService {
this.updateSuperAdminUser(userId, tenantId, dept);

// 新增公路/路段与部门数据
addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList());
this.addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList());

log.info("添加部门业务接口:添加部门成功:{}");
return JsonResult.success(dept);
@@ -133,19 +138,16 @@ public class AddDeptService {
}
}

// 新增部门,公路和路段信息不能为空
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();
}

@@ -158,6 +160,10 @@ public class AddDeptService {
* @return 结果
*/
private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) {
if (CollectionUtil.isEmpty(roadSectionDtoList)) {
log.info("新增部门公路/路段数据为空");
return;
}
List<RoadInformation> roadInformationList = new ArrayList<>();
List<Section> sectionList = new ArrayList<>();
RoadInformation road;

+ 13
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java Прегледај датотеку

@@ -3,6 +3,8 @@ package com.tuoheng.admin.service.dept.query;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.code.dept.QueryDeptChildListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper;
@@ -13,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
@@ -35,17 +38,23 @@ public class QueryChildListService {
* @return
*/
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);
if (0 != result.getCode()) {
log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg());
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)) {
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);
return JsonResult.success(deptList);

+ 28
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeByDeptIdService.java Прегледај датотеку

@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.conver.DeptConverMapper;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.RoadInformation;
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.mapper.DeptMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
@@ -44,20 +47,36 @@ public class QueryListTreeByDeptIdService {
public JsonResult getListTree(String deptId) {
List<DeptTreeVo> deptTreeVoList = new ArrayList<>();
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)) {
log.info("获取部门列表为空");
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);
Map<String, DeptTreeVo> deptVoMap = new HashMap<>();
for (DeptTreeVo deptTreeVo : deptTreeVoListTmp) {

+ 29
- 21
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/update/UpdateDeptService.java Прегледај датотеку

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.dto.RoadSectionDto;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.dept.EditDeptCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.RoadDeptMapper;
@@ -138,19 +139,17 @@ public class UpdateDeptService {
}
}

// 修改部门,公路和路段信息不能为空
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();
}

@@ -205,9 +204,11 @@ public class UpdateDeptService {
// Collection<String> union = org.apache.commons.collections4.CollectionUtils.union(oldRoadIdList, newRoadIdList);

// 差集:新增公路
Collection<String> addRoadIdList;
Collection<String> addRoadIdList = null;
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 {
addRoadIdList = newRoadIdList;
}
@@ -219,7 +220,12 @@ public class UpdateDeptService {

// 差集:删除公路
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> subRoadIdMap = subRoadIdList.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting()));
if (CollectionUtil.isNotEmpty(subRoadIdList)) {
@@ -290,7 +296,7 @@ public class UpdateDeptService {

List<Dept> deptList = new ArrayList<>();
deptList.add(parentDept);
queryChildDeptList(deptList, parentDept);
this.queryChildDeptList(tenantId, deptList, parentDept);

List<String> deptIdList = deptList.stream().map(p -> p.getId()).collect(Collectors.toList());;
for (String roadId : roadIdList) {
@@ -319,8 +325,10 @@ public class UpdateDeptService {

List<RoadSectionDto> newRoadSectionList = newEditDeptRequest.getRoadSectionDtoList();
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());

@@ -415,14 +423,14 @@ public class UpdateDeptService {
* @param deptList
* @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>()
.eq(Dept::getTenantId, 0)
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getPid, parentDept.getId())
.eq(Dept::getMark, 1));
.eq(Dept::getMark, MarkEnum.VALID.getCode()));

for (Dept dept : childDeptlist) {
queryChildDeptList(deptList, dept);
queryChildDeptList(tenantId, deptList, dept);
}
deptList.addAll(childDeptlist);
}

+ 3
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java Прегледај датотеку

@@ -99,8 +99,9 @@ public class QueryInspectionPageListService {

public JsonResult getPageList(QueryInspectionPageListRequest request) {
// 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);

// 不查应急任务
@@ -112,11 +113,6 @@ public class QueryInspectionPageListService {
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>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, user.getDeptId())

+ 2
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java Прегледај датотеку

@@ -44,14 +44,7 @@ public class QueryNewInspectionListService {
public JsonResult getList() {
//获取登录用户信息
User user = CurrentUserUtil.getUserInfo();
if (ObjectUtil.isNull(user)) {
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(), ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
}
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普通用户
if (null == user.getDataPermission()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
@@ -64,7 +57,7 @@ public class QueryNewInspectionListService {
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
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()) {
Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList);
@@ -85,7 +78,7 @@ public class QueryNewInspectionListService {
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if (CollectionUtil.isEmpty(inspectionList)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
return JsonResult.success();
}
Stream<InspectionListVo> inspectionListVoStream = this.getInspectionListVoStream(inspectionList);
return JsonResult.success(inspectionListVoStream);

+ 5
- 166
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java Прегледај датотеку

@@ -1,6 +1,5 @@
package com.tuoheng.admin.service.inspectionfile;

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;
@@ -10,8 +9,6 @@ import com.tuoheng.admin.entity.QuestionType;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.DataPermissionEnum;
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.query.InspectionFileQuery;
import com.tuoheng.admin.request.inspectionfile.*;
@@ -19,17 +16,11 @@ import com.tuoheng.admin.service.inspectionfile.confirm.InspectionFileConfirmSer
import com.tuoheng.admin.service.inspectionfile.handle.QueryInspectionFileHandleByInspectionFileIdService;
import com.tuoheng.admin.service.inspectionfile.ignore.InspectionFileIgnoreService;
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.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.ListByDeptUserTypeVo;
import com.tuoheng.admin.vo.inspection.InspectionFileVo;
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.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -38,7 +29,6 @@ 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;

@@ -94,6 +84,9 @@ public class InspectionFileServiceImpl implements IInspectionFileService {
@Autowired
private UpdateInspectionFileQuestionTypeService updateInspectionFileQuestionTypeService;

@Autowired
private QueryInspectionFileListByDeptUserTypeService queryInspectionFileListByDeptUserTypeService;

/**
* 问题类型和任务名称
*
@@ -201,161 +194,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService {

@Override
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);
}

/**

+ 129
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileListByDeptUserTypeService.java Прегледај датотеку

@@ -0,0 +1,129 @@
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);
}

}

+ 24
- 18
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryReportPageListService.java Прегледај датотеку

@@ -9,6 +9,7 @@ import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.InspectionFileHandle;
import com.tuoheng.admin.entity.Report;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.report.QueryReportPageListRequest;
@@ -19,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@@ -58,9 +60,7 @@ public class QueryReportPageListService {
public JsonResult getPageList(QueryReportPageListRequest request) {
// log.info("进入查询报告分页列表业务");
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
request.setTenantId(tenantId);

JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
@@ -68,11 +68,11 @@ public class QueryReportPageListService {
return result;
}

// 设置分页参数
List<String> deptIdList = this.getDeptIdList(user);
request.setDeptIdList(deptIdList);
request.setTenantId(tenantId);

IPage<Report> page = new Page<>(request.getPage(), request.getLimit());
// 用户只能查看自己生成的报告
request.setCreateUser(userId);
// 查询结果
IPage<Report> pageData = reportMapper.selectPageList(page, request);

// 构造返回结果对象
@@ -98,21 +98,27 @@ public class QueryReportPageListService {
*/
private JsonResult check(String tenantId, QueryReportPageListRequest request) {
// 判断部门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();
}

/**
* 根据用户自己的数据权限,查询对应部门的数据
*
* @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;
}

/**
* 构造返回的数据列表
*

+ 8
- 12
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java Прегледај датотеку

@@ -1,6 +1,7 @@
package com.tuoheng.admin.service.role;


import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -12,6 +13,7 @@ import com.tuoheng.admin.dto.OpPermissionsVo;
import com.tuoheng.admin.dto.RoleMenuDto;
import com.tuoheng.admin.dto.RoleMenuPermissionDto;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.role.RoleDeleteEnum;
import com.tuoheng.admin.mapper.*;
@@ -31,7 +33,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


/**
* @Author ChengWang
* @Date 2022/12/16
@@ -39,6 +40,9 @@ import java.util.stream.Collectors;
@Service
public class RoleServiceImpl implements IRoleService {

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoleMapper roleMapper;

@@ -78,21 +82,17 @@ public class RoleServiceImpl implements IRoleService {
IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit());
// 查询条件
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.eq("tenant_id", CurrentUserUtil.getTenantId());
queryWrapper.eq("mark", MarkEnum.VALID.getCode());
//queryWrapper.orderByAsc("sort");
queryWrapper.orderByAsc("create_time");
//queryWrapper.ne("id", "1");
// 查询分页数据
IPage<Role> pageData = roleMapper.selectPage(page, queryWrapper);
pageData.convert(x -> {
RoleListVo roleListVo = Convert.convert(RoleListVo.class, x);
// TODO...
return roleListVo;
});
return JsonResult.success(pageData);
@@ -196,15 +196,11 @@ public class RoleServiceImpl implements IRoleService {
@Override
public JsonResult getRoleLists() {
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("mark", MarkEnum.VALID.getCode());
queryWrapper.orderByAsc("create_time");
List<Role> rolesLists = roleMapper.selectList(queryWrapper);

return JsonResult.success(rolesLists);
}


+ 16
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserPageListService.java Прегледај датотеку

@@ -16,10 +16,12 @@ import com.tuoheng.admin.request.user.QueryUserPageListRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.user.UserPageListVo;
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.List;
import java.util.Map;
import java.util.function.Function;
@@ -62,7 +64,7 @@ public class QueryUserPageListService {
String tenantId = user.getTenantId();
request.setTenantId(tenantId);

List<String> deptIdList = this.getDeptIdList(user);
List<String> deptIdList = this.getDeptIdList(user, request.getDeptId());
request.setDeptIdList(deptIdList);

// 查询分页数据
@@ -95,9 +97,9 @@ public class QueryUserPageListService {
* @return
*/
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();
}

@@ -110,14 +112,20 @@ public class QueryUserPageListService {
* @param user
* @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()) {
return null;
} else {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
return deptIdList;
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
deptIdList.add(user.getDeptId());
}
return deptIdList;
}

/**

+ 13
- 13
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java Прегледај датотеку

@@ -126,19 +126,19 @@ public class GenerateWorkorderService {
* @return
*/
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();
}

/**

+ 8
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java Прегледај датотеку

@@ -60,9 +60,6 @@ public class QueryWorkOrderPageListService {
return result;
}
User user = CurrentUserUtil.getUserInfo();
if (DataPermissionEnum.ALL.getCode() != user.getDataPermission()) {
request.setUserDeptId(user.getDeptId());
}
String tenantId = user.getTenantId();
request.setTenantId(tenantId);
// 获取部门Id的查询范围
@@ -105,25 +102,26 @@ public class QueryWorkOrderPageListService {

/**
* 获取部门Id的查询范围
* 1)、deptId:如果传了值,查该部门的任务
* 2)、deptId:如果没有传值
* 2.1)、管理员:可查全部确认问题
* 2.2)、管理员/普通用户:本部门及子部门创建的工单
*
* @param deptId
* @return
*/
private List<String> getDeptIdList(User user, String deptId) {
List<String> deptIdList = new ArrayList<>();
if (!StringUtils.isEmpty(deptId)) {
if (StringUtils.isNotEmpty(deptId)) {
deptIdList.add(deptId);
return deptIdList;
}
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null;
} else {
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
return deptIdList;
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
deptIdList = new ArrayList<>();
deptIdList.add(user.getDeptId());
return deptIdList;
} else {
return null;
}
}


+ 54
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/QuestionTypeVo.java Прегледај датотеку

@@ -0,0 +1,54 @@
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;
}

+ 6
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/ReportMapper.xml Прегледај датотеку

@@ -75,7 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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.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>
order by create_time desc
</select>

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml Прегледај датотеку

@@ -87,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select <include refid="selectUserVo"/>
from th_user
<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.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>

+ 11
- 29
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java Прегледај датотеку

@@ -1,6 +1,5 @@
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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -68,25 +67,19 @@ public class InspectionServiceImpl implements IInspectionService {
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();
if (StringUtils.isEmpty(tenantId)) {
return null;
}

query.setTenantId(tenantId);
query.setType(1);
//查询部门及下级部门列表
List<Dept> list = deptMapper.selectList(Wrappers.<Dept>lambdaQuery()
.eq(Dept::getMark, 1));

//初始部门id
String deptIdInt = query.getDeptId();

//获取当前部门对应的巡检任务
//获取分页数据
IPage<Inspection> page = new Page<>(query.getPage(), query.getLimit());
@@ -99,13 +92,11 @@ public class InspectionServiceImpl implements IInspectionService {
}
query.setStartTimeDate(startTime);
query.setEndTimeDate(endTime);
Integer type = user.getDataPermission();
if (null == type) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}

List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>();
//用户角色判断 1超级管理员 2部门管理员 3普通用户
if (DataPermissionEnum.ALL.getCode() == type) {
query.setDeptId(""); // 要查所有部门的, 因此不通过deptId过滤
IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query);
IPageData.getRecords().stream().forEach(x -> {
//修改执行人属性
@@ -124,7 +115,7 @@ public class InspectionServiceImpl implements IInspectionService {
long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count();
problemsFoundNum = (int) (count + count1 + count2);
}
x.setFlag(0);
x.setFlag(1);
x.setProblemsFoundNum(problemsFoundNum);
x.setProblemsVerifiedNum(problemsVerifiedNum);
});
@@ -162,12 +153,7 @@ public class InspectionServiceImpl implements IInspectionService {
long count2 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count();
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.setProblemsVerifiedNum(problemsVerifiedNum);
});
@@ -177,10 +163,7 @@ public class InspectionServiceImpl implements IInspectionService {
}
}
}

pageDataVo.setRecords(inspectionInfoVoList);


return JsonResult.success(pageDataVo);
}

@@ -241,7 +224,6 @@ public class InspectionServiceImpl implements IInspectionService {

}


/**
* 递归获取部门的子集
*

+ 165
- 222
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java Прегледај датотеку

@@ -142,25 +142,18 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
*/
@Override
public JsonResult getTodoList(WorkOrderQuery query) {
log.info("获取代办工单列表,query={}", query);
if (query.getLimit() == null && query.getPage() == 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);
//获取分页数据
IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit());
@@ -174,101 +167,109 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
}
query.setOrderStartTime(startTime);
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.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;
}

/**
@@ -364,21 +365,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
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();
if (null == tenantId) {
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg());
}
query.setTenantId(tenantId);
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户
Integer type = user.getDataPermission();
@@ -400,8 +388,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>()
.eq(WorkOrder::getStatus, 15)
.eq(WorkOrder::getTenantId, tenantId)
.eq(WorkOrder::getAssignUser, user.getId())
.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));
//设置每条工单对应的已完成问题数量 问题状态为25问题已处理
List<WorkOrderInfoVo> collect = workPageData.getRecords().stream().map(s -> {
@@ -616,21 +605,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
@Override
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();
if (StringUtils.isEmpty(tenantId)) {
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg());
}
//用户角色
Integer type = user.getDataPermission();
if (null == type) {
@@ -644,48 +624,35 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
if (null == endTime || null == startTime) {
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);
}

@@ -697,21 +664,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
@Override
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();
if (StringUtils.isEmpty(tenantId)) {
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(), WorkOrderEnum.TENANT_ID_IS_NULL.getMsg());
}
//用户角色
Integer type = user.getDataPermission();
if (null == type) {
@@ -732,48 +690,33 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
if (null == endTime || null == beginTime) {
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);
}


+ 2
- 2
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/WorkOrderInfoVo.java Прегледај датотеку

@@ -26,8 +26,8 @@ public class WorkOrderInfoVo {
/**
* 创建时间
*/
@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;

/**

Loading…
Откажи
Сачувај