Przeglądaj źródła

删除以前的从excel读取报告数据的接口

4228306 6 lat temu
rodzic
commit
32df852e26

+ 0 - 62
src/main/java/edu/math/diagnosis/controller/ExcelReportController.java

@@ -1,62 +0,0 @@
-package edu.math.diagnosis.controller;
-
-import edu.math.diagnosis.model.GeneralInfo;
-import edu.math.diagnosis.model.Report;
-import edu.math.diagnosis.word.ExcelUtils;
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@Api(tags = "获取报告信息 马上废弃")
-@RestController
-@RequestMapping("/getTempPapers")
-//@PreAuthorize("hasRole('ROLE_ADMIN')")
-public class ExcelReportController {
-
-    @Resource
-    private ExcelUtils excelUtils;
-
-    @RequestMapping(value = "/getGeneralInfo", method = RequestMethod.GET)
-    public GeneralInfo getCorrectInfo() {
-        GeneralInfo info = new GeneralInfo();
-        info.setCorrectOptions(excelUtils.getCorrectAns());
-        info.setRates(excelUtils.getCorrectRate());
-        info.setAbilityAveScore(excelUtils.getAbilityAveScore());
-        info.setCurveGraph(excelUtils.getCurveGraph());
-
-        return info;
-    }
-
-    @RequestMapping(value = "/getReportData", method = RequestMethod.GET)
-    public List<Report> getPaperData() {
-        List<Report> reports = new ArrayList<>(81);
-        List<String> names = excelUtils.getNames();
-        Map<String, List<String>> optionMap = excelUtils.getOptions();
-        Map<String, List<Integer>> optionRwMap = excelUtils.getOptionRw();
-        Map<String, List<String>> optionCommentMap = excelUtils.getOptionCommentMap(optionRwMap);
-        Map<String, List<Integer>> abilityLevelMap = excelUtils.getAbilityLevel();
-        Map<String, List<Double>> abilityScoreMap = excelUtils.getAbilityScore();
-        Map<String, List<String>> abilityCommentMap = excelUtils.getAbilityWords(abilityLevelMap, abilityScoreMap);
-        Map<String, Integer> scoreMap = excelUtils.getTotalScore();
-        for (String name : names) {
-            Report report = new Report();
-            report.setName(name);
-            report.setOptions(optionMap.get(name));
-            report.setAbilityComments(abilityCommentMap.get(name));
-            report.setAbilityLevel(abilityLevelMap.get(name));
-            report.setRw(optionRwMap.get(name));
-            report.setComments(optionCommentMap.get(name));
-            report.setAbilityScore(abilityScoreMap.get(name));
-            report.setTotalScore(scoreMap.get(name));
-            reports.add(report);
-        }
-
-        return reports;
-    }
-}

+ 0 - 87
src/main/java/edu/math/diagnosis/model/Report.java

@@ -1,87 +0,0 @@
-package edu.math.diagnosis.model;
-
-import java.util.List;
-
-public class Report {
-    private String name;
-    private String grade;
-    private Integer totalScore;
-    private List<Double> abilityScore;
-    private List<Integer> abilityLevel;
-    private List<String> abilityComments;//各项能力的评语
-    private List<Integer> rw;//每一题的对错
-    private List<String> comments;//每一题的评语
-    private List<String> options;//每一题学生所选的选项
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getGrade() {
-        return grade;
-    }
-
-    public void setGrade(String grade) {
-        this.grade = grade;
-    }
-
-    public Integer getTotalScore() {
-        return totalScore;
-    }
-
-    public void setTotalScore(Integer totalScore) {
-        this.totalScore = totalScore;
-    }
-
-    public List<Double> getAbilityScore() {
-        return abilityScore;
-    }
-
-    public void setAbilityScore(List<Double> abilityScore) {
-        this.abilityScore = abilityScore;
-    }
-
-    public List<Integer> getAbilityLevel() {
-        return abilityLevel;
-    }
-
-    public void setAbilityLevel(List<Integer> abilityLevel) {
-        this.abilityLevel = abilityLevel;
-    }
-
-    public List<String> getAbilityComments() {
-        return abilityComments;
-    }
-
-    public void setAbilityComments(List<String> abilityComments) {
-        this.abilityComments = abilityComments;
-    }
-
-    public List<Integer> getRw() {
-        return rw;
-    }
-
-    public void setRw(List<Integer> rw) {
-        this.rw = rw;
-    }
-
-    public List<String> getComments() {
-        return comments;
-    }
-
-    public void setComments(List<String> comments) {
-        this.comments = comments;
-    }
-
-    public List<String> getOptions() {
-        return options;
-    }
-
-    public void setOptions(List<String> options) {
-        this.options = options;
-    }
-}

+ 0 - 314
src/main/java/edu/math/diagnosis/word/ExcelUtils.java

