From 2b28b5171787b7f2ead539564abbc8a65c0239af Mon Sep 17 00:00:00 2001 From: purple <purple_lihe@163.com> Date: Thu, 9 Jul 2020 11:18:08 +0800 Subject: [PATCH] =?UTF-8?q?feature=20(=E5=8A=9E=E5=85=AC=E4=BD=9C=E4=BB=B7?= =?UTF-8?q?)=EF=BC=9A=20=E6=8E=A8=E9=80=81=E4=BD=9C=E4=BB=B7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 创建案例表 2. 推送案例数据 3. 创建价格表(备份上期价格表) 4. 推送价格数据 --- .../price/domain/UltimateOfficeBasePrice.java | 37 ++++- .../UltimateOfficeBasePriceServiceImpl.java | 10 ++ ruoyi/src/main/resources/application-dev.yml | 6 +- ruoyi/src/main/resources/application-uat.yml | 74 +-------- .../mybatis/data/OriginalOfficeCaseMapper.xml | 142 ++++++++++++------ .../data/SyncOfficeAggregationCaseMapper.xml | 23 ++- .../data/UltimateOfficeBasePriceMapper.xml | 76 ++++++---- .../ruoyi/compute/OfficeBasePriceTests.java | 2 +- 8 files changed, 205 insertions(+), 165 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/domain/UltimateOfficeBasePrice.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/domain/UltimateOfficeBasePrice.java index 92bd5bc1f..2241eb79d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/domain/UltimateOfficeBasePrice.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/domain/UltimateOfficeBasePrice.java @@ -8,7 +8,6 @@ import java.math.BigDecimal; import java.util.Date; /** - * * @author purple * @date 2020-05-20 */ @@ -22,6 +21,7 @@ public class UltimateOfficeBasePrice extends BaseEntity { private Integer yearMonth; @JSONField(serialize = false) private Integer lastYearMonth; + @Excel(name = "楼栋ID-平台") private String buildingId; @Excel(name = "小区ID-平台") @@ -74,19 +74,23 @@ public class UltimateOfficeBasePrice extends BaseEntity { private BigDecimal yearCoefficient; @Excel(name = "基价楼栋系数") private BigDecimal buildingCoefficient; -// @Excel(name = "更新日期") + // @Excel(name = "更新日期") private Date updateDate; -// @Excel(name = "状态") + // @Excel(name = "状态") private Boolean status; @Excel(name = "是否标准楼栋") private Boolean standardBuilding; -// @Excel(name = "更改价格说明") + // @Excel(name = "更改价格说明") private String adjustPriceComment; /** * 名称或者地址 */ private String nameOrAddress; + private String deprecatedBuildingId; + private String deprecatedCommunityId; + private String unifiedId; + public Integer getLastYearMonth() { return lastYearMonth; } @@ -374,4 +378,29 @@ public class UltimateOfficeBasePrice extends BaseEntity { public void setNameOrAddress(String nameOrAddress) { this.nameOrAddress = nameOrAddress; } + + + public String getDeprecatedBuildingId() { + return deprecatedBuildingId; + } + + public void setDeprecatedBuildingId(String deprecatedBuildingId) { + this.deprecatedBuildingId = deprecatedBuildingId; + } + + public String getDeprecatedCommunityId() { + return deprecatedCommunityId; + } + + public void setDeprecatedCommunityId(String deprecatedCommunityId) { + this.deprecatedCommunityId = deprecatedCommunityId; + } + + public String getUnifiedId() { + return unifiedId; + } + + public void setUnifiedId(String unifiedId) { + this.unifiedId = unifiedId; + } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateOfficeBasePriceServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateOfficeBasePriceServiceImpl.java index 69dcb81ec..31e1782ad 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateOfficeBasePriceServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateOfficeBasePriceServiceImpl.java @@ -235,6 +235,13 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr .replace("#today#", priceDate) .replace("#lastMonth#", lastPriceDate); jdbcTemplate.update(sql); + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(lastValuePoint); + calendar.add(Calendar.MONTH, -1); + Integer lastPriceTableRoute = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH) + 1)); + pushData(yearMonth, lastYearMonth, lastPriceTableRoute); } /** @@ -250,6 +257,7 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr syncOfficeAggregationCaseMapper.createAggregationCaseTable(currentPriceTableRoute); List<OfficeAggregationCase> list = originalOfficeCaseMapper.getOfficeAggregationCases(yearMonth); list.parallelStream().forEach(officeAggregationCase -> { + officeAggregationCase.setYearMonth(currentPriceTableRoute); syncOfficeAggregationCaseMapper.insertAggregationCase(officeAggregationCase); }); @@ -258,6 +266,7 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr List<UltimateOfficeBasePrice> ultimateOfficeBasePrices = ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(yearMonth); ultimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { + ultimateOfficeBasePrice.setYearMonth(currentPriceTableRoute); syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); }); @@ -272,6 +281,7 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr List<UltimateOfficeBasePrice> lastUltimateOfficeBasePrices = ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(lastPriceTableRoute); lastUltimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { + ultimateOfficeBasePrice.setYearMonth(lastPriceTableRoute); syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); }); } diff --git a/ruoyi/src/main/resources/application-dev.yml b/ruoyi/src/main/resources/application-dev.yml index 68b90cedc..1d507d4d5 100644 --- a/ruoyi/src/main/resources/application-dev.yml +++ b/ruoyi/src/main/resources/application-dev.yml @@ -70,9 +70,9 @@ spring: password: Lcdatacenter_888 calc: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver - url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_calc - username: sa - password: Lcdatacenter_888 + 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 diff --git a/ruoyi/src/main/resources/application-uat.yml b/ruoyi/src/main/resources/application-uat.yml index ee341b402..0ef2d7df0 100644 --- a/ruoyi/src/main/resources/application-uat.yml +++ b/ruoyi/src/main/resources/application-uat.yml @@ -60,7 +60,7 @@ spring: password: lc1234 compute: driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver - url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_compute_test + url: jdbc:sqlserver://172.16.30.233:1433;DatabaseName=uv_compute username: sa password: Lcdatacenter_888 clean: @@ -77,74 +77,4 @@ spring: 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 \ No newline at end of file + password: liancheng \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/OriginalOfficeCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/OriginalOfficeCaseMapper.xml index 3eb732e1c..98e20d0d0 100644 --- a/ruoyi/src/main/resources/mybatis/data/OriginalOfficeCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/OriginalOfficeCaseMapper.xml @@ -154,54 +154,102 @@ IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL drop table ${targetTableName}; </update> + <resultMap id="AggregationCaseResultMapping" type="com.ruoyi.project.data.cases.domain.OfficeAggregationCase"> + <result property="url" column="url"/> + <result property="title" column="title"/> + <result property="floorAreaRatio" column="容积率"/> + <result property="caseTotalPrice" column="总价售"/> + <result property="caseUnitPrice" column="均价售"/> + <result property="name" column="楼盘名称"/> + <result property="name_m" column="楼盘名称_M"/> + <result property="caseFloor" column="楼层"/> + <result property="area" column="面积"/> + <result property="managementFee" column="物业费"/> + <result property="seatCount" column="工位数"/> + <result property="address" column="地址"/> + <result property="metro" column="地铁"/> + <result property="publishDate" column="发布时间" jdbcType="DATE"/> + <result property="sourceNo" column="房源编号"/> + <result property="lng" column="百度lng"/> + <result property="lat" column="百度lat"/> + <result property="county" column="区域"/> + <result property="catalog" column="分类"/> + <result property="source" column="来源"/> + <result property="level" column="等级"/> + <result property="homePageUrl" column="楼盘网址"/> + <result property="decoration" column="装修"/> + <result property="type" column="类型"/> + <result property="block" column="板块"/> + <result property="agency" column="挂牌中介"/> + <result property="rentOfMonthly" column="月租金租"/> + <result property="rentOfStandard" column="标准租金租"/> + <result property="updateDate" column="更新时间" jdbcType="DATE"/> + <result property="score" column="得房率"/> + <result property="totalPrice" column="总价"/> + <result property="unitPrice" column="单价"/> + <result property="buildingId" column="BuildingID_P"/> + <result property="communityId" column="ProjectID_P"/> + <result property="totalFloor" column="TotalFloorSum"/> + <result property="floorCoefficient" column="FloorCoff"/> + <result property="decorationCoefficient" column="DecorationCoff"/> + <result property="priceAmend" column="PriceAmend"/> + <result property="mainPrice_1" column="MainPrice_1"/> + <result property="mainPriceRent_1" column="MainPriceRent_1"/> + <result property="listedPrice_1" column="ListedPrice_1"/> + <result property="listedPriceRent_1" column="ListedPriceRent_1"/> + <result property="listedPrice" column="ListedPrice"/> + <result property="listedPriceRent" column="ListedPriceRent"/> + <result property="vopp" column="VOPP"/> + <result property="voppt" column="VOPPT"/> + </resultMap> <!-- 汇总案例 --> - <select id="getOfficeAggregationCases" resultType="com.ruoyi.project.data.cases.domain.OfficeAggregationCase"> - SELECT url as url - ,title as title - ,容积率 as floorAreaRatio - ,总价售 as caseTotalPrice - ,均价售 as caseUnitPrice - ,楼盘名称 as name - ,楼盘名称_M as name_m - ,楼层 as caseFloor - ,面积 as area - ,物业费 as managementFee - ,工位数 as seatCount - ,地址 as address - ,地铁 as metro - ,发布时间 as publishDate - ,房源编号 as sourceNo - ,百度lng as lng - ,百度lat as lat - ,区域 as county - ,分类 as catalog - ,来源 as source - ,等级 as level - ,楼盘网址 as homePageUrl - ,装修 as decoration - ,类型 as type - ,板块 as block - ,挂牌中介 as agency - ,月租金租 as rentOfMonthly - ,标准租金租 as rentOfStandard - ,更新时间 as updateDate - ,得房率 as score - ,总价 as totalPrice - ,单价 as unitPrice - ,BuildingID_P as buildingId - ,ProjectID_P as communityId - ,TotalFloorSum as totalFloor - ,FloorCoff as floorCoefficient - ,DecorationCoff as decorationCoefficient - ,PriceAmend as priceAmend - ,MainPrice_1 as mainPrice_1 - ,MainPriceRent_1 as mainPriceRent_1 - ,ListedPrice_1 as listedPrice_1 - ,ListedPriceRent_1 as listedPriceRent_1 - ,ListedPrice as listedPrice - ,ListedPriceRent as listedPriceRent - ,VOPP as vopp - ,VOPPT as voppt + <select id="getOfficeAggregationCases" resultMap="AggregationCaseResultMapping"> + SELECT url + ,title + ,容积率 + ,总价售 + ,均价售 + ,楼盘名称 + ,楼盘名称_M + ,楼层 + ,面积 + ,物业费 + ,工位数 + ,地址 + ,地铁 + ,发布时间 + ,房源编号 + ,百度lng + ,百度lat + ,区域 + ,分类 + ,来源 + ,等级 + ,楼盘网址 + ,装修 + ,类型 + ,板块 + ,挂牌中介 + ,月租金租 + ,标准租金租 + ,更新时间 + ,得房率 + ,总价 + ,单价 + ,BuildingID_P + ,ProjectID_P + ,TotalFloorSum + ,FloorCoff + ,DecorationCoff + ,PriceAmend + ,MainPrice_1 + ,MainPriceRent_1 + ,ListedPrice_1 + ,ListedPriceRent_1 + ,ListedPrice + ,ListedPriceRent + ,VOPP + ,VOPPT FROM dbo.DW_OFFICECASE_COMM_${yearMonth} </select> </mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/SyncOfficeAggregationCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/SyncOfficeAggregationCaseMapper.xml index 55d50ca6d..0d2e8e5c1 100644 --- a/ruoyi/src/main/resources/mybatis/data/SyncOfficeAggregationCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/SyncOfficeAggregationCaseMapper.xml @@ -162,21 +162,28 @@ </insert> <!--备份表--> <update id="dumpPriceTable"> + <bind name="backUpTableName" value="'dbo.ODS_OFFICE_BUILDING_PRICE_INFO_' + yearMonth+'_'+operateDate+'_bak'"/> + <bind name="targetTableName" value="'dbo.ODS_OFFICE_BUILDING_PRICE_INFO_' + yearMonth"/> + IF OBJECT_ID(#{backUpTableName}, 'U') IS NOT NULL + drop table ${backUpTableName} + select * into ${backUpTableName} from ${targetTableName} + </update> + <update id="clearPriceTable"> <bind name="targetTableName" value="'dbo.ODS_OFFICE_BUILDING_PRICE_INFO_' + yearMonth"/> IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL - select * into ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth}_${operateDate}_bak from ${targetTableName} + truncate table ${targetTableName} </update> <!--创建价格表--> - <update id="createPriceTable"> + <update id="createUltimatePriceTable"> <bind name="targetTableName" value="'dbo.ODS_OFFICE_BUILDING_PRICE_INFO_' + yearMonth"/> IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL drop table ${targetTableName}; create table ${targetTableName}( id bigint identity not null , - BuildingID bigint not null, + BuildingID bigint null, UnifiedID bigint null, - ProjectID bigint not null, + ProjectID bigint null, BuildingID_P nvarchar(20) not null, ProjectID_P bigint null, MainPrice decimal(38, 6) null, @@ -243,6 +250,9 @@ , UpperFloorSum , OfficeClass , Grade + , BuildingID + , ProjectID + , UnifiedID ) values( #{buildingId}, #{communityId}, @@ -273,7 +283,10 @@ #{totalFloorSum}, #{upperFloorSum}, #{officeClass}, - #{officeLevel} + #{officeLevel}, + #{deprecatedBuildingId}, + #{deprecatedCommunityId}, + #{unifiedId} ) </update> </mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml b/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml index b1800d4e7..72abe1b43 100644 --- a/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml @@ -16,7 +16,7 @@ <result property="mainPriceRentPst" column="MainPriceRentPst"/> <result property="mainPriceType" column="MainPriceType"/> <result property="mainPriceRentType" column="MainPriceRentType"/> - <result property="updateDate" column="ModifyDate"/> + <result property="updateDate" column="ModifyDate" jdbcType="DATE"/> <result property="status" column="Status"/> <result property="standardBuilding" column="BuildingStd"/> <result property="adjustPriceComment" column="AdjEvd"/> @@ -38,10 +38,16 @@ <result property="officeLevel" column="Grade"/> <result property="mainPrice_1" column="mainPrice_1"/> <result property="mainPriceRent_1" column="mainPriceRent_1"/> + <result property="deprecatedBuildingId" column="BuildingID"/> + <result property="deprecatedCommunityId" column="ProjectID"/> + <result property="unifiedId" column="UnifiedID"/> </resultMap> <sql id="getById"> SELECT a.ID + ,a.BuildingID + ,a.ProjectID + ,a.UnifiedID ,a.BuildingID_P ,a.ProjectID_P ,a.MainPrice @@ -336,38 +342,42 @@ <update id="clearPriceTable"> truncate table ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} </update> - <select id="getUltimateOfficeBasePrices" resultType="com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice"> - SELECT BuildingID_P as buildingId - ,ProjectID_P as communityId - ,MainPrice as mainPrice - ,MainPriceRent as mainPriceRent - ,MainPricePst as mainPricePst - ,MainPriceRentPst as mainPriceRentPst - ,MainPriceType as mainPriceType - ,MainPriceRentType as mainPriceRentType - ,ModifyDate as updateDate - ,Status as status - ,BuildingStd as standardBuilding - ,AdjEvd as adjustPriceComment - ,MainPrice_1 as mainPrice_1 - ,MainPriceRent_1 as mainPriceRent_1 - ,AreaCoff as areaCoefficient - ,YearCoff as yearCoefficient - ,BuildingCoff as buildingCoefficient - ,ProjectName as communityName - ,ProjectAddr as communityAddress - ,BuildingAddr as buildingAddress - ,County as countyName - ,Loop as loopName - ,Block as blockName - ,Street as streetName - ,Year as year - ,AvgArea as avgArea - ,TotalFloorSum as totalFloorSum - ,UpperFloorSum as upperFloorSum - ,OfficeClass as officeClass - ,Grade as officeLevel, - ${yearMonth} as yearMonth + <select id="getUltimateOfficeBasePrices" resultMap="OfficeBasePriceUltimateResult"> + SELECT id + , BuildingID + , ProjectID + , UnifiedID + ,BuildingID_P + ,ProjectID_P + ,MainPrice + ,MainPriceRent + ,MainPricePst + ,MainPriceRentPst + ,MainPriceType + ,MainPriceRentType + ,ModifyDate + ,Status + ,BuildingStd + ,AdjEvd + ,AreaCoff + ,YearCoff + ,BuildingCoff + ,ProjectName + ,ProjectAddr + ,BuildingAddr + ,County + ,Loop + ,Block + ,Street + ,Year + ,AvgArea + ,TotalFloorSum + ,UpperFloorSum + ,OfficeClass + ,Grade + ,MainPrice_1 + ,MainPriceRent_1 + ,${yearMonth} as yearMonth FROM dbo.ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} </select> </mapper> \ No newline at end of file diff --git a/ruoyi/src/test/java/com/ruoyi/compute/OfficeBasePriceTests.java b/ruoyi/src/test/java/com/ruoyi/compute/OfficeBasePriceTests.java index 19b10ff06..07af7ea72 100644 --- a/ruoyi/src/test/java/com/ruoyi/compute/OfficeBasePriceTests.java +++ b/ruoyi/src/test/java/com/ruoyi/compute/OfficeBasePriceTests.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 OfficeBasePriceTests { @Autowired