feature (办公作价):办公作价自动化

This commit is contained in:
purple
2020-07-27 14:13:25 +08:00
parent 6bf3f519c7
commit 152f082034
10 changed files with 127 additions and 92 deletions

View File

@ -1,5 +1,6 @@
package com.ruoyi.framework.task; package com.ruoyi.framework.task;
import com.ruoyi.project.data.cases.service.IOriginalOfficeCaseService;
import com.ruoyi.project.data.cases.service.IOriginalResidenceRentOpeningCaseService; import com.ruoyi.project.data.cases.service.IOriginalResidenceRentOpeningCaseService;
import com.ruoyi.project.data.cases.service.impl.DownloadOriginalNewHouseCaseServiceImpl; import com.ruoyi.project.data.cases.service.impl.DownloadOriginalNewHouseCaseServiceImpl;
import com.ruoyi.project.data.cases.service.impl.DownloadOriginalResidenceSaleClosingCaseServiceImpl; import com.ruoyi.project.data.cases.service.impl.DownloadOriginalResidenceSaleClosingCaseServiceImpl;
@ -22,6 +23,8 @@ public class RyTask {
private DownloadOriginalResidenceSaleClosingCaseServiceImpl downloadOriginalResidenceSaleClosingCaseService; private DownloadOriginalResidenceSaleClosingCaseServiceImpl downloadOriginalResidenceSaleClosingCaseService;
@Autowired @Autowired
private DownloadOriginalNewHouseCaseServiceImpl downloadOriginalNewHouseCaseService; private DownloadOriginalNewHouseCaseServiceImpl downloadOriginalNewHouseCaseService;
@Autowired
private IOriginalOfficeCaseService originalOfficeCaseService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
@ -63,4 +66,11 @@ public class RyTask {
downloadOriginalNewHouseCaseService.downloadSecond(); downloadOriginalNewHouseCaseService.downloadSecond();
} }
/**
* 下载办公案例和作价
*/
public void downloadOfficeCase() {
originalOfficeCaseService.compute();
}
} }

View File

