用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

社区医院预约系统

2017-09-11 作者: 云代码会员举报

[java]代码库

package org.com.dao;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
 
import org.com.model.GuaHao;
import org.com.model.PageBean;
import org.com.model.Patient;
import org.com.util.DateUtil;
import org.com.util.StringUtil;
 
public class GuaHaoDao {
     
    public ResultSet guahaoList(Connection con,PageBean pageBean,Patient patient,GuaHao guahao, String s_bGhDate, String s_eGhDate)throws Exception{
        StringBuffer sb=new StringBuffer("SELECT * FROM t_ghinfo g ,t_patient p ,t_user u WHERE p.userId=u.userId AND g.patientId=p.patientId");
        if(patient.getUserId()!=-1){           
            sb.append(" and p.userId = '"+patient.getUserId()+"'");
        }
        if(StringUtil.isNotEmpty(guahao.getPatientName())){
            sb.append(" and p.patientName like '%"+guahao.getPatientName()+"%'");
        }
        if(StringUtil.isNotEmpty(patient.getSex())){
            sb.append(" and p.sex ='"+patient.getSex()+"'");
        }
        if(StringUtil.isNotEmpty(s_bGhDate)){
            sb.append(" and TO_DAYS(g.date)>=TO_DAYS('"+s_bGhDate+"')");
        }
        if(StringUtil.isNotEmpty(s_eGhDate)){
            sb.append(" and TO_DAYS(g.date)<=TO_DAYS('"+s_eGhDate+"')");
        }
        if(StringUtil.isNotEmpty(guahao.getOfficeName())){
            sb.append(" and g.officeName ='"+guahao.getOfficeName()+"'");
        }
        //分页
        if(pageBean!=null){
            sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows());
        }
        PreparedStatement pstmt=con.prepareStatement(sb.toString());
        return pstmt.executeQuery();
    }
    /**
     * 获取数据总条数
     * @param con
     * @param grade
     * @return
     * @throws Exception
     */
    public int guahaoCount(Connection con,Patient patient, GuaHao guahao, String s_bGhDate, String s_eGhDate)throws Exception{
        StringBuffer sb=new StringBuffer("select count(*) as total from t_ghinfo g ,t_patient p ,t_user u WHERE p.userId=u.userId AND g.patientId=p.patientId");
        if(patient.getUserId()!=-1){           
            sb.append(" and p.userId = '"+patient.getUserId()+"'");
        }
        if(StringUtil.isNotEmpty(guahao.getPatientName())){
            sb.append(" and p.patientName like '%"+guahao.getPatientName()+"%'");
        }
        if(StringUtil.isNotEmpty(patient.getSex())){
            sb.append(" and p.sex ='"+patient.getSex()+"'");
        }
        if(StringUtil.isNotEmpty(s_bGhDate)){
            sb.append(" and TO_DAYS(g.date)>=TO_DAYS('"+s_bGhDate+"')");
        }
        if(StringUtil.isNotEmpty(s_eGhDate)){
            sb.append(" and TO_DAYS(g.date)<=TO_DAYS('"+s_eGhDate+"')");
        }
        if(StringUtil.isNotEmpty(guahao.getOfficeName())){
            sb.append(" and g.officeName ='"+guahao.getOfficeName()+"'");
        }
        PreparedStatement pstmt=con.prepareStatement(sb.toString());
        ResultSet rs=pstmt.executeQuery();
        if(rs.next()){
            return rs.getInt("total");
        }else{
            return 0;
        }
    }
    /**
     *  数据库插入数据
     * @param con
     * @param guahao
     * @return
     * @throws Exception
     */
    public int guahaoAdd(Connection con, GuaHao guahao)throws Exception{
        String sql="insert into t_ghinfo values(null,?,?,?,?,?)";
        PreparedStatement pstmt=con.prepareStatement(sql);
        pstmt.setInt(1, guahao.getPatientId());
        pstmt.setString(2, new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date()));//将当前时间作为流水号码
        pstmt.setString(3, DateUtil.formatDate(guahao.getDate(), "yyyy-MM-dd"));
        pstmt.setString(4, guahao.getOfficeName());
        pstmt.setString(5, guahao.getGhDesc());
        return pstmt.executeUpdate();
    }
    /**
     * 修改数据
     * @param con
     * @param guahao
     * @return
     * @throws Exception
     */
    public int guahaoModify(Connection con, GuaHao guahao)throws Exception{
        String sql="update t_ghinfo set patientId=? , date=? , officeName=? , ghDesc=? where ghId=?";
        PreparedStatement pstmt=con.prepareStatement(sql);
        pstmt.setInt(1, guahao.getPatientId());
        pstmt.setString(2, DateUtil.formatDate(guahao.getDate(), "yyyy-MM-dd"));
        pstmt.setString(3, guahao.getOfficeName());
        pstmt.setString(4, guahao.getGhDesc());
        pstmt.setInt(5, guahao.getGhId());
        return pstmt.executeUpdate();
    }
    /**
     * 删除数据
     * @param con
     * @param delIds
     * @return
     * @throws Exception
     */
    public int guahaoDelete(Connection con,String delIds)throws Exception{
        String sql="delete from t_ghinfo where ghId in("+delIds+")";
        PreparedStatement pstmt=con.prepareStatement(sql);
        return pstmt.executeUpdate();
    }
    /**
     * 统计每个科室的挂号数量
     * @param con
     * @return
     * @throws Exception
     */
    public ResultSet guahaoChart(Connection con,Patient patient, GuaHao guahao) throws Exception {
        StringBuffer sb=new StringBuffer("SELECT g.officeName,COUNT(*) FROM t_ghinfo g ,t_patient p ,t_user u WHERE p.userId=u.userId AND g.patientId=p.patientId");
        if(patient.getUserId()!=-1){           
            sb.append(" AND p.userId = '"+patient.getUserId()+"'");
        }
        sb.append(" GROUP BY g.officeName");           
        PreparedStatement pstmt=con.prepareStatement(sb.toString());
        return pstmt.executeQuery();
    }
}

[代码运行效果截图]


社区医院预约系统

[源代码打包下载]




网友评论    (发表评论)

共6 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...