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

View File

@ -26,13 +26,13 @@ public interface OriginalOfficeCaseMapper {
* @param yearMonth
*/
void createArtificialTable(@Param("yearMonth") Integer yearMonth);
/**
* 创建案例汇总表
*
* @param yearMonth
*/
void createAssembleTable(@Param("yearMonth") Integer yearMonth);
//
// /**
// * 创建案例汇总表
// *
// * @param 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.List;
/**
* 爬取库中的办公案例
*
* @author lihe
*/
@DS("spider")
public interface DownloadOriginalOfficeCaseMapper {
/**
* 下载案例
* 下载办公案例
*
* @param startDate
* @param endDate

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package com.ruoyi.project.data.cases.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.LoadUtil;
import com.ruoyi.project.data.cases.domain.OriginalOfficeCase;
import com.ruoyi.project.data.cases.mapper.OriginalOfficeCaseMapper;
@ -20,6 +21,11 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 办公基价计算Service
*
* @author lihe
*/
@Service
@DS("compute")
public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService {
@ -39,26 +45,18 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService
* 计算
*/
@Override
@Scheduled(cron = "0 0 17 28 * ?")
public void compute() {
Integer yearMonth = DateUtils.getNextYearMonth();
Integer lastYearMonth = DateUtils.getYearMonth();
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 15);
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);
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);
running(yearMonth, lastYearMonth);
@ -72,23 +70,26 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService
private void before(Integer yearMonth, Date startDate, Date endDate) {
// 创建表
originalOfficeCaseMapper.createTable(yearMonth);
originalOfficeCaseMapper.createArtificialTable(yearMonth);
originalOfficeCaseMapper.initAssembleTable(yearMonth);
originalOfficeCaseMapper.initPriceTable(yearMonth);
originalOfficeCaseMapper.createArtificialTable(yearMonth);
// 下载列表
List<OriginalOfficeCase> downloadList = downloadOriginalOfficeCaseMapper.download(startDate, endDate);
SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(downloadList.toArray());
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," +
":floorAreaRatio," +
":caseTotalPrice," +
":caseUnitPrice,:name,:name_m,:caseFloor,:area,:managementFee,:seatCount,:address,:metro," +
":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);
}

View File

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

View File

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

View File

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

View File

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