CREATE OR REPLACE PROCEDURE SP_REPORT_YK_RKHZB(ai_baseid numeric,
adt_date_b date,
adt_date_e date,
ai_tjfs number,
ai_fsid number,
ai_forgid number,
out_cur out his_zyjs.ref_cur)
AS
/************************************************************
功能:入库汇总统计
名称:
参数 ai_baseid 当前科室ID
as_date_b 统计时间段
as_date_e 统计时间段
ai_tjfs 1按入库方式 2按供应商 3 按产地
ai_fsid 对就方式,对应供应商ID 对应产地ID
调用:药库管理-统计查询-入库汇总表
创建:xck 2012-07-07
*************************************************************/
vd_begin date;
vd_end date;
begin
vd_begin := to_date(to_char(adt_date_b,'yyyy-mm-dd')||'00:00:00','yyyy-mm-dd hh24:mi:ss');
vd_end := to_date(to_char(adt_date_e,'yyyy-mm-dd')||'23:59:59','yyyy-mm-dd hh24:mi:ss');
if ai_tjfs = 1 then
--按入库方式统计
open out_cur for
SELECT pkg_bshis_common.F_GET_ADD('dictorigin',a.tranid,'originname') as tjmc,
d.typecode,
d.typename,
sum(b.actmon) as gjje,
sum(b.retailmon) as lsje,
sum(b.retailmon - b.actmon) as ce
FROM glide_total a,
glide b,
dictmedi c,
dicttype d
WHERE a.glideid = b.glideid
and b.mediid = c.mediid
and c.typeid = d.typecode
and a.forgid = b.forgid
and b.forgid = c.forgid
and c.forgid = d.forgid
and a.inout = 1
and a.auditdate >= vd_begin
and a.auditdate <= vd_end
and a.baseid = ai_baseid
and a.forgid = ai_forgid
GROUP BY a.tranid,d.typecode,d.typename
order by d.typecode;
elsif ai_tjfs = 2 then
--按供应商统计
open out_cur for
SELECT pkg_bshis_common.F_GET_ADD('dictoffice',a.fellowid,'officename') as tjmc,
d.typecode,
d.typename,
sum(b.actmon) as gjje,
sum(b.retailmon) as lsje,
sum(b.retailmon - b.actmon) as ce
FROM glide_total a,
glide b,
dictmedi c,
dicttype d
WHERE a.glideid = b.glideid
and b.mediid = c.mediid
and c.typeid = d.typecode
and a.forgid = b.forgid
and b.forgid = c.forgid
and c.forgid = d.forgid
and a.inout = 1
and a.auditdate >= vd_begin
and a.auditdate <= vd_end
and (a.fellowid = ai_fsid or ai_fsid = 0)
and a.baseid = ai_baseid
and a.forgid = ai_forgid
GROUP BY a.fellowid,d.typecode,d.typename
order by d.typecode;
elsif ai_tjfs = 3 then
--按产地统计
open out_cur for
SELECT pkg_bshis_common.F_GET_ADD('echocarry',b.carrid,'carryname') as tjmc,
d.typecode,
d.typename,
sum(b.actmon) as gjje,
sum(b.retailmon) as lsje,
sum(b.retailmon - b.actmon) as ce
FROM glide_total a,
glide b,
dictmedi c,
dicttype d
WHERE a.glideid = b.glideid
and b.mediid = c.mediid
and c.typeid = d.typecode
and a.forgid = b.forgid
and b.forgid = c.forgid
and c.forgid = d.forgid
and a.inout = 1
and a.auditdate >= vd_begin
and a.auditdate <= vd_end
and (b.carrid = ai_fsid or ai_fsid = 0)
and a.baseid = ai_baseid
and a.forgid = ai_forgid
GROUP BY b.carrid,d.typecode,d.typename
order by d.typecode;
end if;
end;
java 代码---------------------
{call sp_report_yk_rkhzb(?,?,?,?,?,?,?)}
public List byInstorage(Map map) {
getSqlMapClientTemplate().queryForObject("INSTORAGESUM.sp_report_yk_rkhzb", map);
Object data = map.get("DATA");
return data != null ? (List)data : new ArrayList();
}