From 5dda87a9842696927935c5cef4025ab8ddd5ad4f Mon Sep 17 00:00:00 2001 From: purple Date: Thu, 30 Jul 2020 15:55:12 +0800 Subject: [PATCH] =?UTF-8?q?feature(=E4=BD=8F=E5=AE=85=E7=A7=9F=E8=B5=81?= =?UTF-8?q?=E4=BD=9C=E4=BB=B7)=EF=BC=9A=E6=96=B0=E5=A2=9E=E6=88=90?= =?UTF-8?q?=E4=BA=A4=E6=A1=88=E4=BE=8B=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 添加太平洋提供住宅租赁案例数据 2. 查询页面和导出添加主力面积字段 --- .../data/price/ComputeResidenceRentPrice.vue | 1 + .../ComputeDataNotFoundException.java | 27 ++ .../java/com/ruoyi/framework/task/RyTask.java | 18 ++ .../OriginalResidenceRentClosingCase.java | 1 + .../domain/OtherResidenceRentClosingCase.java | 184 +++++++++++++ ...riginalResidenceRentClosingCaseMapper.java | 11 + ...riginalResidenceSaleClosingCaseMapper.java | 4 + ...riginalResidenceRentClosingCaseMapper.java | 7 + ...adOtherResidenceRentClosingCaseMapper.java | 25 ++ ...iginalResidenceRentClosingCaseService.java | 8 + ...alResidenceSaleClosingCaseServiceImpl.java | 2 +- .../impl/OriginalOfficeCaseServiceImpl.java | 4 + ...alResidenceRentClosingCaseServiceImpl.java | 49 +++- ...alResidenceRentOpeningCaseServiceImpl.java | 13 +- .../ComputeResidenceRentPriceMapper.java | 2 + ruoyi/src/main/resources/application-dev.yml | 7 +- ruoyi/src/main/resources/application-prod.yml | 7 +- ruoyi/src/main/resources/application-uat.yml | 7 +- .../data/ComputeResidenceRentPriceMapper.xml | 11 +- .../data/DownloadOriginalOfficeCaseMapper.xml | 8 +- ...OriginalResidenceRentClosingCaseMapper.xml | 22 +- ...OriginalResidenceRentOpeningCaseMapper.xml | 2 +- ...riginalResidenceRentPlatformCaseMapper.xml | 2 +- ...oadOtherResidenceRentClosingCaseMapper.xml | 37 +++ ...OriginalResidenceRentClosingCaseMapper.xml | 47 +++- .../clear_other_rent_closing_case.sql | 258 ++++++++++++++++++ .../java/com/ruoyi/GenerateTableTests.java | 6 +- .../compute/ResidenceRentBasePriceTests.java | 2 +- 28 files changed, 710 insertions(+), 62 deletions(-) create mode 100644 ruoyi/src/main/java/com/ruoyi/common/exception/ComputeDataNotFoundException.java create mode 100644 ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OtherResidenceRentClosingCase.java create mode 100644 ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOtherResidenceRentClosingCaseMapper.java create mode 100644 ruoyi/src/main/resources/mybatis/data/DownloadOtherResidenceRentClosingCaseMapper.xml create mode 100644 ruoyi/src/main/resources/sql-template/clear_other_rent_closing_case.sql diff --git a/ruoyi-ui/src/views/data/price/ComputeResidenceRentPrice.vue b/ruoyi-ui/src/views/data/price/ComputeResidenceRentPrice.vue index 2300dd4c7..ddb37d071 100644 --- a/ruoyi-ui/src/views/data/price/ComputeResidenceRentPrice.vue +++ b/ruoyi-ui/src/views/data/price/ComputeResidenceRentPrice.vue @@ -79,6 +79,7 @@ + diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/ComputeDataNotFoundException.java b/ruoyi/src/main/java/com/ruoyi/common/exception/ComputeDataNotFoundException.java new file mode 100644 index 000000000..eea89a88e --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/common/exception/ComputeDataNotFoundException.java @@ -0,0 +1,27 @@ +package com.ruoyi.common.exception; + +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.StringUtils; + +/** + * 作价数据未找到 + * + * @author ruoyi + */ +public class ComputeDataNotFoundException extends RuntimeException { + private static final long serialVersionUID = 1L; + + /** + * 所属模块 + */ + private String module; + + public ComputeDataNotFoundException(String module) { + this.module = module; + } + + @Override + public String getMessage() { + return module + "未找到相关案例数据。"; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java b/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java index 6cc8758ee..296636451 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.task; import com.ruoyi.project.data.cases.service.IOriginalOfficeCaseService; +import com.ruoyi.project.data.cases.service.IOriginalResidenceRentClosingCaseService; 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; @@ -25,6 +26,10 @@ public class RyTask { private DownloadOriginalNewHouseCaseServiceImpl downloadOriginalNewHouseCaseService; @Autowired private IOriginalOfficeCaseService originalOfficeCaseService; + @Autowired + private IOriginalResidenceRentOpeningCaseService originalResidenceRentOpeningCaseService; + @Autowired + private IOriginalResidenceRentClosingCaseService originalResidenceRentClosingCaseService; public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); @@ -73,4 +78,17 @@ public class RyTask { originalOfficeCaseService.compute(); } + /** + * 住宅租赁挂牌案例下载 + */ + public void downloadRentOpeningCase() { + originalResidenceRentOpeningCaseService.pullData(); + } + + /** + * 住宅租赁成交案例下载 + */ + public void downloadRentClosingCase() { + originalResidenceRentClosingCaseService.pullData(); + } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalResidenceRentClosingCase.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalResidenceRentClosingCase.java index 4f1ba2228..7dba428ec 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalResidenceRentClosingCase.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalResidenceRentClosingCase.java @@ -7,6 +7,7 @@ import java.util.Date; /** * 租赁成交案例 + * @author lihe */ public class OriginalResidenceRentClosingCase { private String caseId; diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OtherResidenceRentClosingCase.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OtherResidenceRentClosingCase.java new file mode 100644 index 000000000..5e1706548 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OtherResidenceRentClosingCase.java @@ -0,0 +1,184 @@ +package com.ruoyi.project.data.cases.domain; + +import org.springframework.util.DigestUtils; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.UUID; + +/** + * 新的租赁成交案例 + * + * @author lihe + */ +public class OtherResidenceRentClosingCase { + /** + * id + */ + private String caseId; + /** + * 案例区域 + */ + private String caseDistrict; + /** + * 案例小区名称 + */ + private String caseCommunityName; + /** + * 案例地址 + */ + private String caseAddress; + /** + * 面积 + */ + private BigDecimal caseArea; + /** + * 成交日期 + */ + private Date closingDate; + /** + * 总价 + */ + private BigDecimal caseTotalPrice; + /** + * 朝向 + */ + private String caseDecoration; + /** + * 总楼层 + */ + private Integer caseTotalFloor; + /** + * 所在层 + */ + private String caseCurrentFloor; + /** + * 朝向 + */ + private String caseToward; + /** + * 楼层 + */ + private String caseFloor; + /** + * 小区 + */ + private String uvCommunityId; + /** + * 楼栋 + */ + private String uvBuildingId; + + + public String getCaseId() { + return UUID.randomUUID().toString().replace("-",""); + } + + public void setCaseId(String caseId) { + this.caseId = caseId; + } + + public String getCaseDistrict() { + return caseDistrict; + } + + public void setCaseDistrict(String caseDistrict) { + this.caseDistrict = caseDistrict; + } + + public String getCaseCommunityName() { + return caseCommunityName; + } + + public void setCaseCommunityName(String caseCommunityName) { + this.caseCommunityName = caseCommunityName; + } + + public String getCaseAddress() { + return caseAddress; + } + + public void setCaseAddress(String caseAddress) { + this.caseAddress = caseAddress; + } + + public BigDecimal getCaseArea() { + return caseArea; + } + + public void setCaseArea(BigDecimal caseArea) { + this.caseArea = caseArea; + } + + public Date getClosingDate() { + return closingDate; + } + + public void setClosingDate(Date closingDate) { + this.closingDate = closingDate; + } + + public BigDecimal getCaseTotalPrice() { + return caseTotalPrice; + } + + public void setCaseTotalPrice(BigDecimal caseTotalPrice) { + this.caseTotalPrice = caseTotalPrice; + } + + public String getCaseDecoration() { + return caseDecoration; + } + + public void setCaseDecoration(String caseDecoration) { + this.caseDecoration = caseDecoration; + } + + public Integer getCaseTotalFloor() { + return caseTotalFloor; + } + + public void setCaseTotalFloor(Integer caseTotalFloor) { + this.caseTotalFloor = caseTotalFloor; + } + + public String getCaseCurrentFloor() { + return caseCurrentFloor; + } + + public void setCaseCurrentFloor(String caseCurrentFloor) { + this.caseCurrentFloor = caseCurrentFloor; + } + + public String getCaseToward() { + return caseToward; + } + + public void setCaseToward(String caseToward) { + this.caseToward = caseToward; + } + + public String getCaseFloor() { + return caseFloor; + } + + public void setCaseFloor(String caseFloor) { + this.caseFloor = caseFloor; + } + + public String getUvCommunityId() { + return uvCommunityId; + } + + public void setUvCommunityId(String uvCommunityId) { + this.uvCommunityId = uvCommunityId; + } + + public String getUvBuildingId() { + return uvBuildingId; + } + + public void setUvBuildingId(String uvBuildingId) { + this.uvBuildingId = uvBuildingId; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceRentClosingCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceRentClosingCaseMapper.java index c89eaaa37..9e94eac72 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceRentClosingCaseMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceRentClosingCaseMapper.java @@ -18,6 +18,14 @@ public interface OriginalResidenceRentClosingCaseMapper { */ int createRawTable(@Param("yearMonth") Integer yearMonth); + /** + * 创建其他住宅租赁成交案例 + * + * @param tableRoute + * @return + */ + int createOtherRawTable(@Param("yearMonth") Integer tableRoute); + /** * 创建清洗完成之后的表ODS_HOUSINGCASELISTED_LJ_YYYYMM * @@ -33,8 +41,10 @@ public interface OriginalResidenceRentClosingCaseMapper { * @return */ int createAssembleTable(@Param("yearMonth") Integer yearMonth); + /** * 作价表 + * * @param yearMonth * @return */ @@ -42,6 +52,7 @@ public interface OriginalResidenceRentClosingCaseMapper { /** * 人工修正价格表 + * * @param yearMonth * @return */ diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceSaleClosingCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceSaleClosingCaseMapper.java index 511abc0d5..5332ed3d5 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceSaleClosingCaseMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalResidenceSaleClosingCaseMapper.java @@ -25,6 +25,8 @@ public interface OriginalResidenceSaleClosingCaseMapper { */ int createRawTable(@Param("yearMonth") Integer yearMonth); + + /** * 插入住宅销售成交案例 * @@ -54,4 +56,6 @@ public interface OriginalResidenceSaleClosingCaseMapper { * @return */ List pageList(OriginalResidenceSaleOpeningCaseQueryModel queryModel); + + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalResidenceRentClosingCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalResidenceRentClosingCaseMapper.java index f8be48e5a..a13181fff 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalResidenceRentClosingCaseMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalResidenceRentClosingCaseMapper.java @@ -6,13 +6,20 @@ import org.apache.ibatis.annotations.Param; import java.util.List; +/** + * 住宅租赁成交案例下载 + * + * @author lihe + */ @DS("calc") public interface DownloadOriginalResidenceRentClosingCaseMapper { /** * 租赁成交案例数据下载 * + * @param yearMonth * @return */ List download(@Param("yearMonth") Integer yearMonth); + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOtherResidenceRentClosingCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOtherResidenceRentClosingCaseMapper.java new file mode 100644 index 000000000..6934f8c07 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOtherResidenceRentClosingCaseMapper.java @@ -0,0 +1,25 @@ +package com.ruoyi.project.data.cases.mapper.sync; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.project.data.cases.domain.OriginalResidenceRentClosingCase; +import com.ruoyi.project.data.cases.domain.OtherResidenceRentClosingCase; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 其他住宅租赁案例下载 + * + * @author lihe + */ +@DS("spider2") +public interface DownloadOtherResidenceRentClosingCaseMapper { + + /** + * 租赁成交案例数据下载 + * + * @param yearMonth + * @return + */ + List download(@Param("yearMonth") Integer yearMonth); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/IOriginalResidenceRentClosingCaseService.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/IOriginalResidenceRentClosingCaseService.java index a52ed4d0b..e8444b7dc 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/IOriginalResidenceRentClosingCaseService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/IOriginalResidenceRentClosingCaseService.java @@ -1,5 +1,13 @@ package com.ruoyi.project.data.cases.service; +/** + * 住宅租赁成交案例Service + * + * @author lihe + */ public interface IOriginalResidenceRentClosingCaseService { + /** + * 数据下载 + */ void pullData(); } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/DownloadOriginalResidenceSaleClosingCaseServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/DownloadOriginalResidenceSaleClosingCaseServiceImpl.java index 62c438ac5..d7e58f458 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/DownloadOriginalResidenceSaleClosingCaseServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/DownloadOriginalResidenceSaleClosingCaseServiceImpl.java @@ -65,7 +65,7 @@ public class DownloadOriginalResidenceSaleClosingCaseServiceImpl { running(tableRoute, originalResidenceSaleClosingCases); after(tableRoute); -// copy2UVData(tableRoute, remoteTableRoute); + copy2UVData(tableRoute, remoteTableRoute); } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalOfficeCaseServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalOfficeCaseServiceImpl.java index c820630a2..833144074 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalOfficeCaseServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalOfficeCaseServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.project.data.cases.service.impl; import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.common.exception.ComputeDataNotFoundException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.LoadUtil; import com.ruoyi.project.data.cases.domain.OriginalOfficeCase; @@ -76,6 +77,9 @@ public class OriginalOfficeCaseServiceImpl implements IOriginalOfficeCaseService // 下载列表 List downloadList = downloadOriginalOfficeCaseMapper.download(startDate, endDate); + if (0 == downloadList.size()) { + throw new ComputeDataNotFoundException("办公作价"); + } SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(downloadList.toArray()); namedParameterJdbcTemplate.batchUpdate("insert into dbo.ODS_OFFICECASELISTED_" + yearMonth.toString() + "_RAW" + "(case_id,url, title,容积率,总价售,均价售, 楼盘名称, 楼盘名称_M, 楼层, 面积, 物业费, 工位数, 地址, 地铁, 发布时间, 房源编号, 百度lng, " + diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentClosingCaseServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentClosingCaseServiceImpl.java index e651892b1..30ca3faea 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentClosingCaseServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentClosingCaseServiceImpl.java @@ -1,10 +1,13 @@ 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.OriginalResidenceRentClosingCase; +import com.ruoyi.project.data.cases.domain.OtherResidenceRentClosingCase; import com.ruoyi.project.data.cases.mapper.OriginalResidenceRentClosingCaseMapper; import com.ruoyi.project.data.cases.mapper.sync.DownloadOriginalResidenceRentClosingCaseMapper; +import com.ruoyi.project.data.cases.mapper.sync.DownloadOtherResidenceRentClosingCaseMapper; import com.ruoyi.project.data.cases.service.IOriginalResidenceRentClosingCaseService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,6 +34,8 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes @Autowired private DownloadOriginalResidenceRentClosingCaseMapper downloadOriginalResidenceRentClosingCaseMapper; @Autowired + private DownloadOtherResidenceRentClosingCaseMapper downloadOtherResidenceRentClosingCaseMapper; + @Autowired private NamedParameterJdbcTemplate namedParameterJdbcTemplate; @Autowired private JdbcTemplate jdbcTemplate; @@ -38,26 +43,19 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes /** * */ - @Scheduled(cron = "0 0 15 29 * ?") @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))); - Integer lastYearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), - calendar.get(Calendar.MONTH) + 1)); - calendar.add(Calendar.MONTH, 1); - Integer computeTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), - calendar.get(Calendar.MONTH) + 1)); - -// targetTableRoute = 202005; -// computeTableRoute = 202007; + Integer targetTableRoute = DateUtils.getLastYearMonth(); + Integer lastYearMonth = DateUtils.getYearMonth(); + Integer computeTableRoute = DateUtils.getNextYearMonth(); prepare(computeTableRoute); List list = downloadOriginalResidenceRentClosingCaseMapper.download(targetTableRoute); - running(computeTableRoute, list); + + List otherResidenceRentClosingCaseList = + downloadOtherResidenceRentClosingCaseMapper.download(targetTableRoute); + running(computeTableRoute, list, otherResidenceRentClosingCaseList); after(computeTableRoute, lastYearMonth); } @@ -68,6 +66,8 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes */ public void prepare(Integer computeTableRoute) { originalResidenceRentClosingCaseMapper.createRawTable(computeTableRoute); + // 新增住宅租赁成交案例 + originalResidenceRentClosingCaseMapper.createOtherRawTable(computeTableRoute); originalResidenceRentClosingCaseMapper.createCleanTable(computeTableRoute); originalResidenceRentClosingCaseMapper.createAssembleTable(computeTableRoute); originalResidenceRentClosingCaseMapper.createComputeTable(computeTableRoute); @@ -81,7 +81,8 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes * @param computeTableRoute * @param list */ - public void running(Integer computeTableRoute, List list) { + public void running(Integer computeTableRoute, List list, + List otherResidenceRentClosingCaseList) { SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(list.toArray()); int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("insert into dbo" + ".ODS_HOUSINGCASEDEAL_RENT_" + computeTableRoute + "_RAW(case_id, case_contract_no, " + @@ -92,6 +93,18 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes ":caseRentPrice,:caseTotalFloor,:caseArea,:caseToward,:caseApartmentLayout,:caseDecoration," + ":cleanCommunityId,:cleanBuildingId);", batchParams); + + batchParams = SqlParameterSourceUtils.createBatch(otherResidenceRentClosingCaseList.toArray()); + updateCounts = namedParameterJdbcTemplate.batchUpdate("insert into dbo" + + ".TEMP_ODS_HOUSINGCASEDEAL_RENT_" + computeTableRoute + "_RAW(case_id,case_district," + + "case_community_name,case_address,case_area,case_closing_date,case_total_price," + + "case_decoration,case_total_floor,case_current_floor,case_toward,case_floor,uv_community_id," + + "uv_building_id) " + + "values (:caseId,:caseDistrict,:caseCommunityName,:caseAddress,:caseArea,:closingDate," + + ":caseTotalPrice,:caseDecoration,:caseTotalFloor,:caseCurrentFloor,:caseToward,:caseFloor," + + ":uvCommunityId,:uvBuildingId);", + batchParams); + } /** @@ -104,6 +117,12 @@ public class OriginalResidenceRentClosingCaseServiceImpl implements IOriginalRes String rawSql = LoadUtil.loadContent("sql-template/clear_rent_closing_case.sql"); String sql = rawSql.replace("#yearMonth#", yearMonth.toString()); jdbcTemplate.update(sql); + + // 其他住宅租赁成交案例 + rawSql = LoadUtil.loadContent("sql-template/clear_other_rent_closing_case.sql"); + sql = rawSql.replace("#yearMonth#", yearMonth.toString()); + jdbcTemplate.update(sql); + // 计算 rawSql = LoadUtil.loadContent("sql-template/compute_rent_price.sql"); sql = rawSql.replace("#yearMonth#", yearMonth.toString()) diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentOpeningCaseServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentOpeningCaseServiceImpl.java index e98c6df3c..61ec03113 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentOpeningCaseServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/service/impl/OriginalResidenceRentOpeningCaseServiceImpl.java @@ -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.OriginalResidencePlatformRentOpeningCase; import com.ruoyi.project.data.cases.domain.OriginalResidenceRentOpeningCase; @@ -43,22 +44,20 @@ public class OriginalResidenceRentOpeningCaseServiceImpl implements IOriginalRes /** * 29号拉取挂牌案例 */ - @Scheduled(cron = "0 0 5 29 * ?") @Override public void pullData() { + Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); - Integer syncTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), - calendar.get(Calendar.MONTH))); - Integer lastYearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), - calendar.get(Calendar.MONTH) + 1)); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1); Date startDate = calendar.getTime(); calendar.add(Calendar.MONTH, 1); - Integer computeTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), - calendar.get(Calendar.MONTH) + 1)); Date endDate = calendar.getTime(); + Integer computeTableRoute = DateUtils.getNextYearMonth(); + Integer lastYearMonth = DateUtils.getYearMonth(); + Integer syncTableRoute = DateUtils.getLastYearMonth(); + prepare(computeTableRoute, syncTableRoute); // 拉取案例 List list = downloadOriginalResidenceRentOpeningCaseMapper.download(); diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/ComputeResidenceRentPriceMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/ComputeResidenceRentPriceMapper.java index 8723041ec..7c26e84b9 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/ComputeResidenceRentPriceMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/ComputeResidenceRentPriceMapper.java @@ -18,6 +18,8 @@ public interface ComputeResidenceRentPriceMapper { /** * 查询列表 + * @param ComputeResidenceRentBasePrice + * @return */ List selectPageList(ComputeResidenceRentBasePrice ComputeResidenceRentBasePrice); diff --git a/ruoyi/src/main/resources/application-dev.yml b/ruoyi/src/main/resources/application-dev.yml index 86fe1314e..ec1af67e8 100644 --- a/ruoyi/src/main/resources/application-dev.yml +++ b/ruoyi/src/main/resources/application-dev.yml @@ -77,4 +77,9 @@ spring: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=TEST username: purple - password: liancheng \ No newline at end of file + password: liancheng + spider2: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.246:1433;DatabaseName=LCSP + username: lc_spider + password: lc123456 \ No newline at end of file diff --git a/ruoyi/src/main/resources/application-prod.yml b/ruoyi/src/main/resources/application-prod.yml index e9bb7aff1..8a98be459 100644 --- a/ruoyi/src/main/resources/application-prod.yml +++ b/ruoyi/src/main/resources/application-prod.yml @@ -83,4 +83,9 @@ spring: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=TEST username: purple - password: liancheng \ No newline at end of file + password: liancheng + spider2: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.246:1433;DatabaseName=LCSP + username: lc_spider + password: lc123456 \ No newline at end of file diff --git a/ruoyi/src/main/resources/application-uat.yml b/ruoyi/src/main/resources/application-uat.yml index ecb11c819..66fb482e7 100644 --- a/ruoyi/src/main/resources/application-uat.yml +++ b/ruoyi/src/main/resources/application-uat.yml @@ -77,4 +77,9 @@ spring: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://139.196.201.83:1433;DatabaseName=TEST username: purple - password: liancheng \ No newline at end of file + password: liancheng + spider2: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://172.16.30.246:1433;DatabaseName=LCSP + username: lc_spider + password: lc123456 \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/ComputeResidenceRentPriceMapper.xml b/ruoyi/src/main/resources/mybatis/data/ComputeResidenceRentPriceMapper.xml index 3162b5cad..3f681ecf5 100644 --- a/ruoyi/src/main/resources/mybatis/data/ComputeResidenceRentPriceMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/ComputeResidenceRentPriceMapper.xml @@ -65,6 +65,7 @@ + @@ -127,6 +128,7 @@ ,Bind_MixProject_Pst ,VOPPAT ,VOPPA + ,area FROM dbo.DWA_PROJECTBASEPRICE_RENT_IMDT_${yearMonth} @@ -143,10 +145,11 @@ + + FROM dbo.DWA_PROJECTBASEPRICE_RENT_IMDT_${yearMonth} + order by ProjectID ASC OFFSET #{pageIndex} rows fetch next #{pageSize} rows only + diff --git a/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentClosingCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentClosingCaseMapper.xml index 9735b39b2..594642101 100644 --- a/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentClosingCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentClosingCaseMapper.xml @@ -4,18 +4,18 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentOpeningCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentOpeningCaseMapper.xml index aa80581a2..c866f0441 100644 --- a/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentOpeningCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalResidenceRentOpeningCaseMapper.xml @@ -30,7 +30,7 @@ - select top 100 面积 + select 面积 ,block ,地址 ,小区名 diff --git a/ruoyi/src/main/resources/mybatis/data/DownloadOtherResidenceRentClosingCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/DownloadOtherResidenceRentClosingCaseMapper.xml new file mode 100644 index 000000000..7c745b265 --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/DownloadOtherResidenceRentClosingCaseMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentClosingCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentClosingCaseMapper.xml index 5c188cc2f..66258ecb4 100644 --- a/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentClosingCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentClosingCaseMapper.xml @@ -10,19 +10,40 @@ CREATE TABLE ${targetTableName} ( - case_id varchar(32) not null, - case_contract_no nvarchar (32) NOT null primary key, - case_community_name nvarchar (512) NULL, - case_opening_date date NULL, - case_closing_date date NULL, - case_rent_price decimal (18, 2) NULL, - case_area decimal (18, 2) NULL, - case_total_floor int NULL, - case_toward nvarchar (16) NULL, - case_apartment_layout nvarchar (16) NULL, - case_decoration nvarchar (16) NULL, - clean_community_id nvarchar (32) NULL, - clean_building_id nvarchar (32) NULL + case_id varchar(32) not null, + case_contract_no nvarchar (32) NOT null primary key, + case_community_name nvarchar (512) NULL, + case_opening_date date NULL, + case_closing_date date NULL, + case_rent_price decimal (18, 2) NULL, + case_area decimal (18, 2) NULL, + case_total_floor int NULL, + case_toward nvarchar (16) NULL, + case_apartment_layout nvarchar (16) NULL, + case_decoration nvarchar (16) NULL, + clean_community_id nvarchar (32) NULL, + clean_building_id nvarchar (32) NULL + ) + + + + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + CREATE TABLE ${targetTableName}( + case_id varchar(32) NOT NULL primary key, + case_district nvarchar(64) NULL, + case_community_name nvarchar(1024) NULL, + case_address nvarchar(1024) NULL, + case_area decimal(18, 2) NULL, + case_closing_date date NULL, + case_total_price decimal(18, 2) NOT NULL, + case_decoration nvarchar(64) NULL, + case_total_floor int null, + case_current_floor nvarchar(32) NULL, + case_toward nvarchar(64) NULL, + case_floor nvarchar(32) NULL, + uv_community_id nvarchar(20) null, + uv_building_id nvarchar(20) null ) diff --git a/ruoyi/src/main/resources/sql-template/clear_other_rent_closing_case.sql b/ruoyi/src/main/resources/sql-template/clear_other_rent_closing_case.sql new file mode 100644 index 000000000..58dbcbe61 --- /dev/null +++ b/ruoyi/src/main/resources/sql-template/clear_other_rent_closing_case.sql @@ -0,0 +1,258 @@ +delete from ODS_HOUSINGCASEDEAL_RENT_#yearMonth# where Origin='太平洋'; + +create table #HousingCaseListAdj +( + case_id varchar(32) not null + , HouseholdsID_SRC nvarchar(64) primary key + , ProjectID_SRC nvarchar(64) not null + , ProjectID nvarchar(64) + , BuildingID nvarchar(64) + , RentType tinyint + , Area decimal(18, 2) + , Towards nvarchar(64) + , UpperFloorSum nvarchar(32) + , UpperFloorNum nvarchar(32) + , Decoration nvarchar(64) + , PriceTotal decimal(18, 2) not null + , PriceUnit decimal(18, 2) not null + , PriceDateOut date + , CaseName nvarchar(512) +); + +declare @HouseholdsID_SRC nvarchar(64) + , @CaseName nvarchar(512) + , @ProjectID nvarchar(64) + , @BuildingID nvarchar(64) + , @roomtype nvarchar(50) + , @UpperFloorSum nvarchar(32) + , @UpperFloorNum nvarchar(32) + , @area decimal(28, 2) + , @towards nvarchar(50) + , @decora nvarchar(64) + , @price decimal(28, 2) + , @dueDate date + , @case_id varchar(32) + , @RentType tinyint + , @priceunit decimal(28, 2); +declare Record2Insert cursor for +SELECT case_id + ,case_id + ,case_community_name + ,case_closing_date + ,case_total_price + ,case_area + ,case_total_floor + ,case_current_floor + ,case_toward + ,case_decoration + ,uv_community_id + ,uv_building_id +FROM dbo.TEMP_ODS_HOUSINGCASEDEAL_RENT_#yearMonth#_RAW; +open Record2Insert; +fetch next from Record2Insert +into @case_id + , @HouseholdsID_SRC + , @CaseName + , @dueDate + , @price + , @area + , @UpperFloorSum + , @UpperFloorNum + , @towards + , @decora + , @ProjectID + , @BuildingID; +set nocount on; --忽略行数显示 +while @@fetch_status = 0 +begin + begin + --租赁类型 + set @RentType = case + when @area < 30 then + 3 + else + 2 + end; --散租 + --面积 + set @area = case + when @area <> 0 then + @area + end; + --单价 + set @priceunit = @price * 1.0 / isnull(@area, 1.0); + --插入数据 + insert into #HousingCaseListAdj(case_id,HouseholdsID_SRC,ProjectID_SRC,ProjectID,BuildingID,RentType,Area,Towards, + UpperFloorSum,UpperFloorNum,Decoration,PriceTotal,PriceUnit,PriceDateOut,CaseName) + values + (@case_id, @HouseholdsID_SRC, '-1', @ProjectID, @BuildingID, @RentType, @area + , @towards, @UpperFloorSum, @UpperFloorNum, @decora, @price, @priceunit, @dueDate, @CaseName); + end; + fetch next from Record2Insert + into @case_id + , @HouseholdsID_SRC + , @CaseName + , @dueDate + , @price + , @area + , @UpperFloorSum + , @UpperFloorNum + , @towards + , @decora + , @ProjectID + , @BuildingID; +end; +close Record2Insert; +deallocate Record2Insert; +set nocount off; + +create table #HousingCaseListSTD +( + case_id varchar(32) + , HouseholdsID_SRC nvarchar(64) + , ProjectID_SRC nvarchar(64) + , ProjectID nvarchar(64) + , BuildingID nvarchar(64) + , AreaCoff decimal(7, 4) + , TowardsCoff decimal(7, 4) + , FloorCoff decimal(7, 4) + , DecorationRng int + , YearCoff decimal(7, 4) + , BuildingCoff decimal(7, 4) + , RoomTypeCoff decimal(7, 4) + , PriceUnit decimal(18, 2) not null + , PriceScatterRent decimal(18, 2) --散租单价 + , PriceEntireRent decimal(18, 2) --整租单价 + , PriceShareRent0 decimal(18, 2) --合租单间价 + , PriceShareRent decimal(18, 2) --合租折算价 +); + +insert into #HousingCaseListSTD +select a.case_id + , A.HouseholdsID_SRC + , A.ProjectID_SRC + , A.ProjectID + , null + , D.CoefficientA * A.Area + D.CoefficientB as AreaCoff + , E.Coefficient as TowardsCoff + , F.Coefficient as FloorCoff + , G.Coefficient as DecorationRng + , null as YearCoff + , null as BuildingCoff + , NULL as RoomTypeCoff + , 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) PriceScatterRent + , (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(G.Coefficient, 0) PriceEntireRent + , A.PriceTotal * 1.0 / isnull(F.Coefficient, 1) / isnull(E.Coefficient, 1) as PriceShareRent0 + , null as PriceShareRent +from #HousingCaseListAdj A + left join + (select projectid,ProjectLevel from obpm_LianCheng_Data.dbo.V_RESIDENCE_COMMUNITY) C + on A.ProjectID = C.projectid + left join + ( + select ProjectLevel + , UpperKey + , LowerKey + , CoefficientA + , CoefficientB + from obpm_LianCheng_Data.dbo.DIM_PARAMETERS + where CoffType = '面积修正(租金)' + and ProjectType = '公寓' + ) D --面积修正 + on C.ProjectLevel = D.ProjectLevel + and + ( + A.Area > D.LowerKey + and A.Area <= D.UpperKey + ) + left join + ( + select SingleKey + , Coefficient + from obpm_LianCheng_Data.dbo.DIM_PARAMETERS + where CoffType = '朝向(租金)' + and ProjectType = '公寓' + ) E --朝向修正 + on A.Towards = E.SingleKey + left join + ( + select UpperKey + , LowerKey + , Elevator + , Coefficient + from obpm_LianCheng_Data.dbo.DIM_PARAMETERS + where CoffType = '楼层(租金)' + and ProjectType = '公寓' + ) F --楼层修正 + on F.Elevator is null + and A.UpperFloorSum = F.UpperKey + and A.UpperFloorNum = F.LowerKey + left join + ( + select SingleKey + , Coefficient + from obpm_LianCheng_Data.dbo.DIM_PARAMETERS + where CoffType = '室内装修(租金)' + and ProjectType = '公寓' + ) G --装修修正 + on A.Decoration = G.SingleKey; + + +insert into ODS_HOUSINGCASEDEAL_RENT_#yearMonth# +select a.case_id + , A.HouseholdsID_SRC + , A.ProjectID_SRC + , A.ProjectID + , A.BuildingID + , A.RentType + , NULL + , NULL + , NULL + , A.Area + , A.Towards + , A.UpperFloorSum + , A.UpperFloorNum + , null Elevator + , A.Decoration + , null as Year + , B.AreaCoff + , B.TowardsCoff + , B.FloorCoff + , B.DecorationRng + , B.YearCoff + , B.BuildingCoff + , B.RoomTypeCoff + , A.PriceTotal + , A.PriceUnit + , B.PriceScatterRent + , B.PriceEntireRent + , B.PriceShareRent0 + , B.PriceShareRent + , null + , null + , null + , null + , 4 as Status + , null + , null + , null + , null + , null + , null + , null + , A.PriceTotal PriceTotalIn + , A.PriceTotal PriceTotalOut + , NULL + , A.PriceDateOut + , '太平洋' + , null + , null + , CaseName +from #HousingCaseListAdj A + left join #HousingCaseListSTD B + on A.HouseholdsID_SRC = B.HouseholdsID_SRC; + +drop table #HousingCaseListAdj + , #HousingCaseListSTD; \ No newline at end of file diff --git a/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java b/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java index 7fd0f41f0..1f1b13706 100644 --- a/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java +++ b/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java @@ -82,7 +82,7 @@ public class GenerateTableTests { @Test public void generateBatchInsertSqL() { - Class targetClass = OriginalResidenceRentClosingCase.class; + Class targetClass = OtherResidenceRentClosingCase .class; List fieldList = new ArrayList<>(); while (targetClass != null) { @@ -224,5 +224,9 @@ public class GenerateTableTests { } } + @Test + public void printUUID(){ + System.out.println(UUID.randomUUID().toString().replace("-","")); + } } diff --git a/ruoyi/src/test/java/com/ruoyi/compute/ResidenceRentBasePriceTests.java b/ruoyi/src/test/java/com/ruoyi/compute/ResidenceRentBasePriceTests.java index 1269bc15b..d52d873de 100644 --- a/ruoyi/src/test/java/com/ruoyi/compute/ResidenceRentBasePriceTests.java +++ b/ruoyi/src/test/java/com/ruoyi/compute/ResidenceRentBasePriceTests.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class) -@ActiveProfiles("uat") +@ActiveProfiles("dev") public class ResidenceRentBasePriceTests { @Autowired