@@ -1,314 +0,0 @@
-package edu.math.diagnosis.word;
-
-import org.apache.poi.xssf.usermodel.XSSFRow;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-@Component
-public class ExcelUtils {
-
-    @Value("${dataPathname:doc/}")
-    private String dataPathname = "doc/";
-    private List<List<Double>> valves = new ArrayList<>();
-    private List<String> ability = new ArrayList<>();
-    private List<String> optionWords;
-    private Map<String, Map<Integer, String>> words;
-    private XSSFSheet sheet;
-
-    private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
-
-    @PostConstruct
-    private boolean init() {
-        logger.info("docpath: {} ", dataPathname);
-        InputStream is;
-        try {
-            is = new ClassPathResource(dataPathname + "Data.xlsx").getInputStream();
-        } catch (IOException e) {
-            logger.error("can not loaded data.xlsx", e);
-            return false;
-        }
-        try (XSSFWorkbook workbook = new XSSFWorkbook(is)) {
-            sheet = workbook.getSheetAt(0);
-            optionWords = getOptionWords();
-            words = getWords();
-            ability.addAll(words.keySet());
-            List<Double> valve = new ArrayList<>();
-            valve.add(3.3);
-            valve.add(6.7);
-            valve.add(9.0);
-            valves.add(valve);
-            valve = new ArrayList<>();
-            valve.add(2.0);
-            valve.add(6.7);
-            valve.add(9.0);
-            valves.add(valve);
-            valve = new ArrayList<>();
-            valve.add(3.2);
-            valve.add(6.7);
-            valve.add(9.0);
-            valves.add(valve);
-            valve = new ArrayList<>();
-            valve.add(1.7);
-            valve.add(6.7);
-            valve.add(9.0);
-            valves.add(valve);
-            valve = new ArrayList<>();
-            valve.add(3.4);
-            valve.add(6.7);
-            valve.add(9.0);
-            valves.add(valve);
-            valve = new ArrayList<>();
-            valve.add(2.3);
-            valve.add(6.7);
-            valves.add(valve);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-        return true;
-    }
-
-    public static void main(String[] args) throws IOException {
-        System.out.println(System.getProperty("user.dir"));
-        ExcelUtils excelUtils = new ExcelUtils();
-        Map map1 = excelUtils.getAbilityLevel();
-        Map map2 = excelUtils.getAbilityScore();
-        Map map3 = excelUtils.getAbilityWords(map1, map2);
-        System.out.println();
-    }
-
-    public List<String> getLines(String pathname) throws IOException {
-//        File file = new File(pathname);
-        InputStream fis = new ClassPathResource(pathname).getInputStream();
-        InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
-        BufferedReader br = new BufferedReader(isr);
-        String line;
-        List<String> lines = new ArrayList<>();
-        while ((line = br.readLine()) != null) {
-            lines.add(line);
-        }
-        br.close();
-        isr.close();
-        fis.close();
-        return lines;
-    }
-
-    public Map<String, Map<Integer, String>> getWords() throws IOException {
-        Map<String, Map<Integer, String>> result = new LinkedHashMap<>();
-        List<String> lines = getLines(dataPathname + "word.txt");
-        int cnt = 0;
-        for (int i = 1; i <= 6; i++) {
-            Map<Integer, String> map = new LinkedHashMap<>();
-            String key = lines.get(cnt++);
-            for (int j = 1; j <= 7; j++) {
-                map.put(j, lines.get(cnt++));
-            }
-            result.put(key, map);
-        }
-        return result;
-    }
-
-    public List<String> getOptionWords() throws IOException {
-        return getLines(dataPathname + "option.txt");
-    }
-
-    public Map<String, List<Integer>> getAbilityLevel() {
-        Map<String, List<Integer>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        for (int i = 1; i <= 20; i++) {
-            List<Integer> values = new ArrayList<>(6);
-            for (int j = 50; j <= 55; j++) {
-                values.add((int) Math.round(sheet.getRow(j).getCell(i).getNumericCellValue()));
-            }
-            result.put(names.get(i - 1), values);
-        }
-        return result;
-    }
-
-    public List<Double> getCorrectRate() {
-        List<Double> rates = new ArrayList<>(20);
-        for (int i = 27; i < 47; i++) {
-            XSSFRow row = sheet.getRow(i);
-            rates.add(row.getCell(0).getNumericCellValue());
-        }
-        return rates;
-    }
-
-    public Map<String, List<Double>> getAbilityScore() {
-        Map<String, List<Double>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        for (int i = 1; i <= 20; i++) {
-            List<Double> values = new ArrayList<>(6);
-            for (int j = 58; j <= 63; j++) {
-                values.add(sheet.getRow(j).getCell(i).getNumericCellValue());
-            }
-            result.put(names.get(i - 1), values);
-        }
-        return result;
-    }
-
-    public Map<String, List<String>> getPaperOptions() {
-        Map<String, List<String>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        int cnt = 1;
-        for (String name : names) {
-            List<String> options = new ArrayList<>(20);
-            for (int i = 6; i < 26; i++) {
-                options.add(sheet.getRow(i).getCell(cnt).getStringCellValue());
-            }
-            result.put(name, options);
-            cnt++;
-        }
-        return result;
-    }
-
-    public Map<String, List<Integer>> getOptionRw() {
-        Map<String, List<Integer>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        int cnt = 1;
-        for (String name : names) {
-            List<Integer> rw = new ArrayList<>(20);
-            for (int i = 27; i < 47; i++) {
-                rw.add((int) Math.round(sheet.getRow(i).getCell(cnt).getNumericCellValue()));
-            }
-            cnt++;
-            result.put(name, rw);
-        }
-        return result;
-    }
-
-    public Map<String, List<String>> getOptionCommentMap(Map<String, List<Integer>> optionMap) {
-        Map<String, List<String>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        for (String name : names) {
-            List<Integer> options = optionMap.get(name);
-            List<String> comments = new ArrayList<>(20);
-            for (int i = 0; i < 20; i++) {
-                comments.add(optionWords.get(2 * i + 1 - options.get(i)));
-            }
-            result.put(name, comments);
-        }
-        return result;
-    }
-
-    public Map<String, List<String>> getAbilityWords(Map<String, List<Integer>> levels, Map<String, List<Double>> scores) {
-        Map<String, List<String>> result = new LinkedHashMap<>();
-        for (String key : levels.keySet()) {
-            List<Integer> level = levels.get(key);
-            List<Double> score = scores.get(key);
-            List<String> word = new ArrayList<>();
-            for (int i = 0; i < 6; i++) {
-                int l = level.get(i);
-                double s = score.get(i);
-                List<Double> valve = valves.get(i);
-                if (l == 0) {
-                    word.add(words.get(ability.get(i)).get(1));
-                } else {
-                    if (s >= valve.get(l - 1)) {
-                        word.add(words.get(ability.get(i)).get(2 * l + 1));
-                    } else {
-                        word.add(words.get(ability.get(i)).get(2 * l));
-                    }
-                }
-            }
-            result.put(key, word);
-        }
-        return result;
-    }
-
-    public List<String> getNames() {
-        List<String> names = new ArrayList<>();
-        XSSFRow row = sheet.getRow(1);
-        int num = row.getLastCellNum();
-        for (short i = 1; i < num; i++) {
-            names.add(row.getCell(i).getStringCellValue());
-        }
-        return names;
-    }
-
-    public List<String> getSchools() {
-        List<String> shcools = new ArrayList<>();
-        XSSFRow row = sheet.getRow(3);
-        int num = row.getLastCellNum();
-        for (short i = 1; i < num; i++) {
-            shcools.add(row.getCell(i).getStringCellValue());
-        }
-        return shcools;
-    }
-
-    public List<String> getTeachers() {
-        List<String> teachers = new ArrayList<>();
-        XSSFRow row = sheet.getRow(4);
-        int num = row.getLastCellNum();
-        for (short i = 1; i < num; i++) {
-            teachers.add(row.getCell(i).getStringCellValue());
-        }
-        return teachers;
-    }
-
-    public List<Double> getAbilityAveScore() {
-        List<Double> result = new ArrayList<>(6);
-        for (int i = 89; i < 95; i++) {
-            result.add(sheet.getRow(i).getCell(1).getNumericCellValue());
-        }
-        return result;
-    }
-
-    public List<Double> getCurveGraph() {
-        List<Double> result = new ArrayList<>(101);
-        for (int i = 90; i < 191; i++) {
-            result.add(sheet.getRow(i).getCell(4).getNumericCellValue());
-        }
-        return result;
-    }
-
-    public List<String> getCorrectAns() {
-        List<String> ans = new ArrayList<>(20);
-        for (int i = 6; i <= 25; i++) {
-            XSSFRow row = sheet.getRow(i);
-            ans.add(row.getCell(0).getStringCellValue());
-        }
-        return ans;
-    }
-
-    public Map<String, Integer> getTotalScore() {
-        Map<String, Integer> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        int cnt = 1;
-        int row = 48;
-        for (String name : names) {
-            int score = (int) sheet.getRow(row).getCell(cnt++).getNumericCellValue();
-            result.put(name, score);
-        }
-        return result;
-    }
-
-    public Map<String, List<String>> getOptions() {
-        Map<String, List<String>> result = new LinkedHashMap<>();
-        List<String> names = getNames();
-        for (int i = 1; i <= 20; i++) {
-            List<String> options = new ArrayList<>(20);
-            for (int j = 6; j <= 25; j++) {
-                options.add(sheet.getRow(j).getCell(i).getStringCellValue());
-            }
-            result.put(names.get(i - 1), options);
-        }
-        return result;
-    }
-}