我们安装显示的要求:

我们能看到显示的目录里面有:供货企业的名字(这个数据来自于供货商的表[usergys]),流水号,通用名,剂型(这些都来自药品信息表),供货的状态(这个呢在gysypml_control中其实就是一个数字1或者0,但是我们要显示的是正常或者暂停 啊,这样的话这个信息就要查找数据字典表dictinfo才能达到这个功能的 )。。。。

所以我们在查上面要显示的内容的时候:要关联的表有

gysypml, usergys, gysypml_control, ypxx,dictinfo等

我们来看一下sql语句:

select gysypml.ypxxid,
gysypml.usergysid,
usergys.mc usergysmc,
gysypml_control.control,
(select info
from dictinfo
where typecode = ''
and dictcode = gysypml_control.control) controlmc, --这里去查的是数据字典,就是为了把0,1对应显示为暂停,正常。
ypxx.id,
ypxx.bm,
ypxx.mc,
ypxx.jx,
ypxx.gg,
ypxx.zhxs,
ypxx.scqymc,
ypxx.spmc,
ypxx.zbjg,
ypxx.jyzt, (select info
from dictinfo
where ypxx.jyzt = dictcode
and typecode = '') jyztmc from gysypml, usergys, gysypml_control, ypxx
where gysypml.usergysid = usergys.id
and gysypml.ypxxid = gysypml_control.ypxxid
and gysypml.usergysid = gysypml_control.usergysid
and gysypml.ypxxid = ypxx.id --数据范围权限,这个功能就是一个药品供应商只能看到自己能供应的药品不能看到别人的药品,所以要传一个供应商的id过来,这个id是从Action层到service层再到Dao层这样来的。
and gysypml.usergysid = '5197cdd2-08cf-11e3-8a4f-60a44cea4388'

到这里我们的sql语句就写完了。

我们在来看POJO类,以及从页面传入到Action中的包装类。

红色框里面的是用逆向工程生成的。但是我们要查询的选项比自动生成的那些pojo类要复杂,所以我们就设计自定义的pojo类,绿色方框里面的GysypmlCustom.java就是自定义的pojo类。GysypmlQuery是页面传入的包装类。

我们看一下这些类的定义:

下面这个GysypmlCustom.java这个POJO类是从数据库里面查出来的数据保存到这个类中,然后把这个数据传到页面上。这个类里面的字段是根据下面这个页面来添加的。

package yycg.business.pojo.vo;
/*
* 自定义供应商药品目录,这个类里面的字段要包含我们之前写的sql里面要查询的字段。之前要查询的信息中,
* 药品信息的字段是最多的,所以我们这里去继承药品信息表对应的pojo类
*/
public class GysypmlCustom extends YpxxCustom{
private String controlmc;//控制状态的别名1:正常。0:暂停
private String control;//控制状态(1,0)
private String usergysid;//供应商的id
public String getGysypmlid() {
return gysypmlid;
}
public void setGysypmlid(String gysypmlid) {
this.gysypmlid = gysypmlid;
}
private String ypxxid;//
private String gysypmlid;//这个是自己的加的主键。(假设的主键)gysypmlid
public String getUsergysid() {
return usergysid;
}
public void setUsergysid(String usergysid) {
this.usergysid = usergysid;
}
public String getYpxxid() {
return ypxxid;
}
public void setYpxxid(String ypxxid) {
this.ypxxid = ypxxid;
}
public String getControlmc() {
return controlmc;
}
public void setControlmc(String controlmc) {
this.controlmc = controlmc;
}
public String getControl() {
return control;
}
public void setControl(String control) {
this.control = control;
} }

我们再来看一下我们的包装类:包装类根据页面搜索传入的。

我们看一下这个GysypmlQuery.java:这个包装类

package yycg.business.pojo.vo;

import yycg.base.pojo.vo.PageQuery;
/*
*
* 查询GysymplCustom对应的包装类。也就是从页面上输入的字段所对应的包装类。
*
*/
public class GysypmlQueryVo { private PageQuery pageQuery;//页面分页
private YpxxCustom ypxxCustom; //药品信息
private GysypmlCustom gysypmlCustom;//供应商目录
public YpxxCustom getYpxxCustom() {
return ypxxCustom;
} public void setYpxxCustom(YpxxCustom ypxxCustom) {
this.ypxxCustom = ypxxCustom;
} public PageQuery getPageQuery() {
return pageQuery;
} public void setPageQuery(PageQuery pageQuery) {
this.pageQuery = pageQuery;
} public GysypmlCustom getGysymplCustom() {
return gysypmlCustom;
}
public void setGysymplCustom(GysypmlCustom gysymplCustom) {
this.gysypmlCustom = gysymplCustom;
} }

我们来看一下Dao层的代码:

也就是Mapper接口,以及xml文件。

我们看一下Mapper的编写:

package yycg.business.dao.mapper;

import java.util.List;

