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

📄 auditingdao.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 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.AssessDTO;
import edu.yinhe.mis.dto.AuditingDTO;
import edu.yinhe.mis.dto.DemoDTO;
import edu.yinhe.mis.vo.AssessVO;
import edu.yinhe.mis.vo.AuditingVO;
import edu.yinhe.mis.vo.DemoVO;
import edu.yinhe.system.model.BaseDAO;
import edu.yinhe.system.model.IBaseDAO;
/**
 * 
 * @author Administrator  陈雄
 *
 */
public class AuditingDAO extends BaseDAO{

	public Object delete(Object arg0) throws SQLException {
		return null;
	}
	
/**
 * 
 * 查询考场(outline) 
 * @return 返回科目封装在ArrayList中
 */
	public Object find() throws SQLException {
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		String SQL="SELECT DISTINCT object_name FROM check_info_table";
		
		try {
			list=new ArrayList();
			pstat=conn.prepareStatement(SQL);//注意这里的conn是从BaseDAO继承的,可以直接用的
			rst=pstat.executeQuery();
			while(rst.next()){
				avo=new AuditingVO();
				avo.setObject_name(rst.getString("object_name"));
				list.add(avo);
			}
		} catch (RuntimeException e) {
			
		}finally{
			if(rst!=null)rst.close();//由于项目庞大,节约资源
			if(pstat!=null)pstat.close();//由于项目庞大,节约资源
			SQL=null;
		}
		return list;
	}
	
	/**
	 * @param Object obj
	 * 通过考场表中的考试科目 查找考该科目的考场 返回考场的集合
	 */
	public Object find(Object obj) throws SQLException {
		String SQL=null;
		AuditingDTO adto=null;
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		int index=1;
			try {
				list=new ArrayList();
				adto=(AuditingDTO)obj;//由于前面传参数的时候,已经向上转型,所以这里可以向下转型,即把父类的引用给                                            //子类的引用,只有先向上转型才可以向下转型.
				SQL="SELECT check_id FROM check_info_table WHERE object_name=?";
				pstat=conn.prepareStatement(SQL);
			    pstat.setString(index, adto.getObject_name());
				rst=pstat.executeQuery();
				while(rst.next()){
					avo=new AuditingVO();
					avo.setCheck_id(rst.getInt("check_id"));
					list.add(avo);	
				}
			} catch (RuntimeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				if(rst!=null)rst.close();
				if(pstat!=null)pstat.close();
				SQL=null;
				adto=null;
			}

		return list;
	}