@ -26,13 +26,13 @@ public interface OriginalOfficeCaseMapper {
* @param yearMonth * @param yearMonth
*/ */
void createArtificialTable(@Param("yearMonth") Integer yearMonth); void createArtificialTable(@Param("yearMonth") Integer yearMonth);
//
/** // /**
* 创建案例汇总表 // * 创建案例汇总表
* // *
* @param yearMonth // * @param yearMonth
*/ // */
void createAssembleTable(@Param("yearMonth") Integer yearMonth); // void createAssembleTable(@Param("yearMonth") Integer yearMonth);
/** /**
* 初始化案例汇总表 * 初始化案例汇总表

View File

@ -6,10 +6,15 @@ import com.ruoyi.project.data.cases.domain.OriginalOfficeCase;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* 爬取库中的办公案例
*
* @author lihe
*/
@DS("spider") @DS("spider")
public interface DownloadOriginalOfficeCaseMapper { public interface DownloadOriginalOfficeCaseMapper {
/** /**
* 下载案例 * 下载办公案例
* *
* @param startDate * @param startDate
* @param endDate * @param endDate

View File

@ -1,5 +1,10 @@
package com.ruoyi.project.data.cases.service; package com.ruoyi.project.data.cases.service;
/**
* 办公基价计算Service
*
* @author lihe
*/
public interface IOriginalOfficeCaseService { public interface IOriginalOfficeCaseService {
/** /**
* 计算 * 计算

View File

@ -43,7 +43,7 @@ public class DownloadOriginalResidenceSaleOpeningCaseServiceImpl {
*/ */
public void download() { public void download() {
Integer tableRoute = DateUtils.getNextYearMonth(); Integer tableRoute = DateUtils.getNextYearMonth();
Integer remoteTableRoute = DateUtils.getLastYearMonth(); Integer remoteTableRoute = DateUtils.getYearMonth();
download(tableRoute, remoteTableRoute); download(tableRoute, remoteTableRoute);
} }
@ -82,6 +82,9 @@ public class DownloadOriginalResidenceSaleOpeningCaseServiceImpl {
originalResidenceSaleOpeningCaseMapper.createRawTable(tableRoute); originalResidenceSaleOpeningCaseMapper.createRawTable(tableRoute);
originalResidenceSaleOpeningCaseMapper.createCleanTable(tableRoute); originalResidenceSaleOpeningCaseMapper.createCleanTable(tableRoute);
originalResidenceSaleOpeningCaseMapper.createAssembleTable(tableRoute); originalResidenceSaleOpeningCaseMapper.createAssembleTable(tableRoute);
originalResidenceSaleOpeningCaseMapper.createComputePriceTable(tableRoute);
originalResidenceSaleOpeningCaseMapper.createArtificialPriceTable(tableRoute);
originalResidenceSaleOpeningCaseMapper.createUltimatePriceTable(tableRoute);
syncOriginalResidenceSaleOpeningCaseMapper.createRawTable(remoteTableRoute); syncOriginalResidenceSaleOpeningCaseMapper.createRawTable(remoteTableRoute);
} }

View File

@ -1,6 +1,7 @@
package com.ruoyi.project.data.cases.service.impl; package com.ruoyi.project.data.cases.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.LoadUtil; import com.ruoyi.common.utils.LoadUtil;
import com.ruoyi.project.data.cases.domain.OriginalOfficeCase; import com.ruoyi.project.data.cases.domain.OriginalOfficeCase;
import com.ruoyi.project.data.cases.mapper.OriginalOfficeCaseMapper; import com.ruoyi.project.data.cases.mapper.OriginalOfficeCaseMapper;
@ -20,6 +21,11 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* 办公基价计算Service
*
* @author lihe
*/
@Service @Service
@DS("compute") @DS("compute")
public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService { public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService {
@ -39,26 +45,18 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService
* 计算 * 计算
*/ */
@Override @Override
@Scheduled(cron = "0 0 17 28 * ?")
public void compute() { public void compute() {
Integer yearMonth = DateUtils.getNextYearMonth();
Integer lastYearMonth = DateUtils.getYearMonth();
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 15); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 15);
Date startDate = calendar.getTime(); Date startDate = calendar.getTime();
Integer lastYearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH) + 1));
calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.MONTH, 1);
Date endDate = calendar.getTime(); Date endDate = calendar.getTime();
Integer yearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH) + 1));
// yearMonth = 202007;
//// lastYearMonth = 202006;
//// calendar.set(2020, 5, 16);
//// startDate = calendar.getTime();
//// calendar.set(2020, 6, 16);
//// endDate = calendar.getTime();
before(yearMonth, startDate, endDate); before(yearMonth, startDate, endDate);
running(yearMonth, lastYearMonth); running(yearMonth, lastYearMonth);
@ -72,23 +70,26 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService
private void before(Integer yearMonth, Date startDate, Date endDate) { private void before(Integer yearMonth, Date startDate, Date endDate) {
// 创建表 // 创建表
originalOfficeCaseMapper.createTable(yearMonth); originalOfficeCaseMapper.createTable(yearMonth);
originalOfficeCaseMapper.createArtificialTable(yearMonth);
originalOfficeCaseMapper.initAssembleTable(yearMonth); originalOfficeCaseMapper.initAssembleTable(yearMonth);
originalOfficeCaseMapper.initPriceTable(yearMonth); originalOfficeCaseMapper.initPriceTable(yearMonth);
originalOfficeCaseMapper.createArtificialTable(yearMonth);
// 下载列表 // 下载列表
List<OriginalOfficeCase> downloadList = downloadOriginalOfficeCaseMapper.download(startDate, endDate); List<OriginalOfficeCase> downloadList = downloadOriginalOfficeCaseMapper.download(startDate, endDate);
SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(downloadList.toArray()); SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(downloadList.toArray());
namedParameterJdbcTemplate.batchUpdate("insert into dbo.ODS_OFFICECASELISTED_" + yearMonth.toString() + "_RAW" + namedParameterJdbcTemplate.batchUpdate("insert into dbo.ODS_OFFICECASELISTED_" + yearMonth.toString() + "_RAW" +
"(case_id,url, title,容积率,总价售,均价售, 楼盘名称, 楼盘名称_M, 楼层, 面积, 物业费, 工位数, 地址, 地铁, 发布时间, 房源编号, 百度lng, 百度lat, " + "(case_id,url, title,容积率,总价售,均价售, 楼盘名称, 楼盘名称_M, 楼层, 面积, 物业费, 工位数, 地址, 地铁, 发布时间, 房源编号, 百度lng, " +
"百度lat, " +
"区域, 分类, " + "区域, 分类, " +
"来源, 等级, 楼盘网址, 装修,类型, 板块, 挂牌中介, 月租金租, 标准租金租, 得房率, 总价, 单价,更新时间) values(replace(newid(),'-',''),:url," + "来源, 等级, 楼盘网址, 装修,类型, 板块, 挂牌中介, 月租金租, 标准租金租, 得房率, 总价, 单价,更新时间) values(replace(newid(),'-','')" +
",:url," +
":title," + ":title," +
":floorAreaRatio," + ":floorAreaRatio," +
":caseTotalPrice," + ":caseTotalPrice," +
":caseUnitPrice,:name,:name_m,:caseFloor,:area,:managementFee,:seatCount,:address,:metro," + ":caseUnitPrice,:name,:name_m,:caseFloor,:area,:managementFee,:seatCount,:address,:metro," +
":publishDate,:sourceNo,:lng,:lat,:county,:catalog,:source,:level,:homePageUrl,:decoration," + ":publishDate,:sourceNo,:lng,:lat,:county,:catalog,:source,:level,:homePageUrl,:decoration," +
":type,:block,:agency,:rentOfMonthly,:rentOfStandard,:score,:totalPrice,:unitPrice,:updateDate) ", ":type,:block,:agency,:rentOfMonthly,:rentOfStandard,:score,:totalPrice,:unitPrice," +
":updateDate) ",
batchParams); batchParams);
} }

