📄 gradestatservice.java
字号:
package edu.yinhe.mis.services;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.sql.DataSource;
import edu.yinhe.mis.dto.DemoDTO;
import edu.yinhe.mis.dto.GradeDTO;
import edu.yinhe.mis.dto.GradeStatDTO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.vo.DemoVO;
import edu.yinhe.mis.vo.GradeStatVO;
import edu.yinhe.mis.vo.GradeVO;
import edu.yinhe.mis.vo.TestpaperruleVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.IBaseDAO;
import edu.yinhe.system.services.IService;
import edu.yinhe.system.services.Service;
public class GradeStatService extends Service {
private IBaseDAO GradeStatDAO=null;
public Object alllist() throws AppException {
GradeStatVO gsvo=new GradeStatVO();
GradeStatDAO=DAOFactory.getGradeStatDAO(conn);
try {
gsvo=(GradeStatVO) GradeStatDAO.findAll();
} catch (SQLException e) {
e.printStackTrace();
}finally{
this.closeConnection();
}
return gsvo;
}
public Object alllist(Object arg0) throws AppException {
GradeStatDTO gsdto=new GradeStatDTO();
gsdto=(GradeStatDTO) arg0;
ArrayList alist=new ArrayList();
GradeStatVO gsvo=new GradeStatVO();
GradeStatDAO=DAOFactory.getGradeStatDAO(conn);
try {
gsvo = (GradeStatVO) GradeStatDAO.findAll(gsdto);
alist=(ArrayList) GradeStatDAO.delete(gsdto);
alist.add(gsvo);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return alist;
}
public Object create(Object arg0) throws AppException {
return null;
}
/**
* 统计考生成绩
*/
public Object findAll() throws AppException {
Integer flag=0;
Integer sum=0;//考生总人数
Double sumscore=0.0;//所有考生的总分之和
Double sumfollow=0.0;//所有考生的客观题得分之和
Double summain=0.0;//所有考生的主观题得分之和
Double rate=0.0;//某个考生的某科目的得分率
String averagescore=null;//所有考生的平均分
String passpercent=null;//考生的及格率
String followscorekeeper=null;//考生的客观题得分率
String mainscorekeeper=null;//考生的主观题得分率
Double objectscore=0.0;//某科目的设定的总分值
Double objectfollow=0.0;//某科目设定的客观题分值
Double objecrmain=0.0;//某科目设定的主观题分值
Double passman=0.0;//,某科目的及格人数
ArrayList alist=null;
ArrayList alist1=null;
ArrayList alist2=null;
GradeDTO gdto=new GradeDTO();
GradeStatDTO gsdto=new GradeStatDTO();
GradeVO gvo=new GradeVO();
GradeVO gvo1=new GradeVO();
TestpaperruleVO tvo=new TestpaperruleVO();
GradeStatDAO=DAOFactory.getGradeStatDAO(conn);
try {
alist=new ArrayList();
alist=(ArrayList) GradeStatDAO.find();//得到科目,统计每科目下的考生成绩
Iterator it=alist.iterator();
while(it.hasNext()){
gvo=(GradeVO) it.next();
gsdto.setObject_name(gvo.getObjectname());
sum=(Integer) GradeStatDAO.find(gvo);//得到有成绩记录的考生的总人数
alist1=new ArrayList();
alist1=(ArrayList) GradeStatDAO.findByObject(gvo);//得到所有考生的成绩
Iterator it1=alist1.iterator();
while(it1.hasNext()){
gvo1=(GradeVO) it1.next();
//将所有考生的总分相加
sumscore=Double.valueOf(gvo1.getSumscore())+sumscore;
//将所有考生的客观题分相加
sumfollow=Double.valueOf(gvo1.getFollowscore())+sumfollow;
//将所有考生的主观题得分相加
summain=Double.valueOf(gvo1.getMainscore())+summain;
alist2=(ArrayList) GradeStatDAO.findById(gvo);//得到某科目的总分及客观题主观题总分
Iterator it2=alist2.iterator();
while(it2.hasNext()){
tvo=(TestpaperruleVO) it2.next();
objectscore=tvo.getQuestionValue()+objectscore;//科目总分
//设定的客观题分值
if(tvo.getQuestionTypeID()==1||tvo.getQuestionTypeID()==2||tvo.getQuestionTypeID()==3){
objectfollow=tvo.getQuestionValue()+objectfollow;
}
//设定的主观题分值
if(tvo.getQuestionTypeID()==4||tvo.getQuestionTypeID()==5){
objecrmain=tvo.getQuestionValue()+objecrmain;
}
}
rate=Double.valueOf(gvo1.getSumscore())/objectscore;
if(rate>=0.6){
passman++;
}
}
averagescore=String.valueOf(sumscore/sum);//平均分
passpercent=String.valueOf((passman/sum)*100)+"%";//及格率
//客观题得分率
Double fk= ((sumfollow/(objectfollow*sum))*10000);
followscorekeeper=String.valueOf(fk.intValue()/100.00)+"%";
//主观题得分率
mainscorekeeper=String.valueOf((summain/(objecrmain*sum))*100)+"%";
gsdto.setAveragescore(averagescore);
gsdto.setPasspercent(passpercent);
gsdto.setFollowscorekeeper(followscorekeeper);
gsdto.setMainscorekeeper(mainscorekeeper);
flag=(Integer) GradeStatDAO.insert(gsdto);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
}
return flag;
}
public Object findAll(Object arg0) throws AppException {
return null;
}
public Object findById(Object arg0) throws AppException {
return null;
}
public Object findByObject(Object arg0) throws AppException {
return null;
}
public int getcount() throws AppException {
return 0;
}
public int getcount(Object arg0) throws AppException {
return 0;
}
public Object list() throws AppException {
return null;
}
public Object list(Object arg0) throws AppException {
return null;
}
public Object load(Object arg0) throws AppException {
return null;
}
public Object modify(Object arg0) throws AppException {
GradeStatDTO gsdto=new GradeStatDTO();
GradeStatDAO=DAOFactory.getGradeStatDAO(conn);
try {
GradeStatDAO.update(gsdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return null;
}
public Object remove(Object arg0) throws AppException {
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -