Browse Source

问题类型修改

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
1d80580e28
7 changed files with 100 additions and 32 deletions
  1. +10
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionTypeController.java
  2. +6
    -6
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/QuestionType.java
  3. +10
    -10
      tuoheng-admin/src/main/java/com/tuoheng/admin/enums/QuestionTypeEnum.java
  4. +14
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionTypeMapper.java
  5. +6
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionTypeService.java
  6. +17
    -12
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  7. +37
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionTypeServiceImpl.java

+ 10
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionTypeController.java View File

package com.tuoheng.admin.controller; package com.tuoheng.admin.controller;


import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.tuoheng.admin.entity.domain.QuestionType;
import com.tuoheng.admin.entity.request.QuestionTypeQuery; import com.tuoheng.admin.entity.request.QuestionTypeQuery;
import com.tuoheng.admin.service.IDspService; import com.tuoheng.admin.service.IDspService;
import com.tuoheng.admin.service.IQuestionTypeService;
import com.tuoheng.common.utils.JsonResult; import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.utils.ShiroUtils; import com.tuoheng.system.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** /**
* 巡检问题表 前端控制器 * 巡检问题表 前端控制器
* *
public class QuestionTypeController { public class QuestionTypeController {


@Autowired @Autowired
private IDspService dspService;
private IQuestionTypeService questionTypeService;


/** /**
* 获取巡检问题列表 * 获取巡检问题列表
*/ */
@GetMapping("") @GetMapping("")
public JsonResult getQuestionType() { public JsonResult getQuestionType() {
return JsonResult.success(dspService.getQuestionType());
return JsonResult.success(questionTypeService.list());
} }





+ 6
- 6
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/QuestionType.java View File

private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;


/** /**
* 项目名称:1水面 2岸线 3水质 4排口
*问题编码
*/ */
private Integer name;
private String code;


/** /**
* 项目类型:1日常监测 2重点核查
*项目类型:林斑、病死树、人员活动、火灾隐患
*/ */
private String type;
private String content;


/** /**
* 巡检内容
* 问题描述
*/ */
private String content;
private String description;


