feature(住宅住宅作价):开发住宅作价
1. 下载成交案例 2. 清洗成交案例 3. 下载挂牌案例 4. 清洗挂牌案例 5. 计算住宅销售基价
This commit is contained in:
parent
952d2332de
commit
afeb1cffc9
@ -18,6 +18,13 @@ public interface OriginalResidenceSaleClosingCaseMapper {
|
||||
*/
|
||||
int createTable(@Param("yearMonth") Integer yearMonth);
|
||||
|
||||
/**
|
||||
* 原始成交案例
|
||||
* @param yearMonth
|
||||
* @return
|
||||
*/
|
||||
int createClosingCaseRawTable(@Param("yearMonth") Integer yearMonth);
|
||||
|
||||
/**
|
||||
* 创建清洗完成之后的表ODS_HOUSINGCASELISTED_LJ_YYYYMM
|
||||
* @param yearMonth
|
||||
|
@ -18,6 +18,15 @@ public interface OriginalResidenceSaleOpeningCaseMapper {
|
||||
*/
|
||||
int createTable(@Param("yearMonth") Integer yearMonth);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param yearMonth
|
||||
* @return
|
||||
*/
|
||||
int createOpeningCaseRawTable(@Param("yearMonth") Integer yearMonth);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建清洗完成之后的表ODS_HOUSINGCASELISTED_LJ_YYYYMM
|
||||
*
|
||||
|
@ -6,7 +6,7 @@ import com.ruoyi.project.data.cases.domain.OriginalOfficeCase;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@DS("test")
|
||||
@DS("spider")
|
||||
public interface DownloadOriginalOfficeCaseMapper {
|
||||
/**
|
||||
* 下载案例
|
||||
|
@ -1,5 +1,5 @@
|
||||
package com.ruoyi.project.data.cases.service;
|
||||
|
||||
public interface IOriginalResidenceSaleClosingCaseService {
|
||||
void pullData();
|
||||
void clear();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.project.data.cases.service;
|
||||
|
||||
public interface IOriginalResidenceSaleOpeningCaseService {
|
||||
void pullData();
|
||||
|
||||
void clear();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Calendar;
|
||||
@ -31,7 +32,7 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService
|
||||
* 计算
|
||||
*/
|
||||
@Override
|
||||
// @Scheduled(cron = "")
|
||||
@Scheduled(cron = "0 0 17 28 * ?")
|
||||
public void compute() {
|
||||
Date date = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
@ -1,110 +1,111 @@
|
||||
package com.ruoyi.project.data.cases.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.ruoyi.common.utils.LoadUtil;
|
||||
import com.ruoyi.project.data.cases.domain.OriginalResidenceSaleClosingCase;
|
||||
import com.ruoyi.project.data.cases.mapper.OriginalResidenceSaleClosingCaseMapper;
|
||||
import com.ruoyi.project.data.cases.mapper.sync.DownloadOriginalResidenceSaleClosingCaseMapper;
|
||||
import com.ruoyi.project.data.cases.service.IOriginalResidenceRentClosingCaseService;
|
||||
import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleClosingCaseService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@DS("compute")
|
||||
public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalResidenceRentClosingCaseService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OriginalResidenceRentClosingCaseServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private OriginalResidenceSaleClosingCaseMapper originalResidenceSaleClosingCaseMapper;
|
||||
@Autowired
|
||||
private DownloadOriginalResidenceSaleClosingCaseMapper downloadOriginalResidenceSaleClosingCaseMapper;
|
||||
@Autowired
|
||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Scheduled(cron = "0 0 5 9 * ?")
|
||||
@Override
|
||||
public void pullData() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
Integer targetTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH)));
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
Integer computeTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH) + 1));
|
||||
|
||||
prepare(computeTableRoute);
|
||||
List<OriginalResidenceSaleClosingCase> list =
|
||||
downloadOriginalResidenceSaleClosingCaseMapper.download(targetTableRoute);
|
||||
list.parallelStream().forEach(originalResidenceSaleClosingCase -> {
|
||||
originalResidenceSaleClosingCase.setCaseId(originalResidenceSaleClosingCase.generateCaseId());
|
||||
originalResidenceSaleClosingCase.setCleanPropertyType(originalResidenceSaleClosingCase.refinePropertyType());
|
||||
// originalResidenceSaleClosingCase.setCleanCurrentFloor(originalResidenceSaleClosingCase
|
||||
// .refineCurrentFloor());
|
||||
// originalResidenceSaleClosingCase.setCleanBuildingAddress(originalResidenceSaleClosingCase
|
||||
// .refineBuildingAddress());
|
||||
});
|
||||
running(computeTableRoute, list);
|
||||
after(computeTableRoute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备工作 创建表
|
||||
*
|
||||
* @param computeTableRoute
|
||||
*/
|
||||
public void prepare(Integer computeTableRoute) {
|
||||
originalResidenceSaleClosingCaseMapper.createTable(computeTableRoute);
|
||||
originalResidenceSaleClosingCaseMapper.createCleanTable(computeTableRoute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量入库
|
||||
*
|
||||
* @param computeTableRoute
|
||||
* @param list
|
||||
*/
|
||||
public void running(Integer computeTableRoute, List<OriginalResidenceSaleClosingCase> list) {
|
||||
SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(list.toArray());
|
||||
int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("insert into dbo" +
|
||||
".original_residence_sale_closing_case_" + computeTableRoute + "(case_id,case_county_name," +
|
||||
"case_block_name,case_loopline_name,case_community_name,case_address,case_area," +
|
||||
"case_unit_price,case_total_price,case_house_type,case_signing_date,case_register_date," +
|
||||
"case_agency_name,case_agency_type,case_seller_type,case_buyer_type,case_birthday," +
|
||||
"case_deal_type,clean_property_type,create_time) " +
|
||||
"values (:caseId,:caseCountyName,:caseBlockName,:caseLoopName,:caseCommunityName," +
|
||||
":caseAddress,:caseArea,:caseUnitPrice,:caseTotalPrice,:caseHouseType,:caseSigningDate," +
|
||||
":caseRegisterDate,:agencyName,:agencyType,:sellerType,:buyerType,:birthday," +
|
||||
":cleanCaseType,:cleanPropertyType,GETDATE());",
|
||||
batchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配数据
|
||||
*
|
||||
* @param yearMonth
|
||||
*/
|
||||
public void after(Integer yearMonth) {
|
||||
// 清洗挂牌案例
|
||||
String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_closing_case.sql");
|
||||
String sql = rawSql.replace("#yearMonth#", yearMonth.toString());
|
||||
jdbcTemplate.update(sql);
|
||||
}
|
||||
}
|
||||
//package com.ruoyi.project.data.cases.service.impl;
|
||||
//
|
||||
//import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
//import com.ruoyi.common.utils.LoadUtil;
|
||||
//import com.ruoyi.project.data.cases.domain.OriginalResidenceSaleClosingCase;
|
||||
//import com.ruoyi.project.data.cases.mapper.OriginalResidenceSaleClosingCaseMapper;
|
||||
//import com.ruoyi.project.data.cases.mapper.sync.DownloadOriginalResidenceSaleClosingCaseMapper;
|
||||
//import com.ruoyi.project.data.cases.service.IOriginalResidenceRentClosingCaseService;
|
||||
//import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleClosingCaseService;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.jdbc.core.JdbcTemplate;
|
||||
//import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
//import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
//import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Service
|
||||
//@DS("compute")
|
||||
//public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalResidenceRentClosingCaseService {
|
||||
//
|
||||
// private static Logger logger = LoggerFactory.getLogger(OriginalResidenceRentClosingCaseServiceImpl.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private OriginalResidenceSaleClosingCaseMapper originalResidenceSaleClosingCaseMapper;
|
||||
// @Autowired
|
||||
// private DownloadOriginalResidenceSaleClosingCaseMapper downloadOriginalResidenceSaleClosingCaseMapper;
|
||||
// @Autowired
|
||||
// private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
// @Autowired
|
||||
// private JdbcTemplate jdbcTemplate;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// @Scheduled(cron = "0 0 5 9 * ?")
|
||||
// @Override
|
||||
// public void pullData() {
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.setTime(new Date());
|
||||
// Integer targetTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
// calendar.get(Calendar.MONTH)));
|
||||
// calendar.add(Calendar.MONTH, 1);
|
||||
// Integer computeTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
// calendar.get(Calendar.MONTH) + 1));
|
||||
//
|
||||
// prepare(computeTableRoute);
|
||||
// List<OriginalResidenceSaleClosingCase> list =
|
||||
// downloadOriginalResidenceSaleClosingCaseMapper.download(targetTableRoute);
|
||||
// list.parallelStream().forEach(originalResidenceSaleClosingCase -> {
|
||||
// originalResidenceSaleClosingCase.setCaseId(originalResidenceSaleClosingCase.generateCaseId());
|
||||
//// originalResidenceSaleClosingCase.setCleanPropertyType(originalResidenceSaleClosingCase.refinePropertyType());
|
||||
//// originalResidenceSaleClosingCase.setCleanCurrentFloor(originalResidenceSaleClosingCase
|
||||
//// .refineCurrentFloor());
|
||||
//// originalResidenceSaleClosingCase.setCleanBuildingAddress(originalResidenceSaleClosingCase
|
||||
//// .refineBuildingAddress());
|
||||
// });
|
||||
// running(computeTableRoute, list);
|
||||
//// after(computeTableRoute);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 准备工作 创建表
|
||||
// *
|
||||
// * @param computeTableRoute
|
||||
// */
|
||||
// public void prepare(Integer computeTableRoute) {
|
||||
// originalResidenceSaleClosingCaseMapper.createTable(computeTableRoute);
|
||||
//// originalResidenceSaleClosingCaseMapper.createClosingCaseRawTable(computeTableRoute);
|
||||
// originalResidenceSaleClosingCaseMapper.createCleanTable(computeTableRoute);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量入库
|
||||
// *
|
||||
// * @param computeTableRoute
|
||||
// * @param list
|
||||
// */
|
||||
// public void running(Integer computeTableRoute, List<OriginalResidenceSaleClosingCase> list) {
|
||||
// SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(list.toArray());
|
||||
// int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("insert into dbo" +
|
||||
// ".original_residence_sale_closing_case_" + computeTableRoute + "(case_id,case_county_name," +
|
||||
// "case_block_name,case_loopline_name,case_community_name,case_address,case_area," +
|
||||
// "case_unit_price,case_total_price,case_house_type,case_signing_date,case_register_date," +
|
||||
// "case_agency_name,case_agency_type,case_seller_type,case_buyer_type,case_birthday," +
|
||||
// "case_deal_type,clean_property_type,create_time) " +
|
||||
// "values (:caseId,:caseCountyName,:caseBlockName,:caseLoopName,:caseCommunityName," +
|
||||
// ":caseAddress,:caseArea,:caseUnitPrice,:caseTotalPrice,:caseHouseType,:caseSigningDate," +
|
||||
// ":caseRegisterDate,:agencyName,:agencyType,:sellerType,:buyerType,:birthday," +
|
||||
// ":cleanCaseType,:cleanPropertyType,GETDATE());",
|
||||
// batchParams);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 匹配数据
|
||||
// *
|
||||
// * @param yearMonth
|
||||
// */
|
||||
// public void after(Integer yearMonth) {
|
||||
// // 清洗挂牌案例
|
||||
// String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_closing_case.sql");
|
||||
// String sql = rawSql.replace("#yearMonth#", yearMonth.toString());
|
||||
// jdbcTemplate.update(sql);
|
||||
// }
|
||||
//}
|
||||
|
@ -71,7 +71,6 @@ public class OriginalResidenceRentOpeningCaseServiceImpl implements IOriginalRes
|
||||
});
|
||||
|
||||
// 两种数据,分别插入不同的表当中
|
||||
|
||||
running(computeTableRoute, list);
|
||||
after(computeTableRoute, lastYearMonth, valuePoint);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class OriginalResidenceSaleClosingCaseServiceImpl implements IOriginalRes
|
||||
*/
|
||||
@Scheduled(cron = "0 0 5 9 * ?")
|
||||
@Override
|
||||
public void pullData() {
|
||||
public void clear() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
Integer targetTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
@ -96,13 +96,14 @@ public class OriginalResidenceSaleClosingCaseServiceImpl implements IOriginalRes
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配数据
|
||||
* 清洗成交数据
|
||||
*
|
||||
* @param yearMonth
|
||||
*/
|
||||
public void after(Integer yearMonth) {
|
||||
// 清洗挂牌案例
|
||||
String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_closing_case.sql");
|
||||
// sql-template/.sql
|
||||
// String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_closing_case.sql");
|
||||
String rawSql = LoadUtil.loadContent("sql-template/clear_sale_closing_case.sql");
|
||||
String sql = rawSql.replace("#yearMonth#", yearMonth.toString());
|
||||
jdbcTemplate.update(sql);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class OriginalResidenceSaleOpeningCaseServiceImpl implements IOriginalRes
|
||||
*/
|
||||
@Scheduled(cron = "0 0 5 25 * ?")
|
||||
@Override
|
||||
public void pullData() {
|
||||
public void clear() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
Integer syncTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
@ -56,16 +56,18 @@ public class OriginalResidenceSaleOpeningCaseServiceImpl implements IOriginalRes
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
Integer computeTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH) + 1));
|
||||
computeTableRoute = 202007;
|
||||
lastYearMonth = 202006;
|
||||
|
||||
prepare(computeTableRoute, syncTableRoute);
|
||||
List<OriginalResidenceSaleOpeningCase> list = downloadOriginalResidenceSaleOpeningCaseMapper.download();
|
||||
list.parallelStream().forEach(originalResidenceOpeningCase -> {
|
||||
originalResidenceOpeningCase.clear();
|
||||
originalResidenceOpeningCase.setYearMonth(syncTableRoute);
|
||||
syncOriginalResidenceSaleOpeningCaseMapper.insert(originalResidenceOpeningCase);
|
||||
// originalResidenceOpeningCase.clear();
|
||||
// originalResidenceOpeningCase.setYearMonth(syncTableRoute);
|
||||
// syncOriginalResidenceSaleOpeningCaseMapper.insert(originalResidenceOpeningCase);
|
||||
});
|
||||
running(computeTableRoute, list);
|
||||
after(computeTableRoute, lastYearMonth, valuePoint);
|
||||
after(computeTableRoute, lastYearMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,13 +77,13 @@ public class OriginalResidenceSaleOpeningCaseServiceImpl implements IOriginalRes
|
||||
* @param syncTableRoute
|
||||
*/
|
||||
public void prepare(Integer computeTableRoute, Integer syncTableRoute) {
|
||||
originalResidenceSaleOpeningCaseMapper.createTable(computeTableRoute);
|
||||
originalResidenceSaleOpeningCaseMapper.createOpeningCaseRawTable(computeTableRoute);
|
||||
originalResidenceSaleOpeningCaseMapper.createCleanTable(computeTableRoute);
|
||||
originalResidenceSaleOpeningCaseMapper.createAssembleTable(computeTableRoute);
|
||||
originalResidenceSaleOpeningCaseMapper.createComputePriceTable(computeTableRoute);
|
||||
originalResidenceSaleOpeningCaseMapper.createArtificialPriceTable(computeTableRoute);
|
||||
|
||||
syncOriginalResidenceSaleOpeningCaseMapper.createTable(syncTableRoute);
|
||||
// syncOriginalResidenceSaleOpeningCaseMapper.createTable(syncTableRoute);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,22 +95,14 @@ public class OriginalResidenceSaleOpeningCaseServiceImpl implements IOriginalRes
|
||||
public void running(Integer computeTableRoute, List<OriginalResidenceSaleOpeningCase> list) {
|
||||
SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(list.toArray());
|
||||
int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("insert into dbo" +
|
||||
".original_residence_sale_opening_case_" + computeTableRoute + "(case_id, case_lianjia_id, " +
|
||||
"case_lianjia_community_id, case_title, clean_property_type, case_apartment_layout, " +
|
||||
"case_house_structure, case_area, case_underground_area, case_toward, clean_toward, " +
|
||||
"case_storey, clean_total_floor, clean_current_floor_desc, case_elevator, clean_elevator, " +
|
||||
"case_tihu, case_decoration, clean_decoration, case_year, clean_year, case_address, " +
|
||||
"case_price, clean_unit_price, clean_total_price, case_community_name, case_visited_num, " +
|
||||
"case_visited_num_15, case_visited_num_30, case_latest_deal_date, case_latest_visited_date, " +
|
||||
"case_first_visited_date, case_url, case_community_url, case_get_date, case_provider, " +
|
||||
"create_time) values (:newCaseId,:caseLianJiaId,:caseLianJiaCommunityId,:caseTitle," +
|
||||
":cleanPropertyType," +
|
||||
":caseApartmentLayout,:caseHouseStructure,:caseArea,:caseUndergroundArea,:caseToward," +
|
||||
":cleanToward,:caseStorey,:cleanTotalFloor,:cleanCurrentFloorDesc,:caseElevator," +
|
||||
":cleanElevator,:caseTiHu,:caseDecoration,:cleanDecoration,:caseYear,:cleanYear,:caseAddress," +
|
||||
":casePrice,:cleanUnitPrice,:cleanTotalPrice,:caseCommunityName,:caseVisitedNum," +
|
||||
":caseVisitedNum15,:caseVisitedNum30,NULL,:caseLatestVisitTime,:caseFirstVisitTime,:caseUrl," +
|
||||
":caseCommunityUrl,:caseGetDate,:caseProvider,GETDATE());",
|
||||
".ODS_HOUSINGCASELISTED_LJ_" + computeTableRoute + "_RAW(case_id, llid, lcid, Name, " +
|
||||
"Roomtype, Area, Towards, Storey, Lastdeal, Condoelev, Decoration, Year, Address, Price, " +
|
||||
"Cname, Visited_Num, First_Visit_Time, Visited_Num_15, Visited_Num_30, Url, Curl, CurlDate) " +
|
||||
"values (:newCaseId,:caseLianJiaId,:caseLianJiaCommunityId,:caseTitle," +
|
||||
":caseApartmentLayout,:caseArea,:caseToward,:caseStorey,:caseLastDeal,:caseElevator" +
|
||||
",:caseDecoration,:caseYear,:caseAddress,:casePrice,:caseCommunityName,:caseVisitedNum," +
|
||||
":caseFirstVisitTime,:caseVisitedNum15,:caseVisitedNum30,:caseUrl,:caseCommunityUrl," +
|
||||
":caseGetDate);",
|
||||
batchParams);
|
||||
}
|
||||
|
||||
@ -118,21 +112,20 @@ public class OriginalResidenceSaleOpeningCaseServiceImpl implements IOriginalRes
|
||||
*
|
||||
* @param yearMonth
|
||||
* @param lastYearMonth
|
||||
* @param valuePoint
|
||||
*/
|
||||
public void after(Integer yearMonth, Integer lastYearMonth, Date valuePoint) {
|
||||
public void after(Integer yearMonth, Integer lastYearMonth) {
|
||||
// 清洗挂牌案例
|
||||
String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_opening_case.sql");
|
||||
|
||||
String rawSql = LoadUtil.loadContent("sql-template/clear_sale_opening_case.sql");
|
||||
// String rawSql = LoadUtil.loadContent("sql-template/clear_residence_sale_opening_case.sql");
|
||||
String sql = rawSql.replace("#yearMonth#", yearMonth.toString())
|
||||
.replace("#lastYearMonth#", lastYearMonth.toString());
|
||||
jdbcTemplate.update(sql);
|
||||
|
||||
// 作价
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
rawSql = LoadUtil.loadContent("sql-template/compute_residence_sale_base_price.sql");
|
||||
rawSql = LoadUtil.loadContent("sql-template/compute_sale_price.sql");
|
||||
sql = rawSql.replace("#yearMonth#", yearMonth.toString())
|
||||
.replace("#lastYearMonth#", lastYearMonth.toString())
|
||||
.replace("#valuePoint#", simpleDateFormat.format(valuePoint));
|
||||
.replace("#lastYearMonth#", lastYearMonth.toString());
|
||||
jdbcTemplate.update(sql);
|
||||
|
||||
logger.debug("#作价完成#");
|
||||
|
@ -94,10 +94,6 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr
|
||||
officeBasePriceUltimateMapper.insertArtificialOfficeBasePrice(inputModel);
|
||||
});
|
||||
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// String url = String.format(uvConfig.getAitificialOfficeBasePriceUrl(), yearMonth, lastYearMonth);
|
||||
// UVResponse<Integer> affectCount = restTemplate.getForObject(url, UVResponse.class);
|
||||
|
||||
String rawSql = LoadUtil.loadContent("sql-template/update_office_price.sql");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int year = yearMonth / 100;
|
||||
@ -114,10 +110,6 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr
|
||||
.replace("#lastMonth#", simpleDateFormat.format(lastMonth));
|
||||
jdbcTemplate.update(sql);
|
||||
|
||||
// String rawSql =
|
||||
// String sql = rawSql.replace("#yearMonth#", yearMonth.toString());
|
||||
// jdbcTemplate.execute(sql);
|
||||
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
150
ruoyi/src/main/resources/application-uat.yml
Normal file
150
ruoyi/src/main/resources/application-uat.yml
Normal file
@ -0,0 +1,150 @@
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 2.2.0
|
||||
# 版权年份
|
||||
copyrightYear: 2019
|
||||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||
profile: /var/log/ruoyi/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
|
||||
# web服务器配置
|
||||
server:
|
||||
port: 9700
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
# tomcat最大线程数,默认为200
|
||||
max-threads: 800
|
||||
# Tomcat启动初始化的线程数,默认值25
|
||||
min-spare-threads: 30
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: master
|
||||
hikari:
|
||||
connection-timeout: 30000
|
||||
validation-timeout: 30000
|
||||
idle-timeout: 30000
|
||||
max-lifetime: 30000
|
||||
max-pool-size: 30
|
||||
min-idle: 10
|
||||
initialization-fail-timeout: 30000
|
||||
connection-init-sql: select 1
|
||||
connection-test-query: select 1
|
||||
is-auto-commit: true
|
||||
is-read-only: false
|
||||
datasource:
|
||||
master:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://172.16.30.243:6060/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: LOLm2dI2UQF#RxOf
|
||||
teemlink:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=obpm_LianCheng_Data
|
||||
username: sa
|
||||
password: Lcdatacenter_888
|
||||
oldProd:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://139.196.201.83:8433;DatabaseName=LC_DataCenter
|
||||
username: sa
|
||||
password: lc1234
|
||||
compute:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_compute_test
|
||||
username: sa
|
||||
password: Lcdatacenter_888
|
||||
clean:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_clean
|
||||
username: sa
|
||||
password: Lcdatacenter_888
|
||||
calc:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=CALC
|
||||
username: purple
|
||||
password: liancheng
|
||||
spider:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=TEST
|
||||
username: purple
|
||||
password: liancheng
|
||||
|
||||
# druid:
|
||||
# statViewServlet:
|
||||
# enabled: true
|
||||
# # 设置白名单,不填则允许所有访问
|
||||
# allow:
|
||||
# url-pattern: /druid/*
|
||||
# # 控制台管理用户名和密码
|
||||
# login-username:
|
||||
# login-password:
|
||||
# dynamic:
|
||||
# druid:
|
||||
# # 初始连接数
|
||||
# initialSize: 5
|
||||
# # 最小连接池数量
|
||||
# minIdle: 10
|
||||
# # 最大连接池数量
|
||||
# maxActive: 20
|
||||
# # 配置获取连接等待超时的时间
|
||||
# maxWait: 60000
|
||||
# # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
# timeBetweenEvictionRunsMillis: 60000
|
||||
# # 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
# minEvictableIdleTimeMillis: 300000
|
||||
# # 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
# maxEvictableIdleTimeMillis: 900000
|
||||
# # 配置检测连接是否有效
|
||||
# validationQuery: SELECT 1
|
||||
# testWhileIdle: true
|
||||
# testOnBorrow: false
|
||||
# testOnReturn: false
|
||||
## webStatFilter:
|
||||
## enabled: true
|
||||
## filters: stat,wall
|
||||
## wall:
|
||||
## multiStatementAllow: true
|
||||
# stat:
|
||||
# log-slow-sql: true
|
||||
# slow-sql-millis: 1000
|
||||
# merge-sql: true
|
||||
# primary: master
|
||||
# datasource:
|
||||
# # 主库数据源
|
||||
# master:
|
||||
# driver-class-name: com.mysql.jdbc.Driver
|
||||
# url: jdbc:mysql://172.16.30.243:6060/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: root
|
||||
# password: LOLm2dI2UQF#RxOf
|
||||
# # 从库数据源
|
||||
## slave:
|
||||
## # 从数据源开关/默认关闭
|
||||
## enabled: false
|
||||
## url:
|
||||
## username:
|
||||
## password:
|
||||
# teemlink:
|
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=obpm_LianCheng_Data
|
||||
# username: sa
|
||||
# password: Lcdatacenter_888
|
||||
# compute:
|
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_compute
|
||||
# username: sa
|
||||
# password: Lcdatacenter_888
|
||||
# clean:
|
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_clean
|
||||
# username: sa
|
||||
# password: Lcdatacenter_888
|
@ -28,7 +28,7 @@
|
||||
<result property="caseProvider" column="caseProvider"/>
|
||||
</resultMap>
|
||||
<select id="download" resultMap="resultMapping">
|
||||
select llid
|
||||
select top 100 llid
|
||||
, lcid
|
||||
, name
|
||||
, type
|
||||
|
@ -3,6 +3,34 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.project.data.cases.mapper.OriginalResidenceSaleClosingCaseMapper">
|
||||
|
||||
<update id="createRawClosingCaseTable">
|
||||
<bind name="targetTableName" value="'dbo.二手房成交数据' + yearMonth" />
|
||||
IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL
|
||||
drop table ${targetTableName};
|
||||
|
||||
create table ${targetTableName}
|
||||
(
|
||||
case_id uniqueidentifier not null primary key,
|
||||
区域 varchar (255) NULL,
|
||||
板块 varchar (255) NULL,
|
||||
环线 varchar (255) NULL,
|
||||
小区名称 varchar (255) NULL,
|
||||
房屋地址 varchar (255) NULL,
|
||||
面积 float NULL,
|
||||
房屋类型 varchar (255) NULL,
|
||||
总价 float NULL,
|
||||
单价 float NULL,
|
||||
登记日期 varchar (255) NULL,
|
||||
签约日期 varchar (255) NULL,
|
||||
中介公司 varchar (255) NULL,
|
||||
中介类型 varchar (255) NULL,
|
||||
卖家类型 float NULL,
|
||||
买家类型 varchar (5) NULL,
|
||||
出生年月日 varchar (5) NULL
|
||||
)
|
||||
</update>
|
||||
|
||||
<!-- 外部数据重复问题 -->
|
||||
<update id="createTable">
|
||||
<bind name="targetTableName" value="'dbo.original_residence_sale_closing_case_' + yearMonth"/>
|
||||
@ -11,7 +39,7 @@
|
||||
|
||||
CREATE TABLE ${targetTableName}
|
||||
(
|
||||
id bigint identity (1,1) not null primary key,
|
||||
id int identity(1,1) not null,
|
||||
case_id varchar(32) not null,
|
||||
case_county_name nvarchar(20) null,
|
||||
case_block_name nvarchar(20) null,
|
||||
@ -55,7 +83,7 @@
|
||||
|
||||
CREATE TABLE ${targetTableName}
|
||||
(
|
||||
SID int NOT NULL IDENTITY(1, 1) ,
|
||||
id int identity(1,1) not null primary key,
|
||||
case_id varchar(32) not null,
|
||||
ProjectID bigint NULL,
|
||||
BuildingID bigint NULL,
|
||||
|
@ -4,6 +4,40 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.project.data.cases.mapper.OriginalResidenceSaleOpeningCaseMapper">
|
||||
|
||||
<update id="createOpeningCaseRawTable">
|
||||
<bind name="targetTableName" value="'dbo.ODS_HOUSINGCASELISTED_LJ_' + yearMonth +'_RAW'" />
|
||||
IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL
|
||||
drop table ${targetTableName};
|
||||
|
||||
create table ${targetTableName}
|
||||
(
|
||||
case_id varchar (32) not null primary key
|
||||
, llid bigint
|
||||
, lcid bigint
|
||||
, Name sql_variant
|
||||
, Roomtype nvarchar(50)
|
||||
, Area decimal(18, 2)
|
||||
, Towards nvarchar(50)
|
||||
, Storey nvarchar(50)
|
||||
, Lastdeal date
|
||||
, Condoelev nvarchar(50)
|
||||
, Decoration nvarchar(50)
|
||||
, Year int
|
||||
, Address nvarchar(1024)
|
||||
, Price decimal(18, 2)
|
||||
, Cname nvarchar(1024)
|
||||
, Visited_Num int
|
||||
, First_Visit_Time date
|
||||
, Visited_Num_15 int
|
||||
, Visited_Num_30 int
|
||||
, Url nvarchar(512)
|
||||
, Curl nvarchar(512)
|
||||
, CurlDate date
|
||||
);
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<update id="createTable">
|
||||
<bind name="targetTableName" value="'dbo.original_residence_sale_opening_case_' + yearMonth" />
|
||||
IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL
|
||||
|
@ -0,0 +1,127 @@
|
||||
--二手房成交记录处理
|
||||
select t.*, left(addr_floornum,charindex('|', addr_floornum, 1)-1) as 楼栋地址,
|
||||
substring(addr_floornum, charindex('|', addr_floornum, 1)+1, len(addr_floornum)-charindex('|', addr_floornum, 1)) as "所在层"
|
||||
into #temp
|
||||
from (
|
||||
select case_id
|
||||
,case_county_name
|
||||
,case_block_name
|
||||
,case_loopline_name
|
||||
,case_community_name
|
||||
,case_address
|
||||
,case_area
|
||||
,case_unit_price
|
||||
,case_total_price
|
||||
,case_house_type
|
||||
,case_signing_date
|
||||
,case_register_date
|
||||
,case_agency_name
|
||||
,case_agency_type
|
||||
,case_seller_type
|
||||
,case_buyer_type
|
||||
,case_birthday
|
||||
, dbo.remove_last_numbers(case_address) as addr_floornum
|
||||
from original_residence_sale_closing_case_#yearMonth#
|
||||
) t;
|
||||
|
||||
update #temp set case_county_name=case_county_name+'区';
|
||||
update #temp set case_county_name='浦东新区' where case_county_name='浦东区';
|
||||
|
||||
--成交插入到临时表 #result
|
||||
select a.*, b.楼栋ID, b.小区ID
|
||||
into #result
|
||||
from #temp a
|
||||
left join (
|
||||
select row_number()over(partition by 区县, 地址 order by newid()) sq, 楼栋ID, 小区ID, 区县, 地址 from obpm_LianCheng_Data.dbo.AI单套地址20190508
|
||||
) b
|
||||
on a.case_county_name = b.区县 and a.楼栋地址 = b.地址 and b.sq=1;
|
||||
|
||||
--添加物业类型等字段
|
||||
alter table #result
|
||||
add 年月 varchar(16), 物业类型 varchar(16);
|
||||
|
||||
update #result
|
||||
set 年月= left(case_signing_date,7),
|
||||
物业类型 = case when case_house_type not in ('办公楼','商铺','未知','其它','工厂','车库') then '居住'
|
||||
when case_house_type in ('办公','办公楼','写字楼') then '办公'
|
||||
when case_house_type in ('商铺','商店','商铺') then '商业'
|
||||
else '其他' end;
|
||||
|
||||
|
||||
select
|
||||
case_id
|
||||
,left(case_county_name,2) case_county_name
|
||||
,case_block_name
|
||||
,case_loopline_name
|
||||
,case_community_name
|
||||
,case_address
|
||||
,case_area as Area
|
||||
,case_unit_price
|
||||
,case_total_price as PriceTotal
|
||||
,case_house_type as ProjectType
|
||||
,case_signing_date as DateContract
|
||||
,case_register_date
|
||||
,case_agency_name
|
||||
,case_agency_type
|
||||
,case_seller_type as IsAgency
|
||||
,case_buyer_type
|
||||
,case_birthday
|
||||
,addr_floornum
|
||||
,楼栋地址
|
||||
, 所在层 as UpperFloorNum
|
||||
, cast(convert(decimal(8,0),楼栋ID) as bigint) as BuildingID
|
||||
, cast(convert(decimal(8,0),小区ID) as bigint) as ProjectID
|
||||
, 年月
|
||||
, 物业类型
|
||||
into #tmp
|
||||
from #result
|
||||
where case_area <> 0;
|
||||
|
||||
insert into dbo.ODS_HOUSINGCASE_DEAL_#yearMonth#
|
||||
(case_id
|
||||
,ProjectID
|
||||
,BuildingID
|
||||
,Area
|
||||
,UpperFloorSum
|
||||
,UpperFloorNum
|
||||
,AreaCoff
|
||||
,FloorCoff
|
||||
,BuildingCoff
|
||||
,PriceTotal
|
||||
,PriceUnit
|
||||
,PriceUnitAdj
|
||||
,DateContract)
|
||||
select a.case_id
|
||||
, a.ProjectID
|
||||
, a.BuildingID
|
||||
, a.Area
|
||||
, b.地上层数 as UpperFloorSum
|
||||
, a.UpperFloorNum
|
||||
, d.CoefficientA * a.Area + d.CoefficientB as AreaCoff
|
||||
, 1 as FloorCoff
|
||||
, e.Coefficient as BuildingCoff
|
||||
, a.PriceTotal
|
||||
, a.PriceTotal * 1.0 / a.Area as PriceUnit
|
||||
, a.PriceTotal * 1.0 / a.Area / isnull(d.CoefficientA * a.Area + d.CoefficientB, 1) / isnull(e.Coefficient, 1) as PriceUnitAdj
|
||||
, DateContract
|
||||
from #tmp a
|
||||
left join obpm_LianCheng_Data.dbo.AI楼栋数据_610 b
|
||||
on a.ProjectID = b.AI小区ID
|
||||
and a.BuildingID = b.AI楼栋ID
|
||||
left join obpm_LianCheng_Data.dbo.TLK_小区信息管理 c
|
||||
on a.ProjectID = c.ITEM_AIRAID and c.ITEM_ISBUILDINDEX='1'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 f on c.ITEM_PROPERTYLEVEL = f.ITEM_DICVALUE and f.ITEM_DICTYPE='物业档次'
|
||||
left join
|
||||
(select Coefficient,CoefficientA,CoefficientB,LowerKey,UpperKey,ProjectLevel from obpm_LianCheng_Data.dbo.DIM_PARAMETERS where CoffType = '面积修正(链家挂牌)' and ProjectType = '公寓') d --面积修正
|
||||
on f.ITEM_DICTEXT = d.ProjectLevel
|
||||
and
|
||||
(
|
||||
a.Area > d.LowerKey
|
||||
and a.Area <= d.UpperKey
|
||||
)
|
||||
left join obpm_LianCheng_Data.dbo.DIM_BUILDING_COFF e
|
||||
on a.BuildingID = e.BuildingID;
|
||||
|
||||
|
||||
drop table #temp;
|
||||
drop table #result;
|
@ -0,0 +1,229 @@
|
||||
----建临时表#HousingCaseListAdj, 插入挂牌清洗数据
|
||||
------ 20200312BUG修复:朝向处理规则优化
|
||||
create table #HousingCaseListAdj
|
||||
(
|
||||
case_id varchar(32) not null
|
||||
, HouseholdsID_LJ bigint
|
||||
, ProjectID_LJ bigint
|
||||
, Roomtype nvarchar(64)
|
||||
, Area decimal(18, 2)
|
||||
, Towards nvarchar(64)
|
||||
, UpperFloorSum nvarchar(32)
|
||||
, UpperFloorNum nvarchar(32)
|
||||
, Elevator tinyint
|
||||
, Decoration nvarchar(64)
|
||||
, [Year] int
|
||||
, PriceTotal decimal(18, 2)
|
||||
, PriceUnit decimal(18, 2) not null
|
||||
, Visited_Num int
|
||||
, First_Visit_Time date
|
||||
, Visited_Num_15 int
|
||||
, Visited_Num_30 int
|
||||
);
|
||||
|
||||
DECLARE @llid bigint,
|
||||
@lcid bigint,
|
||||
@roomtype nvarchar(50),
|
||||
@area decimal(28, 10),
|
||||
@towards nvarchar(50),
|
||||
@storey nvarchar(50),
|
||||
@condoElev nvarchar(50),
|
||||
@decoration nvarchar(50),
|
||||
@yr int,
|
||||
@price DECIMAL(18,8),
|
||||
@priceunit DECIMAL(18,8),
|
||||
@visited_num int,
|
||||
@first_visit_time date,
|
||||
@visited_num_15 int,
|
||||
@visited_num_30 int,
|
||||
@toward nvarchar(50),
|
||||
@curr int,
|
||||
@prev int,
|
||||
@trimstr nvarchar(32),
|
||||
@flag int,
|
||||
@UpperFloorSum NVARCHAR(32),
|
||||
@UpperFloorNum NVARCHAR(32),
|
||||
@Elevator tinyint,
|
||||
@case_id varchar(32)
|
||||
|
||||
DECLARE Record2Insert CURSOR
|
||||
FOR select case_id
|
||||
, llid
|
||||
, lcid
|
||||
, roomtype
|
||||
, area
|
||||
, towards
|
||||
, storey
|
||||
, condoElev
|
||||
, decoration
|
||||
, [year]
|
||||
, price
|
||||
, visited_num
|
||||
, first_visit_time
|
||||
, visited_num_15
|
||||
, visited_num_30
|
||||
from ODS_HOUSINGCASELISTED_LJ_#yearMonth#_Raw;
|
||||
OPEN Record2Insert
|
||||
FETCH NEXT FROM Record2Insert into @case_id, @llid , @lcid , @roomtype , @area , @towards , @storey , @condoElev , @decoration , @yr, @price , @visited_num ,
|
||||
@first_visit_time , @visited_num_15 , @visited_num_30
|
||||
SET NOCOUNT ON --忽略行数显示
|
||||
WHILE @@FETCH_STATUS=0
|
||||
BEGIN
|
||||
BEGIN
|
||||
--朝向处理(按照"东南, 西南, 西北, 东北, 南, 东, 西, 北"的优先级取朝向的值。注:表的一列赋值给单变量,只有最后赋的值有效)
|
||||
set @toward = NULL
|
||||
select @toward = StringSub from StringSplit(@towards, ' ') order by charindex(StringSub, '北, 西, 东, 南, 东北, 西北, 西南, 东南')
|
||||
--楼层处理
|
||||
set @UpperFloorNum = case when substring(@storey,1,3)='高楼层' then '高区'
|
||||
when substring(@storey,1,3)='中楼层' then '中区'
|
||||
when substring(@storey,1,3)='低楼层' then '低区' end
|
||||
set @UpperFloorSum = substring(@storey,charindex('共',@storey,1)+1,charindex('层',@storey,charindex('共',@storey,1))-charindex('共',@storey,1)-1)
|
||||
--电梯处理
|
||||
set @Elevator = case when @condoElev='有' then 1
|
||||
when @condoElev='无' then 0 end
|
||||
--装修处理
|
||||
set @decoration = case when @decoration <> '其他' then @decoration end
|
||||
--单价
|
||||
set @priceunit = @price*1.0/isnull(@area,1)
|
||||
--插入数据
|
||||
insert into #HousingCaseListAdj values(@case_id, @llid, @lcid, @roomtype, @area, @toward, @UpperFloorSum, @UpperFloorNum, @Elevator, @decoration, @yr, 10000*@price, 10000*@priceunit,
|
||||
@visited_num, @first_visit_time, @visited_num_15, @visited_num_30)
|
||||
END
|
||||
FETCH NEXT FROM Record2Insert INTO @case_id, @llid , @lcid , @roomtype , @area , @towards , @storey , @condoElev , @decoration , @yr, @price , @visited_num ,
|
||||
@first_visit_time , @visited_num_15 , @visited_num_30
|
||||
END
|
||||
CLOSE Record2Insert
|
||||
DEALLOCATE Record2Insert
|
||||
SET NOCOUNT OFF
|
||||
|
||||
|
||||
----案例标准化
|
||||
create table #HousingCaseListSTD
|
||||
(
|
||||
HouseholdsID_LJ bigint
|
||||
, ProjectID_LJ bigint
|
||||
, ProjectID bigint
|
||||
, BuildingID bigint
|
||||
, AreaCoff decimal(7, 4)
|
||||
, TowardsCoff decimal(7, 4)
|
||||
, FloorCoff decimal(7, 4)
|
||||
, DecorationRng int
|
||||
, YearCoff decimal(7, 4)
|
||||
, BuildingCoff decimal(7, 4)
|
||||
, PriceUnit decimal(18, 2) not null
|
||||
, PriceUnitAdj decimal(18, 2) not null
|
||||
);
|
||||
|
||||
INSERT INTO #HousingCaseListSTD
|
||||
SELECT A.HouseholdsID_LJ, A.ProjectID_LJ, B.ProjectID, B.BuildingID,
|
||||
D.CoefficientA*A.Area+D.CoefficientB as AreaCoff, E.Coefficient as TowardsCoff, F.Coefficient as FloorCoff,
|
||||
G.Coefficient as DecorationRng, H.Coefficient as YearCoff, I.Coefficient as BuildingCoff, A.PriceUnit,
|
||||
(A.PriceUnit-isnull(G.Coefficient,0))*1.0/isnull(D.CoefficientA*A.Area+D.CoefficientB,1)/isnull(E.Coefficient,1)/isnull(F.Coefficient,1)/isnull(H.Coefficient,1)/isnull(I.Coefficient,1)
|
||||
FROM #HousingCaseListAdj A
|
||||
LEFT JOIN obpm_LianCheng_Data.dbo.DIM_PROJECTID_LJ2AI B
|
||||
ON A.ProjectID_LJ = B.ProjectID_LJ
|
||||
left join (select * from uv_compute.dbo.ODS_PROJECT_INFO_202004 WHERE EffDate <= GETDATE() and ExpirDate > GETDATE() ) C
|
||||
on B.ProjectID = C.ProjectID
|
||||
LEFT JOIN (SELECT * FROM obpm_LianCheng_Data.dbo.DIM_PARAMETERS WHERE CoffType='面积修正(链家挂牌)') D --面积修正
|
||||
on D.ProjectType = '公寓' and C.ProjectLevel = D.ProjectLevel and ( A.Area > D.LowerKey and A.Area <= D.UpperKey)
|
||||
LEFT JOIN (SELECT * FROM obpm_LianCheng_Data.dbo.DIM_PARAMETERS WHERE CoffType='朝向(链家挂牌)') E --朝向修正
|
||||
on E.ProjectType = '公寓' and A.Towards = E.SingleKey
|
||||
LEFT JOIN (SELECT * FROM obpm_LianCheng_Data.dbo.DIM_PARAMETERS WHERE CoffType='楼层(链家挂牌)') F --楼层修正
|
||||
on F.ProjectType = '公寓' and isnull(A.Elevator,99)=isnull(F.Elevator,99) and A.UpperFloorSum = F.UpperKey and A.UpperFloorNum = F.LowerKey
|
||||
LEFT JOIN (SELECT * FROM obpm_LianCheng_Data.dbo.DIM_PARAMETERS WHERE CoffType='室内装修(链家挂牌)') G --装修修正
|
||||
on G.ProjectType = '公寓' and A.Decoration = G.SingleKey
|
||||
LEFT JOIN (SELECT * FROM obpm_LianCheng_Data.dbo.DIM_PARAMETERS WHERE CoffType='竣工日期') H --竣工日期修正
|
||||
on H.ProjectType = '公寓' and A.[Year]=H.SingleKey
|
||||
LEFT JOIN obpm_LianCheng_Data.dbo.DIM_BUILDING_COFF I
|
||||
on B.BuildingID = I.BuildingID;
|
||||
|
||||
|
||||
--当月拍照表调价信息
|
||||
--- 20200205BUG修复:AdjustedValue、AdjustedPst 中当Status=1时,值不为0的问题
|
||||
select
|
||||
a.HouseholdsID_LJ,
|
||||
case when b.Status is null then 3
|
||||
when a.PriceTotal=b.PriceTotal then 1
|
||||
else 2 end as Status,
|
||||
case when a.PriceTotal=b.PriceTotal then 0 -- 20200205修改
|
||||
when b.Status is null then 0
|
||||
else a.PriceTotal-b.PriceTotal end AdjustedValue,
|
||||
case when a.PriceTotal=b.PriceTotal then 0 -- 20200205修改
|
||||
when b.Status is null then 0
|
||||
else (a.PriceTotal-b.PriceTotal)*1.0/b.PriceTotal end AdjustedPst,
|
||||
case when a.PriceTotal=b.PriceTotal then b.AdjustedCumValue
|
||||
when b.Status is null then 0
|
||||
else b.AdjustedCumValue + a.PriceTotal-b.PriceTotal end AdjustedCumValue,
|
||||
case when a.PriceTotal=b.PriceTotal then b.AdjustedCumPst
|
||||
when b.Status is null then 0
|
||||
else (b.AdjustedCumValue + a.PriceTotal-b.PriceTotal)*1.0/b.PriceTotalIn end AdjustedCumPst,
|
||||
case when a.PriceTotal=b.PriceTotal then b.AdjustedCumValueAbs
|
||||
when b.Status is null then 0
|
||||
else b.AdjustedCumValueAbs + abs(a.PriceTotal-b.PriceTotal) end AdjustedCumValueAbs,
|
||||
case when a.PriceTotal=b.PriceTotal then b.AdjustedCumPstAbs
|
||||
when b.Status is null then 0
|
||||
else (b.AdjustedCumValueAbs+ abs(a.PriceTotal-b.PriceTotal))*1.0/b.PriceTotalIn end AdjustedCumPstAbs,
|
||||
case when a.PriceTotal=b.PriceTotal then b.AdjustedCumPstAbs
|
||||
when b.Status is null then 0
|
||||
else b.AdjustedCumNum+1 end AdjustedCumNum,
|
||||
case when b.Status is null then a.PriceTotal else b.PriceTotalIn end PriceTotalIn,
|
||||
NULL as PriceTotalOut,
|
||||
case when b.Status is null then getdate() else b.PriceDateIn end PriceDateIn,
|
||||
cast(NULL as date) as PriceDateOut
|
||||
into #HousingCaseListStatic
|
||||
from #HousingCaseListAdj a
|
||||
left join Ods_HousingCaseListed_LJ_#lastYearMonth# b
|
||||
on a.HouseholdsID_LJ = b.HouseholdsID_LJ;
|
||||
|
||||
--插入当月未下架(活跃)案例数据
|
||||
insert into Ods_HousingCaseListed_LJ_#yearMonth#
|
||||
select a.case_id,a.HouseholdsID_LJ, a.ProjectID_LJ, d.ProjectID, a.Roomtype, a.Area, a.Towards, a.UpperFloorSum, a.UpperFloorNum, a.Elevator, a.Decoration, a.[Year],
|
||||
b.AreaCoff, b.TowardsCoff, b.FloorCoff, b.DecorationRng, b.YearCoff, b.BuildingCoff, a.PriceTotal, a.PriceUnit, b.PriceUnitAdj,
|
||||
a.Visited_Num, a.First_Visit_Time, a.Visited_Num_15, a.Visited_Num_30,
|
||||
c.Status, c.AdjustedValue, c.AdjustedPst, c.AdjustedCumValue, c.AdjustedCumPst, c.AdjustedCumValueAbs,
|
||||
c.AdjustedCumPstAbs, c.AdjustedCumNum, c.PriceTotalIn, c.PriceTotalOut, c.PriceDateIn, c.PriceDateOut
|
||||
from #HousingCaseListAdj a
|
||||
left join #HousingCaseListSTD b
|
||||
on a.HouseholdsID_LJ = b.HouseholdsID_LJ
|
||||
left join #HousingCaseListStatic c
|
||||
on a.HouseholdsID_LJ = c.HouseholdsID_LJ
|
||||
left join obpm_LianCheng_Data.dbo.DIM_PROJECTID_LJ2AI d
|
||||
on a.ProjectID_LJ = d.ProjectID_LJ;
|
||||
|
||||
|
||||
/*插入当月下架记录*/
|
||||
select a.case_id, a.HouseholdsID_LJ, a.ProjectID_LJ, a.ProjectID, a.Roomtype, a.Area, a.Towards, a.UpperFloorSum, a.UpperFloorNum, a.Elevator, a.Decoration, a.[Year],
|
||||
a.AreaCoff, a.TowardsCoff, a.FloorCoff, a.DecorationRng, a.YearCoff, a.BuildingCoff, a.PriceTotal, a.PriceUnit, a.PriceUnitAdj,
|
||||
a.Visited_Num, a.First_Visit_Time, a.Visited_Num_15, a.Visited_Num_30,
|
||||
4 as Status, a.AdjustedValue, a.AdjustedPst, a.AdjustedCumValue, a.AdjustedCumPst,
|
||||
a.AdjustedCumValueAbs, a.AdjustedCumPstAbs, a.AdjustedCumNum, a.PriceTotalIn, a.PriceTotal as PriceTotalOut, a.PriceDateIn, getdate() as PriceDateOut
|
||||
into #TmpRecordAddCurr
|
||||
from Ods_HousingCaseListed_LJ_#lastYearMonth# a
|
||||
left join Ods_HousingCaseListed_LJ_#yearMonth# b
|
||||
on a.HouseholdsID_LJ = b.HouseholdsID_LJ
|
||||
where b.HouseholdsID_LJ is null and a.Status not in (4,5);
|
||||
|
||||
insert into dbo.Ods_HousingCaseListed_LJ_#yearMonth# select * from #TmpRecordAddCurr;
|
||||
|
||||
|
||||
/*插入历史下架记录*/
|
||||
|
||||
select a.case_id,a.HouseholdsID_LJ, a.ProjectID_LJ, a.ProjectID, a.Roomtype, a.Area, a.Towards, a.UpperFloorSum, a.UpperFloorNum, a.Elevator, a.Decoration, a.[Year],
|
||||
a.AreaCoff, a.TowardsCoff, a.FloorCoff, a.DecorationRng, a.YearCoff, a.BuildingCoff, a.PriceTotal, a.PriceUnit, a.PriceUnitAdj,
|
||||
a.Visited_Num, a.First_Visit_Time, a.Visited_Num_15, a.Visited_Num_30, 5 as Status,
|
||||
a.AdjustedValue, a.AdjustedPst, a.AdjustedCumValue, a.AdjustedCumPst,
|
||||
a.AdjustedCumValueAbs, a.AdjustedCumPstAbs, a.AdjustedCumNum, a.PriceTotalIn, a.PriceTotal as PriceTotalOut, a.PriceDateIn, a.PriceDateOut
|
||||
into #TmpRecordAddHis
|
||||
from Ods_HousingCaseListed_LJ_#lastYearMonth# a
|
||||
left join Ods_HousingCaseListed_LJ_#yearMonth# b
|
||||
on a.HouseholdsID_LJ = b.HouseholdsID_LJ
|
||||
where b.HouseholdsID_LJ is null and a.Status in (4,5);
|
||||
|
||||
insert into dbo.Ods_HousingCaseListed_LJ_#yearMonth# select * from #TmpRecordAddHis
|
||||
|
||||
|
||||
drop table #HousingCaseListAdj
|
||||
drop table #HousingCaseListSTD
|
||||
drop table #HousingCaseListStatic
|
||||
drop table #TmpRecordAddCurr
|
||||
drop table #TmpRecordAddHis
|
497
ruoyi/src/main/resources/sql-template/compute_sale_price.sql
Normal file
497
ruoyi/src/main/resources/sql-template/compute_sale_price.sql
Normal file
@ -0,0 +1,497 @@
|
||||
truncate table DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
truncate table DWA_PROJECTBASEPRICE_IMDT_#yearMonth#
|
||||
|
||||
insert into DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
select
|
||||
a.case_id
|
||||
, a.HouseholdsID_LJ
|
||||
, a.ProjectID_LJ
|
||||
, c.ITEM_AIRAID
|
||||
, c.ITEM_RANAME
|
||||
, c.ITEM_RAADRESS
|
||||
, f.ITEM_DICTEXT
|
||||
, g.ITEM_DICTEXT
|
||||
, h.ITEM_DICTEXT
|
||||
, a.Roomtype
|
||||
, a.Area
|
||||
, a.Towards
|
||||
, a.UpperFloorSum
|
||||
, a.UpperFloorNum
|
||||
, a.Elevator
|
||||
, a.Decoration
|
||||
, a.Year
|
||||
, isnull(a.AreaCoff, 1)
|
||||
, isnull(a.TowardsCoff, 1)
|
||||
, isnull(a.FloorCoff, 1)
|
||||
, isnull(a.DecorationRng, 0)
|
||||
, isnull(a.YearCoff, 1)
|
||||
, isnull(a.BuildingCoff, 1)
|
||||
, d.BasePrice as BasePrice_1
|
||||
, a.PriceTotal
|
||||
, a.PriceUnit
|
||||
, a.PriceUnitAdj
|
||||
, a.Visited_Num
|
||||
, a.First_Visit_Time
|
||||
, a.Visited_Num_15
|
||||
, a.Visited_Num_30
|
||||
, a.Status
|
||||
, a.AdjustedValue
|
||||
, a.AdjustedPst
|
||||
, a.AdjustedCumValue
|
||||
, a.AdjustedCumPst
|
||||
, a.AdjustedCumValueAbs
|
||||
, a.AdjustedCumPstAbs
|
||||
, a.AdjustedCumNum
|
||||
, a.PriceTotalIn
|
||||
, a.PriceDateIn
|
||||
, null
|
||||
, NULL
|
||||
from ODS_HOUSINGCASELISTED_LJ_#yearMonth# a
|
||||
left join obpm_LianCheng_Data.dbo.DIM_PROJECTID_LJ2AI b
|
||||
on a.ProjectID_LJ = b.ProjectID_LJ
|
||||
left join obpm_LianCheng_Data.dbo.TLK_小区信息管理 c
|
||||
on b.ProjectID = c.ITEM_AIRAID and c.ITEM_ISBUILDINDEX='1' and c.ITEM_RUNNINGSTATE=1
|
||||
and c.ITEM_PROJECTTYPE='1'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 f
|
||||
on c.ITEM_DISTRICT1=f.ITEM_DICVALUE and f.ITEM_DICTYPE='区域'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 g
|
||||
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 );
|
||||
|
||||
|
||||
insert into DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
select
|
||||
a.case_id
|
||||
,null
|
||||
,null
|
||||
, a.ProjectID
|
||||
, c.ITEM_RANAME
|
||||
, c.ITEM_RAADRESS
|
||||
, f.ITEM_DICTEXT
|
||||
, g.ITEM_DICTEXT
|
||||
, h.ITEM_DICTEXT
|
||||
, convert(varchar, null)
|
||||
, a.Area
|
||||
, convert(varchar, null)
|
||||
, a.UpperFloorSum
|
||||
, a.UpperFloorNum
|
||||
, convert(int, null)
|
||||
, convert(varchar, null)
|
||||
, convert(int, null)
|
||||
, isnull(a.AreaCoff, 1)
|
||||
, 1
|
||||
, isnull(a.FloorCoff, 1)
|
||||
, 0
|
||||
, 1
|
||||
, isnull(a.BuildingCoff, 1)
|
||||
, d.BasePrice as BasePrice_1
|
||||
, a.PriceTotal
|
||||
, a.PriceUnit
|
||||
, a.PriceUnitAdj
|
||||
, 0
|
||||
, convert(date, null)
|
||||
, 0
|
||||
, 0
|
||||
, convert(int, null)
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, a.DateContract
|
||||
, null
|
||||
, NULL
|
||||
from ODS_HOUSINGCASE_DEAL_#lastYearMonth# a
|
||||
left join obpm_LianCheng_Data.dbo.TLK_小区信息管理 c
|
||||
on a.ProjectID = c.ITEM_AIRAID and c.ITEM_ISBUILDINDEX='1' and c.ITEM_RUNNINGSTATE=1 and c.ITEM_PROJECTTYPE='1'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 f
|
||||
on c.ITEM_DISTRICT1=f.ITEM_DICVALUE and f.ITEM_DICTYPE='区域'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 g
|
||||
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;
|
||||
|
||||
|
||||
---成交案例的HouseholdsID_LJ,在上期由0优化为NULL,因此RangeFlag类型需要修改
|
||||
update DW_HOUSINGCASE_COMM_#yearMonth#
|
||||
set CaseType = case when HouseholdsID_LJ is null then 0 else 1 end,
|
||||
RangeFlag = case when BasePrice_1 is null then 19
|
||||
when HouseholdsID_LJ is null and abs(PriceUnitAdj*1.0/BasePrice_1-1)<=0.1 then 10
|
||||
when HouseholdsID_LJ is not null and abs(PriceUnitAdj*1.0/BasePrice_1-1)<=0.06 then 10
|
||||
when abs(PriceUnitAdj*1.0/BasePrice_1-1)>0.5 then 17
|
||||
else 16 end;
|
||||
|
||||
/******************************小区基价计算中间表***********************************/
|
||||
----第一步;根据小区做基础信息汇总汇总;
|
||||
create table #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
(
|
||||
ProjectID bigint primary key
|
||||
, ProjectName nvarchar(1024)
|
||||
, ProjectAddr nvarchar(1024)
|
||||
, County nvarchar(512)
|
||||
, Block nvarchar(512)
|
||||
, Loop nvarchar(512)
|
||||
, IsIndxGen tinyint
|
||||
, IsPstCalc tinyint
|
||||
, StatusRun tinyint
|
||||
, BasePrice_1 decimal(18, 2)
|
||||
, PriceUnitAdj decimal(18, 2)
|
||||
, Visited_Num int
|
||||
, First_Visit_Time date
|
||||
, Visited_Num_15 int
|
||||
, Visited_Num_30 int
|
||||
, PriceDealMean_1 decimal(18, 2)
|
||||
, PriceDealMax_1 decimal(18, 2)
|
||||
, SumDeal_1 int
|
||||
, PriceDealMean decimal(18, 2)
|
||||
, PriceDealMax decimal(18, 2)
|
||||
, SumDeal int
|
||||
, PriceListedMin decimal(18, 2)
|
||||
, PriceCase1_ToAI_Pst decimal(18, 6)
|
||||
, PriceCase2_ToAI_Pst decimal(18, 6)
|
||||
, PriceCase1_ToLst_Pst decimal(18, 6)
|
||||
, PriceCase2_ToLst_Pst decimal(18, 6)
|
||||
, PriceCase1 decimal(18, 2)
|
||||
, PriceCase1AdjPst decimal(18, 6)
|
||||
, SumCase1 int
|
||||
, PriceCase2 decimal(18, 2)
|
||||
, PriceCase2AdjPst decimal(18, 6)
|
||||
, SumCase2 int
|
||||
, PriceCase2_ToAI_0 decimal(18, 6) --PriceCase2_ToAI_Pst非空的案例数量
|
||||
, PriceCase2_ToLst_0 decimal(18, 6) --PriceCase2_ToLst_Pst非空的案例数量
|
||||
, PriceCase2Adj_0 decimal(18, 6) --PriceCase2AdjPst非空的案例数量
|
||||
);
|
||||
|
||||
|
||||
---规则修改:链家1和链家2调价幅度,status in (1,2) 都纳入计算范围
|
||||
insert into #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
select a.ITEM_AIRAID, a.ITEM_RANAME, a.ITEM_RAADRESS,f.ITEM_DICTEXT , g.ITEM_DICTEXT, h.ITEM_DICTEXT, a.ITEM_ISBUILDINDEX, a.ITEM_GAINCALCULATION, a.ITEM_RUNNINGSTATE,
|
||||
d.BasePrice, 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,
|
||||
(PriceCase2 - PriceCase2_1)*1.0/PriceCase2_1 as PriceCase2_ToLst_Pst,
|
||||
b.PriceCase1, b.PriceCase1AdjPst, b.SumCase1, b.PriceCase2, b.PriceCase2AdjPst, b.SumCase2,
|
||||
b.PriceCase2_ToAI_0,
|
||||
case when b.PriceCase2_ToAI_0<>0 and c.PriceCase2_1 is not null then PriceCase2_ToAI_0
|
||||
else 0 end as PriceCase2_ToLst_0,
|
||||
b.PriceCase2Adj_0
|
||||
from obpm_LianCheng_Data.dbo.TLK_小区信息管理 a
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 f
|
||||
on a.ITEM_DISTRICT1=f.ITEM_DICVALUE and f.ITEM_DICTYPE='区域'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 g
|
||||
on a.ITEM_SECTOR121=g.ITEM_DICVALUE and g.ITEM_DICTYPE='板块'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 h
|
||||
on a.ITEM_CIRCLEPOSITION=h.ITEM_DICVALUE and h.ITEM_DICTYPE='环线'
|
||||
left join (
|
||||
select ProjectID, avg(BasePrice_1) as BasePrice_1, avg(PriceUnitAdj) as PriceUnitAdj, avg(Visited_Num) as Visited_Num,
|
||||
min(First_Visit_Time) as First_Visit_Time, avg(Visited_Num_15) Visited_Num_15, avg(Visited_Num_30) as Visited_Num_30,
|
||||
avg(case when CaseType=0 then PriceUnitAdj end) as PriceDealMean,
|
||||
max(case when CaseType=0 then PriceUnitAdj end) as PriceDealMax,
|
||||
count(case when CaseType=0 then 1 end) as SumDeal,
|
||||
min(case when CaseType=1 then PriceUnitAdj end) as PriceListedMin,
|
||||
|
||||
avg(case when RangeFlag<>19 then PriceUnitAdj end) as PriceCase1,
|
||||
count(case when RangeFlag<>19 then 1 end) as SumCase1,
|
||||
avg(case when RangeFlag<>19 then PriceUnitAdj end)*1.0/avg(BasePrice_1)-1 as PriceCase1_ToAI_Pst,
|
||||
avg(case when RangeFlag<>19 and status in (1,2) then AdjustedPst end) as PriceCase1AdjPst,
|
||||
avg(case when RangeFlag = 10 then PriceUnitAdj end) as PriceCase2,
|
||||
count(case when RangeFlag = 10 then 1 end) as SumCase2,
|
||||
avg(case when RangeFlag = 10 then PriceUnitAdj end)*1.0/avg(BasePrice_1)-1 as PriceCase2_ToAI_Pst,
|
||||
avg(case when RangeFlag = 10 and status in (1,2) then AdjustedPst end) as PriceCase2AdjPst,
|
||||
count(case when RangeFlag = 10 then 1 end) as PriceCase2_ToAI_0,
|
||||
count(case when RangeFlag = 10 and status in (1,2) then 1 end) as PriceCase2Adj_0
|
||||
from DW_HOUSINGCASE_COMM_#yearMonth# group by ProjectID
|
||||
) b on a.ITEM_AIRAID = b.ProjectID
|
||||
left join (
|
||||
select ProjectID, avg(case when CaseType=0 then PriceUnitAdj end) as PriceDealMean_1,
|
||||
max(case when CaseType=0 then PriceUnitAdj end) as PriceDealMax_1,
|
||||
count(case when CaseType=0 then 1 end) as SumDeal_1,
|
||||
avg(case when RangeFlag<>19 then PriceUnitAdj end) as PriceCase1_1,
|
||||
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_RUNNINGSTATE=1 and a.ITEM_ISBUILDINDEX='1' and a.ITEM_PROJECTTYPE='1' and d.Status=1;
|
||||
|
||||
----第二步;根据案例自动计算的小区涨跌幅
|
||||
create table #DWA_PROJECTBASEPRICE_IMDT_STEP_2
|
||||
(
|
||||
ProjectID bigint primary key
|
||||
, VOPPBT int --价格涨跌幅类型-调整前
|
||||
, VOPPB decimal(18, 6) --价格涨跌幅-调整前
|
||||
);
|
||||
|
||||
INSERT INTO #DWA_PROJECTBASEPRICE_IMDT_STEP_2
|
||||
SELECT a.ProjectID,
|
||||
CASE WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN 11
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN 12
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN 13
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN 14
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0) THEN 15
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN 16
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN 17
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN 18
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN 19
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN 21
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN 22
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN 23
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN 24
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0
|
||||
AND (PriceCase2_ToAI_0<>0 OR PriceCase2_ToLst_0<>0 OR PriceCase2Adj_0<>0)) THEN 25
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN 26
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN 27
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN 28
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN 29
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN 0
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN 32
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN 33
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN 34
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0) THEN 35
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN 36
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN 37
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN 38
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN 39
|
||||
END AS VOPPBT,
|
||||
CASE WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN MIN --11
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN MDN*1.0/4 --12
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN MDN*1.0/4 --13
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN MDN*1.0/4 --14
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0) THEN 0 --15
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN 0 --16
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN MDN*1.0/4 --17
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN 0 --18
|
||||
WHEN (PriceCase2_ToAI_Pst>0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN MDN --19
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN MDN*1.0/4 --21
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN MDN*1.0/4 --22
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN 0 --23
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN 0 --24
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0
|
||||
AND (PriceCase2_ToAI_0<>0 OR PriceCase2_ToLst_0<>0 OR PriceCase2Adj_0<>0)) THEN 0 --25
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN MIN*1.0/3 --26
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN 0 --27
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN 0 --28
|
||||
WHEN (PriceCase2_ToAI_Pst=0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN MDN --29
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst>0) THEN 0 --31
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst=0) THEN 0 --32
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst>0 AND PriceCase2AdjPst<0) THEN MDN --33
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst>0) THEN 0 --34
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst=0) THEN 0 --35
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst=0 AND PriceCase2AdjPst<0) THEN MDN --36
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst>0) THEN MDN --37
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst=0) THEN MDN --38
|
||||
WHEN (PriceCase2_ToAI_Pst<0 AND PriceCase2_ToLst_Pst<0 AND PriceCase2AdjPst<0) THEN MDN --39
|
||||
END AS VOPPB
|
||||
FROM (SELECT projectid, ISNULL(PriceCase2_ToAI_Pst,0) PriceCase2_ToAI_Pst,
|
||||
ISNULL(PriceCase2_ToLst_Pst,0) PriceCase2_ToLst_Pst, ISNULL(PriceCase2AdjPst,0) PriceCase2AdjPst,
|
||||
PriceCase2_ToAI_0, PriceCase2_ToLst_0, PriceCase2Adj_0
|
||||
FROM #DWA_PROJECTBASEPRICE_IMDT_STEP_1 where PriceUnitAdj is not null) a
|
||||
LEFT JOIN (
|
||||
select projectid, min(vl) as MIN, avg(MDN) as MDN
|
||||
from (
|
||||
select projectid, tp, vl, PERCENTILE_CONT(0.5) within group(order by vl)over(partition by projectid) as MDN --取中位数
|
||||
from (
|
||||
select projectid, PriceCase2_ToAI_Pst, PriceCase2_ToLst_Pst, PriceCase2AdjPst
|
||||
from #DWA_PROJECTBASEPRICE_IMDT_STEP_1 where PriceUnitAdj is not null
|
||||
) as t unpivot(vl for tp in (PriceCase2_ToAI_Pst, PriceCase2_ToLst_Pst, PriceCase2AdjPst)) as up
|
||||
)tt group by projectid
|
||||
)b ON a.projectid = b.projectid;
|
||||
|
||||
----第三步;计算绑定涨跌幅
|
||||
-----2019.11.12规则新增:对于绑定没有推导出、且上周期有价格的小区,沿用上周期价格
|
||||
create table #DWA_PROJECTBASEPRICE_IMDT_STEP_3
|
||||
(
|
||||
ProjectID bigint primary key
|
||||
, BindProjID int
|
||||
, Bind_Proj_Pst decimal(18, 6)
|
||||
, Bind_Block_Class nvarchar(128)
|
||||
, Bind_Block_Class_Pst decimal(18, 6)
|
||||
, Bind_Block_Plevel nvarchar(128)
|
||||
, Bind_Block_Plevel_Pst decimal(18, 6)
|
||||
, Bind_Block_PType nvarchar(128)
|
||||
, Bind_Block_PType_Pst decimal(18, 6)
|
||||
, Bind_County_PType nvarchar(128)
|
||||
, Bind_County_PType_Pst decimal(18, 6)
|
||||
, Bind_Price_1_PType nvarchar(128)
|
||||
, Bind_Price_1_PType_Pst decimal(18, 6)
|
||||
, VOPPAT varchar(64)
|
||||
, VOPPA decimal(18, 6)
|
||||
);
|
||||
|
||||
|
||||
SELECT A.ITEM_AIRAID as ProjectID, g.ITEM_DICTEXT as Block, f.ITEM_DICTEXT 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,
|
||||
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
|
||||
INTO #TempBindProjID
|
||||
FROM obpm_LianCheng_Data.dbo.TLK_小区信息管理 a
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 f
|
||||
on a.ITEM_DISTRICT1=f.ITEM_DICVALUE and f.ITEM_DICTYPE='区域'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 g
|
||||
on a.ITEM_SECTOR121=g.ITEM_DICVALUE and g.ITEM_DICTYPE='板块'
|
||||
left join obpm_LianCheng_Data.dbo.TLK_字典数据信息 h
|
||||
on a.ITEM_PROPERTYLEVEL=h.ITEM_DICVALUE and h.ITEM_DICTYPE='物业档次'
|
||||
LEFT JOIN (SELECT ProjectID, VOPPBT, VOPPB FROM #DWA_PROJECTBASEPRICE_IMDT_STEP_2 WHERE ABS(VOPPB) < 0.1) B
|
||||
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_RUNNINGSTATE='1' and a.ITEM_PROJECTTYPE='1';
|
||||
|
||||
-- 2.板块+绑定
|
||||
SELECT A.ProjectID, A.Block, A.County, A.ProjectLevel, A.ProjectTypeDtl, A.BindClassID, A.BindProjID, A.Bind_Proj_Pst,
|
||||
B.Bind_Block_Class, B.Bind_Block_Class_Pst,
|
||||
CASE WHEN A.VOPPAT IS NOT NULL THEN A.VOPPAT
|
||||
WHEN B.Bind_Block_Class IS NOT NULL AND A.BasePrice IS NOT NULL THEN '8501' END AS VOPPAT,
|
||||
CASE WHEN A.VOPPA IS NOT NULL THEN A.VOPPA
|
||||
WHEN B.Bind_Block_Class IS NOT NULL AND A.BasePrice IS NOT NULL THEN B.Bind_Block_Class_Pst END AS VOPPA,
|
||||
A.BasePrice
|
||||
INTO #Temp_Bind_Block_Class
|
||||
FROM #TempBindProjID A
|
||||
LEFT JOIN (
|
||||
SELECT Block+BindClassID AS Bind_Block_Class, AVG(VOPPA) AS Bind_Block_Class_Pst
|
||||
FROM #TempBindProjID GROUP BY Block+BindClassID
|
||||
) B
|
||||
ON A.Block +A.BindClassID = B.Bind_Block_Class AND B.Bind_Block_Class_Pst IS NOT NULL
|
||||
|
||||
|
||||
-- 3.板块+物业档次
|
||||
SELECT A.ProjectID, A.Block, A.County, A.ProjectLevel, A.ProjectTypeDtl, A.BindClassID, A.BindProjID, A.Bind_Proj_Pst,
|
||||
A.Bind_Block_Class, A.Bind_Block_Class_Pst, B.Bind_Block_Plevel, B.Bind_Block_Plevel_Pst,
|
||||
CASE WHEN A.VOPPAT IS NOT NULL THEN A.VOPPAT
|
||||
WHEN B.Bind_Block_Plevel IS NOT NULL AND A.BasePrice IS NOT NULL THEN '8502' END AS VOPPAT,
|
||||
CASE WHEN A.VOPPA IS NOT NULL THEN A.VOPPA
|
||||
WHEN B.Bind_Block_Plevel IS NOT NULL AND A.BasePrice IS NOT NULL THEN B.Bind_Block_Plevel_Pst END AS VOPPA,
|
||||
A.BasePrice
|
||||
INTO #Temp_Bind_Block_Plevel
|
||||
FROM #Temp_Bind_Block_Class A
|
||||
LEFT JOIN (
|
||||
SELECT Block+ProjectLevel AS Bind_Block_Plevel, AVG(VOPPA) AS Bind_Block_Plevel_Pst
|
||||
FROM #Temp_Bind_Block_Class GROUP BY Block+ProjectLevel
|
||||
) B
|
||||
ON A.Block +A.ProjectLevel = B.Bind_Block_Plevel AND B.Bind_Block_Plevel_Pst IS NOT NULL
|
||||
-- 4.板块+物业类型
|
||||
SELECT A.ProjectID, A.Block, A.County, A.ProjectLevel, A.ProjectTypeDtl, A.BindClassID, A.BindProjID, A.Bind_Proj_Pst,
|
||||
A.Bind_Block_Class, A.Bind_Block_Class_Pst, A.Bind_Block_Plevel, A.Bind_Block_Plevel_Pst,
|
||||
B.Bind_Block_PType, B.Bind_Block_PType_Pst,
|
||||
CASE WHEN A.VOPPAT IS NOT NULL THEN A.VOPPAT
|
||||
WHEN B.Bind_Block_PType IS NOT NULL AND A.BasePrice IS NOT NULL THEN '8503' END AS VOPPAT,
|
||||
CASE WHEN A.VOPPA IS NOT NULL THEN A.VOPPA
|
||||
WHEN B.Bind_Block_PType IS NOT NULL AND A.BasePrice IS NOT NULL THEN B.Bind_Block_PType_Pst END AS VOPPA,
|
||||
A.BasePrice
|
||||
INTO #Temp_Bind_Block_PType
|
||||
FROM #Temp_Bind_Block_Plevel A
|
||||
LEFT JOIN (
|
||||
SELECT Block+ProjectTypeDtl AS Bind_Block_PType, AVG(VOPPA) AS Bind_Block_PType_Pst
|
||||
FROM #Temp_Bind_Block_Plevel GROUP BY Block+ProjectTypeDtl
|
||||
) B
|
||||
ON A.Block+A.ProjectTypeDtl = B.Bind_Block_PType AND B.Bind_Block_PType_Pst IS NOT NULL
|
||||
-- 5.区域+物业类型
|
||||
SELECT A.ProjectID, A.Block, A.County, A.ProjectLevel, A.ProjectTypeDtl, A.BindClassID, A.BindProjID, A.Bind_Proj_Pst,
|
||||
A.Bind_Block_Class, A.Bind_Block_Class_Pst, A.Bind_Block_Plevel, A.Bind_Block_Plevel_Pst,
|
||||
A.Bind_Block_PType, A.Bind_Block_PType_Pst, B.Bind_County_PType, B.Bind_County_PType_Pst,
|
||||
CASE WHEN A.VOPPAT IS NOT NULL THEN A.VOPPAT
|
||||
WHEN B.Bind_County_PType IS NOT NULL AND A.BasePrice IS NOT NULL THEN '8504' END AS VOPPAT,
|
||||
CASE WHEN A.VOPPA IS NOT NULL THEN A.VOPPA
|
||||
WHEN B.Bind_County_PType IS NOT NULL AND A.BasePrice IS NOT NULL THEN B.Bind_County_PType_Pst END AS VOPPA,
|
||||
A.BasePrice
|
||||
INTO #Temp_Bind_County_PType
|
||||
FROM #Temp_Bind_Block_PType A
|
||||
LEFT JOIN (
|
||||
SELECT County+ProjectTypeDtl AS Bind_County_PType, AVG(VOPPA) AS Bind_County_PType_Pst
|
||||
FROM #Temp_Bind_Block_PType GROUP BY County+ProjectTypeDtl
|
||||
) B
|
||||
ON A.County +A.ProjectTypeDtl = B.Bind_County_PType AND B.Bind_County_PType_Pst IS NOT NULL
|
||||
|
||||
--插入结果 (11-39 自动计算; 8505 绑定相同ID平均值; 8506混合小区ID; 8501板块+绑定; 8502板块+物业档次; 8503板块+类型; 8504区域+类型)
|
||||
--6. 上周期有基价、当周期没有涨跌幅的的小区,沿用上周期基价
|
||||
INSERT INTO #DWA_PROJECTBASEPRICE_IMDT_STEP_3
|
||||
SELECT ProjectID, BindProjID, Bind_Proj_Pst,
|
||||
Bind_Block_Class, Bind_Block_Class_Pst, Bind_Block_Plevel, Bind_Block_Plevel_Pst,
|
||||
Bind_Block_PType, Bind_Block_PType_Pst, Bind_County_PType, Bind_County_PType_Pst,
|
||||
'沿用上周期基价' as Bind_Price_1_PType, 0 as Bind_Price_1_PType_Pst,
|
||||
CASE WHEN A.VOPPAT IS NOT NULL THEN A.VOPPAT
|
||||
WHEN A.BasePrice IS NOT NULL THEN '9999' END AS VOPPAT,
|
||||
CASE WHEN A.VOPPA IS NOT NULL THEN A.VOPPA
|
||||
WHEN A.BasePrice IS NOT NULL THEN 0 END AS VOPPA
|
||||
FROM #Temp_Bind_County_PType A
|
||||
|
||||
|
||||
DROP TABLE #TempBindProjID
|
||||
DROP TABLE #Temp_Bind_Block_Class
|
||||
DROP TABLE #Temp_Bind_Block_Plevel
|
||||
DROP TABLE #Temp_Bind_Block_PType
|
||||
DROP TABLE #Temp_Bind_County_PType
|
||||
|
||||
|
||||
|
||||
----第四步;基价中间表的其他字段,包括主力基价的修正系数等等
|
||||
create table #DWA_PROJECTBASEPRICE_IMDT_STEP_4
|
||||
(
|
||||
ProjectID bigint primary key
|
||||
, ProjectSPLabel nvarchar(64)
|
||||
, PropertyType nvarchar(256)
|
||||
, ProjectType nvarchar(256)
|
||||
, ProjectTypeDtl nvarchar(256)
|
||||
, ProjectLevel nvarchar(64)
|
||||
, Year int
|
||||
, MainArea decimal(18, 2)
|
||||
, AreaCoff decimal(7, 4)
|
||||
, YearCoff decimal(7, 4)
|
||||
, PriceNote nvarchar(1024)
|
||||
);
|
||||
|
||||
|
||||
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
|
||||
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='物业档次'
|
||||
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=g.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_RUNNINGSTATE='1' and a.ITEM_ISBUILDINDEX='1' and D.Status=1;
|
||||
|
||||
----第五步;整合到结果表
|
||||
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,
|
||||
A.BasePrice_1*(1+C.VOPPA) AS BasePriceDft,
|
||||
A.BasePrice_1*(1+C.VOPPA)*ISNULL(D.AreaCoff,1)*ISNULL(D.YearCoff,1) AS MainPriceDft,
|
||||
A.BasePrice_1, A.PriceUnitAdj, A.Visited_Num, A.First_Visit_Time, A.Visited_Num_15, A.Visited_Num_30,
|
||||
A.PriceDealMean_1, A.PriceDealMax_1, A.SumDeal_1, A.PriceDealMean, A.PriceDealMax, A.SumDeal,
|
||||
A.PriceListedMin, A.PriceCase1_ToAI_Pst, A.PriceCase2_ToAI_Pst, A.PriceCase1_ToLst_Pst, A.PriceCase2_ToLst_Pst,
|
||||
A.PriceCase1, A.PriceCase1AdjPst, A.SumCase1, A.PriceCase2, A.PriceCase2AdjPst, A.SumCase2, B.VOPPBT, B.VOPPB,
|
||||
C.BindProjID, C.Bind_Proj_Pst, C.Bind_Block_Class, C.Bind_Block_Class_Pst, C.Bind_Block_Plevel, C.Bind_Block_Plevel_Pst,
|
||||
C.Bind_Block_PType, C.Bind_Block_PType_Pst, C.Bind_County_PType, C.Bind_County_PType_Pst, C.VOPPAT, C.VOPPA
|
||||
FROM #DWA_PROJECTBASEPRICE_IMDT_STEP_1 A
|
||||
LEFT JOIN #DWA_PROJECTBASEPRICE_IMDT_STEP_2 B
|
||||
ON A.ProjectID = B.ProjectID
|
||||
LEFT JOIN #DWA_PROJECTBASEPRICE_IMDT_STEP_3 C
|
||||
ON A.ProjectID = C.ProjectID
|
||||
LEFT JOIN #DWA_PROJECTBASEPRICE_IMDT_STEP_4 D
|
||||
ON A.ProjectID = D.ProjectID;
|
||||
|
||||
|
||||
DROP TABLE #DWA_PROJECTBASEPRICE_IMDT_STEP_1
|
||||
DROP TABLE #DWA_PROJECTBASEPRICE_IMDT_STEP_2
|
||||
DROP TABLE #DWA_PROJECTBASEPRICE_IMDT_STEP_3
|
||||
DROP TABLE #DWA_PROJECTBASEPRICE_IMDT_STEP_4
|
@ -205,3 +205,168 @@ from #InfoChgCurr
|
||||
drop table #InfoChg;
|
||||
drop table #InfoChgCurr;
|
||||
drop table #InfoChgLst;
|
||||
|
||||
|
||||
-- 更新上月价格
|
||||
update a
|
||||
set a.ITEM_MAINAREAPRICE = b.MainPriceRent
|
||||
from obpm_LianCheng_Data.dbo.TLK_基价信息 a
|
||||
join dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# b
|
||||
on a.ITEM_AIRAID = b.ProjectID
|
||||
where b.Status = 1
|
||||
and a.ITEM_VALUEPOINT = '#lastPriceDate#'
|
||||
and a.ITEM_PRICETYPE = '2'
|
||||
and a.ITEM_PROJECTTYPE = '2'
|
||||
and a.ITEM_MAINAREAPRICE <> b.MainPriceRent;
|
||||
|
||||
update a
|
||||
set a.ITEM_MAINAREAPRICE = b.MainPriceRent
|
||||
from obpm_LianCheng_Data.dbo.TLK_基价信息 a
|
||||
join dbo.ODS_OFFICE_BUILDING_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 = '2'
|
||||
and a.ITEM_MAINAREAPRICE <> b.MainPrice;
|
||||
|
||||
-- 插入新的价格
|
||||
insert into obpm_LianCheng_Data.dbo.TLK_基价信息
|
||||
(
|
||||
ID
|
||||
, LASTMODIFIED
|
||||
, FORMNAME
|
||||
, AUTHOR
|
||||
, AUTHOR_DEPT_INDEX
|
||||
, CREATED
|
||||
, FORMID
|
||||
, ISTMP
|
||||
, VERSIONS
|
||||
, APPLICATIONID
|
||||
, LASTMODIFIER
|
||||
, DOMAINID
|
||||
, ITEM_PriceID
|
||||
, ITEM_AIRAID
|
||||
, ITEM_PROJECTTYPE
|
||||
, ITEM_PRICETYPE
|
||||
, ITEM_MAINAREAPRICE
|
||||
, ITEM_VALUEPOINT
|
||||
, ITEM_PRICEEXPLAIN
|
||||
, ITEM_UPDATEPERSON
|
||||
, ITEM_UPDATEDATE
|
||||
, ITEM_PRICECHG
|
||||
)
|
||||
select newid()
|
||||
, getdate()
|
||||
, '物业信息管理/基价信息'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, getdate()
|
||||
, 'ybte0OakLV17UzAyoVU'
|
||||
, 0
|
||||
, 1
|
||||
, 'Ts7TykYmuEzzZgWhXHj'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, 'BclzHtmfLQoAA5ICTb5'
|
||||
, newid()
|
||||
, ProjectID
|
||||
, 2
|
||||
, 2
|
||||
, MainPriceRent
|
||||
, '#priceDate#'
|
||||
, AdjEvd
|
||||
, '李贺'
|
||||
, getdate()
|
||||
, MainPriceRentPst
|
||||
from dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth#
|
||||
where Status = 1 and BuildingStd=1;
|
||||
|
||||
insert into obpm_LianCheng_Data.dbo.TLK_基价信息
|
||||
(
|
||||
ID
|
||||
, LASTMODIFIED
|
||||
, FORMNAME
|
||||
, AUTHOR
|
||||
, AUTHOR_DEPT_INDEX
|
||||
, CREATED
|
||||
, FORMID
|
||||
, ISTMP
|
||||
, VERSIONS
|
||||
, APPLICATIONID
|
||||
, LASTMODIFIER
|
||||
, DOMAINID
|
||||
, ITEM_PriceID
|
||||
, ITEM_AIRAID
|
||||
, ITEM_PROJECTTYPE
|
||||
, ITEM_PRICETYPE
|
||||
, ITEM_MAINAREAPRICE
|
||||
, ITEM_VALUEPOINT
|
||||
, ITEM_PRICEEXPLAIN
|
||||
, ITEM_UPDATEPERSON
|
||||
, ITEM_UPDATEDATE
|
||||
, ITEM_PRICECHG
|
||||
)
|
||||
select newid()
|
||||
, getdate()
|
||||
, '物业信息管理/基价信息'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, getdate()
|
||||
, 'ybte0OakLV17UzAyoVU'
|
||||
, 0
|
||||
, 1
|
||||
, 'Ts7TykYmuEzzZgWhXHj'
|
||||
, 'amQRUkvYQAsAec1JGLp'
|
||||
, 'BclzHtmfLQoAA5ICTb5'
|
||||
, newid()
|
||||
, ProjectID
|
||||
, 2
|
||||
, 1
|
||||
, MainPrice
|
||||
, '#priceDate#'
|
||||
, AdjEvd
|
||||
, '李贺'
|
||||
, getdate()
|
||||
, MainPricePst
|
||||
from dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth#
|
||||
where Status = 1 and BuildingStd=1;
|
||||
|
||||
|
||||
insert into obpm_LianCheng_Data.dbo.T_DOCUMENT
|
||||
(
|
||||
ID
|
||||
, LASTMODIFIED
|
||||
, FORMNAME
|
||||
, AUTHOR
|
||||
, AUTHOR_DEPT_INDEX
|
||||
, CREATED
|
||||
, FORMID
|
||||
, ISTMP
|
||||
, VERSIONS
|
||||
, APPLICATIONID
|
||||
, LASTMODIFIER
|
||||
, DOMAINID
|
||||
, AUDITORLIST
|
||||
, COAUDITORLIST
|
||||
, MAPPINGID
|
||||
)
|
||||
select a.ID
|
||||
, a.LASTMODIFIED
|
||||
, a.FORMNAME
|
||||
, a.AUTHOR
|
||||
, a.AUTHOR_DEPT_INDEX
|
||||
, a.CREATED
|
||||
, a.FORMID
|
||||
, a.ISTMP
|
||||
, a.VERSIONS
|
||||
, a.APPLICATIONID
|
||||
, a.LASTMODIFIER
|
||||
, a.DOMAINID
|
||||
, a.AUDITORLIST
|
||||
, a.COAUDITORLIST
|
||||
, a.id
|
||||
from obpm_LianCheng_Data.dbo.TLK_基价信息 a
|
||||
left join obpm_LianCheng_Data.dbo.T_DOCUMENT b
|
||||
on a.ID = b.ID
|
||||
where a.ITEM_VALUEPOINT = '#priceDate#'
|
||||
and a.ITEM_PROJECTTYPE = '2';
|
@ -19,32 +19,32 @@ import java.util.List;
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RuoYiApplication.class)
|
||||
public class ResidenceRentBasePriceTests {
|
||||
|
||||
@Autowired
|
||||
private IOriginalResidenceRentOpeningCaseService originalResidenceRentOpeningCaseService;
|
||||
@Autowired
|
||||
private IArtificialResidenceSalePriceService artificialResidenceSalePriceService;
|
||||
@Autowired
|
||||
private IOriginalResidenceSaleClosingCaseService originalResidenceClosingCaseService;
|
||||
|
||||
@Test
|
||||
public void testClearOpeningCase() {
|
||||
originalResidenceRentOpeningCaseService.pullData();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearClosingCase() {
|
||||
originalResidenceClosingCaseService.pullData();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchImport() {
|
||||
List<ComputeResidenceSaleBasePrice> list = new LinkedList<>();
|
||||
ComputeResidenceSaleBasePrice computeResidenceSaleBasePrice = new ComputeResidenceSaleBasePrice();
|
||||
computeResidenceSaleBasePrice.setCommunityId("10101");
|
||||
computeResidenceSaleBasePrice.setBasePriceDraft(new BigDecimal(12222));
|
||||
list.add(computeResidenceSaleBasePrice);
|
||||
artificialResidenceSalePriceService.batchImport(202007, list);
|
||||
}
|
||||
//
|
||||
// @Autowired
|
||||
// private IOriginalResidenceRentOpeningCaseService originalResidenceRentOpeningCaseService;
|
||||
// @Autowired
|
||||
// private IArtificialResidenceSalePriceService artificialResidenceSalePriceService;
|
||||
// @Autowired
|
||||
// private IOriginalResidenceSaleClosingCaseService originalResidenceClosingCaseService;
|
||||
//
|
||||
// @Test
|
||||
// public void testClearOpeningCase() {
|
||||
// originalResidenceRentOpeningCaseService.pullData();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testClearClosingCase() {
|
||||
// originalResidenceClosingCaseService.clear();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testBatchImport() {
|
||||
// List<ComputeResidenceSaleBasePrice> list = new LinkedList<>();
|
||||
// ComputeResidenceSaleBasePrice computeResidenceSaleBasePrice = new ComputeResidenceSaleBasePrice();
|
||||
// computeResidenceSaleBasePrice.setCommunityId("10101");
|
||||
// computeResidenceSaleBasePrice.setBasePriceDraft(new BigDecimal(12222));
|
||||
// list.add(computeResidenceSaleBasePrice);
|
||||
// artificialResidenceSalePriceService.batchImport(202007, list);
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.uvaluation.compute;
|
||||
|
||||
import com.ruoyi.RuoYiApplication;
|
||||
import com.ruoyi.project.data.cases.service.IOriginalResidenceRentClosingCaseService;
|
||||
import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleClosingCaseService;
|
||||
import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleOpeningCaseService;
|
||||
import com.ruoyi.project.data.price.domain.ComputeResidenceSaleBasePrice;
|
||||
@ -9,6 +10,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -18,6 +20,7 @@ import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RuoYiApplication.class)
|
||||
@ActiveProfiles("uat")
|
||||
public class ResidenceSaleBasePriceTests {
|
||||
|
||||
@Autowired
|
||||
@ -27,16 +30,23 @@ public class ResidenceSaleBasePriceTests {
|
||||
@Autowired
|
||||
private IOriginalResidenceSaleClosingCaseService originalResidenceClosingCaseService;
|
||||
|
||||
@Test
|
||||
public void testClearOpeningCase() {
|
||||
originalResidenceOpeningCaseService.pullData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 成交案例清洗
|
||||
*/
|
||||
@Test
|
||||
public void testClearClosingCase() {
|
||||
originalResidenceClosingCaseService.pullData();
|
||||
originalResidenceClosingCaseService.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂牌案例清洗
|
||||
*/
|
||||
@Test
|
||||
public void testClearOpeningCase() {
|
||||
originalResidenceOpeningCaseService.clear();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBatchImport() {
|
||||
List<ComputeResidenceSaleBasePrice> list = new LinkedList<>();
|
||||
@ -47,4 +57,5 @@ public class ResidenceSaleBasePriceTests {
|
||||
artificialResidenceSalePriceService.batchImport(202007, list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user