|
|
@ -18,7 +18,6 @@ import com.supervision.manage.service.FileManageService;
|
|
|
|
import com.supervision.model.*;
|
|
|
|
import com.supervision.model.*;
|
|
|
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
|
|
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
|
|
|
import com.supervision.service.CommonDicService;
|
|
|
|
import com.supervision.service.CommonDicService;
|
|
|
|
import com.supervision.util.RedisSequenceUtil;
|
|
|
|
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryReqVo;
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryReqVo;
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryResVo;
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryResVo;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@ -37,6 +36,7 @@ import java.io.InputStream;
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -82,36 +82,40 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
public String saveQuestionLibrary(AskTemplateQuestionLibrary askTemplateQuestionLibrary) {
|
|
|
|
public String saveQuestionLibrary(AskTemplateQuestionLibrary askTemplateQuestionLibrary) {
|
|
|
|
assertSave(askTemplateQuestionLibrary);
|
|
|
|
assertSave(askTemplateQuestionLibrary);
|
|
|
|
|
|
|
|
|
|
|
|
String nextCode = RedisSequenceUtil.getQuestionLibraryCode(() -> {
|
|
|
|
CommonDic commonDic = commonDicService.lambdaQuery().eq(CommonDic::getId, askTemplateQuestionLibrary.getDictId()).one();
|
|
|
|
String maxCode = askTemplateQuestionLibraryService.getMaxCode();
|
|
|
|
Assert.notNull(commonDic,"字典信息不存在");
|
|
|
|
if (StrUtil.isNotEmpty(maxCode)) {
|
|
|
|
// 不存在,则新增
|
|
|
|
return Long.parseLong(StrUtil.removePrefix(maxCode, "Q"));
|
|
|
|
AskTemplateQuestionLibrary one = askTemplateQuestionLibraryService.lambdaQuery().eq(AskTemplateQuestionLibrary::getDictId, askTemplateQuestionLibrary.getDictId()).one();
|
|
|
|
}
|
|
|
|
if (Objects.nonNull(one)){
|
|
|
|
return null;
|
|
|
|
// 更新数据
|
|
|
|
});
|
|
|
|
List<String> question = one.getQuestion();
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(question)){
|
|
|
|
String nextDefaultCode = RedisSequenceUtil.getQuestionLibraryDefaultAnswerCode(() -> {
|
|
|
|
question = CollUtil.newArrayList(askTemplateQuestionLibrary.getDescription());
|
|
|
|
String code = askTemplateQuestionLibraryService.getMaxDefaultAnswerCode();
|
|
|
|
}else if (!question.contains(askTemplateQuestionLibrary.getDescription())){
|
|
|
|
if (StrUtil.isNotEmpty(code)) {
|
|
|
|
question.add(askTemplateQuestionLibrary.getDescription());
|
|
|
|
return Long.parseLong(StrUtil.removePrefix(code, "A"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
one.setQuestion(question);
|
|
|
|
return null;
|
|
|
|
one.setDefaultAnswer(askTemplateQuestionLibrary.getDefaultAnswer());
|
|
|
|
});
|
|
|
|
askTemplateQuestionLibraryService.updateById(one);
|
|
|
|
|
|
|
|
return one.getId();
|
|
|
|
askTemplateQuestionLibrary.setCode(nextCode);
|
|
|
|
}else {
|
|
|
|
askTemplateQuestionLibrary.setDefaultAnswerCode(nextDefaultCode);
|
|
|
|
// 新增数据
|
|
|
|
askTemplateQuestionLibrary.setQuestion(CollUtil.newArrayList(askTemplateQuestionLibrary.getDescription()));
|
|
|
|
askTemplateQuestionLibrary.setQuestion(CollUtil.newArrayList(askTemplateQuestionLibrary.getDescription()));
|
|
|
|
askTemplateQuestionLibraryService.save(askTemplateQuestionLibrary);
|
|
|
|
if (StrUtil.isBlank(commonDic.getDescription())){
|
|
|
|
|
|
|
|
askTemplateQuestionLibrary.setDescription(commonDic.getDescription());
|
|
|
|
|
|
|
|
askTemplateQuestionLibrary.getQuestion().add(commonDic.getDescription());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
askTemplateQuestionLibraryService.updateById(askTemplateQuestionLibrary);
|
|
|
|
return askTemplateQuestionLibrary.getId();
|
|
|
|
return askTemplateQuestionLibrary.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateQuestionLibrary(AskTemplateQuestionLibrary askTemplateQuestionLibrary) {
|
|
|
|
public boolean updateQuestionLibrary(AskTemplateQuestionLibrary askTemplateQuestionLibrary) {
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getId(),"id不能为空");
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getId(),"id不能为空");
|
|
|
|
assertSave(askTemplateQuestionLibrary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
askTemplateQuestionLibrary.setQuestion(CollUtil.newArrayList(askTemplateQuestionLibrary.getDescription()));
|
|
|
|
assertSave(askTemplateQuestionLibrary);
|
|
|
|
return askTemplateQuestionLibraryService.updateById(askTemplateQuestionLibrary);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -134,6 +138,7 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
assertTitle(reader);
|
|
|
|
assertTitle(reader);
|
|
|
|
|
|
|
|
|
|
|
|
List<UploadQuestionLibraryDTO> uploadQuestionLibraryDTOS = reader.readAll(UploadQuestionLibraryDTO.class);
|
|
|
|
List<UploadQuestionLibraryDTO> uploadQuestionLibraryDTOS = reader.readAll(UploadQuestionLibraryDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
questionExcelDoAction(uploadQuestionLibraryDTOS);
|
|
|
|
questionExcelDoAction(uploadQuestionLibraryDTOS);
|
|
|
|
|
|
|
|
|
|
|
|
// 更新知识库
|
|
|
|
// 更新知识库
|
|
|
@ -178,7 +183,8 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertSave(AskTemplateQuestionLibrary askTemplateQuestionLibrary){
|
|
|
|
private void assertSave(AskTemplateQuestionLibrary askTemplateQuestionLibrary){
|
|
|
|
//Assert.notNull(askTemplateQuestionLibrary.getDictId(),"问题类目不能为空");
|
|
|
|
// 问题类目不能为空
|
|
|
|
|
|
|
|
Assert.notNull(askTemplateQuestionLibrary.getDictId(),"问题类目不能为空");
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDescription(),"问题不能为空");
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDescription(),"问题不能为空");
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDefaultAnswer(),"默认回答不能为空");
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDefaultAnswer(),"默认回答不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -222,8 +228,8 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
// 查询问题库问题
|
|
|
|
// 查询问题库问题
|
|
|
|
List<AskTemplateQuestionLibrary> questionLibraryList = askTemplateQuestionLibraryService.list();
|
|
|
|
List<AskTemplateQuestionLibrary> questionLibraryList = askTemplateQuestionLibraryService.list();
|
|
|
|
// 查询类目字段
|
|
|
|
// 查询类目字段
|
|
|
|
//List<CommonDic> questionTypeDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
|
|
|
List<CommonDic> questionTypeDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
|
|
|
uploadQuestionLibraryDTOS.forEach(dto->dto.doAction(questionLibraryList,CollUtil.newArrayList()));
|
|
|
|
uploadQuestionLibraryDTOS.forEach(dto->dto.doAction(questionLibraryList,questionTypeDicList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|