|
|
|
package com.supervision.controller;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
|
import cn.hutool.extra.pinyin.PinyinUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
|
import com.supervision.model.AskDiseaseQuestionAnswer;
|
|
|
|
import com.supervision.model.AskTemplateQuestion;
|
|
|
|
import com.supervision.model.ConfigPhysicalTool;
|
|
|
|
import com.supervision.service.AskDiseaseQuestionAnswerService;
|
|
|
|
import com.supervision.service.AskTemplateQuestionService;
|
|
|
|
import com.supervision.service.ConfigPhysicalToolService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("test")
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class TestController {
|
|
|
|
|
|
|
|
private final ConfigPhysicalToolService configPhysicalToolService;
|
|
|
|
|
|
|
|
@GetMapping("testExpireTime")
|
|
|
|
public String testExpireTime() {
|
|
|
|
return "OK";
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("testQueryJSON")
|
|
|
|
public List<ConfigPhysicalTool> testQueryJSON() {
|
|
|
|
return configPhysicalToolService.list();
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("saveQuestion")
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void saveQuestion() {
|
|
|
|
ExcelReader reader = ExcelUtil.getReader("/Users/flevance/Desktop/template.xlsx");
|
|
|
|
List<List<Object>> read = reader.read();
|
|
|
|
for (List<Object> readLine : read) {
|
|
|
|
String desc = (String) readLine.get(0);
|
|
|
|
String pinyin = PinyinUtil.getPinyin((String) readLine.get(0), "_");
|
|
|
|
String question = (String) readLine.get(1);
|
|
|
|
|
|
|
|
String answer = (String) readLine.get(2);
|
|
|
|
String otherQuestionStr = (String) readLine.get(3);
|
|
|
|
|
|
|
|
AskTemplateQuestion templateQuestion = new AskTemplateQuestion();
|
|
|
|
templateQuestion.setCode("ask_" + pinyin);
|
|
|
|
templateQuestion.setDescription(desc);
|
|
|
|
List<String> questionList = JSONUtil.toList(otherQuestionStr, String.class);
|
|
|
|
questionList.add(0, question);
|
|
|
|
templateQuestion.setQuestion(questionList);
|
|
|
|
templateQuestion.insert();
|
|
|
|
|
|
|
|
|
|
|
|
AskDiseaseQuestionAnswer askDiseaseQuestionAnswer = new AskDiseaseQuestionAnswer();
|
|
|
|
askDiseaseQuestionAnswer.setDiseaseId("1");
|
|
|
|
askDiseaseQuestionAnswer.setTemplateQuestionId(templateQuestion.getId());
|
|
|
|
askDiseaseQuestionAnswer.setAnswer(ListUtil.of(answer));
|
|
|
|
askDiseaseQuestionAnswer.insert();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|