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

部门信息简报饼状图

tags/v1.0.0^2
chengwang пре 1 година
родитељ
комит
4279fef8f1
6 измењених фајлова са 184 додато и 0 уклоњено
  1. +11
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionFileController.java
  2. +45
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspectionFile/ListByDeptUserTypeEnum.java
  3. +17
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/InspectionFileQuery.java
  4. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/IInspectionFileService.java
  5. +87
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/InspectionFileServiceImpl.java
  6. +21
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/ListByDeptUserTypeVo.java

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

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

import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.admin.service.IInspectionFileService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,5 +28,15 @@ public class InspectionFileController {
return iInspectionFileService.getQuestionList();
}

/**
* 根据登录人角色获取该部门及子部门下问题列表
* @param query
* @return
*/
@GetMapping("/listByDeptUserType")
public JsonResult getListByDeptUserType(InspectionFileQuery query){
return iInspectionFileService.getListByDeptUserType(query);
}


}

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

@@ -0,0 +1,45 @@
package com.tuoheng.admin.enums.code.inspectionFile;

/**
* @Author ChengWang
* @Date 2022/12/2
*/
public enum ListByDeptUserTypeEnum {

QUERY_IS_FAILED(1100300, "获取数据失败"),
USER_NAME_IS_NULL(1100301, "登录用户名为空"),
USER_IS_NULL(1100302, "用户不存在"),
INSPECTION_TYPE_LIST_IS_NULL(1100303, "问题列表为空"),
QUESTION_ID_IS_NULL(1100304, "问题列表为空");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

ListByDeptUserTypeEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}
}

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

@@ -0,0 +1,17 @@
package com.tuoheng.admin.query;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2022/12/2
*/
@Data
public class InspectionFileQuery {

/**
* 用户id
*/
private String userId;

}

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

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

import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.common.core.utils.JsonResult;

/**
@@ -8,4 +9,6 @@ import com.tuoheng.common.core.utils.JsonResult;
*/
public interface IInspectionFileService {
JsonResult getQuestionList();

JsonResult getListByDeptUserType(InspectionFileQuery query);
}

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

@@ -1,17 +1,27 @@
package com.tuoheng.admin.service.impl;

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.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.UserTypeEnum;
import com.tuoheng.admin.enums.code.inspectionFile.ListByDeptUserTypeEnum;
import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.QuestionTypeMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.admin.service.IInspectionFileService;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.admin.vo.InspectionFileVo;
import com.tuoheng.admin.vo.ListByDeptUserTypeVo;
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.SecurityUserUtils;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
@@ -42,6 +52,10 @@ public class InspectionFileServiceImpl implements IInspectionFileService {
@Autowired
private QuestionTypeMapper questionTypeMapper;

@Autowired
private UserMapper userMapper;



/**
* 问题类型和任务名称
@@ -95,5 +109,78 @@ public class InspectionFileServiceImpl implements IInspectionFileService {
return JsonResult.success(list);
}

@Override
public JsonResult getListByDeptUserType(InspectionFileQuery query) {
if(query.getUserId()==null){
JsonResult.error(ListByDeptUserTypeEnum.QUERY_IS_FAILED.getCode(),ListByDeptUserTypeEnum.QUERY_IS_FAILED.getMsg());
}
//获取当前登录人信息
String username = SecurityUserUtils.username();
if(StringUtils.isEmpty(username)){
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg());
}
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getMark, 1).eq(User::getUsername, username));
if(ObjectUtil.isNull(user)){
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
}
String tenantId = ShiroUtils.getTenantId();
//用户角色判断 1超级管理员 2部门管理员 3普通用户
if(null == user.getType()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
List<ListByDeptUserTypeVo> list = new ArrayList<>();
ListByDeptUserTypeVo vo = new ListByDeptUserTypeVo();
//问题数量
Long count = 0l;
//若角色为超级管理员,查看状态为已生成工单和和问题已处理
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()){
//直接查问题列表
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getMark, 1)
.eq(InspectionFile::getTenantId, tenantId)
.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.getQuestionId())){
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::getId, inspectionFile.getQuestionId()));
if(ObjectUtil.isNull(questionType)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
Integer name = questionType.getName();
//1坑槽
if(name==1) {
count+=1;
vo.setType(1);
vo.setNum(count);
list.add(vo);
}
//
if(name==2){

}
//
if(name==3){

}

}



}


return null;
}


}

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

@@ -0,0 +1,21 @@
package com.tuoheng.admin.vo;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2022/12/2
*/
@Data
public class ListByDeptUserTypeVo {

/**
* 问题类型:1坑槽,2积水,3裂缝
*/
private Integer type;

/**
* 问题数量
*/
private Long num;
}

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