@@ -1,12 +1,20 @@ | |||
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.service.IDspService; | |||
import com.tuoheng.admin.service.IQuestionTypeService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.system.utils.ShiroUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* 巡检问题表 前端控制器 | |||
* | |||
@@ -18,14 +26,14 @@ import org.springframework.web.bind.annotation.*; | |||
public class QuestionTypeController { | |||
@Autowired | |||
private IDspService dspService; | |||
private IQuestionTypeService questionTypeService; | |||
/** | |||
* 获取巡检问题列表 | |||
*/ | |||
@GetMapping("") | |||
public JsonResult getQuestionType() { | |||
return JsonResult.success(dspService.getQuestionType()); | |||
return JsonResult.success(questionTypeService.list()); | |||
} | |||
@@ -23,19 +23,19 @@ public class QuestionType extends BaseEntity implements Serializable { | |||
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; | |||
/** | |||
* 排序 |
@@ -7,28 +7,28 @@ import lombok.Getter; | |||
*/ | |||
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.description = description; | |||
this.content = description; | |||
} | |||
@Getter | |||
private Integer code; | |||
private String code; | |||
@Getter | |||
private String description; | |||
private String content; | |||
public static QuestionTypeEnum getByDesc(String description){ | |||
public static QuestionTypeEnum getByDesc(String content){ | |||
for (QuestionTypeEnum questionType : values()) { | |||
if(questionType.getDescription().equals(description)){ | |||
if(questionType.getContent().equals(content)){ | |||
return questionType; | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
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,11 +6,15 @@ import com.tuoheng.admin.entity.domain.QuestionType; | |||
import com.tuoheng.admin.entity.request.QuestionQuery; | |||
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> { | |||
List<QuestionType> getQuestionType(); | |||
} |
@@ -9,6 +9,7 @@ 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.domain.ThInspection; | |||
import com.tuoheng.admin.entity.domain.ThMission; | |||
import com.tuoheng.admin.entity.request.*; | |||
@@ -18,8 +19,8 @@ import com.tuoheng.admin.enums.*; | |||
import com.tuoheng.admin.mapper.QuestionMapper; | |||
import com.tuoheng.admin.mapper.ThInspectionMapper; | |||
import com.tuoheng.admin.mapper.ThMissionMapper; | |||
import com.tuoheng.admin.service.IDspService; | |||
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.JsonResult; | |||
@@ -30,10 +31,7 @@ import org.springframework.http.HttpStatus; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.CollectionUtils; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 巡检问题表 服务实现类 | |||
@@ -54,7 +52,7 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
private ThInspectionMapper inspectionMapper; | |||
@Autowired | |||
private IDspService dspService; | |||
private IQuestionTypeService questionTypeService; | |||
//private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
@@ -178,16 +176,15 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
//content | |||
//添加问题的分类 | |||
JSONArray questionTypeList=new JSONArray(); | |||
List<QuestionType> questionTypeList=new ArrayList<>(); | |||
try { | |||
questionTypeList = dspService.getQuestionType(); | |||
questionTypeList = questionTypeService.getQuestionType(); | |||
}catch (Exception e){ | |||
e.printStackTrace(); | |||
} | |||
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) { | |||
questionTypeCountVO.setContent(codeMap.get(questionTypeCountVO.getType())); | |||
@@ -264,6 +261,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
if(ObjectUtil.isEmpty(questionFiles)){ | |||
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) { | |||
Question question=new Question(UpdateOrCreateEnum.CREATE.getCode()); | |||
ThInspection flightDataByTime = getFlightDataByTime(flightDataList, questionFile.getAnalyseTime().getTime()); | |||
@@ -274,8 +277,10 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
//待确认 | |||
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); | |||
questionList.add(question); | |||
} |
@@ -0,0 +1,37 @@ | |||
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(); | |||
} | |||
} |