create or replace package pack_materialUtils
is
--type materialRecordsType is table of eachMaterialRecord index by binary_integer;
--获得指定出库单包含的物资的名称
--molId:出库单id
--strlink:物资名称的连接符
function getNamesByMol(molId number) return varchar2;
function getNamesByMil(milId number) return varchar2;
function getMaterialSerialNumber(deptId varchar2) return varchar2;
function getPiciByMilSn(milsn varchar2) return varchar2;
function getPiciByMolSn(molsn varchar2) return varchar2;
function searchMaterial(materialName varchar2,
deptId varchar2,
storeType varchar2,
gridRibboncode varchar2,
materialType varchar2,
storeId varchar2)
return materialRecordsType;
end pack_materialUtils;
create or replace package body pack_materialUtils
is
--*******函数1***********
--取出库单物资的名称(拼接成字符串)
--Chency
--20130927
function getNamesByMol(molId number) return varchar2
is
resultNames varchar2(2000) := '';
tempName material.name%type;
cursor c_mo is select m.name from material m right join material_out mo on mo.material_id = m.id where mo.material_out_list_id = molId;
begin
open c_mo;
fetch c_mo into tempName;
while c_mo%found loop
resultNames := tempName || ',' || resultNames;
fetch c_mo into tempName;
end loop;
return resultNames;
close c_mo;
end;
--*******函数1***********
--取入库单物资的名称(拼接成字符串)
--Chency
--20130927
function getNamesByMil(milId number) return varchar2
is
resultNames varchar2(20000) := '';
tempName material.name%type;
cursor c_mi is select m.name from material m right join material_in mi on mi.material_id = m.id where mi.material_in_list_id = milId;
begin
open c_mi;
fetch c_mi into tempName;
while c_mi%found loop
resultNames := tempName || ',' || resultNames;
fetch c_mi into tempName;
end loop;
return resultNames;
close c_mi;
end;
/*
--/取得单位的出库单、入库单的流水号
说明:
1,流水号:形式20130912xxxxxMMMMMM,前面是年月日,中间xxxxx是部门的id后边是本田的第几个流水号5位数字组成
2,该函数每次调用都会返回当日最大的流水号,调用完之后更新最大流水号加一。
3,出库单,入库单的流水号是全市唯一的
*/
function getMaterialSerialNumber(deptId varchar2) return varchar2
is
v_realToday varchar2(20);
v_tempToday varchar2(20);
v_realMaxNumber int;
v_tempMaxNumber int;
v_tempId material_serial_number.id%type;
v_result varchar2(20);
cursor c is select today from material_serial_number where dept_id = deptId for update;
begin
select hibernate_sequence.nextval into v_tempId from dual;
select to_char(sysdate,'yyyymmdd') into v_realToday from dual;
-- select today from material_serial_number where dept_id = deptId;
open c;
fetch c into v_tempToday;
if c%FOUND THEN
select today into v_tempToday from material_serial_number where dept_id = deptId;
dbms_output.put_line('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
if v_realToday = v_tempToday then --如果序列表里有当前的记录
select maxNumber into v_realMaxNumber from material_serial_number where dept_id = deptId and today = v_realToday;
--生成流水号最后的序号
dbms_output.put_line('长度:' || lengthb(to_char(v_realMaxNumber)));
case lengthb(to_char(v_realMaxNumber))
when 1 then
v_result := v_realToday || to_char(deptId) || '0000' || to_char(v_realMaxNumber);
when 2 then
v_result := v_realToday || to_char(deptId) || '000' || to_char(v_realMaxNumber);
when 3 then
v_result := v_realToday || to_char(deptId) || '00' || to_char(v_realMaxNumber);
when 4 then
v_result := v_realToday || to_char(deptId)|| '0' || to_char(v_realMaxNumber);
else
v_result := v_realToday || to_char(deptId) || to_char(v_realMaxNumber);
end case;
--更新序列表
else
delete from material_serial_number where dept_id = deptId;
insert into material_serial_number values(v_tempId,0,v_realToday,1,deptId);
dbms_output.put_line('ccccccccccccccccccccccccccccccccccccccccccc');
v_result := v_realToday || to_char(deptId) || '00001';
end if;
else
insert into material_serial_number values(v_tempId,0,v_realToday,1,deptId);
dbms_output.put_line('ddddddddddddddddddddddddddddddddddddddddddddddddd');
v_result := v_realToday || to_char(deptId) || '00001';
end if;
update material_serial_number set maxnumber = maxnumber + 1 where dept_id = deptId;
commit;
return v_result;
end;
/*
根据入库单的流水号
*/
function getPiciByMilSn(milsn varchar2) return varchar2
is
v_count integer;
v_result varchar2(10);
begin
select count(*)+1 into v_count from material_in where mil_serial_number = milsn;
case lengthb(v_count)
when 1 then
v_result := '00'|| to_char(v_count);
when 2 then
v_result := '0'|| to_char(v_count);
when 3 then
v_result := to_char(v_count);
else
v_result := '批次达到最大数';
end case;
return v_result;
end;
--取得出库记录的批次
function getPiciByMolSn(molsn varchar2) return varchar2
is
v_count integer;
v_result varchar2(10);
begin
select count(*)+1 into v_count from material_out where mol_serial_number = molsn;
case lengthb(v_count)
when 1 then
v_result := '00'|| to_char(v_count);
when 2 then
v_result := '0'|| to_char(v_count);
when 3 then
v_result := to_char(v_count);
else
v_result := '批次达到最大数';
end case;
return v_result;
end;
--******************根据传递的参数查询库里的物资 **************************************
function searchMaterial(
materialName varchar2,
deptId varchar2,
storeType varchar2,
gridRibboncode varchar2,
materialType varchar2,
storeId varchar2)
return materialRecordsType
is
type ref_eachMaterialTotal is ref cursor; --声明游标变量类型
v_materialRecords materialRecordsType := materialRecordsType(); --定义存放结果集 表
v_cursor ref_eachMaterialTotal; --定义游标变量
v_cursorTemp ref_eachMaterialTotal; --定义暂时的游标变量
v_temp eachMaterialRecord; --测试变量
v_i int := 1;
begin
FOR emp_record IN ( select m.id,m.name materialName ,mi.totalnumber inputMaterialNumber,totalrealnumber remaindNumber,mi.totalPrice totalPrice from material m
join (select material_id, sum(material_mumber) totalnumber,sum(real_mumber) totalrealnumber, sum(price * real_mumber) totalPrice from material_in
where 1=1
and instr(decode(deptId, '', 'yes', dept_id,'yes'), 'y') > 0
and instr(decode(storeId, '', 'yes', store_id,'yes'), 'y') > 0
group by material_id)mi
on m.id = mi.material_id
where 1=1
and instr(decode(materialName, '', 'yes', m.name,'yes'), 'y') > 0
)
LOOP
v_materialRecords.extend();
v_materialRecords(v_materialRecords.count) := eachMaterialRecord(
emp_record.id,
emp_record.materialname,
emp_record.inputMaterialNumber,
emp_record.remaindNumber,
emp_record.totalPrice,
0,
0,
0,
0,
0,
0,
0,
0,
0);
BEGIN --获取物资的实物储备总数量、总库存、总金额
select mi.totalnumber inputMaterialNumberSw,totalrealnumber remaindNumberSw,mi.totalPrice totalPriceSw into
v_materialRecords(v_materialRecords.count).inputMaterialNumberSw, v_materialRecords(v_materialRecords.count).remaindNumberSw, v_materialRecords(v_materialRecords.count).totalPriceSw from material m
join (select material_id, sum(material_mumber) totalnumber,sum(real_mumber) totalrealnumber, sum(price * real_mumber) totalPrice from material_in
where material_id = emp_record.id
and store_type = '实物储备'
and instr(decode(deptId, '', 'yes', dept_id,'yes'), 'y') > 0
and instr(decode(storeId, '', 'yes', store_id,'yes'), 'y') > 0
group by material_id)mi
on m.id = mi.material_id
where 1=1
and instr(decode(materialName, '', 'yes', m.name,'yes'), 'y') > 0;
EXCEPTION
WHEN no_data_found THEN
null;
END;
BEGIN --获取物资的协议储备总数量、总库存、总金额
select mi.totalnumber inputMaterialNumberSw,totalrealnumber remaindNumberSw,mi.totalPrice totalPriceSw into
v_materialRecords(v_materialRecords.count).inputMaterialNumberXy, v_materialRecords(v_materialRecords.count).remaindNumberXy, v_materialRecords(v_materialRecords.count).totalPriceXy from material m
join (select material_id, sum(material_mumber) totalnumber,sum(real_mumber) totalrealnumber, sum(price * real_mumber) totalPrice from material_in
where material_id = emp_record.id
and store_type = '协议储备'
and instr(decode(deptId, '', 'yes', dept_id,'yes'), 'y') > 0
and instr(decode(storeId, '', 'yes', store_id,'yes'), 'y') > 0
group by material_id)mi
on m.id = mi.material_id
where 1=1
and instr(decode(materialName, '', 'yes', m.name,'yes'), 'y') > 0;
EXCEPTION
WHEN no_data_found THEN
null;
END;
BEGIN --获取物资的产能储备总数量、总库存、总金额
select mi.totalnumber inputMaterialNumberSw,totalrealnumber remaindNumberSw,mi.totalPrice totalPriceSw into
v_materialRecords(v_materialRecords.count).inputMaterialNumberCn, v_materialRecords(v_materialRecords.count).remaindNumberCn, v_materialRecords(v_materialRecords.count).totalPriceCn from material m
join (select material_id, sum(material_mumber) totalnumber,sum(real_mumber) totalrealnumber, sum(price * real_mumber) totalPrice from material_in
where material_id = emp_record.id
and store_type = '产能储备'
and instr(decode(deptId, '', 'yes', dept_id,'yes'), 'y') > 0
and instr(decode(storeId, '', 'yes', store_id,'yes'), 'y') > 0
group by material_id)mi
on m.id = mi.material_id
where 1=1
and instr(decode(materialName, '', 'yes', m.name,'yes'), 'y') > 0;
EXCEPTION
WHEN no_data_found THEN
null;
END;
v_i := v_i + 1;
END LOOP;
dbms_output.put_line('集合的长度为:'|| v_materialRecords.count);
/*
if v_materialRecords.count > 0 then
for v_count in v_materialRecords.first..v_materialRecords.last loop
dbms_output.put_line(v_materialRecords(v_count).id || ' ' ||
v_materialRecords(v_count).materialname || ' ' ||
v_materialRecords(v_count).inputMaterialNumber || ' ' ||
v_materialRecords(v_count).remaindnumber || ' ' ||
v_materialRecords(v_count).totalprice || ' ' ||
v_materialRecords(v_count).inputMaterialNumberSw || ' ' ||
v_materialRecords(v_count).remaindNumberSw || ' ' ||
v_materialRecords(v_count).totalPriceSw || ' ' ||
v_materialRecords(v_count).inputMaterialNumberXy || ' ' ||
v_materialRecords(v_count).remaindNumberXy || ' ' ||
v_materialRecords(v_count).totalPriceXy || ' ' ||
v_materialRecords(v_count).inputMaterialNumberCn || ' ' ||
v_materialRecords(v_count).remaindNumberCn || ' ' ||
v_materialRecords(v_count).totalPriceCn
);
end loop;
end if;
*/
return v_materialRecords;
end;
end pack_materialUtils;
分享到:
相关推荐
这部分内容将理论与实践相结合,通过一系列的实战练习,帮助学习者巩固所学知识,提高在实际工作中的应用能力。 综上所述,这个压缩包文件集合提供了一个全面的学习路径,从Oracle数据库的基础知识到PL/SQL编程的...
标题 "jquery_aja_plsql_xml_hibernate" 涉及到的是几个关键的IT技术领域,包括jQuery、AJAX、PL/SQL、Hibernate以及XML。接下来,我们将详细探讨这些技术及其相互之间的联系。 1. **jQuery**:jQuery是一个广泛...
SpringMvc_SSM综合练习.分页.增删改查 16-SSM分布式案例-互联网商城(学习13天) day01_电商介绍--互联网术语-SOA-分布式-集群介绍-环境配置-框架搭建 day02_Dubbo介绍_dubbo框架整合_商品列表查询实现_分页_逆向...
另外,尚硅谷提供了不同季度的在线课程,如面向对象的深入理解,Java就业面试攻略,以及Android应用的开发实践等,覆盖了从理论到实战的广泛领域。 通过这一系列的Java学习资源,学员不仅可以扎实地掌握Java编程...
课程目标:综合应用Linux系统编程、Linux网络编程、C++所学的知识编写一个大并发服务器。 实训主题:大并发服务器设计、Mysql编程、Winsock编程、Linux Epoll模型、网络编程基础组件封装。 实战项目:银行储蓄系统...
- **尚硅谷Java基础实战-Bank项目**:实践项目帮助学习者将理论知识应用于实际,理解面向对象设计原则。 - **ORACLE、SQL、PLSQL视频教程**:数据库管理是Java开发中的重要技能,这些教程涵盖了数据库操作和查询...
同时,学习Oracle、SQL和PLSQL,能够掌握数据库管理和查询技能,JDBC教程则教你如何在Java中与数据库进行交互。此外,Java8的新特性如Lambda表达式、Stream API和Optional类,以及Java9的模块化系统,都是这一阶段的...
2. **尚硅谷Java基础实战-Bank项目**:通过实际项目,学习如何运用Java基础知识解决实际问题。 3. **Oracle、SQL、PLSQL**:学习数据库操作,包括SQL语句的编写、数据库设计和管理。 4. **JDBC**:Java数据库连接...
这些课程旨在为师资培训提供全面的技能传授,覆盖了从基础知识到高级应用,再到实际项目开发的全过程,旨在培养具备实战经验和理论知识的专业软件工程师。通过这样的培训,教师能够更好地教导学生,帮助他们适应市场...
4. **SSH整合&综合案例视频**:Struts、Spring、Hibernate三个框架的整合应用。 5. **SpringMVC视频教程**:Spring MVC框架的使用技巧。 6. **JPA视频教程**:Java Persistence API的介绍。 7. **SpringData视频**:...
Oracle数据库是全球最广泛使用的商业关系型数据库管理系统之一,它提供了强大的数据管理、事务处理和企业级应用开发能力。这个“Oracle中文帮助与学习资料大全”包含了一系列宝贵的资源,可以帮助初学者和经验丰富的...
- **ORACLE、SQL、PLSQL视频教程** - SQL语言基础:查询、更新、删除等基本操作。 - PL/SQL程序设计:存储过程、触发器编写。 - **JDBC视频教程** - JDBC连接数据库的方式。 - PreparedStatement与ResultSet的...