View File

@ -36,6 +36,7 @@
<result property="unitPrice" column="单价" javaType="java.math.BigDecimal"/> <result property="unitPrice" column="单价" javaType="java.math.BigDecimal"/>
<result property="updateDate" column="更新时间" javaType="java.sql.Date"/> <result property="updateDate" column="更新时间" javaType="java.sql.Date"/>
</resultMap> </resultMap>
<!-- 获取爬虫库中的办公案例 -->
<select id="download" resultMap="DownloadMapping"> <select id="download" resultMap="DownloadMapping">
select url, title, 容积率, 总价售, 均价售, 楼盘名称, 楼层, case 面积 when 'nan' then NULL ELSE 面积 END 面积, select url, title, 容积率, 总价售, 均价售, 楼盘名称, 楼层, case 面积 when 'nan' then NULL ELSE 面积 END 面积,
物业费, 工位数, 地址, 地铁, 物业费, 工位数, 地址, 地铁,
@ -46,6 +47,6 @@
case when 分类 = '售' then (case 均价售 when 'nan' then NULL ELSE 均价售 END) case when 分类 = '售' then (case 均价售 when 'nan' then NULL ELSE 均价售 END)
when 分类 = '租' then (case 标准租金租 when 'nan' then NULL ELSE 标准租金租 END) end as 单价 when 分类 = '租' then (case 标准租金租 when 'nan' then NULL ELSE 标准租金租 END) end as 单价
from dbo.办公 from dbo.办公
where 更新时间 >= #{startDate} and 更新时间 <![CDATA[ < ]]> #{endDate} where 更新时间 >= #{startDate,jdbcType=DATE} and 更新时间 <![CDATA[ < ]]> #{endDate,jdbcType=DATE}
</select> </select>
</mapper> </mapper>

View File

@ -79,7 +79,7 @@
#{casePrice}, #{casePrice},
#{caseCommunityName}, #{caseCommunityName},
#{caseVisitedNum}, #{caseVisitedNum},
#{caseFirstVisitTime}, #{caseFirstVisitTime,jdbcType=DATE},
#{caseVisitedNum15}, #{caseVisitedNum15},
#{caseVisitedNum30}, #{caseVisitedNum30},
#{caseUrl}, #{caseUrl},

View File

@ -1,3 +1,5 @@
truncate table ODS_HOUSINGCASELISTED_LJ_#yearMonth#;
update a update a
set a.uv_community_id=b.ITEM_ProjectID, set a.uv_community_id=b.ITEM_ProjectID,
a.uv_building_id=b.ITEM_BuildingID, a.uv_building_id=b.ITEM_BuildingID,

View File

@ -14,6 +14,14 @@ import java.util.stream.Stream;
public class GenerateTableTests { public class GenerateTableTests {
@Test
public void testLastYearMonth() {
Integer lastYearMonth = DateUtils.getLastYearMonth();
Assert.assertTrue(202007 == lastYearMonth);
}
@Test @Test
public void getELTableColumn() { public void getELTableColumn() {
Class<?> targetClass = ComputeResidenceSaleBasePrice.class; Class<?> targetClass = ComputeResidenceSaleBasePrice.class;