⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assessservice.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
字号:
package edu.yinhe.mis.services;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.sql.DataSource;

import edu.yinhe.mis.dto.AssessDTO;
import edu.yinhe.mis.dto.AuditingDTO;
import edu.yinhe.mis.model.AssessDAO;
import edu.yinhe.mis.model.AuditingDAO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.vo.AssessVO;
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 AssessService extends Service{
/**
 * 得到考试的全部科目
 */
	public Object alllist() throws AppException {
		
		ArrayList list=null;  
		try {
			BaseDAO dao=(BaseDAO) DAOFactory.getAssessDAO(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 {
		AssessDAO dao=null;
		ArrayList list=null; 
		AssessDTO adto=null;
		try {
			adto=(AssessDTO) obj;
			dao=(AssessDAO) DAOFactory.getAssessDAO(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 {
		AssessDAO dao=null;
		ArrayList list=null;
		AssessDTO adto=null;
		Integer count=0;
		Object[] obje=new Object[2];
		try {
			adto=(AssessDTO) obj;
			dao=(AssessDAO) DAOFactory.getAssessDAO(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 {
		AssessDAO dao=null;
		ArrayList list=null;
		AssessDTO adto=null;
		AssessVO avo=null;
		Object obje[]=null;
		try {
			obje=new Object[2];
			list=new ArrayList();
			adto=(AssessDTO) obj;
			dao=(AssessDAO) DAOFactory.getAssessDAO(conn);
			list=(ArrayList) dao.findById(adto);
			avo=(AssessVO) 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 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 {
		// TODO Auto-generated method stub
		return null;
	}

//	public Object list(Object obj) throws AppException {
//		AssessDAO dao=null;
//		AssessDTO adto=null;
//		AssessVO avo=null;
//		ArrayList list=null;
//		boolean flag=false;
//		
//		try {
//			adto=(AssessDTO) obj;
//			dao=(AssessDAO) DAOFactory.getAssessDAO(conn);
//			String scorearray=adto.getScorearry();
//			list=(ArrayList) this.splited(scorearray);
//			adto.setList(list);
//			avo=(AssessVO) dao.insert(obj);
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}finally{
//			closeConnection();
//		}
//		return avo;
//	}
/**
 * 将老师对考生的评分插入到数据库中
 */
	public Object load(Object obj) throws AppException {
		AssessDAO dao=null;
		boolean flag=false;
		//ArrayList list=null;
		AssessDTO adto=null;
		try {
			//list=new ArrayList();
			adto=(AssessDTO)obj;
			dao=(AssessDAO) DAOFactory.getAssessDAO(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 {
        AssessDTO adto=null;
		boolean flag=false;
		adto=(AssessDTO)obj;
		boolean isOK=false;
		String scorearry=adto.getScorearry();
		ArrayList list=(ArrayList) this.splited(scorearry);//将字符串拆分
		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){
		String scorearry=(String) obj;
		String[]str=scorearry.split("_");
		AssessDTO adto=null;
		ArrayList  dtos=new ArrayList();
		String[] temps=null;
		for(int i=0;i<str.length;i++){
			temps=str[i].split(":");
			adto = new AssessDTO();
			adto.setTestpaperquestion_id(Integer.parseInt(temps[0]));
			adto.setFact_socre(temps[1]);
			dtos.add(adto);
		}
		return dtos;
		
	}



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -