package cn.com.qmth.stmms.common.utils;


public class MarkerExcelParser {

	/* private static Logger log = LoggerFactory.getLogger(MarkerExcelParser.class);

    private Workbook wb;

    public MarkerExcelParser(InputStream ins) throws BiffException, IOException {
        this.wb = Workbook.getWorkbook(ins);
    }

    public List<Marker> parseMarker() {
        List<Marker> list = new LinkedList<Marker>();
        Sheet[] sheets = wb.getSheets();
        if (sheets != null && sheets.length > 0) {
            Sheet rs = wb.getSheet(0);
            // 获得行数，列数
            int rowCount = rs.getRows();
            int colCount = rs.getColumns();
            if (colCount > 0) {
                for (int i = 1; i < rowCount; i++) {
                    try {
                        Marker marker = new Marker();
                        Integer subjectId = null;
                        String subjectName = StringUtils.trimToNull(rs.getCell(0, i).getContents());
                        if (subjectName.equals("语文")) {
                            subjectId = 1;
                        } else if (subjectName.equals("数学")) {
                            subjectId = 2;
                        } else if (subjectName.equals("英语")) {
                            subjectId = 3;
                        } else if (subjectName.equals("物理")) {
                            subjectId = 4;
                        } else if (subjectName.equals("化学")) {
                            subjectId = 5;
                        } else if (subjectName.equals("生物")) {
                            subjectId = 6;
                        } else if (subjectName.equals("政治")) {
                            subjectId = 7;
                        } else if (subjectName.equals("历史")) {
                            subjectId = 8;
                        } else if (subjectName.equals("地理")) {
                            subjectId = 9;
                        }
                        marker.setSubjectId(subjectId);
                        String classTypeContent = StringUtils.trimToNull(rs.getCell(1, i).getContents());
                        if (classTypeContent != null) {
                            if (ClassType.BASE.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.BASE);
                            } else if (ClassType.ART.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.ART);
                            } else if (ClassType.SCIENCE.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.SCIENCE);
                            } else if (StringUtils.isNumeric(classTypeContent)) {
                                marker.setClassType(ClassType.findByValue(Integer.valueOf(classTypeContent)));
                            }
                        }
                        marker.setCode(StringUtils.trimToNull(rs.getCell(2, i).getContents()));
                        marker.setName(StringUtils.trimToNull(rs.getCell(3, i).getContents()));
                        marker.setPassword(StringUtils.trimToNull(rs.getCell(4, i).getContents()));
                        marker.setLastLoginTime(new Date());
                        marker.setMarkCount(0);
                        marker.setMarkStage(MarkStage.WAITING);
                        String status = StringUtils.trimToNull(rs.getCell(5, i).getContents());
                        if (status.equals("是")) {
                            marker.setStatus(1);
                        } else if (status.equals("否")) {
                            marker.setStatus(0);
                        }
                        list.add(marker);
                    } catch (Exception e) {
                        log.error("MarkerExcelParser-parseMarker", e);
                        continue;
                    }
                }
            }
        }
        return list;
    }

    public List<Marker> parseMarker(int examId) {
        List<Marker> list = new LinkedList<Marker>();
        Sheet[] sheets = wb.getSheets();
        if (sheets != null && sheets.length > 0) {
            Sheet rs = wb.getSheet(0);
            // 获得行数，列数
            int rowCount = rs.getRows();
            int colCount = rs.getColumns();
            if (colCount > 0) {
                for (int i = 1; i < rowCount; i++) {
                    try {
                        Marker marker = new Marker();
                        Integer subjectId = null;
                        String subjectName = StringUtils.trimToNull(rs.getCell(0, i).getContents());
                        if (subjectName.equals("语文")) {
                            subjectId = 1;
                        } else if (subjectName.equals("数学")) {
                            subjectId = 2;
                        } else if (subjectName.equals("英语")) {
                            subjectId = 3;
                        } else if (subjectName.equals("物理")) {
                            subjectId = 4;
                        } else if (subjectName.equals("化学")) {
                            subjectId = 5;
                        } else if (subjectName.equals("生物")) {
                            subjectId = 6;
                        } else if (subjectName.equals("政治")) {
                            subjectId = 7;
                        } else if (subjectName.equals("历史")) {
                            subjectId = 8;
                        } else if (subjectName.equals("地理")) {
                            subjectId = 9;
                        }
                        marker.setSubjectId(subjectId);
                        marker.setExamId(examId);
                        String classTypeContent = StringUtils.trimToNull(rs.getCell(1, i).getContents());
                        // Integer classTypeValue = null;
                        if (classTypeContent != null) {
                            if (ClassType.BASE.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.BASE);
                                // classTypeValue = ClassType.BASE.getValue();
                            } else if (ClassType.ART.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.ART);
                                // classTypeValue = ClassType.ART.getValue();
                            } else if (ClassType.SCIENCE.getName().equals(classTypeContent)) {
                                marker.setClassType(ClassType.SCIENCE);
                                // classTypeValue =
                                // ClassType.SCIENCE.getValue();
                            } else if (StringUtils.isNumeric(classTypeContent)) {
                                marker.setClassType(ClassType.findByValue(Integer.valueOf(classTypeContent)));
                                // classTypeValue =
                                // Integer.valueOf(classTypeContent);
                            }
                        }
                        String code = StringUtils.trimToNull(rs.getCell(2, i).getContents());
                        marker.setCode(code);
                        marker.setName(StringUtils.trimToNull(rs.getCell(3, i).getContents()));
                        marker.setPassword(StringUtils.trimToNull(rs.getCell(4, i).getContents()));
                        marker.setLastLoginTime(new Date());
                        marker.setMarkCount(0);
                        marker.setMarkStage(MarkStage.WAITING);
                        String status = StringUtils.trimToNull(rs.getCell(5, i).getContents());
                        if (status.equals("是")) {
                            marker.setStatus(1);
                        } else if (status.equals("否")) {
                            marker.setStatus(0);
                        }
                        list.add(marker);
                    } catch (Exception e) {
                        log.error("MarkerExcelParser-parseMarker", e);
                        continue;
                    }
                }
            }
        }
        return list;
    }*/
}
