📄 examdao.java
字号:
package edu.yinhe.mis.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import edu.yinhe.mis.dto.ExamineeDTO;
import edu.yinhe.mis.dto.IExamDTO;
import edu.yinhe.mis.dto.Reply_cardDTO;
import edu.yinhe.mis.dto.TestPaperDTO;
import edu.yinhe.mis.vo.CheckInfoVO;
import edu.yinhe.mis.vo.ExamVO;
import edu.yinhe.mis.vo.ExamineeVO;
import edu.yinhe.mis.vo.TestPaperVO;
import edu.yinhe.mis.vo.TestpaperruleVO;
import edu.yinhe.system.model.BaseDAO;
/**
*
* @author 刘洲
*
*/
public class ExamDAO extends BaseDAO{
public Object delete(Object arg0) throws SQLException {
return null;
}
public Object find() throws SQLException {
return null;
}
public Object find(Object obj) throws SQLException {
ArrayList alist=null;
IExamDTO idto=null;
idto=(IExamDTO)obj;
if(idto!=null){
if(idto.getFlag()==1){
alist=(ArrayList) this.findByTsetPaperID(idto.getTestPaperNO());
}else if(idto.getFlag()==2){
alist=(ArrayList) this.findByTsetPaperRuleID(idto.getTestPaperRuleID());
}
}
return alist;
}
public Object findAll() throws SQLException {
return null;
}
public Object findAll(Object arg0) throws SQLException {
return null;
}
/**
* 根据考场ID查询考场信息
* @param 考场ID
* @return 考场相关信息
* @throws SQLException
*/
public Object findById(Object obj) throws SQLException {
Integer checkID;
CheckInfoVO checkInfoVO=null;
PreparedStatement ps=null;
ResultSet rs=null;
String SQL="";
try {
checkID=(Integer)obj;
SQL="SELECT CHECK_ID,COUNT,OBJECT_NAME,CHECK_BEGINTIME,CHECK_FINISHTIME,TESTPAPER_NO FROM check_info_table WHERE CHECK_ID="+checkID;
ps=conn.prepareStatement(SQL);
rs=ps.executeQuery();
while(rs.next()){
checkInfoVO=new CheckInfoVO();
checkInfoVO.setCheck_id(rs.getInt("check_id"));
checkInfoVO.setCount(rs.getInt("count"));
checkInfoVO.setObject_name(rs.getString("object_name"));
checkInfoVO.setCheck_begintime(rs.getString("check_begintime"));
checkInfoVO.setCheck_finishtime(rs.getString("check_finishtime"));
checkInfoVO.setTestPaper_no(rs.getString("testpaper_no"));
}
} finally{
if(ps!=null) ps.close();
if(rs!=null)rs.close();
SQL=null;
}
return checkInfoVO;
}
/**
* 根据考生登录信息查询考生信息
* @param 考生考号和密码
* @return 考生信息
* @throws SQLException
*/
public Object findByObject(Object obj) throws SQLException {
ExamineeDTO examineeDTO=null;
ExamineeVO examineeVO=null;
ArrayList alist=null;
PreparedStatement ps=null;
ResultSet rs=null;
String SQL="";
try {
examineeDTO=(ExamineeDTO)obj;
SQL="SELECT ID,NAME,EXAM_NO,PASSWORD,CHECK_ID,OBJECT_NAME,STATE,FETLE FROM examinee WHERE exam_no=? AND password=?";
ps=conn.prepareStatement(SQL);
ps.setString(1, examineeDTO.getExam_NO());
ps.setString(2, examineeDTO.getPassword());
rs=ps.executeQuery();
while(rs.next()){
examineeVO=new ExamineeVO();
examineeVO.setID(rs.getInt("id"));
examineeVO.setName(rs.getString("name"));
examineeVO.setExam_NO(rs.getString("exam_no"));
examineeVO.setPassword(rs.getString("password"));
examineeVO.setCheck_ID(rs.getInt("check_id"));
examineeVO.setObject_name(rs.getString("object_name"));
examineeVO.setState(rs.getInt("state"));
}
}finally{
if(ps!=null) ps.close();
if(rs!=null)rs.close();
SQL=null;
}
return examineeVO;
}
public int getCount(Object arg0) throws SQLException {
return 0;
}
public Object getMaxId(Object arg0) throws SQLException {
return null;
}
/**
* 在reply_card表中插入数据
* @param reply_cardDTO
* @return boolean
* @throws SQLException
*/
public Object insert(Object obj) throws SQLException {
boolean isTrue=false;
Reply_cardDTO reply_cardDTO=null;
PreparedStatement ps=null;
ResultSet rs=null;
String SQL="";
int index=1;
try {
reply_cardDTO=(Reply_cardDTO)obj;
SQL="INSERT INTO reply_card(EXAM_NO,CHECK_ID,OBJECT_NAME,TESTPAPERQUESTION_ID,CONTENT,SCORE,QUESTION_TYPE,STANDARD_KEY,TESTPAPER_ID) " +
"VALUE(?,?,?,?,?,?,?,?,?)";
ps=conn.prepareStatement(SQL);
ps.setString(index++, reply_cardDTO.getExam_no());
ps.setInt(index++, reply_cardDTO.getCheck_id());
ps.setString(index++, reply_cardDTO.getObject_name());
ps.setInt(index++, reply_cardDTO.getTestpaperquestion_id());
ps.setString(index++, reply_cardDTO.getContent());
ps.setString(index++, reply_cardDTO.getScore());
ps.setInt(index++, reply_cardDTO.getQuestion_type());
ps.setString(index++, reply_cardDTO.getStandard_key());
ps.setString(index++, reply_cardDTO.getTestpaper_id());
ps.executeUpdate();
isTrue=true;
}finally{
if(ps!=null)ps.close();
if(rs!=null)rs.close();
reply_cardDTO=null;
SQL=null;
}
return isTrue;
}
/**
* 将考生答案写入答题卡中
* @param reply_cardDTO考生信息
* @return boolean
* @throws SQLException
*/
public Object update(Object obj) throws SQLException {
boolean isTrue=false;
Reply_cardDTO reply_cardDTO=null;
PreparedStatement ps=null;
String SQL="";
int index=1;
try {
reply_cardDTO=(Reply_cardDTO)obj;
SQL="UPDATE reply_card SET STUDENT_KEY=? WHERE EXAM_NO=? AND CHECK_ID=? AND TESTPAPERQUESTION_ID=?";
ps=conn.prepareStatement(SQL);
ps.setString(index++, reply_cardDTO.getStudent_key());
ps.setString(index++, reply_cardDTO.getExam_no());
ps.setInt(index++, reply_cardDTO.getCheck_id());
ps.setInt(index++, reply_cardDTO.getTestpaperquestion_id());
ps.executeUpdate();
isTrue=true;
}finally{
if(ps!=null)ps.close();
reply_cardDTO=null;
SQL=null;
}
return isTrue;
}
/**
* 根据试卷ID得到试题
* @param 试卷ID
* @return 试题相关信息
* @throws SQLException
*/
private Object findByTsetPaperID(Object obj) throws SQLException {
String testPaperNO;
ExamVO examVO=null;
ArrayList alist=null;
Object[] object=null;
PreparedStatement ps=null;
ResultSet rs=null;
String SQL="";
try {
testPaperNO=(String)obj;
SQL="SELECT t.ID,t.TESTPAPER_NO,t.TESTPAPER_NAME,t.QUESTION_ID,t.QUESTIONTYPE_ID,t.OBJECT_NAME,t.TESTPAPERRULE_NO," +
"q.QUESTION_ID,q.QUESTION_NAME,q.QUESTION_RESULT,q.DIFFICULTYDEGREE_ID,q.QUESTIONTYPE_ID,q.OBJECT_NAME,q.EXPLAINS,q.OPTION_A,q.OPTION_B,q.OPTION_C,q.OPTION_D " +
" FROM testpaper t,question q WHERE t.QUESTION_ID=q.QUESTION_ID AND t.TESTPAPER_NO='"+testPaperNO+"'";
ps=conn.prepareStatement(SQL);
rs=ps.executeQuery();
alist=new ArrayList();
while(rs.next()){
examVO=new ExamVO();
examVO.setTestPaper_NO(rs.getString("testPaper_NO"));
examVO.setTestPaper_Name(rs.getString("testPaper_Name"));
examVO.setTestPaperRule_NO(rs.getString("testPaperRule_NO"));
examVO.setObject_Name(rs.getString("object_Name"));
examVO.setQuestion_ID(rs.getInt("question_ID"));
examVO.setQuestionName(rs.getString("question_name"));
examVO.setExplains(rs.getString("explains"));
examVO.setQuestionResult(rs.getString("question_result"));
examVO.setQuestionType_ID(rs.getInt("questionType_ID"));
examVO.setOptionA(rs.getString("option_A"));
examVO.setOptionB(rs.getString("option_B"));
examVO.setOptionC(rs.getString("option_C"));
examVO.setOptionD(rs.getString("option_D"));
alist.add(examVO);
}
} finally{
}
return alist;
}
/**
*
* @param 试卷规则号
* @return 规则信息
* @throws SQLException
*/
private Object findByTsetPaperRuleID(Object obj) throws SQLException {
String testPaperRuleID;
TestpaperruleVO testPaperRuleVO=null;
ArrayList alist=null;
PreparedStatement ps=null;
ResultSet rs=null;
String SQL="";
testPaperRuleID=(String)obj;
SQL="SELECT ID,TESTPAPERRULE_NO,QUESTIONTYPE_ID,OBJECT_NAME,QUESTIONAMOUNT,QUESTION_VALUE,QUESTIONDIFFICULTSCALE,RULENAME,SCORESCALE FROM testpaperrule WHERE TESTPAPERRULE_NO='"+testPaperRuleID+"'";
ps=conn.prepareStatement(SQL);
rs=ps.executeQuery();
alist=new ArrayList();
while(rs.next()){
testPaperRuleVO=new TestpaperruleVO();
testPaperRuleVO.setTestPaperRuleNo(rs.getString("testPaperRule_NO"));
testPaperRuleVO.setObjectName(rs.getString("object_name"));
testPaperRuleVO.setQuestionTypeID(rs.getInt("questionType_ID"));
testPaperRuleVO.setQuestionAmount(rs.getInt("questionAmount"));
testPaperRuleVO.setQuestionValue(rs.getInt("question_value"));
testPaperRuleVO.setQuestionDifficultScale(rs.getString("questionDifficultScale"));
testPaperRuleVO.setScoreScale(rs.getString("scoreScale"));
alist.add(testPaperRuleVO);
}
return alist;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -