Просмотр исходного кода

问题类型占比改为动态返回数据

tags/V1.3.3
wanjing 1 год назад
Родитель
Сommit
f1fa8ec3ad
3 измененных файлов: 95 добавлений и 84 удалений
  1. +17
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/QuestionTypeConverMapper.java
  2. +24
    -84
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileListByDeptUserTypeService.java
  3. +54
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/QuestionTypeVo.java

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

}

+ 24
- 84
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFileListByDeptUserTypeService.java Просмотреть файл

@@ -2,7 +2,9 @@ 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;
@@ -17,6 +19,7 @@ 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;
@@ -59,30 +62,14 @@ public class QueryInspectionFileListByDeptUserTypeService {
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;

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()) {
//直接查问题列表
@@ -119,71 +106,24 @@ public class QueryInspectionFileListByDeptUserTypeService {
log.info("问题列表为空");
return JsonResult.success();
}
for (InspectionFile inspectionFile : inspectionFileList) {
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) {
log.info("问题类型为空");
return JsonResult.success();
}
//查找问题类型
QuestionType questionType = questionTypeMapper.selectOne(Wrappers.<QuestionType>lambdaQuery()
.eq(QuestionType::getMark, 1)
.eq(QuestionType::getCode, inspectionFile.getQuestionCode()));
if (ObjectUtil.isNull(questionType)) {
log.info("问题类型不存在, questionCode={}", inspectionFile.getQuestionCode());
return JsonResult.success();

List<QuestionTypeVo> questionTypeVoList = QuestionTypeConverMapper.INSTANCE.fromUListToVoList(questionTypeList);
for (QuestionTypeVo questionTypeVo : questionTypeVoList) {
if (ObjectUtil.isEmpty(questionTypeVo.getNum())) {
questionTypeVo.setNum(0);
}
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;
for (InspectionFile inspectionFile : inspectionFileList) {
if (StringUtils.isEmpty(inspectionFile.getQuestionCode())) {
log.info("问题类型为空");
continue;
}
if (questionTypeVo.getCode().equals(inspectionFile.getQuestionCode())) {
questionTypeVo.setNum(questionTypeVo.getNum() + 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);
}

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

}

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

Загрузка…
Отмена
Сохранить