import yycg.business.pojo.vo.GysypmlCustom;
import yycg.business.pojo.vo.GysypmlQueryVo; public interface GysypmlMapperCustom {
public List<GysypmlCustom> findGysymplList(GysypmlQueryVo gysypmlQueryVo) throws Exception; public int findGysypmlCount(GysypmlQueryVo gysypmlQueryVo)throws Exception;
}

我们再来看一下xml文件的编写:

GysypmlMapperCustom.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="yycg.business.dao.mapper.GysypmlMapperCustom" > <!-- 供货商药品目录查询条件 -->
<sql id="query_gysympl_where">
<if test="gysypmlCustom!=null"> <if test="gysypmlCustom.usergysid!=null and gysypmlCustom.usergysid!=''">
and gysypml.usergysid = #{gysypmlCustom.usergysid}
</if>
<if test="gysypmlCustom.ypxxid!=null and gysypmlCustom.ypxxid!=''">
and gysypml.ypxxid = #{gysypmlCustom.ypxxid}
</if> </if>
</sql> <!-- 供货商目录控制查询条件 -->
<sql id="query_gysypmlcontrol_where">
<if test="gysypmlCustom!=null">
<if test="gysypmlCustom.control!=null and gysypmlCustom.control!=''">
and gysypml_control.control = #{gysypmlCustom.control}
</if>
<if test="gysypmlCustom.usergysid!=null and gysypmlCustom.usergysid!=''">
and gysypml_control.usergysid = #{gysypmlCustom.usergysid}
</if>
<if test="gysypmlCustom.ypxxid!=null and gysypmlCustom.ypxxid!=''">
and gysypml_control.ypxxid = #{gysypmlCustom.ypxxid}
</if>
</if> </sql> <!-- 供应商药品目录查询 -->
<select id="findGysymplList" parameterType="yycg.business.pojo.vo.GysypmlQueryVo" resultType="yycg.business.pojo.vo.GysypmlCustom">
<if test="pageQuery!=null">
select page_2.*
from (select page_1.*, rownum page_num
from
(
</if>
select
gysypml.id gysypmlid,
gysypml.ypxxid,
gysypml.usergysid,
usergys.mc usergysmc,
gysypml_control.control,
(select info
from dictinfo
where typecode = '008'
and dictcode = gysypml_control.control) controlmc,
ypxx.id,
ypxx.bm,
ypxx.mc,
ypxx.jx,
ypxx.gg,
ypxx.zhxs,
ypxx.scqymc,
ypxx.spmc,
ypxx.zbjg,
ypxx.jyzt, (select info
from dictinfo
where ypxx.jyzt = dictcode
and typecode = '003') jyztmc from gysypml, usergys, gysypml_control, ypxx
where gysypml.usergysid = usergys.id
and gysypml.ypxxid = gysypml_control.ypxxid
and gysypml.usergysid = gysypml_control.usergysid
and gysypml.ypxxid = ypxx.id
<!-- 传入供应商的id,供应商只能看到自己供应的药品,所以需要传入供应商的id -->
<include refid="query_gysympl_where"></include>
<!-- 根据 -->
<include refid="query_gysypmlcontrol_where" />
<!-- 药品查询条件 -->
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" />
<!-- 分页尾 -->
<if test="pageQuery!=null">
) page_1
<![CDATA[
where rownum <= ${pageQuery.PageQuery_end}) page_2
where page_2.page_num >= ${pageQuery.PageQuery_start}
]]>
</if>
</select> <!-- 供应商药品目录总数查询 -->
<select id="findGysypmlCount" parameterType="yycg.business.pojo.vo.GysypmlQueryVo" resultType="int"> select
count(1) from gysypml, usergys, gysypml_control, ypxx
where gysypml.usergysid = usergys.id
and gysypml.ypxxid = gysypml_control.ypxxid
and gysypml.usergysid = gysypml_control.usergysid
and gysypml.ypxxid = ypxx.id
<!-- 传入供应商的id,供应商只能看到自己供应的药品,所以需要传入供应商的id -->
<include refid="query_gysympl_where"></include>
<!-- 根据 -->
<include refid="query_gysypmlcontrol_where" />
<!-- 药品查询条件 -->
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" /> </select> </mapper>

这里的:

    <include refid="query_gysympl_where"></include>
<!-- 根据 -->
<include refid="query_gysypmlcontrol_where" />
<!-- 药品查询条件 -->
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" />
就是相当于把这些sql语句独立出来。效果跟写在里面是一样的。

