栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

题库tiku

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

题库tiku



	
		
		
		
		
		
	
	
		
  • 通知公告
  • 门诊医生站
  • 住院医生站
  • 住院登记管理
  • 医院报告
  • 全局模板管理
  • 医院模板管理
  • 病例病案管理
  • 病例权限管理
  • 个人设置
患者名称:
  • 本人
  • 科室
待诊患者信息 已诊患者信息
  • 门诊首页
  • 门诊病例
  • 成药处方
  • 草药处方
  • 检查申请
  • 检验申请
  • 处置单
  • 中医项目
  • 患者账单
基本信息 姓名 病例号
性别 出生日期
年龄 身份证号
西医诊断
更新发票号 挂号信息
  • 退费
  • 退号
  • 清屏
  • 医保卡读卡
  • 农合卡读卡
  • 身份证读卡
  • 健康卡读卡
  • 熙康卡读卡
挂号信息列表
病历号 姓名 性别 出生日期 身份证号 发票号 结算类别
挂号发票信息 门诊收费明细
项目名称 药品标识 项目状态 单价 总金额
package com.neusoft.test1.dao; import com.neusoft.test1.model.Toy; import com.neusoft.test1.utils.DBUtil; import org.junit.Test; import java.sql.*; import java.util.ArrayList; import java.util.List; public class ToyDao { @Test public void test1() { List toys = this.findByToyName(1, 10, "test"); for (Toy f : toys) { System.out.println(f.toString()); } } @Test public void test2() { List toys = this.findByTypeName(1, 10, "test"); for (Toy f : toys) { System.out.println(f.toString()); } } @Test public void test3() { List toys = this.findByComment(1, 10, "test"); for (Toy f : toys) { System.out.println(f.toString()); } } @Test public void test4() { List toys = this.findByPrice(1, 10, 10, 50); for (Toy f : toys) { System.out.println(f.toString()); } } public List search(int currentPage, int pageSize, Toy condition, int minPrice, int maxPrice) { List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; List params = new ArrayList(); try { conn = DBUtil.getCon(); StringBuilder builder = new StringBuilder(); builder.append( " select f.id,f.toyname,t.typename,f.intro,f.comment,f.price from toy f left join toytype t on f.type = t.id where 1=1 "); if (null != condition.getToyName() && !condition.getToyName().equals("")) { builder.append(" and f.toyname like ? "); params.add("toyname," + condition.getToyName()); } if (null != condition.getTypeName() && !condition.getTypeName().equals("")) { builder.append(" and t.typename = ? "); params.add("typename," + condition.getTypeName()); } if (null != condition.getComment() && !condition.getComment().equals("")) { builder.append(" and f.comment like ? "); params.add("comment," + condition.getComment()); } if (minPrice != 0 && maxPrice != 0) { builder.append(" and f.price between ? and ? "); params.add("minPrice," + minPrice); params.add("maxPrice," + maxPrice); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); for (int i = 0; i < params.size(); i++) { String str = params.get(i); String[] arr = str.split(","); if ("toyname".equals(arr[0]) || "comment".equals(arr[0])) { ps.setString(i + 1, "%" + arr[1] + "%"); } ps.setString(i + 1, arr[1]); } ps.setInt(params.size()+1, (currentPage - 1) * pageSize); ps.setInt(params.size()+2, pageSize); rs = ps.executeQuery(); while (rs.next()) { Toy f = new Toy(); f.setId(rs.getInt("id")); f.setToyName(rs.getString("toyname")); f.setIntro(rs.getString("intro")); f.setComment(rs.getString("comment")); f.setPrice(rs.getInt("price")); f.setTypeName(rs.getString("typename")); list.add(f); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return list; } public List findByToyName(int currentPage, int pageSize, String toyname) { List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBUtil.getCon(); StringBuilder builder = new StringBuilder(); builder.append( " select f.id,f.toyname,t.typename,f.intro,f.comment,f.price from toy f left join toytype t on f.type = t.id "); if (null != toyname && toyname.length() > 0) { builder.append(" where f.toyname like ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); ps.setString(1, "%" + toyname + "%"); ps.setInt(2, (currentPage - 1) * pageSize); ps.setInt(3, pageSize); rs = ps.executeQuery(); while (rs.next()) { Toy f = new Toy(); f.setId(rs.getInt("id")); f.setToyName(rs.getString("toyname")); f.setIntro(rs.getString("intro")); f.setComment(rs.getString("comment")); f.setPrice(rs.getInt("price")); f.setTypeName(rs.getString("typename")); list.add(f); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return list; } public List findByTypeName(int currentPage, int pageSize, String typename) { List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBUtil.getCon(); StringBuilder builder = new StringBuilder(); builder.append( " select f.id,f.toyname,t.typename,f.intro,f.comment,f.price from toy f left join toytype t on f.type = t.id "); if (null != typename && typename.length() > 0) { builder.append(" where t.typename = ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); ps.setString(1, typename); ps.setInt(2, (currentPage - 1) * pageSize); ps.setInt(3, pageSize); rs = ps.executeQuery(); while (rs.next()) { Toy f = new Toy(); f.setId(rs.getInt("id")); f.setToyName(rs.getString("toyname")); f.setIntro(rs.getString("intro")); f.setComment(rs.getString("comment")); f.setPrice(rs.getInt("price")); f.setTypeName(rs.getString("typename")); list.add(f); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return list; } public List findByComment(int currentPage, int pageSize, String comment) { List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBUtil.getCon(); StringBuilder builder = new StringBuilder(); builder.append( " select f.id,f.toyname,t.typename,f.intro,f.comment,f.price from toy f left join toytype t on f.type = t.id "); if (null != comment && comment.length() > 0) { builder.append(" where f.comment like ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); ps.setString(1, "%" + comment + "%"); ps.setInt(2, (currentPage - 1) * pageSize); ps.setInt(3, pageSize); rs = ps.executeQuery(); while (rs.next()) { Toy f = new Toy(); f.setId(rs.getInt("id")); f.setToyName(rs.getString("toyname")); f.setIntro(rs.getString("intro")); f.setComment(rs.getString("comment")); f.setPrice(rs.getInt("price")); f.setTypeName(rs.getString("typename")); list.add(f); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return list; } public List findByPrice(int currentPage, int pageSize, int minPrice, int maxPrice) { List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBUtil.getCon(); StringBuilder builder = new StringBuilder(); builder.append( " select f.id,f.toyname,t.typename,f.intro,f.comment,f.price from toy f left join toytype t on f.type = t.id "); if (minPrice != 0 && maxPrice != 0) { builder.append(" where f.price between ? and ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); ps.setInt(1, minPrice); ps.setInt(2, maxPrice); ps.setInt(3, (currentPage - 1) * pageSize); ps.setInt(4, pageSize); rs = ps.executeQuery(); while (rs.next()) { Toy f = new Toy(); f.setId(rs.getInt("id")); f.setToyName(rs.getString("toyname")); f.setIntro(rs.getString("intro")); f.setComment(rs.getString("comment")); f.setPrice(rs.getInt("price")); f.setTypeName(rs.getString("typename")); list.add(f); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return list; } } package com.neusoft.test1.utils; import java.sql.*; public class DBUtil { public static Connection getCon() throws Exception { String jdbcName = "com.mysql.jdbc.Driver"; Class.forName(jdbcName); String dbUrl = "jdbc:mysql://localhost:3306/db_test_d?useUnicode=true&characterEncoding=UTF-8"; String dbUser = "root"; String dbPassword = "123456"; Connection conn = DriverManager.getConnection(dbUrl, dbUser, dbPassword); return conn; } public static void close(ResultSet rs, PreparedStatement pstmt, Connection conn) { if (rs != null) { try { rs.close(); if (pstmt != null) { pstmt.close(); if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } } } } package com.neusoft.test.dao; import com.neusoft.test.model.Toy; import com.neusoft.test.utils.DBUtils; import org.junit.Test; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; public class ToyDao { @Test public void test1(){ List lists = this.find(1, 10, "张三", "鸡"); for (Toy f:lists) { System.out.println(f); } } @Test public void test2(){ List lists = this.findByPrice(1, 10, "张三", 5,50); for (Toy f:lists) { System.out.println(f); } } public List find(int currentPage,int pageSize,String username,String toyname){ List list = new ArrayList(); Connection conn=null; PreparedStatement ps = null; ResultSet rs = null; try { conn=DBUtils.getConn(); StringBuilder builder = new StringBuilder(); builder.append(" select f.id, f.toyname, t.typename, f.intro, f.comment, f.price,t.typenamen" + "from shoppingcart on" + " left join user u on o.userid = u.idn" + " left join toy f on f.id = o.toyidn" + " left join toytype t on t.id = f.type where 1=1 "); if(null!=username&&username.length()>0){ builder.append(" and u.username = ? "); } if(null!=toyname&&toyname.length()>0){ builder.append(" and f.toyname like ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); int count=1; if(null!=username&&username.length()>0){ ps.setString(count,username); count++; } if(null!=toyname&&toyname.length()>0){ ps.setString(count,"%"+toyname+"%"); count++; } ps.setInt(count,(currentPage-1)*pageSize); count++; ps.setInt(count,pageSize); rs = ps.executeQuery(); while (rs.next()){ Toy t = new Toy(); t.setId(rs.getInt("id")); t.setToyName(rs.getString("toyname")); t.setIntro(rs.getString("intro")); t.setComment(rs.getString("comment")); t.setPrice(rs.getInt("price")); t.setTypeName(rs.getString("typename")); list.add(t); } }catch (Exception e){ e.printStackTrace(); }finally { DBUtils.close(rs,ps,conn); } return list; } public List findByPrice(int currentPage,int pageSize,String username,int minPrice,int maxPrice){ List list = new ArrayList(); Connection conn=null; PreparedStatement ps = null; ResultSet rs = null; try { conn=DBUtils.getConn(); StringBuilder builder = new StringBuilder(); builder.append(" select f.id, f.toyname, t.typename, f.intro, f.comment, f.price,t.typenamen" + "from shoppingcart on" + " left join user u on o.userid = u.idn" + " left join toy f on f.id = o.toyidn" + " left join toytype t on t.id = f.type where 1=1 "); if(null!=username&&username.length()>0){ builder.append(" and u.username = ? "); } if(0!=minPrice&&maxPrice!=0){ builder.append(" and f.price between ? and ? "); } builder.append(" order by f.id desc limit ?,? "); ps = conn.prepareStatement(builder.toString()); int count=1; if(null!=username&&username.length()>0){ ps.setString(count,username); count++; } if(0!=minPrice&&maxPrice!=0){ ps.setInt(count,minPrice); count++; ps.setInt(count,maxPrice); count++; } ps.setInt(count,(currentPage-1)*pageSize); count++; ps.setInt(count,pageSize); rs = ps.executeQuery(); while (rs.next()){ Toy t = new Toy(); t.setId(rs.getInt("id")); t.setToyName(rs.getString("toyname")); t.setIntro(rs.getString("intro")); t.setComment(rs.getString("comment")); t.setPrice(rs.getInt("price")); t.setTypeName(rs.getString("typename")); list.add(t); } }catch (Exception e){ e.printStackTrace(); }finally { DBUtils.close(rs,ps,conn); } return list; } }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/995411.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号