manage :添加 导入问题库信息 功能
parent
cb9088931a
commit
ba9c67e80f
@ -0,0 +1,169 @@
|
||||
package com.supervision.manage.dto;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.supervision.model.AskTemplateQuestionLibrary;
|
||||
import com.supervision.model.CommonDic;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class UploadQuestionLibraryDTO {
|
||||
|
||||
/**
|
||||
* 问诊类目1
|
||||
*/
|
||||
@Alias(value = "问诊类目Ⅰ")
|
||||
private String questionTypeOne;
|
||||
|
||||
/**
|
||||
* 问诊类目2 对应于 vp_ask_template_question_library 表中的 dict_id对应的 name_zh
|
||||
*/
|
||||
@Alias(value = "问诊类目Ⅱ")
|
||||
private String questionTypeTwo;
|
||||
|
||||
/**
|
||||
* 问题
|
||||
*/
|
||||
@Alias(value = "* 知识")
|
||||
private String question;
|
||||
|
||||
/**
|
||||
* 回答
|
||||
*/
|
||||
@Alias(value = "* 回答")
|
||||
private String answer;
|
||||
|
||||
|
||||
@Alias(value = "错误信息")
|
||||
private static String errorReason;
|
||||
|
||||
private List<UploadQuestionLibraryDTO.ErrorCodeEnum> errorCodeEnums = new ArrayList<>();
|
||||
|
||||
private String dictId;
|
||||
|
||||
|
||||
public static final List<String> READ_ANSWER_VIDEO_TITLE = CollUtil.newArrayList("问诊类目Ⅰ", "问诊类目Ⅱ", "* 知识", "* 回答");
|
||||
|
||||
public static final List<String> WRITE_ANSWER_VIDEO_TITLE = CollUtil.newArrayList("问诊类目Ⅰ", "问诊类目Ⅱ", "* 知识", "* 回答","错误原因");
|
||||
|
||||
public static final Map<String,String> READ_HEADER_ALIAS = getReadAlias();
|
||||
|
||||
public static final Map<String,String> WRITE_HEADER_ALIAS = getWriteAlias();
|
||||
|
||||
|
||||
public void doAction(List<AskTemplateQuestionLibrary> questionLibraryList, List<CommonDic> questionTypeDicList){
|
||||
this.absentCheck();
|
||||
this.matchQuestion(questionLibraryList);
|
||||
this.matchQuestionDicId(questionTypeDicList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String,Object> toExcelMap(){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("questionTypeOne",this.questionTypeOne);
|
||||
map.put("questionTypeTwo",this.questionTypeTwo);
|
||||
map.put("question",this.question);
|
||||
map.put("answer",this.answer);
|
||||
if (CollUtil.isNotEmpty(errorCodeEnums)){
|
||||
String errorMessage = errorCodeEnums.stream().map(i -> i.desc).collect(Collectors.joining(";"));
|
||||
map.put("errorReason",errorMessage);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public void absentCheck(){
|
||||
/*if (StrUtil.isEmpty(questionTypeOne)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.QUESTION_TYPE_ONE_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(questionTypeTwo)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.QUESTION_TYPE_TWO_EMPTY);
|
||||
}*/
|
||||
if (StrUtil.isEmpty(question)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.QUESTION_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(answer)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.ANSWER_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配问题库
|
||||
* @param questionLibraryList 问题库
|
||||
*/
|
||||
public void matchQuestion(List<AskTemplateQuestionLibrary> questionLibraryList){
|
||||
if (StrUtil.isEmpty(this.question)){
|
||||
return;
|
||||
}
|
||||
for (AskTemplateQuestionLibrary questionLibrary : questionLibraryList) {
|
||||
String description = questionLibrary.getDescription();
|
||||
List<String> questionList = questionLibrary.getQuestion();
|
||||
if (this.question.equals(description)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.QUESTION_REPEAT);
|
||||
return;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(questionList) && questionList.contains(this.question)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.QUESTION_REPEAT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void matchQuestionDicId(List<CommonDic> questionTypeDicList){
|
||||
if (StrUtil.isEmpty(this.questionTypeTwo)){
|
||||
return;
|
||||
}
|
||||
if(CollUtil.isEmpty(questionTypeDicList)){
|
||||
errorCodeEnums.add(UploadQuestionLibraryDTO.ErrorCodeEnum.DICE_NOT_FIND);
|
||||
}
|
||||
|
||||
for (CommonDic questionTypeDic : questionTypeDicList) {
|
||||
if (this.questionTypeTwo.equals(questionTypeDic.getNameZh())){
|
||||
this.dictId = String.valueOf(questionTypeDic.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Map<String,String> getReadAlias(){
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("问诊类目Ⅰ","questionTypeOne");
|
||||
map.put("问诊类目Ⅱ", "questionTypeTwo");
|
||||
map.put("* 知识", "question");
|
||||
map.put("* 回答", "answer");
|
||||
System.out.println("init -----getReadAlias -----");
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String,String> getWriteAlias(){
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("questionTypeOne","问诊类目Ⅰ");
|
||||
map.put("questionTypeTwo", "问诊类目Ⅱ");
|
||||
map.put("question", "* 知识");
|
||||
map.put("answer", "* 回答");
|
||||
map.put("errorReason", "错误原因");
|
||||
return map;
|
||||
}
|
||||
public enum ErrorCodeEnum{
|
||||
QUESTION_TYPE_ONE_EMPTY("0001","问诊类目1不能为空"),
|
||||
QUESTION_TYPE_TWO_EMPTY("0002","问诊类目2不能为空"),
|
||||
QUESTION_EMPTY("0003","知识不能为空"),
|
||||
ANSWER_EMPTY("0004","回答不能为空"),
|
||||
ANSWER_VIDEO_NAME_EMPTY("0005","视频名称不能为空"),
|
||||
QUESTION_NOT_FIND("40001","知识未找到"),
|
||||
ANSWER_VIDEO_NAME_NOT_FIND("40002","视频不存在"),
|
||||
DICE_NOT_FIND("40003","类目字典码值未找到"),
|
||||
|
||||
QUESTION_REPEAT("50001","知识数据重复");
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
ErrorCodeEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.supervision.manage.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UploadQuestionLibraryResVo {
|
||||
|
||||
@ApiModelProperty("消息内容")
|
||||
private String message;
|
||||
|
||||
@ApiModelProperty("文件id")
|
||||
private String fileId;
|
||||
|
||||
@ApiModelProperty("模板是否正确 true:正确 false:错误")
|
||||
private boolean templateErrorFlag = true;
|
||||
}
|
Loading…
Reference in New Issue