/** /**
* 排序 * 排序

+ 10
- 10
tuoheng-admin/src/main/java/com/tuoheng/admin/enums/QuestionTypeEnum.java View File

*/ */
public enum QuestionTypeEnum { public enum QuestionTypeEnum {


Q1(1,"林场问题图斑"),
Q1("002000","林场问题图斑"),


Q2(2,"病死树"),
Q2("002001","病死树"),


Q3(3,"人员活动"),
Q3("002003","人员活动"),


Q4(4,"火灾隐患");
Q4("002004","火灾隐患");


QuestionTypeEnum(int code, String description){
QuestionTypeEnum(String code, String description){
this.code = code; this.code = code;
this.description = description;
this.content = description;
} }


@Getter @Getter
private Integer code;
private String code;


@Getter @Getter
private String description;
private String content;


public static QuestionTypeEnum getByDesc(String description){
public static QuestionTypeEnum getByDesc(String content){
for (QuestionTypeEnum questionType : values()) { for (QuestionTypeEnum questionType : values()) {
if(questionType.getDescription().equals(description)){
if(questionType.getContent().equals(content)){
return questionType; return questionType;
} }
} }

+ 14
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionTypeMapper.java View File

package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.domain.QuestionType;

import java.util.List;

/**
* 巡检问题表 Mapper 接口
*
* @author qiujinyang
* @since 2022-08-19
*/
public interface QuestionTypeMapper extends BaseMapper<QuestionType> {}

+ 6
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/service/IQuestionTypeService.java View File

import com.tuoheng.admin.entity.request.QuestionQuery; import com.tuoheng.admin.entity.request.QuestionQuery;
import com.tuoheng.common.common.IBaseService; import com.tuoheng.common.common.IBaseService;


import java.util.List;

/** /**
* 巡检问题表 服务类 * 巡检问题表 服务类
* *
* @author WangHaoran
* @since 2021-09-02
* @author qiujinyang
* @since 2022-8-19
*/ */
public interface IQuestionTypeService extends IBaseService<QuestionType> { public interface IQuestionTypeService extends IBaseService<QuestionType> {

List<QuestionType> getQuestionType();
} }

+ 17
- 12
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum; import com.tuoheng.admin.common.ServiceExceptionEnum;
import com.tuoheng.admin.entity.domain.Question; import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.QuestionType;
import com.tuoheng.admin.entity.domain.ThInspection; import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission; import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.*; import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.mapper.QuestionMapper; import com.tuoheng.admin.mapper.QuestionMapper;
import com.tuoheng.admin.mapper.ThInspectionMapper; import com.tuoheng.admin.mapper.ThInspectionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper; import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.service.IDspService;
import com.tuoheng.admin.service.IQuestionService; import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.admin.service.IQuestionTypeService;
import com.tuoheng.common.common.BaseServiceImpl; import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.exception.ServiceException; import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.JsonResult; import com.tuoheng.common.utils.JsonResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;


/** /**
* 巡检问题表 服务实现类 * 巡检问题表 服务实现类
private ThInspectionMapper inspectionMapper; private ThInspectionMapper inspectionMapper;


@Autowired @Autowired
private IDspService dspService;
private IQuestionTypeService questionTypeService;


//private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


//content //content


//添加问题的分类 //添加问题的分类
JSONArray questionTypeList=new JSONArray();
List<QuestionType> questionTypeList=new ArrayList<>();
try { try {
questionTypeList = dspService.getQuestionType();
questionTypeList = questionTypeService.getQuestionType();
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
Map<String,String> codeMap=new HashMap<>(); Map<String,String> codeMap=new HashMap<>();
for (Object questionTypeObject : questionTypeList) {
JSONObject question=(JSONObject)questionTypeObject;
codeMap.put(question.getString("code"),question.getString("content"));
for (QuestionType questionType : questionTypeList) {
codeMap.put(questionType.getCode(),questionType.getContent());
} }
for (QuestionTypeCountVO questionTypeCountVO : questionTypeCountList) { for (QuestionTypeCountVO questionTypeCountVO : questionTypeCountList) {
questionTypeCountVO.setContent(codeMap.get(questionTypeCountVO.getType())); questionTypeCountVO.setContent(codeMap.get(questionTypeCountVO.getType()));
if(ObjectUtil.isEmpty(questionFiles)){ if(ObjectUtil.isEmpty(questionFiles)){
return questionList; return questionList;
} }

List<QuestionType> questionType = questionTypeService.getQuestionType();
Map<String,QuestionType> typeMap=new HashMap<>();
for (QuestionType type : questionType) {
typeMap.put(type.getCode(),type);
}
for (CallbackRequest.QuestionFilesDTO questionFile : questionFiles) { for (CallbackRequest.QuestionFilesDTO questionFile : questionFiles) {
Question question=new Question(UpdateOrCreateEnum.CREATE.getCode()); Question question=new Question(UpdateOrCreateEnum.CREATE.getCode());
ThInspection flightDataByTime = getFlightDataByTime(flightDataList, questionFile.getAnalyseTime().getTime()); ThInspection flightDataByTime = getFlightDataByTime(flightDataList, questionFile.getAnalyseTime().getTime());
//待确认 //待确认
question.setStatus(QuestionStatusEnum.NOTREVIEWED.getCode()); question.setStatus(QuestionStatusEnum.NOTREVIEWED.getCode());
//问题类型 //问题类型
question.setType(questionFile.getQuestionCode());
question.setQuestionName(questionFile.getQuestionName());
QuestionType questionTypeInfo = typeMap.get(questionFile.getQuestionCode());
question.setType(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getCode():"");
question.setQuestionName(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getContent():"");
question.setQuestionDesc(ObjectUtil.isNotEmpty(questionTypeInfo)? questionTypeInfo.getDescription():"");
BeanUtils.copyProperties(questionFile,question); BeanUtils.copyProperties(questionFile,question);
questionList.add(question); questionList.add(question);
} }

+ 37
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionTypeServiceImpl.java View File

package com.tuoheng.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.QuestionType;
import com.tuoheng.admin.entity.request.QuestionQuery;
import com.tuoheng.admin.mapper.QuestionMapper;
import com.tuoheng.admin.mapper.QuestionTypeMapper;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.admin.service.IQuestionTypeService;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 巡检问题表 服务类
*
* @author qiujinyang
* @since 2022-8-19
*/
@Service
public class QuestionTypeServiceImpl extends BaseServiceImpl<QuestionTypeMapper, QuestionType> implements IQuestionTypeService {



@Override
public List<QuestionType> getQuestionType() {
return this.list();
}
}

Loading…
Cancel
Save