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 代碼---------------------
<sqlMap>
<resultMap class="java.util.HashMap" id="out_ResultMap">
<result column="tjmc" property="tjmc" jdbcType="VARCHAR" />
<result column="typecode" property="typecode" jdbcType="VARCHAR" />
<result column="typename" property="typename" jdbcType="VARCHAR" />
<result column="gjje" property="gjje" jdbcType="DECIMAL" />
<result column="lsje" property="lsje" jdbcType="DECIMAL" />
<result column="ce" property="ce" jdbcType="DECIMAL" />
</resultMap>
<parameterMap id="byinstorageParam" class="java.util.HashMap">
<parameter property="OFFICEID" jdbcType="NUMBER" mode="IN"/>
<parameter property="S_DATE" jdbcType="DATE" mode="IN"/>
<parameter property="E_DATE" jdbcType="DATE" mode="IN"/>
<parameter property="TJFX" jdbcType="NUMBER" mode="IN"/>
<parameter property="FSID" jdbcType="NUMBER" mode="IN"/>
<parameter property="FORGID" jdbcType="NUMBER" mode="IN"/>
<parameter jdbcType="ORACLECURSOR" mode="OUT"
property="DATA" javaType="java.sql.ResultSet" resultMap="out_ResultMap"/>
</parameterMap>
<procedure id="sp_report_yk_rkhzb" parameterMap="byinstorageParam">
{call sp_report_yk_rkhzb(?,?,?,?,?,?,?)}
</procedure>
</sqlMap>
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();
}