From 5ef0853f58ad962d3bee36f3fcbe747af6ff1aaf Mon Sep 17 00:00:00 2001 From: purple <purple_lihe@163.com> Date: Thu, 9 Jul 2020 12:03:46 +0800 Subject: [PATCH] =?UTF-8?q?feature=20(=E4=BD=8F=E5=AE=85=E7=A7=9F=E8=B5=81?= =?UTF-8?q?=E5=9F=BA=E4=BB=B7=E4=BD=9C=E4=BB=B7)=EF=BC=9A=20=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E4=BD=8F=E5=AE=85=E7=A7=9F=E8=B5=81=E5=9F=BA=E4=BB=B7?= =?UTF-8?q?=E4=BD=9C=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 创建汇总案例表 2. 推送汇总案例数据 3. 创建价格表(备份上期价格表) 4. 推送价格数据 --- .../CleanResidenceRentAggregationCase.java | 111 ++++++++++++++++ .../ResidenceRentAggregationCaseMapper.java | 27 ++++ ...nalResidenceRentAggregationCaseMapper.java | 26 ---- .../sync/SyncResidenceRentCaseMapper.java | 65 +++++++++ .../ResidenceRentBasePriceController.java | 4 +- .../UltimateResidenceRentPriceMapper.java | 27 +++- ...> IUltimateResidenceRentPriceService.java} | 13 +- ...tificialResidenceRentPriceServiceImpl.java | 74 ++++++++++- .../UltimateOfficeBasePriceServiceImpl.java | 61 +++++---- ...ltimateResidenceRentPriceServiceImpl.java} | 9 +- .../ResidenceRentAggregationCaseMapper.xml | 124 ++++++++++++++++++ ...er.xml => SyncResidenceRentCaseMapper.xml} | 95 ++++++++++---- ...l => UltimateResidenceRentPriceMapper.xml} | 53 ++++++++ .../java/com/ruoyi/GenerateTableTests.java | 3 +- 14 files changed, 598 insertions(+), 94 deletions(-) create mode 100644 ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/ResidenceRentAggregationCaseMapper.java delete mode 100644 ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncOriginalResidenceRentAggregationCaseMapper.java create mode 100644 ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncResidenceRentCaseMapper.java rename ruoyi/src/main/java/com/ruoyi/project/data/price/service/{IUltimateResidenceRentBasePriceService.java => IUltimateResidenceRentPriceService.java} (75%) rename ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/{UltimateResidenceRentBasePriceServiceImpl.java => UltimateResidenceRentPriceServiceImpl.java} (83%) create mode 100644 ruoyi/src/main/resources/mybatis/data/ResidenceRentAggregationCaseMapper.xml rename ruoyi/src/main/resources/mybatis/data/{SyncOriginalResidenceRentAggregationCaseMapper.xml => SyncResidenceRentCaseMapper.xml} (63%) rename ruoyi/src/main/resources/mybatis/data/{UltimateResidenceRentBasePriceMapper.xml => UltimateResidenceRentPriceMapper.xml} (68%) diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/CleanResidenceRentAggregationCase.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/CleanResidenceRentAggregationCase.java index dc914c034..163fe750e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/CleanResidenceRentAggregationCase.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/CleanResidenceRentAggregationCase.java @@ -9,42 +9,153 @@ import java.util.Date; public class CleanResidenceRentAggregationCase { private Integer yearMonth; + /** + * 案例单套ID + */ private String householdsIdSRC; + /** + * 案例小区ID + */ private String projectIdSRC; + /** + * 小区ID + */ private String communityId; + private String buildingId; + /** + * WHEN A.RentType=1 THEN ''整租'' + * WHEN A.RentType=2 THEN ''散租'' + * WHEN A.RentType=3 THEN ''分租'' + */ private Integer rentType; + /** + * 室 + */ private Integer roomNum; + /** + * 厅 + */ private Integer hallNum; + /** + * 卫 + */ private Integer bashRoomNum; + /** + * 面积 + */ private BigDecimal area; + /** + * 朝向 + */ private String toward; + /** + * UpperFloorSum 总层数 + */ private String totalFloor; + /** + * UpperFloorNum 所在层 + */ private String currentFloor; + /** + * 有无电梯 + */ private Boolean elevator; + /** + * 装修类型 + */ private String decoration; + /** + * 建成年代 + */ private Integer year; + /** + * 房屋面积系数 + */ private BigDecimal areaCoefficient; + /** + * 朝向系数 + */ private BigDecimal towardCoefficient; + /** + * 楼层系数 + */ private BigDecimal floorCoefficient; + /** + * 装修系数 + */ private Integer decorationCoefficient; + /** + * 建成年代系数 + */ private BigDecimal yearCoefficient; + /** + * 楼栋系数 + */ private BigDecimal buildingCoefficient; + /** + * 室厅修正系数 + */ private BigDecimal roomTypeCoefficient; + /** + * 总价(元) + */ private BigDecimal totalPrice; + /** + * 单价(元每平方米) + */ private BigDecimal unitPrice; + /** + * 散租单价 + */ private BigDecimal priceScatterRent; + /** + * 整租单价 + */ private BigDecimal priceEntireRent; + /** + * 合租单间价 + */ private BigDecimal priceShareRent0; + /** + * 合租折算价 + */ private BigDecimal priceShareRent; + /** + * 带看总次数 + */ private Integer visitedNum; + /** + * 首次带看时间 + */ private Date firstVisitedDate; + /** + * 15天内带看总次数 + */ private Integer visitedNum15; + /** + * 30天内带看总次数 + */ private Integer visitedNum30; + /** + * 案例状态 + */ private Integer status; + /** + * 最近一次挂牌总价调整幅度 + */ private BigDecimal adjustedValue; + /** + * 最近一次挂牌总价调整比例 + */ private BigDecimal adjustedPst; + /** + * 累计挂牌总价调整幅度 + */ private BigDecimal adjustedCumValue; + /** + * 累计挂牌总价调整比例 + */ private BigDecimal adjustedCumPst; /** * 累计挂牌总价绝对调整幅度 diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/ResidenceRentAggregationCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/ResidenceRentAggregationCaseMapper.java new file mode 100644 index 000000000..d870c6198 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/ResidenceRentAggregationCaseMapper.java @@ -0,0 +1,27 @@ +package com.ruoyi.project.data.cases.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase; +import com.ruoyi.project.data.cases.domain.OriginalResidenceSaleOpeningCase; +import com.ruoyi.project.data.cases.domain.OriginalResidenceSaleOpeningCaseQueryModel; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 汇总案例查询 + * + * @author lihe + */ +@DS("compute") +public interface ResidenceRentAggregationCaseMapper { + + /** + * 获取每月汇总案例列表 + * + * @param yearMonth + * @return + */ + List<CleanResidenceRentAggregationCase> getMonthly(@Param("yearMonth") Integer yearMonth); + +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncOriginalResidenceRentAggregationCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncOriginalResidenceRentAggregationCaseMapper.java deleted file mode 100644 index 1fa15630b..000000000 --- a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncOriginalResidenceRentAggregationCaseMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ruoyi.project.data.cases.mapper.sync; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.ruoyi.project.data.cases.domain.OriginalResidenceRentOpeningCase; -import org.apache.ibatis.annotations.Param; - -/** - * @author lihe - */ -@DS("calc") -public interface SyncOriginalResidenceRentAggregationCaseMapper { - - /** - * 创建挂牌案例表 - * @param yearMonth - */ - int createTable(@Param("yearMonth") Integer yearMonth); - - /** - * - * @param originalResidenceRentOpeningCase - * @return - */ - int insert(OriginalResidenceRentOpeningCase originalResidenceRentOpeningCase); - -} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncResidenceRentCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncResidenceRentCaseMapper.java new file mode 100644 index 000000000..56d9b2378 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/SyncResidenceRentCaseMapper.java @@ -0,0 +1,65 @@ +package com.ruoyi.project.data.cases.mapper.sync; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase; +import com.ruoyi.project.data.cases.domain.OriginalResidenceRentOpeningCase; +import com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice; +import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; +import org.apache.ibatis.annotations.Param; + +/** + * @author lihe + */ +@DS("calc") +public interface SyncResidenceRentCaseMapper { + + /** + * 创建案例汇总表 + * + * @param yearMonth + * @return + */ + int createAggregationCaseTable(@Param("yearMonth") Integer yearMonth); + + /** + * 插入案例汇总表 + * + * @param cleanResidenceRentAggregationCase + * @return + */ + int insertAggregationCaseTable(CleanResidenceRentAggregationCase cleanResidenceRentAggregationCase); + + /** + * 创建最终价格表 + * + * @param yearMonth + * @return + */ + int createUltimatePriceTable(@Param("yearMonth") Integer yearMonth); + + /** + * 备份价格表 + * + * @param yearMonth + * @param operateDate + * @return + */ + int dumpPriceTable(@Param("yearMonth") Integer yearMonth, @Param("operateDate") String operateDate); + + /** + * 清空价格表 + * + * @param yearMonth + * @return + */ + int clearPriceTable(@Param("yearMonth") Integer yearMonth); + + /** + * 插入最终价格 + * + * @param ultimateOfficeBasePrice + * @return + */ + int insertUltimatePriceTable(UltimateResidenceRentBasePrice ultimateOfficeBasePrice); + +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/ResidenceRentBasePriceController.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/ResidenceRentBasePriceController.java index b2885b8d5..8cbe65320 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/ResidenceRentBasePriceController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/ResidenceRentBasePriceController.java @@ -20,7 +20,7 @@ import com.ruoyi.project.data.price.domain.ComputeResidenceRentBasePrice; import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; import com.ruoyi.project.data.price.service.IArtificialResidenceRentPriceService; import com.ruoyi.project.data.price.service.IComputeResidenceRentPriceService; -import com.ruoyi.project.data.price.service.IUltimateResidenceRentBasePriceService; +import com.ruoyi.project.data.price.service.IUltimateResidenceRentPriceService; import com.ruoyi.project.system.domain.UploadFile; import com.ruoyi.project.system.service.IUploadFileService; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +38,7 @@ public class ResidenceRentBasePriceController extends BaseController { @Autowired private IArtificialResidenceRentPriceService artificialResidenceRentPriceService; @Autowired - private IUltimateResidenceRentBasePriceService ultimateResidenceRentBasePriceService; + private IUltimateResidenceRentPriceService ultimateResidenceRentBasePriceService; @Autowired private IUploadFileService fileService; @Autowired diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateResidenceRentPriceMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateResidenceRentPriceMapper.java index 398716e59..fb5dec868 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateResidenceRentPriceMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateResidenceRentPriceMapper.java @@ -3,25 +3,48 @@ package com.ruoyi.project.data.price.mapper; import com.baomidou.dynamic.datasource.annotation.DS; import com.ruoyi.project.common.VueSelectModel; import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; +import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 【请填写功能名称】Mapper接口 + * 住宅租赁最终基价DAO * - * @author ruoyi + * @author purple * @date 2020-05-20 */ @DS("compute") public interface UltimateResidenceRentPriceMapper { + /** + * 获取分页列表 + * + * @param ultimateResidenceRentBasePrice + * @return + */ List<UltimateResidenceRentBasePrice> selectPageList(UltimateResidenceRentBasePrice ultimateResidenceRentBasePrice); + /** + * 获取分页总数 + * + * @param ultimateResidenceRentBasePrice + * @return + */ Integer selectPageCount(UltimateResidenceRentBasePrice ultimateResidenceRentBasePrice); /** + * 获取有效价格表 + * * @return */ List<VueSelectModel> yearMonthList(); + /** + * 获取某个月的数据 + * + * @param yearMonth + * @return + */ + List<UltimateResidenceRentBasePrice> getMonthly(@Param("yearMonth") Integer yearMonth); + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentBasePriceService.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentPriceService.java similarity index 75% rename from ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentBasePriceService.java rename to ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentPriceService.java index 183b34b51..7ee260f7f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentBasePriceService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateResidenceRentPriceService.java @@ -2,21 +2,30 @@ package com.ruoyi.project.data.price.service; import com.ruoyi.project.common.VueSelectModel; import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; +import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 住宅租赁基价 + * 住宅租赁最终基价 + * + * @author lihe */ -public interface IUltimateResidenceRentBasePriceService { +public interface IUltimateResidenceRentPriceService { /** + * 获取分页列表 + * * @param ultimateResidenceRentBasePrice * @return */ List<UltimateResidenceRentBasePrice> selectList(UltimateResidenceRentBasePrice ultimateResidenceRentBasePrice); + + /** + * 获取分页总数 + * * @param ultimateResidenceRentBasePrice * @return */ diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/ArtificialResidenceRentPriceServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/ArtificialResidenceRentPriceServiceImpl.java index f130524c0..75b34dbee 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/ArtificialResidenceRentPriceServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/ArtificialResidenceRentPriceServiceImpl.java @@ -6,9 +6,16 @@ import com.microsoft.sqlserver.jdbc.SQLServerDataTable; import com.microsoft.sqlserver.jdbc.SQLServerException; import com.ruoyi.common.utils.LoadUtil; import com.ruoyi.project.common.VueSelectModel; +import com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase; +import com.ruoyi.project.data.cases.domain.OfficeAggregationCase; +import com.ruoyi.project.data.cases.mapper.ResidenceRentAggregationCaseMapper; +import com.ruoyi.project.data.cases.mapper.sync.SyncResidenceRentCaseMapper; import com.ruoyi.project.data.price.domain.ArtificialResidenceRentBasePrice; import com.ruoyi.project.data.price.domain.ComputeResidenceRentBasePrice; +import com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice; +import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; import com.ruoyi.project.data.price.mapper.ArtificialResidenceRentPriceMapper; +import com.ruoyi.project.data.price.mapper.UltimateResidenceRentPriceMapper; import com.ruoyi.project.data.price.service.IArtificialResidenceRentPriceService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,6 +23,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,6 +53,12 @@ public class ArtificialResidenceRentPriceServiceImpl implements IArtificialResid private ArtificialResidenceRentPriceMapper artificialResidenceRentPriceMapper; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SyncResidenceRentCaseMapper syncResidenceRentCaseMapper; + @Autowired + private ResidenceRentAggregationCaseMapper residenceRentAggregationCaseMapper; + @Autowired + private UltimateResidenceRentPriceMapper ultimateResidenceRentPriceMapper; @Override public ArtificialResidenceRentBasePrice selectById(Integer yearMonth, String id) { @@ -101,7 +115,8 @@ public class ArtificialResidenceRentPriceServiceImpl implements IArtificialResid Date valuePoint = calendar.getTime(); calendar.add(Calendar.MONTH, -1); Date lastValuePoint = calendar.getTime(); - String lastYearMonth = String.format("%d%02d", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1); + Integer lastYearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH) + 1)); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String priceDate = simpleDateFormat.format(valuePoint); String lastPriceDate = simpleDateFormat.format(lastValuePoint); @@ -173,16 +188,69 @@ public class ArtificialResidenceRentPriceServiceImpl implements IArtificialResid // 人工修正导入 String rawSql = LoadUtil.loadContent("sql-template/update_rent_price.sql"); String sql = rawSql.replace("#yearMonth#", yearMonth.toString()) - .replace("#lastYearMonth#", lastYearMonth) + .replace("#lastYearMonth#", lastYearMonth.toString()) .replace("#priceDate#", priceDate) .replace("#lastPriceDate#", lastPriceDate); jdbcTemplate.update(sql); artificialResidenceRentPriceMapper.initProcedure(); + 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); } catch (Exception e) { - e.printStackTrace(); + log.error("住宅租赁基价人工修正异常", e); } StringBuilder successMsg = new StringBuilder("恭喜您,数据已全部导入成功!共 " + (successNum - failureNum) + " 条"); return successMsg.toString(); } + + /** + * 数据推送 + * + * @param yearMonth 作价表 + * @param currentPriceTableRoute 当期表 + * @param lastPriceTableRoute 上期表 + */ + @Async + public void pushData(Integer yearMonth, Integer currentPriceTableRoute, Integer lastPriceTableRoute) { + try { + // 案例同步 + syncResidenceRentCaseMapper.createAggregationCaseTable(currentPriceTableRoute); + List<CleanResidenceRentAggregationCase> list = residenceRentAggregationCaseMapper.getMonthly(yearMonth); + list.parallelStream().forEach(cleanResidenceRentAggregationCase -> { + cleanResidenceRentAggregationCase.setYearMonth(currentPriceTableRoute); + syncResidenceRentCaseMapper.insertAggregationCaseTable(cleanResidenceRentAggregationCase); + }); + + // 当期价格同步 + syncResidenceRentCaseMapper.createUltimatePriceTable(currentPriceTableRoute); + List<UltimateResidenceRentBasePrice> ultimateResidenceRentBasePrices = + ultimateResidenceRentPriceMapper.getMonthly(yearMonth); + ultimateResidenceRentBasePrices.parallelStream().forEach(ultimateResidenceRentBasePrice -> { + ultimateResidenceRentBasePrice.setYearMonth(currentPriceTableRoute); + syncResidenceRentCaseMapper.insertUltimatePriceTable(ultimateResidenceRentBasePrice); + }); + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); + String operateDate = simpleDateFormat.format(calendar.getTime()); + + // 上期价格同步 + syncResidenceRentCaseMapper.dumpPriceTable(lastPriceTableRoute, operateDate); + syncResidenceRentCaseMapper.clearPriceTable(lastPriceTableRoute); + List<UltimateResidenceRentBasePrice> lastUltimateResidenceRentBasePrices = + ultimateResidenceRentPriceMapper.getMonthly(lastPriceTableRoute); + lastUltimateResidenceRentBasePrices.parallelStream().forEach(ultimateResidenceRentBasePrice -> { + ultimateResidenceRentBasePrice.setYearMonth(lastPriceTableRoute); + syncResidenceRentCaseMapper.insertUltimatePriceTable(ultimateResidenceRentBasePrice); + }); + } catch (Exception e) { + log.error("推送住宅租赁数据失败", e); + } + } + } \ No newline at end of file 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 31e1782ad..31275216d 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 @@ -253,36 +253,41 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr */ @Async public void pushData(Integer yearMonth, Integer currentPriceTableRoute, Integer lastPriceTableRoute) { - // 案例同步 - syncOfficeAggregationCaseMapper.createAggregationCaseTable(currentPriceTableRoute); - List<OfficeAggregationCase> list = originalOfficeCaseMapper.getOfficeAggregationCases(yearMonth); - list.parallelStream().forEach(officeAggregationCase -> { - officeAggregationCase.setYearMonth(currentPriceTableRoute); - syncOfficeAggregationCaseMapper.insertAggregationCase(officeAggregationCase); - }); + try { + // 案例同步 + syncOfficeAggregationCaseMapper.createAggregationCaseTable(currentPriceTableRoute); + List<OfficeAggregationCase> list = originalOfficeCaseMapper.getOfficeAggregationCases(yearMonth); + list.parallelStream().forEach(officeAggregationCase -> { + officeAggregationCase.setYearMonth(currentPriceTableRoute); + syncOfficeAggregationCaseMapper.insertAggregationCase(officeAggregationCase); + }); - // 当期价格同步 - syncOfficeAggregationCaseMapper.createUltimatePriceTable(currentPriceTableRoute); - List<UltimateOfficeBasePrice> ultimateOfficeBasePrices = - ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(yearMonth); - ultimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { - ultimateOfficeBasePrice.setYearMonth(currentPriceTableRoute); - syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); - }); + // 当期价格同步 + syncOfficeAggregationCaseMapper.createUltimatePriceTable(currentPriceTableRoute); + List<UltimateOfficeBasePrice> ultimateOfficeBasePrices = + ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(yearMonth); + ultimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { + ultimateOfficeBasePrice.setYearMonth(currentPriceTableRoute); + syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); + }); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); - String operateDate = simpleDateFormat.format(calendar.getTime()); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); + String operateDate = simpleDateFormat.format(calendar.getTime()); - // 上期价格同步 - syncOfficeAggregationCaseMapper.dumpPriceTable(lastPriceTableRoute, operateDate); - syncOfficeAggregationCaseMapper.clearPriceTable(lastPriceTableRoute); - List<UltimateOfficeBasePrice> lastUltimateOfficeBasePrices = - ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(lastPriceTableRoute); - lastUltimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { - ultimateOfficeBasePrice.setYearMonth(lastPriceTableRoute); - syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); - }); + // 上期价格同步 + syncOfficeAggregationCaseMapper.dumpPriceTable(lastPriceTableRoute, operateDate); + syncOfficeAggregationCaseMapper.clearPriceTable(lastPriceTableRoute); + List<UltimateOfficeBasePrice> lastUltimateOfficeBasePrices = + ultimateOfficeBasePriceMapper.getUltimateOfficeBasePrices(lastPriceTableRoute); + lastUltimateOfficeBasePrices.parallelStream().forEach(ultimateOfficeBasePrice -> { + ultimateOfficeBasePrice.setYearMonth(lastPriceTableRoute); + syncOfficeAggregationCaseMapper.insertUltimatePriceTable(ultimateOfficeBasePrice); + }); + } catch (Exception e) { + log.error("推送办公数据失败", e); + } } + } diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentBasePriceServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentPriceServiceImpl.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentBasePriceServiceImpl.java rename to ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentPriceServiceImpl.java index 286475287..7d2ba19e0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentBasePriceServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/impl/UltimateResidenceRentPriceServiceImpl.java @@ -3,7 +3,7 @@ package com.ruoyi.project.data.price.service.impl; import com.ruoyi.project.common.VueSelectModel; import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; import com.ruoyi.project.data.price.mapper.UltimateResidenceRentPriceMapper; -import com.ruoyi.project.data.price.service.IUltimateResidenceRentBasePriceService; +import com.ruoyi.project.data.price.service.IUltimateResidenceRentPriceService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -14,13 +14,11 @@ import java.util.List; /** * 核准住宅租赁基价 Service业务层处理 * - * @author ruoyi + * @author purple * @date 2020-05-20 */ @Service -public class UltimateResidenceRentBasePriceServiceImpl implements IUltimateResidenceRentBasePriceService { - - private static final Logger log = LoggerFactory.getLogger(UltimateResidenceRentBasePriceServiceImpl.class); +public class UltimateResidenceRentPriceServiceImpl implements IUltimateResidenceRentPriceService { @Autowired private UltimateResidenceRentPriceMapper ultimateResidenceRentPriceMapper; @@ -40,5 +38,4 @@ public class UltimateResidenceRentBasePriceServiceImpl implements IUltimateResid return ultimateResidenceRentPriceMapper.yearMonthList(); } - } diff --git a/ruoyi/src/main/resources/mybatis/data/ResidenceRentAggregationCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/ResidenceRentAggregationCaseMapper.xml new file mode 100644 index 000000000..07161788d --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/ResidenceRentAggregationCaseMapper.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.project.data.cases.mapper.ResidenceRentAggregationCaseMapper"> + <resultMap id="AggregationCaseResultMapping" type="com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase"> + <result property="householdsIdSRC" column="HouseholdsID_SRC"/> + <result property="projectIdSRC" column="ProjectID_SRC"/> + <result property="communityId" column="ProjectID"/> + <result property="buildingId" column="BuildingID"/> + <result property="rentType" column="RentType"/> + <result property="roomNum" column="Room"/> + <result property="hallNum" column="Hall"/> + <result property="bashRoomNum" column="Bashroom"/> + <result property="area" column="Area"/> + <result property="toward" column="Towards"/> + <result property="totalFloor" column="UpperFloorSum"/> + <result property="currentFloor" column="UpperFloorNum"/> + <result property="elevator" column="Elevator"/> + <result property="decoration" column="Decoration"/> + <result property="year" column="Year"/> + <result property="areaCoefficient" column="AreaCoff"/> + <result property="towardCoefficient" column="TowardsCoff"/> + <result property="floorCoefficient" column="FloorCoff"/> + <result property="decorationCoefficient" column="DecorationRng"/> + <result property="yearCoefficient" column="YearCoff"/> + <result property="buildingCoefficient" column="BuildingCoff"/> + <result property="roomTypeCoefficient" column="RoomTypeCoff"/> + <result property="totalPrice" column="PriceTotal"/> + <result property="unitPrice" column="PriceUnit"/> + <result property="priceScatterRent" column="PriceScatterRent"/> + <result property="priceEntireRent" column="PriceEntireRent"/> + <result property="priceShareRent0" column="PriceShareRent0"/> + <result property="priceShareRent" column="PriceShareRent"/> + <result property="visitedNum" column="Visited_Num"/> + <result property="firstVisitedDate" column="First_Visit_Time" jdbcType="DATE"/> + <result property="visitedNum15" column="Visited_Num_15"/> + <result property="visitedNum30" column="Visited_Num_30"/> + <result property="status" column="Status"/> + <result property="adjustedValue" column="AdjustedValue"/> + <result property="adjustedPst" column="AdjustedPst"/> + <result property="adjustedCumValue" column="AdjustedCumValue"/> + <result property="adjustedCumPst" column="AdjustedCumPst"/> + <result property="adjustedCumValueAbs" column="AdjustedCumValueAbs"/> + <result property="adjustedCumPstAbs" column="AdjustedCumPstAbs"/> + <result property="adjustedCumNum" column="AdjustedCumNum"/> + <result property="priceTotalIn" column="PriceTotalIn"/> + <result property="priceTotalOut" column="PriceTotalOut"/> + <result property="priceDateIn" column="PriceDateIn" jdbcType="DATE"/> + <result property="priceDateOut" column="PriceDateOut" jdbcType="DATE"/> + <result property="origin" column="Origin"/> + <result property="urlHouseholds" column="UrlHouseholds"/> + <result property="urlProjects" column="UrlProjects"/> + <result property="caseName" column="CaseName"/> + <result property="caseType" column="CaseType"/> + <result property="rentPrice_1" column="RentPrice_1"/> + <result property="range" column="Range"/> + <result property="rangeFlag" column="RangeFlag"/> + <result property="rentPrice" column="RentPrice"/> + <result property="entireRentRatio" column="EntireRentRatio"/> + <result property="shareRentRatio" column="ShareRentRatio"/> + <result property="yearMonth" column="yearMonth"/> + </resultMap> + <!-- 汇总案例 --> + <select id="getOfficeAggregationCases" resultMap="AggregationCaseResultMapping"> + SELECT HouseholdsID_SRC + ,ProjectID_SRC + ,ProjectID + ,BuildingID + ,RentType + ,Room + ,Hall + ,Bashroom + ,Area + ,Towards + ,UpperFloorSum + ,UpperFloorNum + ,Elevator + ,Decoration + ,Year + ,AreaCoff + ,TowardsCoff + ,FloorCoff + ,DecorationRng + ,YearCoff + ,BuildingCoff + ,RoomTypeCoff + ,PriceTotal + ,PriceUnit + ,PriceScatterRent + ,PriceEntireRent + ,PriceShareRent0 + ,PriceShareRent + ,Visited_Num + ,First_Visit_Time + ,Visited_Num_15 + ,Visited_Num_30 + ,Status + ,AdjustedValue + ,AdjustedPst + ,AdjustedCumValue + ,AdjustedCumPst + ,AdjustedCumValueAbs + ,AdjustedCumPstAbs + ,AdjustedCumNum + ,PriceTotalIn + ,PriceTotalOut + ,PriceDateIn + ,PriceDateOut + ,Origin + ,UrlHouseholds + ,UrlProjects + ,CaseName + ,CaseType + ,RentPrice_1 + ,Range + ,RangeFlag + ,RentPrice + ,EntireRentRatio + ,ShareRentRatio + ,${yearMonth} as yearMonth + FROM dbo.DW_HOUSINGCASE_RENT_COMM_${yearMonth} + </select> +</mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/SyncOriginalResidenceRentAggregationCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/SyncResidenceRentCaseMapper.xml similarity index 63% rename from ruoyi/src/main/resources/mybatis/data/SyncOriginalResidenceRentAggregationCaseMapper.xml rename to ruoyi/src/main/resources/mybatis/data/SyncResidenceRentCaseMapper.xml index 689feef1c..00918ba26 100644 --- a/ruoyi/src/main/resources/mybatis/data/SyncOriginalResidenceRentAggregationCaseMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/SyncResidenceRentCaseMapper.xml @@ -2,8 +2,8 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.ruoyi.project.data.cases.mapper.sync.SyncOriginalResidenceRentAggregationCaseMapper"> - <update id="createTable"> +<mapper namespace="com.ruoyi.project.data.cases.mapper.sync.SyncResidenceRentCaseMapper"> + <update id="createAggregationCaseTable"> <bind name="targetTableName" value="'dbo.DW_HOUSINGCASE_RENT_COMM_' + yearMonth"/> IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL drop table ${targetTableName}; @@ -68,7 +68,7 @@ ) </update> - <insert id="insert" parameterType="com.ruoyi.project.data.cases.domain.OriginalResidenceSaleOpeningCase"> + <insert id="insertAggregationCaseTable" parameterType="com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase"> insert into dbo.DW_HOUSINGCASE_RENT_COMM_${yearMonth} ( HouseholdsID_SRC @@ -128,27 +128,74 @@ , ShareRentRatio ) values ( - #{caseLianJiaId}, - #{caseLianJiaCommunityId}, - #{caseTitle}, - #{caseApartmentLayout}, - #{caseArea}, - #{caseToward}, - #{caseStorey}, - #{caseLastDeal,jdbcType=DATE}, - #{caseElevator}, - #{caseDecoration}, - #{caseYear}, - #{caseAddress}, - #{casePrice}, - #{caseCommunityName}, - #{caseVisitedNum}, - #{caseFirstVisitTime,jdbcType=DATE}, - #{caseVisitedNum15}, - #{caseVisitedNum30}, - #{caseUrl}, - #{caseCommunityUrl}, - #{caseGetDate,jdbcType=DATE} + #{householdsIdSRC}, + #{projectIdSRC}, + #{communityId}, + #{buildingId}, + #{rentType}, + #{roomNum}, + #{hallNum}, + #{bashRoomNum}, + #{area}, + #{toward}, + #{totalFloor}, + #{currentFloor}, + #{elevator}, + #{decoration}, + #{year}, + #{areaCoefficient}, + #{towardCoefficient}, + #{floorCoefficient}, + #{decorationCoefficient}, + #{yearCoefficient}, + #{buildingCoefficient}, + #{roomTypeCoefficient}, + #{totalPrice}, + #{unitPrice}, + #{priceScatterRent}, + #{priceEntireRent}, + #{priceShareRent0}, + #{priceShareRent}, + #{visitedNum}, + #{firstVisitedDate,jdbcType=DATE}, + #{visitedNum15}, + #{visitedNum30}, + #{status}, + #{adjustedValue}, + #{adjustedPst}, + #{adjustedCumValue}, + #{adjustedCumPst}, + #{adjustedCumValueAbs}, + #{adjustedCumPstAbs}, + #{adjustedCumNum}, + #{priceTotalIn}, + #{priceTotalOut}, + #{priceDateIn,jdbcType=DATE}, + #{priceDateOut,jdbcType=DATE}, + #{origin}, + #{urlHouseholds}, + #{urlProjects}, + #{caseName}, + #{caseType}, + #{rentPrice_1}, + #{range}, + #{rangeFlag}, + #{rentPrice}, + #{entireRentRatio}, + #{shareRentRatio} ) </insert> + <!--备份表--> + <update id="dumpPriceTable"> + <bind name="backUpTableName" value="'dbo.ODS_PROJECT_RENT_PRICE_INFO_' + yearMonth+'_'+operateDate+'_bak'"/> + <bind name="targetTableName" value="'dbo.ODS_PROJECT_RENT_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_PROJECT_RENT_PRICE_INFO_' + yearMonth"/> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + truncate table ${targetTableName} + </update> </mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentBasePriceMapper.xml b/ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentPriceMapper.xml similarity index 68% rename from ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentBasePriceMapper.xml rename to ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentPriceMapper.xml index b4015d0e1..63d8bfeb1 100644 --- a/ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentBasePriceMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/UltimateResidenceRentPriceMapper.xml @@ -111,4 +111,57 @@ where name like 'ODS_PROJECT_RENT_PRICE_INFO_%' and name not like '%_bak' order by cast(right(name,6) as int) desc </select> + <resultMap id="ultimatePriceMapping" type="com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice"> + <result property="id" column="id"/> + <result property="communityId" column="projectID"/> + <result property="priceType" column="priceType"/> + <result property="basePrice_1" column="basePrice_1"/> + <result property="rentPrice" column="rentPrice"/> + <result property="sumCase1" column="sumCase1"/> + <result property="voppa" column="voppa"/> + <result property="voppat" column="voppat"/> + <result property="gf_1Room" column="gf_1Room"/> + <result property="gf_2Room" column="gf_2Room"/> + <result property="gy_2Room" column="gy_2Room"/> + <result property="gy_3Room" column="gy_3Room"/> + <result property="one_Room" column="one_Room"/> + <result property="two_Room" column="two_Room"/> + <result property="three_Room" column="three_Room"/> + <result property="entireRentRatio" column="entireRentRatio"/> + <result property="entireRentNum" column="entireRentNum"/> + <result property="shareRentRatio" column="shareRentRatio"/> + <result property="shareRentNum" column="shareRentNum"/> + <result property="saleRentRatio" column="saleRentRatio"/> + <result property="modifyDate" column="modifyDate" jdbcType="DATE"/> + <result property="status" column="status"/> + <result property="adjEvd" column="adjEvd"/> + <result property="yearMonth" column="yearMonth"/> + </resultMap> + <select id="getMonthly" resultMap="ultimatePriceMapping"> + SELECT ID + ,ProjectID + ,PriceType + ,BasePrice_1 + ,RentPrice + ,SumCase1 + ,VOPPAT + ,VOPPA + ,GF_1Room + ,GF_2Room + ,GY_2Room + ,GY_3Room + ,One_Room + ,Two_Room + ,Three_Room + ,EntireRentRatio + ,EntireRentNum + ,ShareRentRatio + ,ShareRentNum + ,SaleRentRatio + ,ModifyDate + ,Status + ,AdjEvd + ,${yearMonth} as yearMonth + FROM dbo.ODS_PROJECT_RENT_PRICE_INFO_${yearMonth} + </select> </mapper> \ 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 4ef5df63a..6e1a8502d 100644 --- a/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java +++ b/ruoyi/src/test/java/com/ruoyi/GenerateTableTests.java @@ -1,6 +1,7 @@ package com.ruoyi; +import com.ruoyi.project.data.cases.domain.CleanResidenceRentAggregationCase; import com.ruoyi.project.data.cases.domain.OfficeAggregationCase; import com.ruoyi.project.data.cases.domain.OriginalResidenceRentClosingCase; import com.ruoyi.project.data.price.domain.ComputeResidenceSaleBasePrice; @@ -95,7 +96,7 @@ public class GenerateTableTests { @Test public void generateBatchGuoHaoInsertSqL() { - Class targetClass = UltimateOfficeBasePrice.class; + Class targetClass = CleanResidenceRentAggregationCase.class; List<Field> fieldList = new ArrayList<>(); while (targetClass != null) {