030医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------Dao层:基本的查询语句的编写的更多相关文章

  1. 033医疗项目-模块三:药品供应商目录模块——供货商药品目录t添加查询功能----------Dao层和Service层和Action层和调试

    什么叫做供货商药品目录t添加查询功能?就是说我们前面的博客里面不是说供货商登录后看到了自己供应的药品了么如下: 现在供货商想要往里面添加别的药品,那么这个药品的来源就是卫生局提供的那个Ypxx表(药品 ...

  2. 032医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------Service层和Action层和调试

    我们上一篇文章讲了Dao层代码: 这一篇我们讲解Service层和Action层: Service层: 分为接口和实现类,我们主要看实现类:GysemplServiceImpl package yyc ...

  3. 035医疗项目-模块三:药品供应商目录模块——供货商药品目录(批量)添加药品的功能---------Service

    这篇文章我们重点介绍Service层.因为Dao层就是用Gysypml逆向生成的Mapper就可以了.所以这里重点讲解Service层. 业务逻辑如下: 1:我们从前端页面传入有两个值:1:userg ...

  4. 036医疗项目-模块三:药品供应商目录模块——供货商药品目录(批量)添加药品的功能---------Action层

    这篇文章我们来讲Action层: 我们先讲开发步骤: 1:我们要根据Service层里面要传的参数,在Action层传入对应的参数. Service层是:public void insertGysym ...

  5. 031医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------sql补充知识

    这个补充知识有一个点很有必要,视屏上的老师提出一点: 内链接关联查询: 如果表A和表B有一个外键关联 ,可以通过外键进行内链接查询 select dictinfo.*, dicttype.typena ...

  6. 023医疗项目-模块二:药品目录的导入导出-从数据库中查出数据用XSSF导出excel并存放在虚拟目录最后下载(包括调试)

    我们要实现的效果:     进入到这个页面后,输入要查询的条件,查询出药品表的数据,然后按下导出按钮 ,就会在服务器的一个目录下生成一个药品表的excel表格.  点击"导出"之后 ...

  7. 044医疗项目-模块四:采购单模块—采购单保存(Dao,Service,Action三层)

    我们上上一篇文章(042医疗项目-模块四:采购单模块-采购单明细添加查询,并且把数据添加到数据库中)做的工作是把数据插入到了数据库,我们这篇文章做的是042医疗项目-模块四:采购单模块-采购单明细添加 ...

  8. 005医疗项目-模块一:用户的查找:1.用户表查询的sql语句

    这是医疗项目的第一个模块:做一个用户的查询,可以根据用户的账号,用户的名称,单位的名称,用户的类型去查询.要求效果如下:

  9. SSH项目搭建(三)——Maven多模块搭建项目

    多模块开发,大致的思想就是把一个项目按某种方式分成多个模块,再把模块们连接成一个整体,我们在开发的时候,可以很清晰的操作每一个模块,可以大大提高开发的效率. Java web项目,最常见的就是按代码的 ...

随机推荐

  1. XCode设置(怎么让代码收缩)

    有时候刚使用一台电脑 可能会没有代码收缩的功能. 在哪里设置呢?看图 打开xcode 的 偏好设置 找到textEditing 把Code folding勾选上 就可以了

  2. iOS 从Xcode看应用支持横竖屏

    要看一个应用是否支持横竖屏,要看Xcode里面的info.plist文件设置才清楚,每一个新建工程都会包含三个支持方式,即Supported interface orientations里面的就是 P ...

  3. js window对象

    BOM的核心对象是window,它表示浏览器的一个实例. 在浏览器中,window对象是(1)通过JavaScript访问浏览器窗口的一个接口 (2)ECMAScript规定的Global对象 1.全 ...

  4. 系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式

    PS:下面是性能测试的主要概念和计算公式,记录下: 一.系统吞度量要素: 一个系统的吞度量(承压能力)与request对CPU的消耗.外部接口.IO等等紧密关联.单个reqeust 对CPU消耗越高, ...

  5. SharePoint Content Database简介

    SharePoint作为微软主打的企业Portal平台,功能强大,使用简单,非常的方便.对于很多关系数据,我们可以使用自定义列表来维护,如果是非关系数据,可以使用文档库来维护.另外还可以在上面进行版本 ...

  6. 表单和iframe的使用

    图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果.示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容.示例: 网页的拼接: 在一个网络页面 ...

  7. Storm系列(一):搭建dotNet开发Storm拓扑的环境

    上篇博客比较了目前流行的计算框架特性,如果你是 Java 开发者,那么根据业务场景选择即可:但是如果你是 .Net 开发者,那么三者都不能拿来即用,至少在这篇文章出现之前是如此.基于上篇文章的比较发现 ...

  8. English -有感过四六级后的托福单词表-附下载

    好像自从上学期不高不低过了六级之后就没怎么持续接触英语的东西了,欧,除了要debug的时候遇到问题了,去Google到了再用那些仅有的英语知识去看别人的文章.可能是因为看到的都是自己平时接触过的方面的 ...

  9. bootstrap简单的过一遍

    注:.xxxx 表示类(class=xxxx) <h1>到<h6>均可使用.另外还提供了.h1到.h6的class .lead可以让段落突出显示 <small>  ...

  10. 使用自定义setTimeout和setInterval使之可以传递参数和对象参数

    转载自http://www.jb51.net/article/17859.htm /****************************************************** //  ...