276 lines
10 KiB
Plaintext
276 lines
10 KiB
Plaintext
CREATE OR REPLACE PROCEDURE PROPERTYMANAGE_STORAGE.PRO_数据导入_临城新区_第一步
|
|
IS
|
|
|
|
--************************************小区信息************************************
|
|
Cursor
|
|
C_District Is
|
|
Select
|
|
REGION_ID as District_ID, --小区内码
|
|
REGION_NAME as District_Name, --小区名称
|
|
DISTRICT_ID as City_District, --所在城区
|
|
LOCATE as District_Address, --所在地址
|
|
BUILD_NUM as Build_Count --幢数
|
|
From
|
|
wycadmin.T_ZSKREGION_INFO WHERE DISTRICT_ID=330103;
|
|
|
|
M_District C_District%ROWTYPE;
|
|
|
|
--************************************楼幢信息************************************
|
|
Cursor
|
|
C_Building(M_Region_ID number) IS
|
|
Select
|
|
BI_ID as building_id, --内码
|
|
REGION_ID as district_id, --小区内码
|
|
BUILD_NO as Building_address, --幢号
|
|
PARCELCODE as Graphics_Code, --丘编号
|
|
HOUSE_NUM as House_Num, --户数
|
|
BUILD_AREA as Build_Area, --建筑面积
|
|
--COMP_DATE --竣工时间
|
|
RENDSTAND as RendStand, --缴交标准
|
|
BUILD_STRU as Build_Struct, --房屋结构
|
|
BUILD_YEAR as Build_Year --建筑年代
|
|
From
|
|
wycadmin.T_ZSKBUILDINFO
|
|
where
|
|
region_id=m_region_id;
|
|
|
|
M_Building C_Building%ROWTYPE;
|
|
|
|
--************************************房屋信息************************************
|
|
Cursor
|
|
C_House(M_BI_ID NUMBER) IS
|
|
Select
|
|
a.HOUSEINFO_ID as House_ID, --房屋内码
|
|
a.BI_ID as building_id , --幢内码
|
|
a.FW_NM as Cq_House_ID, --产权房屋内码
|
|
a.HOUSE_NO as Room_Number, --房号
|
|
a.FLOOR_NM as Floor_Num,
|
|
a.LAND_NUM as Land_Num, --地号
|
|
a.UNIT_NUM as Unit_Num, --单元
|
|
a.ISRENDER as IsRender, --是否缴交
|
|
a.BUILD_AREA as Build_Area, --建工面积
|
|
a.OWNER_NAME as Owner_Name, --业主姓名
|
|
a.TEL as Owner_Tel, --电话
|
|
a.ACCOUNT_ID as Account_ID, --帐号
|
|
a.DZDATE as OpenDate, --开户日期
|
|
a.FUND_FREEZED as Fund_Freezed, --维修冻结
|
|
a.TOTALPRINCIPAL as TotalPrincipal, --本金合计
|
|
a.TOTALINTEREST as Totalinterest, --利息总和
|
|
a.BALANCE as Balance, --可用余额
|
|
b.FC_TYPE AS REALTY_TYPE --房屋类型
|
|
From
|
|
wycadmin.T_ZSKHOUSEINFO a,
|
|
jycq.T_HOUSE b
|
|
where
|
|
BI_ID=m_BI_ID and
|
|
a.FW_NM=b.fw_nm(+);
|
|
|
|
M_House C_House%ROWTYPE;
|
|
|
|
--************************************房屋缴款记录信息************************************
|
|
Cursor
|
|
C_HouseFund(M_HOUSEINFO_ID number) is
|
|
Select
|
|
HF_ID as HouseFund_ID,
|
|
HOUSEINFO_ID AS House_ID,
|
|
SERIALNO as Serialno,
|
|
OPTDATE as Oprate_Date,
|
|
OPTTYPE as Oprate_Type,
|
|
OPTMAN as Oprate_Person,
|
|
AMOUNT as HouseFund_Amount
|
|
From
|
|
wycadmin.T_HOUSEFUND
|
|
where
|
|
HOUSEINFO_ID=M_HOUSEINFO_ID;
|
|
|
|
M_HouseFund C_HouseFund%ROWTYPE;
|
|
--首期
|
|
M_Fund_Sum Number(12,2);
|
|
--房屋坐落
|
|
M_House_Address varchar(200);
|
|
--总层数
|
|
M_FLOOR_NUM NUMBER;
|
|
--当前层
|
|
M_FW_FLOOR NUMBER;
|
|
--套内建筑面积
|
|
M_TNJZ_AREA NUMBER;
|
|
--分摊面积
|
|
M_FT_AREA NUMBER;
|
|
--使用面积
|
|
M_SY_AREA NUMBER;
|
|
--业主信息
|
|
M_Owner_Name varchar(200);
|
|
M_Owner_Code varchar(500);
|
|
M_Owner_Tel VARCHAR(100);
|
|
--产权幢内码
|
|
M_Cq_Building_ID number;
|
|
M_Building_Address varchar(200);
|
|
M_Count number;
|
|
M_OpenDate DATE;
|
|
m_cq_house_id number;
|
|
m_city_district varchar(50);
|
|
--执行复制
|
|
BEGIN
|
|
--************小区****************
|
|
OPEN C_District;
|
|
FETCH C_District INTO M_District;
|
|
WHILE C_District%FOUND LOOP
|
|
m_city_district:=null;
|
|
m_city_district:=M_District.City_District;
|
|
Insert into
|
|
PropertyManage_Storage.T_DISTRICT(
|
|
District_ID,District_Name,City_District,District_Address,Build_Count)
|
|
values(
|
|
M_District.District_ID,M_District.District_Name,M_District.City_District,
|
|
M_District.District_Address,M_District.Build_Count
|
|
);
|
|
|
|
--************楼幢****************
|
|
OPEN C_Building(M_District.District_ID);
|
|
FETCH C_Building INTO M_Building;
|
|
WHILE C_Building%FOUND LOOP
|
|
Insert into
|
|
PropertyManage_Storage.T_Building(
|
|
building_id,district_id,Building_address,Graphics_Code,House_Num,Build_Area,RendStand,Build_Struct,Build_Year,RENDTYPE,city_district)
|
|
values(
|
|
M_Building.building_id,M_Building.district_id,M_Building.Building_address,
|
|
M_Building.Graphics_Code,M_Building.House_Num,M_Building.Build_Area,
|
|
M_Building.RendStand,M_Building.Build_Struct,M_Building.Build_Year,1900,m_city_district
|
|
);
|
|
--****房屋************************
|
|
M_Cq_Building_ID:=NULL;M_Building_Address:=NULL;m_cq_house_id:=null;
|
|
OPEN C_House(M_Building.Building_ID);
|
|
FETCH C_House INTO M_House;
|
|
WHILE C_House%FOUND LOOP
|
|
m_cq_house_id:=M_House.Cq_House_ID;
|
|
Insert into
|
|
PropertyManage_Storage.T_HOUSE(
|
|
House_ID,building_id,Cq_House_ID,Room_Number,Floor_Num,Floor_Start,Floor_End,Land_Num,Unit_Num,IsRender,Build_Area,Build_ScArea,
|
|
Owner_Name,Owner_Tel,Account_ID,OpenDate,Fund_Freezed,Totalinterest,Balance,RENDTYPE,RendStand,FundHouse_Type,REALTY_TYPE,city_district)
|
|
VALUES(
|
|
M_House.House_ID,M_House.building_id,M_House.Cq_House_ID,M_House.Room_Number,M_House.Floor_Num,M_House.Floor_Num,M_House.Floor_Num,M_House.Land_Num,
|
|
M_House.Unit_Num,NULL,M_House.Build_Area,M_House.Build_Area,M_House.Owner_Name,M_House.Owner_Tel,M_House.Account_ID,
|
|
M_House.OpenDate,M_House.Fund_Freezed,M_House.Totalinterest,M_House.Balance,1900,M_Building.RendStand,5010,M_House.REALTY_TYPE,m_city_district
|
|
);
|
|
--查询产权幢信息
|
|
IF M_Cq_Building_ID is null THEN
|
|
if m_cq_house_id is not null then
|
|
select count(1) into m_count from jycq.T_HOUSE where fw_nm=m_cq_house_id;
|
|
if m_count>0 then
|
|
select zh_nm into M_Cq_Building_ID from jycq.T_HOUSE where fw_nm=m_cq_house_id;
|
|
if M_Cq_Building_ID is not null then
|
|
Select count(1) into m_count from jycq.T_ZHADDRESS where zh_nm=M_Cq_Building_ID;
|
|
if m_count>0 then
|
|
--谁知道幢内码会有多条,暂时先取1条
|
|
Select ZADDRESS into M_Building_Address from jycq.T_ZHADDRESS where rownum=1 and zh_nm=M_Cq_Building_ID;
|
|
end if;
|
|
end if;
|
|
end if;
|
|
end if;
|
|
END IF;
|
|
M_Count:=0;
|
|
--查询房屋坐落
|
|
M_House_Address:=null;M_FLOOR_NUM:=null;M_FW_FLOOR:=null;M_TNJZ_AREA:=null;M_FT_AREA:=null;M_SY_AREA:=null;
|
|
if m_cq_house_id is not null then
|
|
Select Count(1) into M_Count from jycq.T_HOUSE where FW_NM=m_cq_house_id;
|
|
|
|
if M_Count>0 then
|
|
Select FW_ADDRESS,FLOOR_NUM,FW_FLOOR,TNJZ_AREA,FT_AREA,SY_AREA into
|
|
M_House_Address,M_FLOOR_NUM,M_FW_FLOOR,M_TNJZ_AREA,M_FT_AREA,M_SY_AREA
|
|
From jycq.T_HOUSE where FW_NM=m_cq_house_id;
|
|
END IF;
|
|
end if;
|
|
--产权业主信息
|
|
M_Owner_Name:=null;M_Owner_Code:=null;M_Owner_Tel:=null;
|
|
M_Count:=0;
|
|
if m_cq_house_id is not null then
|
|
Select Count(1) into M_Count from v_realtyhouse_base where house_id=m_cq_house_id;
|
|
if M_Count>0 then
|
|
Select REALTYOWNER_NAME,REALTYOWNER_CODE,REALTYOWNER_tel into
|
|
M_Owner_Name,M_Owner_Code,M_Owner_Tel
|
|
from
|
|
v_realtyhouse_base
|
|
where house_id=m_cq_house_id;
|
|
end if;
|
|
end if;
|
|
--****房屋缴款记录************************
|
|
M_Fund_Sum:=0;M_OpenDate:=NULL;
|
|
OPEN C_HouseFund(M_House.House_ID);
|
|
FETCH C_HouseFund INTO M_HouseFund;
|
|
WHILE C_HouseFund%FOUND LOOP
|
|
--如果一套房子里有单位缴款与房改缴款则首期是两者总和
|
|
if M_HouseFund.Oprate_Type=8001 then
|
|
M_Fund_Sum:=M_Fund_Sum+M_HouseFund.HouseFund_Amount;
|
|
M_OpenDate:=M_HouseFund.Oprate_Date;
|
|
elsif M_HouseFund.Oprate_Type=8007 then
|
|
M_Fund_Sum:=M_Fund_Sum+M_HouseFund.HouseFund_Amount;
|
|
M_OpenDate:=M_HouseFund.Oprate_Date;
|
|
end if;
|
|
Insert into
|
|
PropertyManage_Storage.T_HOUSEFUND(
|
|
HouseFund_ID,House_ID,Serialno,Oprate_Date,Oprate_Type,Oprate_Person,HouseFund_Amount,PAYMENT_FLAG,
|
|
Accounted_Date,DownPayment_Flag,Imputation_Type,RENDTYPE,RendStand,Build_Area)
|
|
values(
|
|
M_HouseFund.HouseFund_ID,M_HouseFund.House_ID,M_HouseFund.Serialno,M_HouseFund.Oprate_Date,
|
|
FUNC_OPRATE_TYPE(M_HouseFund.Oprate_Type),M_HouseFund.Oprate_Person,M_HouseFund.HouseFund_Amount,
|
|
1,M_House.OpenDate,FUNC_DOWNPAYMENT(M_HouseFund.Oprate_Type),1020,1900,M_Building.RendStand,M_House.Build_Area
|
|
);
|
|
FETCH C_HouseFund INTO M_HouseFund;
|
|
END LOOP;
|
|
Close C_HouseFund;
|
|
if M_Fund_Sum>0 then
|
|
--更新首期与有没有交标记
|
|
update
|
|
PropertyManage_Storage.T_HOUSE
|
|
set
|
|
fund_sum=M_Fund_Sum,ISRENDER=1
|
|
WHERE
|
|
HOUSE_ID=M_House.HOUSE_ID;
|
|
end if;
|
|
--更新房屋信息
|
|
update
|
|
PropertyManage_Storage.T_HOUSE
|
|
set
|
|
house_address=M_House_Address,FLOOR_NUM=m_FLOOR_NUM,Floor_Start=m_FLOOR_NUM,Floor_End=m_FLOOR_NUM,
|
|
Build_Area_Inside=M_TNJZ_AREA,Build_Area_Share=M_FT_AREA,Build_Area_Use=M_SY_AREA,Owner_Code=m_Owner_Code
|
|
WHERE
|
|
HOUSE_ID=M_House.HOUSE_ID;
|
|
--更新业主信息
|
|
if M_House.Owner_Name is null then
|
|
update
|
|
PropertyManage_Storage.T_HOUSE
|
|
set
|
|
Owner_Name=M_Owner_Name
|
|
WHERE
|
|
HOUSE_ID=M_House.HOUSE_ID;
|
|
end if;
|
|
if M_House.Owner_Tel is null then
|
|
update
|
|
PropertyManage_Storage.T_HOUSE
|
|
set
|
|
Owner_Tel=M_Owner_Tel
|
|
WHERE
|
|
HOUSE_ID=M_House.HOUSE_ID;
|
|
end if;
|
|
--****************************
|
|
--update t_housefund a set a.Payment_Flag=1 where a.house_id in (select b.house_id from t_house b where a.house_id=b.house_id and b.IsRender=1)
|
|
FETCH C_House INTO M_House;
|
|
END LOOP;
|
|
Close C_House;
|
|
--****************************
|
|
if M_Cq_Building_ID is not null then
|
|
--更新幢信息
|
|
update propertymanage_storage.T_BUILDING set Cq_Building_ID=M_Cq_Building_ID where building_id=M_Building.building_id;
|
|
end if;
|
|
FETCH C_Building INTO M_Building;
|
|
END LOOP;
|
|
Close C_Building;
|
|
--****************************
|
|
FETCH C_District INTO M_District;
|
|
END LOOP;
|
|
Close C_District;
|
|
--update t_housefund a set a.Payment_Flag=1 where a.house_id in (select b.house_id from t_house b where a.house_id=b.house_id and b.IsRender=1)
|
|
--update t_housefund a set a.ACCOUNTED_DATE=(select b.OpenDate from t_house b where a.HOUSE_ID=b.house_id and b.ISRENDER=1 ) where a.OPRATE_TYPE=1001
|
|
END ;
|
|
/
|