📄 auditingservice.java
字号:
package edu.yinhe.mis.services;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.sql.DataSource;
import edu.yinhe.mis.dto.AuditingDTO;
import edu.yinhe.mis.model.AuditingDAO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.vo.AuditingVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.BaseDAO;
import edu.yinhe.system.services.IService;
import edu.yinhe.system.services.Service;
/**
*
* @author 陈雄
*
*/
public class AuditingService extends Service{
/**
* 得到考试的全部科目
*/
public Object alllist() throws AppException {
ArrayList list=null;
try {
BaseDAO dao=(BaseDAO) DAOFactory.getAuditingDAO(conn);
list=(ArrayList) dao.find();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();//注意,连接是在前面有服务层创建,本着谁创建,谁关闭的原则,所以要它关闭;
}
return list;
}
/**
* 根据考试的科目查找 考该科目的考场
*/
public Object alllist(Object obj) throws AppException {
AuditingDAO dao=null;
ArrayList list=null;
AuditingDTO adto=null;
try {
adto=(AuditingDTO) obj;
dao=(AuditingDAO) DAOFactory.getAuditingDAO(conn);
list=(ArrayList) dao.find(adto);
} catch (SQLException e) {
e.printStackTrace();
}finally{
closeConnection();
}
return list;
}
public Object create(Object obj) throws AppException {
return null;
}
public Object findAll() throws AppException {
// TODO Auto-generated method stub
return null;
}
/**
* 根据考场编号 得到该考场里的学生编号 学生姓名 和考试科目
*/
public Object findAll(Object obj) throws AppException {
AuditingDAO dao=null;
ArrayList list=null;
AuditingDTO adto=null;
Integer count=0;
Object[] obje=new Object[2];
try {
adto=(AuditingDTO) obj;
dao=(AuditingDAO) DAOFactory.getAuditingDAO(conn);
list=(ArrayList) dao.findAll(adto);
count=dao.getCount(adto);
obje[0]=list;
obje[1]=count;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();
}
return obje;
}
/**
* 传入一个学生的编号(exam_no) 返回该学生的答题卡 以及客观题总分 封装在List中
*/
public Object findById(Object obj) throws AppException {
AuditingDAO dao=null;
ArrayList list=null;
AuditingDTO adto=null;
AuditingVO avo=null;
Object obje[]=null;
try {
obje=new Object[2];
adto=(AuditingDTO) obj;
dao=(AuditingDAO) DAOFactory.getAuditingDAO(conn);
list=(ArrayList) dao.findById(adto);
avo=(AuditingVO) dao.findByObject(adto);
obje[0]=list;
obje[1]=avo;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();
}
return obje;
}
public Object findByObject(Object obj) throws AppException {
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 {
// TODO Auto-generated method stub
return null;
}
/**
* 得到主观题的总分
*/
public Object list(Object obj) throws AppException {
AuditingDAO dao=null;
AuditingDTO adto=null;
AuditingVO avo=null;
ArrayList list=null;
boolean flag=false;
try {
adto=(AuditingDTO) obj;
dao=(AuditingDAO) DAOFactory.getAuditingDAO(conn);
String scorearray=adto.getScorearry();
list=(ArrayList) this.splited(scorearray);
adto.setList(list);
avo=(AuditingVO) dao.insert(obj);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();
}
return avo;
}
/**
* 将分数添加到数据客中
*/
public Object load(Object obj) throws AppException {
AuditingDAO dao=null;
ArrayList list=null;
AuditingDTO adto=null;
boolean flag=false;
try {
adto=(AuditingDTO) obj;
dao=(AuditingDAO) DAOFactory.getAuditingDAO(conn);
flag= (Boolean) dao.update(adto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeConnection();
}
return flag;
}
/**
* 调用将题号和分数组成的字符串拆分的方法和将分数添加到数据库中的方法
*/
public Object modify(Object obj) throws AppException {
AuditingDAO dao=null;
AuditingDTO adto=null;
ArrayList list=null;
boolean flag=false;
adto=(AuditingDTO) obj;
String scorearray=adto.getScorearry();
list=(ArrayList) this.splited(scorearray);
adto.setList(list);
flag=(Boolean) this.load(adto);
return flag;
}
public Object remove(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
/**
* 对字符串进行拆分
* @param obj
* @return
*/
private Object splited(Object obj){
AuditingDTO adto=null;
ArrayList list=new ArrayList();
String scorearray=(String) obj;
String[] Str=scorearray.split("_");
String[] temp=null;
for(int i=0;i<Str.length;i++){
if(!"".equals(Str[i])&&Str[i]!=null){
temp=Str[i].split(":");
adto=new AuditingDTO();
adto.setTestpaperquestion_id(Integer.parseInt(temp[0]));
adto.setFact_socre(temp[1]);
list.add(adto);
}
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -