You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhky/src/main/java/com/zky/manager/StudentPullulate.java

1027 lines
23 KiB

1 year ago
package com.zky.manager;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zky.manager.Login;
import com.zky.para.SyncPara;
import com.zky.pub.Common;
import com.zky.pub.DbConn;
import com.zky.pub.HashFmlBuf;
import com.zky.util.PageQuery;
import com.zky.util.jdbc.HashFmlBufResultSetHandler;
import com.zky.util.jdbc.JDBCUtils;
import com.zky.util.jdbc.ResultSetHandler;
/**
*
*
* @author LHT
*
*/
public class StudentPullulate {
/**
*
* @param request
* @param params
*/
public void createPullulate(HttpServletRequest request, Object[] params) {
String sql = "insert into TAB_STUDENT_PULLULATE (STUDENT_ID, GRADE, PHOTO, STATURE, AVOIRDUPOIS, EYE, FAVOR, LOGION, GOD, FAVOR_BOOK, FAVOR_FILM,UPDATE_TIME, UPDATE_TEACHER_ID, UPDATE_SCHOOL_ID,CLASS_ID,ADDRESS)"
+ "values (?,?,?,?,?,?,?,?,?,?,?,to_date(?,'%Y-%m-%d'),?,?,?,?)";
Connection conn=null;
conn = DbConn.getConn();
try {
JDBCUtils.update(conn, sql, params);
//oracle数据库手动提交mysql中 自动提交autoCommit();
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
*
* @param request
* @param params
*/
public void updatePullulate(HttpServletRequest request, Object[] params) {
Login login = (Login) request.getSession().getAttribute("login");
String sql = "update TAB_STUDENT_PULLULATE set"
+ " GRADE=?, PHOTO=?, STATURE=?, AVOIRDUPOIS=?, EYE=?, FAVOR=?, LOGION=?, GOD=?, FAVOR_BOOK=?, FAVOR_FILM=?,UPDATE_TIME=to_date(?,'%Y-%m-%d'), UPDATE_TEACHER_ID=?, UPDATE_SCHOOL_ID=?,class_id=?,address=? where update_time=to_date(?,'%Y-%m-%d') and grade=? and student_id=?";
Connection conn=null;
conn = DbConn.getConn();
try {
JDBCUtils.update(conn, sql, params);
//oracle数据库手动提交mysql中 自动提交autoCommit();
conn.commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
*
* @param id
* @param grade
* @return
*/
public HashFmlBuf readPullulate(String id, String grade) {
//String sql = "select * from (select * from TAB_STUDENT_PULLULATE t where student_id=? and t.grade=? order by update_time desc) d left join TAB_CLASS c on c.class_id=d.class_id where rownum = 1";
String sql="select t.student_id,t.grade,t.photo,t.stature,t.avoirdupois,t.eye,t.favor,t.logion,t.god,t.favor_book,t.favor_film,t.update_time,t.update_teacher_id,t.update_school_id,t.class_id,t.address,c.class_name,s.student_name from TAB_STUDENT_PULLULATE t left join TAB_CLASS c on c.class_id=t.class_id left join TAB_STUDENT s on s.student_id=t.student_id where t.student_id=? and t.grade=? and s.state=1";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, id, grade,
new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public HashFmlBuf readPullulate() {
String sql = "select p.student_id,p.grade,p.photo,p.stature,p.avoirdupois,p.eye,p.favor,p.logion,p.god,p.favor_book,p.favor_film,p.update_time,p.update_teacher_id,p.update_school_id,p.class_id,p.address from TAB_STUDENT_PULLULATE p";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql,
new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
/**
*
* @param request
* @param response
* @return
* @throws Exception
*/
public HashFmlBuf readStudent(HttpServletRequest request,
HttpServletResponse response)throws Exception{
String grade = request.getParameter("grade");
String classtu = request.getParameter("classtu");
String stunum = request.getParameter("stunum");
String school=request.getParameter("school");
StringBuffer sql =
new StringBuffer("select p.student_id,p.grade,p.photo,p.stature,p.avoirdupois,p.eye,p.favor,p.logion,p.god,p.favor_book,p.favor_film,p.update_time,p.update_teacher_id,p.update_school_id,p.class_id,p.address,s.student_name,c.class_name from tab_student_pullulate p left join tab_student s on s.student_id=p.student_id left join tab_class c on c.class_id=p.class_id where 1=1 and s.state=1");
if(!Common.isNull(grade)){
sql.append(" and p.grade='").append(grade).append("'");
}
if(!Common.isNull(classtu)){
sql.append(" and p.class_id='").append(classtu).append("'");
}
if(!Common.isNull(stunum)){
sql.append(" and p.student_id='").append(stunum).append("'");
}
if(!Common.isNull(school)){
sql.append(" and s.school_id='").append(school).append("'");
}
Connection conn=null;
conn = DbConn.getConn();
try {
PageQuery pageQuery = new PageQuery(conn,sql.toString(),new HashFmlBufResultSetHandler(),request);
1 year ago
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(20);
1 year ago
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
String errorinfo = "";
errorinfo="无记录!";
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
// 查询学校
public HashFmlBuf readSchool(String state) {
String sql = "select d.departid,d.departname,d.departtypeid from tab_department d where d.departstate=?";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, state,
new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
// 查询班级
public HashFmlBuf readClass(String state) {
String sql = "select c.class_id,c.class_name from tab_class c where c.state=?";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, state,
new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
/**
*
* @param request
* @param response
* @return
*/
public HashFmlBuf readStudents(HttpServletRequest request,
HttpServletResponse response) {
String schoolid=request.getParameter("schoolid");
String classid=request.getParameter("classtu")==null ? request.getParameter("classid") : request.getParameter("classtu");
String sql = "select s.student_id,s.student_name from tab_student s where s.school_id=? and s.class_id=? and s.state=?";
Connection conn=null;
conn = DbConn.getConn();
Object[] params={schoolid,classid,1};
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, params, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public HashFmlBuf readEmployees(HttpServletRequest request,
HttpServletResponse response) {
String schoolid=request.getParameter("schoolid");
//String classid=request.getParameter("classtu")==null ? request.getParameter("classid") : request.getParameter("classtu");
System.out.println("schoolid---"+schoolid);
String sql = "select e.empid,e.empname from tab_employee e where e.departid=? and e.empstate=?";
Connection conn=null;
conn = DbConn.getConn();
Object[] params={schoolid,1};
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, params, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public HashFmlBuf readCompereEmployees(HttpServletRequest request,
HttpServletResponse response) {
String schoolid=request.getParameter("compereschoolid");
System.out.println("compere------"+schoolid);
//String classid=request.getParameter("classtu")==null ? request.getParameter("classid") : request.getParameter("classtu");
String sql = "select e.empid,e.empname from tab_employee e where e.departid=? and e.empstate=?";
Connection conn=null;
conn = DbConn.getConn();
Object[] params={schoolid,1};
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, params, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
// 根据条件查询学生
public HashFmlBuf readStudentName(HttpServletRequest request,
HttpServletResponse response) {
String studentid=request.getParameter("studentid");
String sql = "select s.student_id,s.student_name,c.class_id,c.class_name from tab_student s left join tab_class c on c.class_id=s.class_id where s.student_id=? and s.state=?";
Connection conn=null;
conn = DbConn.getConn();
Object[] params={studentid,1};
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, params, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
/**
*
* @param para
* @param login_obj
* @param school
* @return
*/
public static HashFmlBuf getClass(SyncPara para, Login login_obj,String school) {
Connection conn= null;
PreparedStatement pst = null;
boolean query = true;
StringBuffer sql = new StringBuffer(" select class_id,class_name,class_number,school_id,class_master,monitor,ganger,state,create_time,create_teacher_id,create_school_id,class_ethos,class_train,schoolmate,teacher,class_aim,contribute " +
" from tab_class a where a.state='1'");
sql.append(" and a.school_id='").append(login_obj.departid).append("'");
try {
if (query) {
conn = DbConn.getConn();
HashFmlBuf buf =(HashFmlBuf)JDBCUtils.query(conn, sql.toString(), new HashFmlBufResultSetHandler());
if(buf!=null){
return buf;
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
public HashFmlBuf readPgePullulate(String id, String grade,HttpServletRequest request)throws Exception {
String sql="select t.student_id,t.grade,t.photo,t.stature,t.avoirdupois,t.eye,t.favor,t.logion,t.god,t.favor_book,t.favor_film,t.update_time,t.update_teacher_id,t.update_school_id,t.class_id,t.address,c.class_name from TAB_STUDENT_PULLULATE t left join TAB_CLASS c on c.class_id=t.class_id where student_id='"+id+"' and t.grade='"+grade+"'";
Connection conn=null;
conn = DbConn.getConn();
try {
PageQuery pageQuery = new PageQuery(conn,sql,new HashFmlBufResultSetHandler(),request);
1 year ago
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(20);
1 year ago
if (buf != null && buf.getRowCount() > 0) {
return buf;
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
/**
*
*/
public int check(String grade,String studnetid)throws Exception {
String sql = "select p.student_id,p.grade,p.photo,p.stature,p.avoirdupois,p.eye,p.favor,p.logion,p.god,p.favor_book,p.favor_film,p.update_time,p.update_teacher_id,p.update_school_id,p.class_id,p.address from TAB_STUDENT_PULLULATE p where p.grade=? and p.student_id=?";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, grade, studnetid, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf.getResultRowCount();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return 0;
}
/**
*
* @param length
* @param type
* @param request
* @return
*/
public Integer getCount(int length,String type,HttpServletRequest request){
List listSelf=new ArrayList();
List listTem=new ArrayList();
List listTacher=new ArrayList();
if(type!=null && type.equals("self")){
for (int i =1; i <=length; i++) {
if(request.getParameter("self"+i)!=null && request.getParameter("self"+i).equals("1") ){
listSelf.add(request.getParameter("self"+i));
}
}
return listSelf.size();
}
if(type!=null && type.equals("tem")){
for (int i =1; i <=length; i++) {
if(request.getParameter("self"+i)!=null && request.getParameter("tem"+i).equals("1") ){
listTem.add(request.getParameter("tem"+i));
}
}
return listTem.size();
}
if(type!=null && type.equals("teacher")){
for (int i =1; i <=length; i++) {
if(request.getParameter("teacher"+i)!=null && request.getParameter("teacher"+i).equals("1") ){
listTacher.add(request.getParameter("teacher"+i));
}
}
return listTacher.size();
}
return null;
}
/**
*
* @param total
* @return
*/
public String getGrade(Integer total){
if(total>=14 && total<=17){
return "A";
}else if(total>=10 && total<=13){
return "B";
}else if(total<=9){
return "C";
}else{
return "D";
}
}
/**
*
* @param total
* @return
*/
public String getGradeSmbx(Integer total){
if(total>=8 && total<=11){
return "A";
}else if(total>=6 && total<=7){
return "B";
}else if(total>=4 && total<=5){
return "C";
}else{
return "D";
}
}
/**
*
* @param total
* @return
*/
public String getGradeYdjk(Integer total){
if(total>=10 && total<=12){
return "A";
}else if(total>=7 && total<=9){
return "B";
}else if(total>=1 && total<=6){
return "C";
}else{
return "D";
}
}
/**
*
* @param total
* @return
*/
public String getGradeXxnl(Integer total){
if(total>=13 && total<=16){
return "A";
}else if(total>=9 && total<=12){
return "B";
}else if(total>=5 && total<=8){
return "C";
}else{
return "D";
}
}
/**
*
*/
public String getGradeZhsz(Double score){
if(score>=90 && score<=100){
return "A";
}else if(score>=70 && score<=89.9){
return "B";
}else if(score>=60 && score<=69.9){
return "C";
}else if(score>=0 && score<=59.9){
return "D";
}
return null;
}
//
public static String getArea(String areaid)throws Exception {
String sql = "select t.areadef from TAB_AREA t where t.areaid=?";
Connection conn=null;
conn = DbConn.getConn();
try {
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql, areaid, new HashFmlBufResultSetHandler());
if (buf != null && buf.getRowCount() > 0) {
return buf.fget("areadef", 0);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return "";
}
/**
*
* @return
*/
public static HashFmlBuf readAreas(String frameWorkId) {
Connection conn=DbConn.getConn();
String sql="SELECT AREAID,AREADEF,FRAMEWORKID FROM TAB_AREA a where a.FRAMEWORKID=?";
HashFmlBuf areas=null;
try {
areas=(HashFmlBuf)JDBCUtils.query(conn, sql,frameWorkId, new HashFmlBufResultSetHandler());
if(areas!=null && areas.getRowCount()>0){
return areas;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
/**
*
* @param empid
* @param frameWorkId
* @return
*/
public static HashFmlBuf readAreasUser(String empid,String frameWorkId) {
Connection conn=DbConn.getConn();
System.out.println("empid:"+empid+"frameWorkId:"+frameWorkId);
//String sql="SELECT AREAID,AREADEF,FRAMEWORKID FROM TAB_AREA a where a.FRAMEWORKID=?";
String sql="select s.AREAID,s.AREADEF,s.FRAMEWORKID FROM (select e.areaid,a.AREADEF,a.FRAMEWORKID from tab_employee e left join tab_area a on e.areaid=a.areaid where e.empid=? and a.frameworkid=? ) s ";
HashFmlBuf areas=null;
try {
areas=(HashFmlBuf)JDBCUtils.query(conn, sql,empid,frameWorkId, new HashFmlBufResultSetHandler());
if(areas!=null && areas.getRowCount()>0){
return areas;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
/**
*
* @param areaId
* @return
*/
public HashFmlBuf readSchoolByAreaId(String areaId,Login login_obj) {
String sql="SELECT DEPARTID,DEPARTTYPEID,DEPARTNAME,DEPARTADDR,DEPARTPHONE,DEPARTREPNAME,DEPARTREPPHONE,DEPARTREPMOBPHONE,DEPARTREPEMAIL,DEPARTREPFAX,DEPARTSTATE,DEPARTSTATDATE,DEPARTLVLID,ACPTSITEID,AREAID,FRAMEWORKID,PARENTDEPTID,NET_ADDRESS,POST_CODE,CREATE_TIME,CREATE_TEACHER_ID,CREATE_SCHOOL_ID,SCHOOL_ETHOS,SCHOOL_TRAIN,MASTER_ETHOS,TEACHER_ETHOS,STUDENT_ETHOS,SCHOOL_KNOW,SCHOOL_FEATURE,UPDATE_TIME,UPDATE_TEACHER_ID,UPDATE_SCHOOL_ID FROM TAB_DEPARTMENT WHERE DEPARTSTATE='1' and DEPARTID!='001' AND AREAID=?";
HashFmlBuf schools=null;
Connection conn=DbConn.getConn();
try {
schools=(HashFmlBuf)JDBCUtils.query(conn, sql,areaId, new HashFmlBufResultSetHandler());
if(schools!=null && schools.getRowCount()>0){
return schools;
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
/**
*
* @param schoolId
* @return
*/
public HashFmlBuf readAllClassBySchoolId(String schoolId) {
Connection conn=DbConn.getConn();
String sql="SELECT c.CLASS_ID,c.CLASS_NAME,c.SCHOOL_ID FROM TAB_CLASS c WHERE c.STATE='1' AND c.SCHOOL_ID=?";
HashFmlBuf classAll=null;
try {
classAll=(HashFmlBuf)JDBCUtils.query(conn, sql,schoolId, new HashFmlBufResultSetHandler());
if(classAll!=null && classAll.getRowCount()>0){
return classAll;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}