1、使用供货商登陆系统,点击“供货商药品目录维护”
显示了供货商药品目录 信息。
5.2.1 Dao
自定义查询条件,查询供货商药品目录,供货商只允许查询到本供货商供应的药品信息
自定义mapper:
Sql:
主查询表:gysypml(供货商药品目录表),查询结果数量根据主查询表来定。
关联查询表:供货商名称(usergys)、供货状态(gysypml_control),药品信息(ypxx)
-- 确定主查询表 gysypml
-- V1.0 查询出供应商名称 添加辅助查询表 usergys
select gysypml.*, usergys.mc gysmc
from gysypml, usergys
where gysypml.usergysid = usergys.id
-- V2.0 查询出供货状态 gysypml_control
-- 状态是数字需要转换成文字状态
select gysypml.*, usergys.mc gysmc,gysypml_control.control,
(select info from dictinfo where typecode ='' and dictcode = gysypml_control.control )controlmc
from gysypml, usergys, gysypml_control
where gysypml.usergysid = usergys.id
and gysypml.ypxxid = gysypml_control.ypxxid
and gysypml.usergysid = gysypml_control.usergysid
-- V3.0 查询出药品信息
select gysypml.ypxxid,
gysypml.usergysid,
usergys.mc gysmc,
gysypml_control.control,
(select info
from dictinfo
where typecode = ''
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
-- V4.0 查询出某一个供应商的信息
--数据范围权限
and gysypml.usergysid = '5197cdd2-08cf-11e3-8a4f-60a44cea4388'
and gysypml_control.control = '1' -- 控制状态
// dao
/** 供应商药品目录查询 */
public List<GysypmlCustom> findGysypmlList(GysypmlQueryVo gysypmlQueryVo) throws Exception;
public int findGysypmlCount(GysypmlQueryVo gysypmlQueryVo) throws Exception;
<sql id="query_ypml_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_ypmlcontrol_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="findGysypmlList" 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 gysmc,
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
<include refid="query_ypml_where">include>
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where">include>
<include refid="query_ypmlcontrol_where">include>
<if test="pageQuery!=null">
) page_1
= ${pageQuery.PageQuery_start}
]]>
if>
select>
5.2.2 Service
接口功能:供货商查询供货商自己药品目录信息
接口参数:供货商id(数据范围权限),查询条件
public List findGysypmlList(String usergysId,
GysypmlQueryVo gysypmlQueryVo) throws Exception {
// 非空判断
gysypmlQueryVo = gysypmlQueryVo != null?gysypmlQueryVo:new GysypmlQueryVo();
GysypmlCustom gysypmlCustom = gysypmlQueryVo.getGysypmlCustom();
if(gysypmlCustom == null){
gysypmlCustom = new GysypmlCustom();
}
// 设置供货商id
gysypmlCustom.setUsergysid(usergysId);
gysypmlQueryVo.setGysypmlCustom(gysypmlCustom);
return gysypmlMapperCustom.findGysypmlList(gysypmlQueryVo);
}
5.2.3 Action:
//查询页面
@RequestMapping("querygysypml")
public String querygysypml(Model model) throws Exception{
return "/business/ypml/querygysypml";
}
//供货商药品目录 json数据
//查询页面
@RequestMapping("querygysypml_result")
public @ResponseBody DataGridResultInfo querygysypml_result(HttpSession session,
GysypmlQueryVo gysypmlQueryVo, int page, int rows)
throws Exception{
// 数据总数
// 当前用户 用户所属的单位
ActiveUser activeUser = (ActiveUser)session.getAttribute(Config.ACTIVEUSER_KEY);
String usergysId = activeUser.getSysid();
int total = ypmlSerice.findGysypmlCount(usergysId, gysypmlQueryVo);
// 数据列表
// 分页参数
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
gysypmlQueryVo.setPageQuery(pageQuery);
List list = ypmlSerice.findGysypmlList(usergysId, gysypmlQueryVo);
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
dataGridResultInfo.setRows(list);
dataGridResultInfo.setTotal(total);
return dataGridResultInfo;
}
5.2.4 调试
错误:
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘ypxxCustom’ in ‘class yycg.business.pojo.vo.GysypmlQueryVo’
at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:377)
执行mapper查询时,查询条件需要从’ypxxCustom’获取属性值 ,调用parameterType指定对象的getter方法。
6 供货商药品目录添加查询
供货商查询药品目录(ypxx) ,从里边选择要供应的药品.
6.2.1 dao
供货商药品添加目录查询,查询药品目录表,查询列表中将供货商药品目录已经存在药品过虑掉。
Sql:
主查询表:ypxx表
关联查询表:在where条件 中,过虑掉供货商药品目录 表的记录
原始sql
select *
--子查询,关联查询到说明此药品id在供货商药品目录存在
from ypxx
--查询子查询不为空的值
where not exists
(select id from gysypml where usergysid='5197cdd2-08cf-11e3-8a4f-60a44cea4388' and ypxx.id = gysypml.ypxxid)
<select id="findAddGysypmlCount" parameterType="yycg.business.pojo.vo.GysypmlQueryVo"
resultType="int">
select count(*) from ypxx
where not exists (select id from gysypml where usergysid = #{gysypmlCustom.usergysid}
and ypxx.id = gysypml.ypxxid)
"yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" />
select>
bean
public class SysuserCustom extends Sysuser {
// 单位名称
private String sysmc;
// 用户类别名称
private String groupname;
}
public class SysuserQueryVo {
private SysuserCustom sysuserCustom;
// 分页参数
private PageQuery pageQuery;
}
mapper 方法
/** 供应商药品目录查询 */
public List findAddGysypmlList(GysypmlQueryVo gysypmlQueryVo) throws Exception;
public int findAddGysypmlCount(GysypmlQueryVo gysypmlQueryVo) throws Exception;
service同上
action 同上