我们安装显示的要求:

我们能看到显示的目录里面有:供货企业的名字(这个数据来自于供货商的表[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. NSJSONSerialization

    /*     总结:   json格式的读写: 解析: data =   NSData  dataWithContentsOfUrl:XXX id obj  =  [ NSJsonSerializat ...

  2. android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习

    跑马灯效果 1.用过属性的方式实现跑马灯效果 属性:                  android:singleLine="true" 这个属性是设置TextView文本中文字 ...

  3. iOS开发之集成百度地图踩过的那些坑(基于 Xcode7.0/iOS9.2)

    本篇分4步讲述如何在项目中集成百度地图: 第一步:创建项目 第二步:利用 cocoaPod 导入百度地图的 SDK(pod 'BaiduMapKit' #百度地图SDK) 第三步:在 pch 文件中导 ...

  4. art.dialog.art 中,将子页面窗口中的值传递给父框架中

    artDialog.open.origin.document.getElementById('父元素ID').value=document.getElementById('子页面元素ID').valu ...

  5. php设计模式 观察者模式

    观察者模式的核心是把客户元素(观察者)从一个中心类(主体)中分离开来.当主体知道事件发生时,观察者需要被通知到.同时,我们并不希望将主体与观察者之间的关系进行硬编码.为了达到这个目的,我们可以允许观察 ...

  6. 原 ng-include用法分析以及多标签页面的简单实现方式

    Demo:http://webenh.chinacloudsites.cn/Default/Demo2 在平时的项目开发中,应该会经常遇到上图所示的需求,就是在一个页面中有多个标签,被选中的标签颜色会 ...

  7. JAVA 8 Optional类介绍及其源码

    什么是Optional对象 Java 8中所谓的Optional对象,即一个容器对象,该对象可以包含一个null或非null值.如果该值不为null,则调用isPresent()方法将返回true,且 ...

  8. *MyBatis框架 在控制台打印sql语句

    在 log4j.properties  中将这段代码添加进去就好了#log4j.rootLogger=INFO, Console#Consolelog4j.appender.Console=org.a ...

  9. js技术发展

    将.NET代码编译为JavaScript 你可以使用如下工具将C#.F#以及其他.NET代码编译为JavaScript代码. Apps in Motion:允许使用C#来构建可以运行在任何设备上的We ...

  10. MongoDB 常用故障排查工具

    1.profile profiling levels: 0,关闭profile:1,只抓取slow查询:2,抓取所有数据. 启动profile并且设置Profile级别: 可以通过mongo shel ...