	public Object findAll() throws SQLException {
		
		return null;
	}
/**
 * 根据考场编号 得到该考场里的学生编号 学生姓名 和考试科目
 */
	public Object findAll(Object obj) throws SQLException {
		String SQL=null;
		AuditingDTO adto=null;
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		int index=1;
		StringBuffer buf=new StringBuffer("SELECT e.name,e.exam_no,e.object_name FROM examinee e,grade_table g WHERE e.exam_no=g.exam_no AND e.check_id=? AND e.fetle=?");
		
	
			try {
				adto=(AuditingDTO) obj;
				
				list=new ArrayList();
				if(adto.getKeyword()!=null&&!"".equals(adto.getKeyword())&&"".equals(adto.getKeyword2())){
					buf.append(" AND e.exam_no="+adto.getKeyword());
				}
				if("".equals(adto.getKeyword())&&adto.getKeyword2()!=null&&!"".equals(adto.getKeyword2())){
					buf.append(" AND e.name='"+adto.getKeyword2()+"'");
				}
				if(adto.getKeyword()!=null&&!"".equals(adto.getKeyword())&&!"".equals(adto.getKeyword2())){
					buf.append(" AND e.exam_no="+adto.getKeyword()+" AND e.name='"+adto.getKeyword2()+"'");
				}
				buf.append(" limit ?,?");
				SQL=buf.toString();
				pstat=conn.prepareStatement(SQL);
				pstat.setInt(index++, adto.getCheck_id());
				pstat.setInt(index++, 1);
				pstat.setInt(index++, (Integer.parseInt((adto.getCurrentPage()))-1)*(Integer.parseInt(adto.getRowPerPage())));
				pstat.setInt(index++, Integer.parseInt(adto.getRowPerPage()));
				
				rst=pstat.executeQuery();
				while(rst.next()){
					avo=new AuditingVO();
					avo.setName(rst.getString("name"));
					avo.setObject_name(rst.getString("object_name"));
				    avo.setExam_no(rst.getInt("exam_no"));
					list.add(avo);
				}
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	
		return list;
	}

	/**
	 * 通过考生的编号(exam_no) 得到该考生的答题卡 
	 */
	public Object findById(Object obj) throws SQLException {
		String SQL=null;
		AuditingDTO adto=null;
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		int index=1;
		SQL="SELECT r.TESTPAPERQUESTION_ID,r.CONTENT,r.STUDENT_KEY,r.STANDARD_KEY,r.SCORE,r.fact_score FROM reply_card r,grade_table g WHERE r.exam_no=g.exam_no AND r.exam_no=? AND r.QUESTION_TYPE=?";
		
		try {
			adto=(AuditingDTO) obj;
		
			list=new ArrayList();
			pstat=conn.prepareStatement(SQL);
			pstat.setInt(index++, adto.getExam_no()); 
			pstat.setInt(index++, 5);
			rst=pstat.executeQuery();
			while(rst.next()){
				avo=new AuditingVO();
				avo.setTestpaperquestion_id(rst.getInt("TESTPAPERQUESTION_ID"));
				avo.setContent(rst.getString("CONTENT"));
				avo.setStudent_key(rst.getString("STUDENT_KEY"));
				avo.setStandard_key(rst.getString("STANDARD_KEY"));
				avo.setScore(rst.getString("SCORE"));
				avo.setFact_score(rst.getString("fact_score"));
				list.add(avo);
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(rst!=null)rst.close();
			if(pstat!=null)pstat.close();
			SQL=null;
			adto=null;
		}
		return list;
	}

	/**
	 * 客观题总分
	 */
	public Object findByObject(Object obj) throws SQLException {
		
		String SQL=null;
		AuditingDTO adto=null;
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		int index=1;
		SQL="SELECT e.name,g.OBJECT_NAME,g.FOLLOW_SCORE FROM examinee e,grade_table g WHERE e.exam_no=g.exam_no AND g.exam_no=?";
		
		try {
			adto=(AuditingDTO) obj;
			
			list=new ArrayList();
			pstat=conn.prepareStatement(SQL);
			pstat.setInt(index, adto.getExam_no());
			rst=pstat.executeQuery();
			while(rst.next()){
				avo=new AuditingVO();
				avo.setName(rst.getString("name"));
				avo.setObject_name(rst.getString("OBJECT_NAME"));
				avo.setFollow_score(rst.getString("FOLLOW_SCORE"));
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(rst!=null)rst.close();
			if(pstat!=null)pstat.close();
			SQL=null;
			adto=null;
		}
		return avo;
	}
/**
 * 得到满足条件的数据的条数
 */
	public int getCount(Object obj) throws SQLException {
		String SQL=null;
		AuditingDTO adto=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		Integer integer=0;
		int index=1;
		StringBuffer buf=new StringBuffer("SELECT COUNT(*) FROM examinee e,grade_table g WHERE e.exam_no=g.exam_no AND e.check_id=? AND fetle=?");
		
		try {
			adto=(AuditingDTO) obj;
			if(adto.getKeyword()!=null&&!"".equals(adto.getKeyword())&&"".equals(adto.getKeyword2())){
				buf.append(" AND e.exam_no="+adto.getKeyword());
			}
			if("".equals(adto.getKeyword())&&adto.getKeyword2()!=null&&!"".equals(adto.getKeyword2())){
				buf.append(" AND e.name='"+adto.getKeyword2()+"'");
			}
			if(adto.getKeyword()!=null&&!"".equals(adto.getKeyword())&&!"".equals(adto.getKeyword2())){
				buf.append(" AND e.exam_no="+adto.getKeyword()+" AND e.name='"+adto.getKeyword2()+"'");
			}
			SQL=buf.toString();
			pstat=conn.prepareStatement(SQL);
			pstat.setInt(index++, adto.getCheck_id());
			pstat.setInt(index++, 1);
			rst=pstat.executeQuery();
			while(rst.next()){
				integer=new Integer(rst.getInt(1));
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally{
			if(rst!=null)rst.close();
			if(pstat!=null)pstat.close();
			SQL=null;
			adto=null;
		}
		return integer;
	}
	
/**
 * 传入一个考生的编号
 * 得到主观题总分
 */
	public Object getMaxId(Object obj) throws SQLException {
		String SQL=null;
		AuditingDTO adto=null;
		AuditingVO avo=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ArrayList list=null;
		double mainScore=0;
		int index=1;
		SQL="SELECT fact_score FROM reply_card WHERE exam_no=?";
		
		try {
			avo=new AuditingVO();
			adto=(AuditingDTO) obj;
			pstat=conn.prepareStatement(SQL); 
			pstat.setInt(index, adto.getExam_no());
			rst=pstat.executeQuery();
			while(rst.next()){
				mainScore+=Double.parseDouble(rst.getString("fact_score"));
			    
			}
			avo.setMain_score(String.valueOf(mainScore));
			System.out.println(avo.getMain_score()); 
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	finally{
			if(rst!=null)rst.close();
			if(pstat!=null)pstat.close();
			SQL=null;
			adto=null;
		}
		return avo;
	}

	public Object insert(Object obj) throws SQLException {
	    AuditingDTO adto=null;
	    AuditingVO avo=null;
	    boolean flag=false;
	    adto=(AuditingDTO) obj;
	    flag=(Boolean) this.update(adto);
	    if(flag=true){
	    	avo=(AuditingVO) this.getMaxId(adto);
	    }
	
		return avo;
	}
	
/**
 * 把审核后的分写到数据库中
 */
	public Object update(Object obj) throws SQLException {
		PreparedStatement pstat = null;
		int n=0;
		boolean isOk=false;
	            AuditingDTO adto=(AuditingDTO)obj;
	            int examnum =adto.getExam_no();
		        ArrayList list = (ArrayList)adto.getList();
		        System.out.println(list.size());
		        
		        try {
					for(int i=0; i<list.size();i++)
					{   	
						int index=1;
					    adto=(AuditingDTO)list.get(i);
						System.out.println(adto.getTestpaperquestion_id());
						System.out.println(adto.getFact_socre());
					
						String SQL = "UPDATE reply_card SET  FACT_SCORE=? WHERE TESTPAPERQUESTION_ID=?";	
						pstat = conn.prepareStatement(SQL);
					    pstat.setString(index++, adto.getFact_socre());
						pstat.setInt(index++,adto.getTestpaperquestion_id());
						n = pstat.executeUpdate();
					}
					if(n!=0)
					{
						isOk=true;
						System.out.println(examnum);
						int index=1;
						String SQL="UPDATE examinee SET fetle=? WHERE exam_no=?";
						pstat = conn.prepareStatement(SQL);
						pstat.setInt(index++, 1);
						pstat.setInt(index++, examnum);
						pstat.executeUpdate();
						
					}
				} catch (RuntimeException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}	finally{
					if(pstat!=null)pstat.close();
				}
			
		return isOk;
	}


}

⌨️ 快捷键说明

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