Commit edfc3f32 authored by congweijing's avatar congweijing

增加JOB事件判断合同到期和房屋到期

parent a2cb82d9
......@@ -29,12 +29,13 @@ create or replace package HLS_Contract_info_pkg is
p_remark varchar2,
p_contract_remark varchar2) ;
procedure modifi_contract_condition(p_h_contract_number varchar2);
procedure contract_room_status_update;
end HLS_Contract_info_pkg;
/
create or replace package body HLS_Contract_info_pkg is
-- Function and procedure implementations
--新增一条合同信息
procedure insert_contract_info(p_contract_start_date date,
p_contract_finish_date date,
p_room_id number,
......@@ -92,6 +93,7 @@ create or replace package body HLS_Contract_info_pkg is
sysdate);
end;
--更新合同信息
procedure update_contract_info(p_h_contract_number varchar2,
p_contract_start_date date,
p_contract_finish_date date,
......@@ -110,10 +112,7 @@ create or replace package body HLS_Contract_info_pkg is
into v_old_room_id
from hls_contract_info
where h_contract_number = p_h_contract_number;
--更新原来合同中的房屋状态为“空闲”
update hls_room_info
set room_status = 'status1'
where room_id = v_old_room_id;
--更新合同信息
update HLS_Contract_info
set contract_start_date = p_contract_start_date,
......@@ -131,21 +130,41 @@ create or replace package body HLS_Contract_info_pkg is
last_updated_by = -1,
last_update_date = sysdate
where h_contract_number = p_h_contract_number;
--更新新合同中房屋状态为“已租住”
update hls_room_info
set room_status = 'status2'
where room_id = p_room_id;
end;
end;
--合同信息确认(将将合同状态变成合同确认、合同中的房屋ID对应的状态变成已租住)
procedure modifi_contract_condition(p_h_contract_number varchar2) is
begin
update HLS_Contract_info
set contract_condition = 'type2'
where h_contract_number = p_h_contract_number;
--更新房屋状态
update hls_room_info
set room_status = 'status2'
where room_id IN (select room_id from hls_contract_info where h_contract_number = p_h_contract_number);
end;
--合同到期 和 房屋到期
procedure contract_room_status_update is
cursor room_id_cursor is
select hr.room_id
from hls_room_info hr,hls_contract_info hc
where hr.room_id = hc.room_id
and months_between(sysdate,hc.contract_finish_date) >0
and hc.contract_condition='type2';
begin
for room_item in room_id_cursor loop
if room_item.room_id is not null then
update hls_contract_info hc
set hc.contract_condition = 'type3'
where hc.room_id = room_item.room_id;
update hls_room_info hr
set hr.room_status = 'status3'
where hr.room_id = room_item.room_id;
end if;
end loop;
end;
end HLS_Contract_info_pkg;
/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment