📄 gradeservice.java
字号:
/**
*
*/
package edu.yinhe.mis.services;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import edu.yinhe.mis.dto.GradeDTO;
import edu.yinhe.mis.dto.Reply_cardDTO;
import edu.yinhe.mis.dto.TestpaperruleDTO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.util.Testequals;
import edu.yinhe.mis.vo.ExamineeVO;
import edu.yinhe.mis.vo.GradeVO;
import edu.yinhe.mis.vo.QuestionTypeVO;
import edu.yinhe.mis.vo.Reply_cardVO;
import edu.yinhe.mis.vo.TestpaperruleVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.IBaseDAO;
import edu.yinhe.system.services.Service;
/**
* @author 何亮
*
*/
public class GradeService extends Service{
private IBaseDAO GradeDAO=null;
public Object alllist() throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object alllist(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object create(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object findAll() throws AppException {
// TODO Auto-generated method stub
return null;
}
/**
* @param
* @return Inreger i;0表示插入失败,1表示插入成功
*/
public Object findAll(Object arg0) throws AppException {
GradeDTO dto=new GradeDTO();
dto=(GradeDTO) arg0;
Reply_cardDTO rdto=new Reply_cardDTO();
TestpaperruleDTO tdto=new TestpaperruleDTO();
ExamineeVO evo=null;
Reply_cardVO rvo=null;
QuestionTypeVO qvo=null;
TestpaperruleVO tvo=null;
GradeVO gvo=null;
ArrayList alist = null;
GradeDAO= DAOFactory.getGradeDAO(conn);
int right=0;//答对的题的数量
Integer i=0;//检查插入是否成攻
try {
ArrayList alist3=(ArrayList) GradeDAO.findAll();
Iterator it3=alist3.iterator();
while(it3.hasNext()){//取出考生考号
evo=new ExamineeVO();
gvo=new GradeVO();
evo=(ExamineeVO) it3.next();
rdto.setExam_no(evo.getExam_NO());
gvo.setExamno(evo.getExam_NO());
ArrayList alist1=(ArrayList) GradeDAO.find(rdto);
Iterator it1=alist1.iterator();
while(it1.hasNext()){ //取出科目名
ExamineeVO evo1=new ExamineeVO();
evo1=(ExamineeVO) it1.next();
rdto.setObject_name(evo1.getObject_name());
tdto.setObjectName(evo1.getObject_name());
gvo.setObjectname(evo1.getObject_name());
ArrayList alist2=(ArrayList) GradeDAO.find();
Iterator it2=alist2.iterator();
while(it2.hasNext()){ //取出题目类型ID
qvo=(QuestionTypeVO) it2.next();
if(qvo.getQuestionTypeID()==1){//若为单选题
System.out.println("单选题");
rdto.setQuestion_type(1);
tdto.setQuestionTypeID(1);
tvo=new TestpaperruleVO();
tvo=(TestpaperruleVO) GradeDAO.findById(tdto);
if(tvo!=null){
Integer questionValue=tvo.getQuestionValue();//得到题型分值
Integer questionAmount=tvo.getQuestionAmount();//得到题型数量
alist=(ArrayList) GradeDAO.findAll(rdto);
if(alist.size()==0){
System.out.println("考号为"+evo.getExam_NO()+"科目为"+evo1.getObject_name()+"的单选题在答题卡中没有记录");
}else{
Iterator it=alist.iterator();
while(it.hasNext()){//取出考生答案和标准答案
rvo=(Reply_cardVO) it.next();
if(rvo.getStandard_key().equals(rvo.getStudent_key())){//若考生答案与标准答案一致
right++;
}
}
}
Integer selectonepoint=right*(questionValue/questionAmount);//计算某考生某科目单选题分数
gvo.setSelectonepoint(String.valueOf(selectonepoint));
}
}
if(qvo.getQuestionTypeID()==2){//若为多选题
System.out.println("多选题");
rdto.setQuestion_type(2);
tdto.setQuestionTypeID(2);
tvo=new TestpaperruleVO();
tvo=(TestpaperruleVO) GradeDAO.findById(tdto);
if(tvo!=null){
Integer questionValue=tvo.getQuestionValue();//得到题型分值
Integer questionAmount=tvo.getQuestionAmount();//得到题型数量
Integer halfright=0;//答半对的题的数量
alist=(ArrayList) GradeDAO.findAll(rdto);
if(alist.size()==0){
System.out.println("考号为"+evo.getExam_NO()+"科目为"+evo1.getObject_name()+"的多选题在答题卡中没有记录");
}else{
Iterator it=alist.iterator();
int in=0;
while(it.hasNext()){//取出考生答案和标准答案
rvo=(Reply_cardVO) it.next();
rdto.setStudent_key(rvo.getStudent_key());
rdto.setStandard_key(rvo.getStandard_key());
Testequals tq=null;
if(rvo.getStudent_key().length()==rvo.getStandard_key().length()){
rdto.setStudent_key(rvo.getStudent_key());
rdto.setStandard_key(rvo.getStandard_key());
tq=new Testequals();
in=tq.eq(rdto);//调用Testequals()比较答案
//System.out.println(in);
if(in==2){
right++;
}if(in==1){
halfright++;
}
}
if(rvo.getStudent_key().length()<rvo.getStandard_key().length()&&rvo.getStandard_key().length()==4){
halfright++;//标准答案选项为4个且考生答案比标准答案的选项少时 得半对
}
if(rvo.getStudent_key().length()<rvo.getStandard_key().length()&&rvo.getStandard_key().length()!=4){
rdto.setStudent_key(rvo.getStudent_key());
rdto.setStandard_key(rvo.getStandard_key());
tq=new Testequals();
in=tq.co(rdto);
if(in==1){
halfright++;//标准答案选项不为4个且考生答案漏选而不错选时 得半对
}
}
if(rvo.getStudent_key().length()>rvo.getStandard_key().length()){//考生答案的选项比标准答案的多
rdto.setStudent_key(rvo.getStudent_key());
rdto.setStandard_key(rvo.getStandard_key());
tq=new Testequals();
in=tq.cy(rdto);
if(in==2){
right++;
}
if(in==1){
halfright++;
}
}
}
Integer selectmanypoint=right*(questionValue/questionAmount)+halfright*(questionValue/questionAmount)/2;
gvo.setSelectmanypoint(String.valueOf(selectmanypoint));
}
}
}
// if(qvo.getQuestionTypeID()==3){//若为判断题
// System.out.println("判断题");
// rdto.setQuestion_type(3);
// tdto.setQuestionTypeID(3);
// tvo=new TestpaperruleVO();
// tvo=(TestpaperruleVO) GradeDAO.findById(tdto);
// if(tvo!=null){
// Integer questionValue = tvo.getQuestionValue();//得到题型分值
// Integer questionAmount = tvo.getQuestionAmount();//得到题型数量
// alist=(ArrayList) GradeDAO.findAll(rdto);
// if(alist.size()==0){
// System.out.println("考号为"+evo.getExam_NO()+"科目为"+evo1.getObject_name()+"的多选题在答题卡中没有记录");
// }else{
// Iterator it=alist.iterator();
// while(it.hasNext()){//取出考生答案和标准答案
// rvo=(Reply_cardVO) it.next();
// if(rvo.getStandard_key().equals(rvo.getStudent_key())){//若考生答案与标准答案一致
// right++;
// }
// }
// }
// Integer judgementpoint=right*(questionValue/questionAmount);//计算某考生某科目判断题分数
// gvo.setJudgementpoint(String.valueOf(judgementpoint));
// }
// }
}
}
i=(Integer) GradeDAO.insert(gvo);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return i;
}
public Object findById(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object findByObject(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public int getcount() throws AppException {
// TODO Auto-generated method stub
return 0;
}
public int getcount(Object arg0) throws AppException {
// TODO Auto-generated method stub
return 0;
}
public Object list() throws AppException {
GradeDAO=DAOFactory.getGradeDAO(conn);
Integer i=0;
ExamineeVO evo=null;
try {
evo=(ExamineeVO) GradeDAO.findByObject(evo);//调用DAO中的方法判断是否已评分
i=evo.getEstate();
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
e.printStackTrace();
}finally{
this.closeConnection();
}
return i;
}
public Object list(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object load(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object modify(Object arg0) throws AppException {
GradeDTO gdto=new GradeDTO();
gdto=(GradeDTO) arg0;
GradeDAO=DAOFactory.getGradeDAO(conn);
Integer i=0;
try {
i=(Integer) GradeDAO.update(gdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();
}
return i;
}
public Object remove(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -