test(每月作价):修改作价逻辑
1. 调整作价上月表的数据获取(改成TLK_基价信息) 2. 调整作价人工修正作价入库程序
This commit is contained in:
parent
f55c0a77ec
commit
23cb131206
@ -1,32 +0,0 @@
|
||||
create type dbo.DWA_PROJECTBASEPRICE_OFFICE_MANU_Table as table(
|
||||
id int not null,
|
||||
BuildingID_P nvarchar(20) not null,
|
||||
ProjectID_P nvarchar(20) null,
|
||||
ProjectName nvarchar(200) null,
|
||||
ProjectAddr nvarchar(200) null,
|
||||
BuildingAddr nvarchar(200) null,
|
||||
County nvarchar(200) null,
|
||||
Loop nvarchar(200) null,
|
||||
Block nvarchar(200) null,
|
||||
Street nvarchar(200) null,
|
||||
Year int null,
|
||||
AvgArea decimal(10, 2) null,
|
||||
TotalFloorSum nvarchar(50) null,
|
||||
UpperFloorSum nvarchar(50) null,
|
||||
OfficeClass nvarchar(50) null,
|
||||
Grade nvarchar(50) null,
|
||||
MainPrice_1 decimal(18, 6) null,
|
||||
MainPriceRent_1 decimal(18, 6) null,
|
||||
MainPrice decimal(18, 6) null,
|
||||
MainPriceRent decimal(18, 6) null,
|
||||
MainPricePst decimal(18, 6) null,
|
||||
MainPriceRentPst decimal(18, 6) null,
|
||||
MainPriceType varchar(2) null,
|
||||
MainPriceRentType varchar(2) null,
|
||||
AreaCoff decimal(18, 6) null,
|
||||
YearCoff decimal(18, 6) null,
|
||||
BuildingCoff decimal(18, 6) null,
|
||||
BuildingStd bit null,
|
||||
AdjEvd nvarchar(1000) null
|
||||
)
|
||||
go
|
@ -1,11 +0,0 @@
|
||||
create type [dbo].[DWA_PROJECTBASEPRICE_RENT_MANU_Table] as table(
|
||||
ID int not null
|
||||
, ProjectID nvarchar(32) primary key
|
||||
, MainCoff_Rent decimal(7, 4)
|
||||
, RentPrice decimal(18, 2)
|
||||
, MainRentPrice decimal(18, 2)
|
||||
, RentPrice_1 decimal(18, 2)
|
||||
, VOPPAT varchar(64)
|
||||
, VOPPA decimal(18, 6)
|
||||
)
|
||||
go
|
@ -1,61 +0,0 @@
|
||||
create type [dbo].[DWA_PROJECTBASEPRICE_MANU_Table] as table(
|
||||
[communityId] [nvarchar](20) null,
|
||||
[communityName] [nvarchar](200) null,
|
||||
[communityAddress] [nvarchar](1024) null,
|
||||
[countyName] [nvarchar](200) null,
|
||||
[blockName] [nvarchar](200) null,
|
||||
[loopName] [nvarchar](200) null,
|
||||
[hasIndex] [int] null,
|
||||
[isPstCalc] [int] null,
|
||||
[status] [int] null,
|
||||
[label] [nvarchar](200) null,
|
||||
[propertyType] [nvarchar](200) null,
|
||||
[projectType] [nvarchar](200) null,
|
||||
[projectTypeDtl] [nvarchar](200) null,
|
||||
[propertyLevel] [nvarchar](200) null,
|
||||
[year] [int] null,
|
||||
[area] [decimal](18, 2) null,
|
||||
[areaCoefficient] [decimal](7, 4) null,
|
||||
[yearCoefficient] [decimal](7, 4) null,
|
||||
[comment] [nvarchar](1024) null,
|
||||
[basePriceDraft] [decimal](18, 2) null,
|
||||
[mainPriceDraft] [decimal](18, 2) null,
|
||||
[basePrice_1] [decimal](18, 2) null,
|
||||
[voppat] [nvarchar](200) null,
|
||||
[voppa] [decimal](18, 2) null,
|
||||
[priceUnitAdj] [decimal](18, 2) null,
|
||||
[visitedNum] [int] null,
|
||||
[firstVisitTime] [date] null,
|
||||
[visitedNum15] [int] null,
|
||||
[visitedNum30] [int] null,
|
||||
[priceDealMean_1] [decimal](18, 2) null,
|
||||
[priceDealMax_1] [decimal](18, 2) null,
|
||||
[sumDeal_1] [int] null,
|
||||
[priceDealMean] [decimal](18, 2) null,
|
||||
[priceDealMax] [decimal](18, 2) null,
|
||||
[sumDeal] [int] null,
|
||||
[priceListedMin] [decimal](18, 2) null,
|
||||
[priceCase1_ToAI_Pst] [decimal](18, 6) null,
|
||||
[priceCase2_ToAI_Pst] [decimal](18, 6) null,
|
||||
[priceCase1_ToLst_Pst] [decimal](18, 6) null,
|
||||
[priceCase2_ToLst_Pst] [decimal](18, 6) null,
|
||||
[priceCase1] [decimal](18, 2) null,
|
||||
[priceCase1AdjPst] [decimal](18, 6) null,
|
||||
[sumCase1] [int] null,
|
||||
[priceCase2] [decimal](18, 2) null,
|
||||
[priceCase2AdjPst] [decimal](18, 6) null,
|
||||
[sumCase2] [int] null,
|
||||
[voppbt] [nvarchar](200) null,
|
||||
[voppb] [decimal](18, 6) null,
|
||||
[bindCommunityId] [int] null,
|
||||
[bindCommunityPst] [decimal](18, 6) null,
|
||||
[bindBlockClass] [nvarchar](200) null,
|
||||
[bindBlockClassPst] [decimal](18, 6) null,
|
||||
[bindBlockPropertyLevel] [nvarchar](200) null,
|
||||
[bindBlockPropertyLevelPst] [decimal](18, 6) null,
|
||||
[bindBlockProjectType] [nvarchar](200) null,
|
||||
[bindBlockProjectTypePst] [decimal](18, 6) null,
|
||||
[bindCountyProjectType] [nvarchar](200) null,
|
||||
[bindCountyProjectTypePst] [decimal](18, 6) null
|
||||
)
|
||||
go
|
@ -124,7 +124,8 @@ public class DownloadOriginalResidenceSaleOpeningCaseServiceImpl {
|
||||
// 作价
|
||||
rawSql = LoadUtil.loadContent("sql-template/compute_sale_price.sql");
|
||||
sql = rawSql.replace("#yearMonth#", tableRoute.toString())
|
||||
.replace("#lastYearMonth#", remoteTableRoute.toString());
|
||||
.replace("#lastYearMonth#", remoteTableRoute.toString())
|
||||
.replace("#lastPriceDate#", String.format("%d-%d-01", tableRoute / 100, tableRoute % 100));
|
||||
jdbcTemplate.update(sql);
|
||||
} catch (Exception e) {
|
||||
logger.error("住宅作价异常", e);
|
||||
|
@ -270,7 +270,7 @@ public class ArtificialResidenceSalePriceServiceImpl implements IArtificialResid
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String sql =
|
||||
rawSql.replace("#yearMonth#", yearMonth.toString())
|
||||
.replace("#lastYearMonth#", lastYearMonth.toString())
|
||||
// .replace("#lastYearMonth#", lastYearMonth.toString())
|
||||
.replace("#lastPriceDate#", simpleDateFormat.format(lastPriceDate))
|
||||
.replace("#priceDate#", simpleDateFormat.format(priceDate));
|
||||
jdbcTemplate.update(sql);
|
||||
|
@ -1,6 +1,7 @@
|
||||
truncate table DW_HOUSINGCASE_COMM_#yearMonth#;
|
||||
truncate table DWA_PROJECTBASEPRICE_IMDT_#yearMonth#;
|
||||
|
||||
|
||||
insert into DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
select
|
||||
a.case_id
|
||||
@ -26,7 +27,7 @@ select
|
||||
, isnull(a.DecorationRng, 0)
|
||||
, isnull(a.YearCoff, 1)
|
||||
, isnull(a.BuildingCoff, 1)
|
||||
, d.BasePrice as BasePrice_1
|
||||
, d.ITEM_STANDARDPRICE as BasePrice_1
|
||||
, a.PriceTotal
|
||||
, a.PriceUnit
|
||||
, a.PriceUnitAdj
|
||||
@ -57,10 +58,10 @@ from ODS_HOUSINGCASELISTED_LJ_#yearMonth# a
|
||||
on c.ITEM_SECTOR121=g.ITEM_DICVALUE and g.ITEM_DICTYPE='板块'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 h
|
||||
on c.ITEM_CIRCLEPOSITION=h.ITEM_DICVALUE and h.ITEM_DICTYPE='环线'
|
||||
left join ODS_PROJECT_PRICE_INFO_#lastYearMonth# d
|
||||
on b.ProjectID = d.ProjectID
|
||||
and d.Status = 1
|
||||
where a.status not in ( 4, 5 );
|
||||
left join obpm_LianCheng_Data.dbo.TLK_基价信息 d
|
||||
on cast(b.ProjectID as nvarchar(20)) = d.ITEM_AIRAID
|
||||
and d.ITEM_PROJECTTYPE = '1' and d.ITEM_PRICETYPE='1'
|
||||
where a.status not in ( 4, 5 ) and d.ITEM_VALUEPOINT='#lastPriceDate#';
|
||||
|
||||
|
||||
insert into DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
@ -88,7 +89,7 @@ select
|
||||
, 0
|
||||
, 1
|
||||
, isnull(a.BuildingCoff, 1)
|
||||
, d.BasePrice as BasePrice_1
|
||||
, d.ITEM_STANDARDPRICE as BasePrice_1
|
||||
, a.PriceTotal
|
||||
, a.PriceUnit
|
||||
, a.PriceUnitAdj
|
||||
@ -116,9 +117,11 @@ from ODS_HOUSINGCASE_DEAL_#lastYearMonth# a
|
||||
on c.ITEM_SECTOR121=g.ITEM_DICVALUE and g.ITEM_DICTYPE='板块'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 h
|
||||
on c.ITEM_CIRCLEPOSITION=h.ITEM_DICVALUE and h.ITEM_DICTYPE='环线'
|
||||
left join ODS_PROJECT_PRICE_INFO_#lastYearMonth# d
|
||||
on a.ProjectID = d.ProjectID
|
||||
and d.Status = 1;
|
||||
left join obpm_LianCheng_Data.dbo.TLK_基价信息 d
|
||||
on cast(a.ProjectID as nvarchar(20)) = d.ITEM_AIRAID
|
||||
and d.ITEM_PROJECTTYPE = '1' and d.ITEM_PRICETYPE='1'
|
||||
where d.ITEM_VALUEPOINT='#lastPriceDate#';
|
||||
|
||||
|
||||
|
||||
---成交案例的HouseholdsID_LJ,在上期由0优化为NULL,因此RangeFlag类型需要修改
|
||||
@ -175,7 +178,7 @@ create table #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
---规则修改:链家1和链家2调价幅度,status in (1,2) 都纳入计算范围
|
||||
insert into #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
select a.ITEM_AIRAID, a.ITEM_RANAME, a.ITEM_RAADRESS,f.CountyName , g.ITEM_DICTEXT, h.ITEM_DICTEXT, a.ITEM_ISBUILDINDEX, a.ITEM_GAINCALCULATION, a.ITEM_RUNNINGSTATE,
|
||||
d.BasePrice, b.PriceUnitAdj, b.Visited_Num,
|
||||
d.ITEM_STANDARDPRICE, b.PriceUnitAdj, b.Visited_Num,
|
||||
b.First_Visit_Time, b.Visited_Num_15, b.Visited_Num_30, c.PriceDealMean_1, c.PriceDealMax_1, c.SumDeal_1,
|
||||
b.PriceDealMean, b.PriceDealMax, b.SumDeal, b.PriceListedMin, b.PriceCase1_ToAI_Pst, b.PriceCase2_ToAI_Pst,
|
||||
(PriceCase1 - PriceCase1_1)*1.0/PriceCase1_1 as PriceCase1_ToLst_Pst,
|
||||
@ -219,8 +222,10 @@ left join (
|
||||
avg(case when RangeFlag = 10 then PriceUnitAdj end) as PriceCase2_1
|
||||
from DW_HOUSINGCASE_COMM_#lastYearMonth# group by ProjectID
|
||||
) c on a.ITEM_AIRAID = c.ProjectID
|
||||
left join ODS_PROJECT_PRICE_INFO_#lastYearMonth# d on a.ITEM_AIRAID = d.ProjectID
|
||||
where a.ITEM_ISBUILDINDEX='1' and a.ITEM_PROJECTTYPE='1' and d.Status=1;
|
||||
left join obpm_LianCheng_Data.dbo.TLK_基价信息 d
|
||||
on cast(b.ProjectID as nvarchar(20)) = d.ITEM_AIRAID
|
||||
and d.ITEM_PROJECTTYPE = '1' and d.ITEM_PRICETYPE='1'
|
||||
where a.ITEM_ISBUILDINDEX='1' and a.ITEM_PROJECTTYPE='1' and d.ITEM_VALUEPOINT='#lastPriceDate#';
|
||||
|
||||
----第二步;根据案例自动计算的小区涨跌幅
|
||||
update #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
@ -405,10 +410,10 @@ create table #DWA_PROJECTBASEPRICE_IMDT_STEP_3
|
||||
|
||||
SELECT A.ITEM_AIRAID as ProjectID, g.ITEM_DICTEXT as Block, f.CountyName as County, h.ITEM_DICTEXT as ProjectLevel, A.item_ProjectTypeDtl as ProjectTypeDtl, A.item_BindClassID as BindClassID, B.ProjectID AS BindProjID, B.VOPPB AS Bind_Proj_Pst,
|
||||
CASE WHEN C.ProjectID IS NOT NULL THEN C.VOPPBT
|
||||
WHEN B.ProjectID IS NOT NULL AND D.BasePrice IS NOT NULL THEN '8505' END AS VOPPAT,
|
||||
WHEN B.ProjectID IS NOT NULL AND D.ITEM_STANDARDPRICE IS NOT NULL THEN '8505' END AS VOPPAT,
|
||||
CASE WHEN C.ProjectID IS NOT NULL THEN C.VOPPB
|
||||
WHEN B.ProjectID IS NOT NULL AND D.BasePrice IS NOT NULL THEN B.VOPPB END AS VOPPA,
|
||||
D.BasePrice
|
||||
WHEN B.ProjectID IS NOT NULL AND D.ITEM_STANDARDPRICE IS NOT NULL THEN B.VOPPB END AS VOPPA,
|
||||
D.ITEM_STANDARDPRICE as BasePrice
|
||||
INTO #TempBindProjID
|
||||
FROM obpm_LianCheng_Data.dbo.TLK_小区信息管理 a
|
||||
left join obpm_LianCheng_Data.dbo.V_CountyDict f on f.CountyId=a.ITEM_DISTRICT1
|
||||
@ -420,9 +425,10 @@ LEFT JOIN (SELECT ProjectID, VOPPBT, VOPPB FROM #DWA_PROJECTBASEPRICE_IMDT_STEP_
|
||||
ON A.item_BindProjID = B.ProjectID
|
||||
LEFT JOIN (SELECT ProjectID, VOPPBT, VOPPB FROM #DWA_PROJECTBASEPRICE_IMDT_STEP_2 WHERE ABS(VOPPB) < 0.1) C
|
||||
ON A.ITEM_AIRAID = C.ProjectID
|
||||
LEFT JOIN ODS_PROJECT_PRICE_INFO_#lastYearMonth# D
|
||||
ON A.ITEM_AIRAID = D.ProjectID AND D.Status=1
|
||||
where a.ITEM_ISBUILDINDEX='1' and a.ITEM_PROJECTTYPE='1';
|
||||
left join obpm_LianCheng_Data.dbo.TLK_基价信息 d
|
||||
on cast(b.ProjectID as nvarchar(20)) = d.ITEM_AIRAID
|
||||
and d.ITEM_PROJECTTYPE = '1' and d.ITEM_PRICETYPE='1'
|
||||
where a.ITEM_ISBUILDINDEX='1' and a.ITEM_PROJECTTYPE='1' and d.ITEM_VALUEPOINT='#lastPriceDate#';
|
||||
|
||||
-- 2.板块+绑定
|
||||
SELECT A.ProjectID, A.Block, A.County, A.ProjectLevel, A.ProjectTypeDtl, A.BindClassID, A.BindProjID, A.Bind_Proj_Pst,
|
||||
@ -529,7 +535,7 @@ create table #DWA_PROJECTBASEPRICE_IMDT_STEP_4
|
||||
|
||||
INSERT INTO #DWA_PROJECTBASEPRICE_IMDT_STEP_4
|
||||
SELECT A.ITEM_AIRAID, A.ITEM_RALABLE, g.ITEM_DICTEXT, i.ITEM_DICTEXT, A.item_ProjectTypeDtl, h.ITEM_DICTEXT, A.ITEM_MAINCOMPLETIONYEAR, A.item_MainArea,
|
||||
A.item_AreaCoff, A.item_YearCoff, D.PriceNote
|
||||
A.item_AreaCoff, A.item_YearCoff, D.ITEM_PRICEEXPLAIN
|
||||
FROM obpm_LianCheng_Data.dbo.TLK_小区信息管理 A
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 h
|
||||
on a.ITEM_PROPERTYLEVEL=h.ITEM_DICVALUE and h.ITEM_DICTYPE='物业档次'
|
||||
@ -537,12 +543,12 @@ left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 g
|
||||
on a.ITEM_RAPropertyType=g.ITEM_DICVALUE and g.ITEM_DICTYPE='物业类型'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 i
|
||||
on a.ITEM_RAType=i.ITEM_DICVALUE and i.ITEM_DICTYPE='小区类型'
|
||||
LEFT JOIN ODS_PROJECT_PRICE_INFO_#lastYearMonth# D
|
||||
ON A.ITEM_AIRAID = D.ProjectID
|
||||
where A.ITEM_PROJECTTYPE='1' and a.ITEM_ISBUILDINDEX='1' and D.Status=1;
|
||||
left join obpm_LianCheng_Data.dbo.TLK_基价信息 d
|
||||
on A.ITEM_AIRAID = d.ITEM_AIRAID
|
||||
and d.ITEM_PROJECTTYPE = '1' and d.ITEM_PRICETYPE='1'
|
||||
where A.ITEM_PROJECTTYPE='1' and a.ITEM_ISBUILDINDEX='1' and D.ITEM_VALUEPOINT='#lastPriceDate#';
|
||||
|
||||
----第五步;整合到结果表
|
||||
|
||||
INSERT INTO DWA_PROJECTBASEPRICE_IMDT_#yearMonth#
|
||||
SELECT A.ProjectID, A.ProjectName, A.ProjectAddr, A.County, A.Block, A.Loop, a.IsIndxGen, a.IsPstCalc, a.StatusRun, D.ProjectSPLabel, D.PropertyType, D.ProjectType,
|
||||
D.ProjectTypeDtl, D.ProjectLevel, D.[Year], D.MainArea, ISNULL(D.AreaCoff,1), ISNULL(D.YearCoff,1), D.PriceNote,
|
||||
|
@ -1,126 +1,5 @@
|
||||
|
||||
truncate table ODS_PROJECT_PRICE_INFO_#yearMonth#;
|
||||
|
||||
insert into ODS_PROJECT_PRICE_INFO_#yearMonth#
|
||||
select ProjectID, 1 PriceType, BasePriceDft, MainPriceDft, AreaCoff, YearCoff, VOPPAT, VOPPA, '#priceDate#', PriceNote, '#priceDate#', 1, NULL ---注意:AdjEvd下期调整
|
||||
from DWA_PROJECTBASEPRICE_IMDT_#yearMonth# a
|
||||
|
||||
--判断有无新增小区(根据当期、上期价格表和当期小区信息表分别判断)
|
||||
select a.ProjectID,
|
||||
case when b.ProjectID is null then 1 else 0 end as PriceTableAdd,
|
||||
case when c.ProjectID is null then 1 else 0 end as PriceTableAdd_1,
|
||||
case when d.ITEM_AIRAID is null then 1 else 0 end as InfoTableAdd
|
||||
into #ProjectAdd
|
||||
from DWA_PROJECTBASEPRICE_MANU_#yearMonth# a
|
||||
left join ODS_PROJECT_PRICE_INFO_#yearMonth# b
|
||||
on a.ProjectID = b.ProjectID and b.Status=1
|
||||
left join ODS_PROJECT_PRICE_INFO_#lastYearMonth# c
|
||||
on a.ProjectID = c.ProjectID and c.Status=1
|
||||
left join obpm_LianCheng_Data.dbo.TLK_小区信息管理 d
|
||||
on a.ProjectID = d.ITEM_AIRAID and d.ITEM_PROJECTTYPE='1' and d.ITEM_ISBUILDINDEX='1'
|
||||
where b.ProjectID is null or c.ProjectID is null or d.ITEM_AIRAID is null;
|
||||
|
||||
-------DWA_PROJECTBASEPRICE_MANU_201902记录有更新,触发下面流程
|
||||
-------价格表调整
|
||||
select a.ProjectID, a.IsIndxGen, a.IsPstCalc, a.StatusRun, a.ProjectType, a.ProjectTypeDtl, a.ProjectLevel, a.[Year], a.MainArea, a.AreaCoff, a.YearCoff,
|
||||
a.BasePriceDft as BasePrice, a.BasePrice_1, a.PriceNote, a.VOPPAT, a.VOPPA, getdate() as ModifyDate,
|
||||
case when b.ProjectID is not null and isnull(a.BasePriceDft, 0) <> isnull(b.BasePrice, 0) then 1 else 0 end as PriceChg, --指当期基价变化
|
||||
case when b.ProjectID is not null and isnull(a.priceNote, '') <> isnull(b.priceNote, '') then 1 else 0 end as PriceNoteChg, -- 指当期价格说明字段变化
|
||||
case when b.ProjectID is not null and isnull(a.AreaCoff,1) <> isnull(b.AreaCoff,1) then 1 else 0 end as AreaCoffChg, -- 指当期面积修正系数字段变化
|
||||
case when b.ProjectID is not null and isnull(a.YearCoff,1) <> isnull(b.YearCoff,1) then 1 else 0 end as YearCoffChg, -- 指当期年代修正系数字段变化
|
||||
case when b.ProjectID is not null and isnull(a.VOPPAT,'') <> isnull(b.VOPPAT,'') then 1 else 0 end as VOPPATChg, -- 指当期价格涨跌幅类型字段变化
|
||||
case when b.ProjectID is not null and isnull(a.VOPPA,0) <> isnull(b.VOPPA,0) then 1 else 0 end as VOPPAChg, -- 指当期价格涨跌幅字段变化
|
||||
case when c.ProjectID is not null then 1 else 0 end as Price_1Chg -- 指上期基价变化
|
||||
into #InfoChg
|
||||
from DWA_PROJECTBASEPRICE_MANU_#yearMonth# a
|
||||
left join ODS_PROJECT_PRICE_INFO_#yearMonth# b
|
||||
on a.ProjectID = b.ProjectID and b.status=1 and (
|
||||
isnull(a.BasePriceDft, 0) <> isnull(b.BasePrice, 0) or
|
||||
isnull(a.priceNote, '') <> isnull(b.priceNote, '') or
|
||||
isnull(a.AreaCoff,1) <> isnull(b.AreaCoff,1) or
|
||||
isnull(a.YearCoff,1) <> isnull(b.YearCoff,1) or
|
||||
isnull(a.VOPPAT,'') <> isnull(b.VOPPAT,'') or
|
||||
isnull(a.VOPPA,0) <> isnull(b.VOPPA,0))
|
||||
left join ODS_PROJECT_PRICE_INFO_#lastYearMonth# c
|
||||
on a.ProjectID = c.ProjectID and isnull(a.BasePrice_1,0) <> isnull(c.BasePrice,0) and c.status=1
|
||||
where b.ProjectID is not null or c.ProjectID is not null;
|
||||
|
||||
select a.ProjectID, 1 PriceType, b.BasePrice,
|
||||
b.BasePrice*1.0*isnull(b.AreaCoff,1)*isnull(b.YearCoff,1) as MainPrice,
|
||||
isnull(b.AreaCoff,1) as AreaCoff, isnull(b.YearCoff, 1) as YearCoff,
|
||||
b.VOPPAT, b.VOPPA, a.PriceDate, b.PriceNote, b.ModifyDate, 1 as Status,
|
||||
case when PriceChg=0 then '' else 'PriceChg|' end + case when PriceNoteChg=0 then '' else 'PriceNoteChg|' end +
|
||||
case when AreaCoffChg=0 then '' else 'AreaCoffChg|' end + case when YearCoffChg=0 then '' else 'YearCoffChg|' end +
|
||||
case when VOPPATChg=0 then '' else 'VOPPATChg|' end + case when VOPPAChg=0 then '' else 'VOPPAChg|' end as AdjEvd
|
||||
into #InfoChgCurr
|
||||
from ODS_PROJECT_PRICE_INFO_#yearMonth# a
|
||||
inner join #InfoChg b
|
||||
on a.ProjectID = b.ProjectID
|
||||
where (b.PriceChg=1 or b.PriceNoteChg=1 or b.AreaCoffChg=1 or b.YearCoffChg=1 or b.VOPPATChg=1 or b.VOPPAChg=1) and a.status=1;
|
||||
|
||||
update a
|
||||
set a.Status = 0
|
||||
from ODS_PROJECT_PRICE_INFO_#yearMonth# a
|
||||
left join #InfoChgCurr b
|
||||
on a.ProjectID = b.ProjectID
|
||||
where b.ProjectID is not null and a.status=1;
|
||||
|
||||
insert into ODS_PROJECT_PRICE_INFO_#yearMonth#
|
||||
select * from #InfoChgCurr;
|
||||
|
||||
select a.ProjectID, 1 PriceType, b.BasePrice_1, b.BasePrice_1*1.0*isnull(a.AreaCoff,1)*isnull(a.YearCoff,1) as MainPrice, a.AreaCoff, a.YearCoff,
|
||||
a.VOPPAT, a.VOPPA, a.PriceDate, b.PriceNote, b.ModifyDate, 1 as Status,'Price_1Chg|' as AdjEvd
|
||||
into #InfoChgLst
|
||||
from ODS_PROJECT_PRICE_INFO_#lastYearMonth# a
|
||||
inner join #InfoChg b
|
||||
on a.ProjectID = b.ProjectID
|
||||
where b.Price_1Chg=1 and a.status=1;
|
||||
|
||||
update a
|
||||
set Status = 0
|
||||
from ODS_PROJECT_PRICE_INFO_#lastYearMonth# a
|
||||
left join #InfoChgLst b
|
||||
on a.ProjectID = b.ProjectID
|
||||
where b.ProjectID is not null and a.status=1;
|
||||
|
||||
insert into ODS_PROJECT_PRICE_INFO_#lastYearMonth#
|
||||
select * from #InfoChgLst;
|
||||
|
||||
--插入新增小区价格信息
|
||||
INSERT INTO ODS_PROJECT_PRICE_INFO_#yearMonth#
|
||||
SELECT A.ProjectID, 1 AS PriceType, A.BasePriceDft, A.MainPriceDft, AreaCoff, YearCoff, VOPPAT, VOPPA, '#priceDate#' AS PriceDate, PriceNote, '#priceDate#' AS ModifyDate, 1 Status, 'NewAdded' AdjEvd
|
||||
FROM DWA_PROJECTBASEPRICE_MANU_#yearMonth# A
|
||||
INNER JOIN #ProjectAdd B
|
||||
ON A.ProjectID = B.ProjectID AND B.PriceTableAdd = 1;
|
||||
|
||||
|
||||
INSERT INTO ODS_PROJECT_PRICE_INFO_#lastYearMonth#
|
||||
SELECT A.ProjectID, 1 AS PriceType, BasePrice_1, BasePrice_1*1.0*ISNULL(AreaCoff,1)*ISNULL(YearCoff,1) MainPrice,
|
||||
AreaCoff, YearCoff, NULL VOPPAT, NULL VOPPA, '#lastPriceDate#' AS PriceDate, PriceNote, '#priceDate#' AS ModifyDate, 1 Status, 'NewAdded_1' AdjEvd
|
||||
FROM DWA_PROJECTBASEPRICE_MANU_#yearMonth# A
|
||||
INNER JOIN #ProjectAdd B
|
||||
ON A.ProjectID = B.ProjectID AND B.PriceTableAdd_1 = 1;
|
||||
|
||||
drop table #InfoChg;
|
||||
drop table #InfoChgCurr;
|
||||
drop table #InfoChgLst;
|
||||
drop table #ProjectAdd;
|
||||
|
||||
-- 上月
|
||||
update a
|
||||
set a.ITEM_STANDARDPRICE = b.BasePrice,a.ITEM_MAINAREAPRICE=b.MainPrice
|
||||
from obpm_LianCheng_Data.dbo.TLK_基价信息 a
|
||||
join dbo.ODS_PROJECT_PRICE_INFO_#lastYearMonth# b
|
||||
on a.ITEM_AIRAID = b.ProjectID
|
||||
where b.Status = 1
|
||||
and a.ITEM_VALUEPOINT = '#lastPriceDate#'
|
||||
and a.ITEM_PRICETYPE = '1'
|
||||
and a.ITEM_PROJECTTYPE = '1'
|
||||
and (
|
||||
a.ITEM_STANDARDPRICE <> b.BasePrice or
|
||||
a.ITEM_MAINAREAPRICE <> b.MainPrice
|
||||
);
|
||||
--
|
||||
insert into obpm_LianCheng_Data.dbo.TLK_基价信息
|
||||
(
|
||||
ID
|
||||
@ -163,15 +42,14 @@ select newid()
|
||||
, ProjectID
|
||||
, 1
|
||||
, 1
|
||||
, BasePrice
|
||||
, MainPrice
|
||||
, BasePriceDft
|
||||
, MainPriceDft
|
||||
, '#priceDate#'
|
||||
, PriceNote
|
||||
, '李贺'
|
||||
, getdate()
|
||||
, VOPPA
|
||||
from dbo.ODS_PROJECT_PRICE_INFO_#yearMonth#
|
||||
where Status = 1;
|
||||
from dbo.DWA_PROJECTBASEPRICE_MANU_#yearMonth#;
|
||||
|
||||
insert into obpm_LianCheng_Data.dbo.T_DOCUMENT
|
||||
(
|
||||
@ -212,3 +90,20 @@ from obpm_LianCheng_Data.dbo.TLK_基价信息 a
|
||||
where a.ITEM_VALUEPOINT = '#priceDate#'
|
||||
and a.ITEM_PROJECTTYPE = '1'
|
||||
and a.ITEM_PRICETYPE = '1';
|
||||
|
||||
|
||||
-- 更新以前的基价
|
||||
update b
|
||||
set b.ITEM_STANDARDPRICE=a.BasePrice_1,
|
||||
b.ITEM_MAINAREAPRICE=a.BasePrice_1 * 1.0 * isnull(c.ITEM_AREACOFF, 1) * isnull(c.ITEM_YEARCOFF, 1)
|
||||
from DWA_PROJECTBASEPRICE_MANU_#yearMonth# a
|
||||
join obpm_LianCheng_Data.dbo.TLK_基价信息 b on a.ProjectID = b.ITEM_AIRAID
|
||||
join obpm_LianCheng_Data.dbo.TLK_小区信息管理 c on b.ITEM_AIRAID = c.ITEM_AIRAID
|
||||
where b.ITEM_PRICETYPE = '1'
|
||||
and b.ITEM_PROJECTTYPE = '1'
|
||||
and b.ITEM_VALUEPOINT = '#lastPriceDate#'
|
||||
and a.BasePrice_1 <> b.ITEM_MAINAREAPRICE;
|
||||
|
||||
-- 插入价格信息
|
||||
insert into ODS_PROJECT_PRICE_INFO_#yearMonth#(projectid, pricetype, baseprice, mainprice, areacoff, yearcoff, voppat, voppa, pricedate, pricenote, modifydate, status, adjevd)
|
||||
select projectid, 1, BasePriceDft, MainPriceDft, areacoff, yearcoff, voppat, voppa, '#priceDate#', pricenote, getdate(), 1, NULL from DWA_PROJECTBASEPRICE_MANU_#yearMonth#;
|
||||
|
Loading…
x
Reference in New Issue
Block a user