diff --git a/ruoyi-ui/src/views/data/price/ArtificialResidenceSalePrice.vue b/ruoyi-ui/src/views/data/price/ArtificialResidenceSalePrice.vue index 7e6646070..22125b938 100644 --- a/ruoyi-ui/src/views/data/price/ArtificialResidenceSalePrice.vue +++ b/ruoyi-ui/src/views/data/price/ArtificialResidenceSalePrice.vue @@ -167,7 +167,7 @@ @pagination="getList" /> - <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> + <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-upload ref="upload" :limit="1" @@ -196,64 +196,6 @@ </div> </el-dialog> </div> - - <!-- 添加或修改办公基价对话框 --> - <!-- <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> - <el-form ref="form" :model="form" :rules="rules" label-width="160px"> - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="小区ID"> - <el-input v-model="form.communityId" disabled="true" readonly /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="楼栋ID"> - <el-input v-model="form.buildingId" disabled="true" readonly /> - </el-form-item> - </el-col> - </el-row> - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="主力基价(元/㎡)"> - <el-input v-model="form.mainPrice" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="主力租金(元/月·㎡)"> - <el-input v-model="form.mainPriceRent" /> - </el-form-item> - </el-col> - </el-row> - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="主力基价涨跌幅"> - <el-input v-model="form.mainPricePst" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="主力租金涨跌幅"> - <el-input v-model="form.mainPriceRentPst" /> - </el-form-item> - </el-col> - </el-row> - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="主力基价类型"> - <el-input v-model="form.mainPriceType" /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="主力租金类型"> - <el-input v-model="form.mainPriceRentType" /> - </el-form-item> - </el-col> - </el-row> - </el-form> - <div slot="footer" class="dialog-footer"> - <el-button type="primary" @click="submitForm">确 定</el-button> - <el-button @click="cancel">取 消</el-button> - </div> - </el-dialog>--> </template> <script> @@ -343,9 +285,6 @@ export default { }); }, methods: { - // yearMonthChange: function(yearMonth) { - // this.upload.url += "/" + yearMonth; - // }, yesOrNotFormatter: function(row, column, cellValue, index) { if (cellValue) return "是"; return "否"; diff --git a/ruoyi-ui/src/views/data/price/UltimateOfficeBasePrice.vue b/ruoyi-ui/src/views/data/price/UltimateOfficeBasePrice.vue index d51b004e4..92fc962c0 100644 --- a/ruoyi-ui/src/views/data/price/UltimateOfficeBasePrice.vue +++ b/ruoyi-ui/src/views/data/price/UltimateOfficeBasePrice.vue @@ -64,7 +64,7 @@ v-hasPermi="['system:user:import']" >导入</el-button> </el-col> - <el-col :span="1.5"> + <!-- <el-col :span="1.5"> <el-button type="success" icon="el-icon-druid" @@ -72,11 +72,10 @@ @click="handleImport" v-hasPermi="['system:user:import']" >基价变化一览</el-button> - </el-col> + </el-col>--> </el-row> <el-table v-loading="loading" :data="dataList"> - <!-- <el-table-column type="selection" width="55" align="center" /> --> <el-table-column label="年月" align="center" prop="yearMonth" /> <el-table-column label="小区ID" align="center" prop="communityId" width="110" /> <el-table-column label="楼栋ID" align="center" prop="buildingId" width="110" /> @@ -107,7 +106,7 @@ /> <el-table-column label="价格更改说明" align="center" prop="adjustPriceComment" /> <el-table-column label="更新日期" align="center" prop="updateDate" :formatter="dateFormatter" /> - <el-table-column + <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" @@ -122,7 +121,7 @@ v-hasPermi="['system:user:edit']" >修改</el-button> </template> - </el-table-column> + </el-table-column> --> </el-table> <pagination @@ -134,7 +133,7 @@ /> <!-- 添加或修改办公基价对话框 --> - <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> + <!-- <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> <el-form ref="form" :model="form" :rules="updateRules" label-width="160px"> <el-row :gutter="20"> <el-col :span="12"> @@ -165,7 +164,7 @@ <el-form-item label="楼栋地址"> <el-input v-model="form.buildingAddress" disabled readonly /> </el-form-item> - </el-col>--> + </el-col> <el-col :span="24"> <el-form-item label="楼栋地址"> <el-input v-model="form.complexRegion" disabled readonly /> @@ -212,12 +211,12 @@ <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="主力基价涨跌幅"> - <el-input v-model="form.mainPricePst" disabled readonly /> + <el-input v-model="form.mainPricePst" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="主力租金涨跌幅"> - <el-input v-model="form.mainPriceRentPst" disabled readonly /> + <el-input v-model="form.mainPriceRentPst" /> </el-form-item> </el-col> </el-row> @@ -286,21 +285,15 @@ <el-button type="primary" @click="submitForm">确 定</el-button> <el-button @click="cancel">取 消</el-button> </div> - </el-dialog> + </el-dialog> --> - <el-dialog - :title="upload.title" - :visible.sync="upload.open" - width="80%" - top="10vh" - append-to-body - > + <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" - :action="upload.url + '?updateSupport=' + upload.updateSupport" + :action="upload.url" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" @@ -313,7 +306,9 @@ <em>点击上传</em> </div> <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div> - <div class="el-upload__tip" style="color:red" slot="tip">基价年月:{{ queryParams.yearMonth }}</div> + <div class="el-upload__tip" slot="tip"> + <el-alert :title="uploadTips" type="warning" effect="dark" :closable="false"></el-alert> + </div> </el-upload> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitFileForm">确 定</el-button> @@ -377,6 +372,9 @@ export default { title: "", // 是否显示弹出层 open: false, + // 上传提示 + uploadTips: "", + // 年月列表 yearMonthList: [], // 查询参数 queryParams: { @@ -515,33 +513,33 @@ export default { this.multiple = !selection.length; }, /** 修改按钮操作 */ - handleUpdate(row) { - this.reset(); - const id = row.id || this.ids; - const yearMonth = row.yearMonth; - getById(yearMonth, id).then(response => { - // 复合信息 - response.data.complexRegion = - response.data.countyName + - "-" + - response.data.blockName + - "-" + - response.data.loopName + - "-" + - response.data.streetName + - "-" + - response.data.buildingAddress; - // 办公信息 - response.data.complexOfficeInfo = - response.data.officeClass + "-" + response.data.officeLevel; - // 层数信息 - response.data.complexFloorInfo = - response.data.upperFloorSum + "-" + response.data.totalFloorSum; - this.form = response.data; - this.open = true; - this.title = "修改办公基价"; - }); - }, + // handleUpdate(row) { + // this.reset(); + // const id = row.id || this.ids; + // const yearMonth = row.yearMonth; + // getById(yearMonth, id).then(response => { + // // 复合信息 + // response.data.complexRegion = + // response.data.countyName + + // "-" + + // response.data.blockName + + // "-" + + // response.data.loopName + + // "-" + + // response.data.streetName + + // "-" + + // response.data.buildingAddress; + // // 办公信息 + // response.data.complexOfficeInfo = + // response.data.officeClass + "-" + response.data.officeLevel; + // // 层数信息 + // response.data.complexFloorInfo = + // response.data.upperFloorSum + "-" + response.data.totalFloorSum; + // this.form = response.data; + // this.open = true; + // this.title = "修改办公基价"; + // }); + // }, /** 提交按钮 */ submitForm: function() { this.$refs["form"].validate(valid => { @@ -575,8 +573,13 @@ export default { .catch(function() {}); }, handleImport() { - this.upload.title = "办公基价导入"; - this.upload.open = true; + this.$refs["queryForm"].validate(valid => { + if (valid) { + this.upload.title = "办公基价导入"; + this.uploadTips = "当前选中的基价月份:" + this.queryParams.yearMonth; + this.upload.open = true; + } + }); }, // 文件上传中处理 handleFileUploadProgress(event, file, fileList) { diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalOfficeCase.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalOfficeCase.java new file mode 100644 index 000000000..faa460c22 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/domain/OriginalOfficeCase.java @@ -0,0 +1,387 @@ +package com.ruoyi.project.data.cases.domain; + +import java.math.BigDecimal; +import java.util.Date; + +public class OriginalOfficeCase { + /** + * url + */ + private String url; + /** + * 标题 + */ + private String title; + /** + * 容积率 + */ + private String floorAreaRatio; + /** + * 总价 + */ + private String caseTotalPrice; + + /** + * 单价 + */ + private String caseUnitPrice; + /** + * 小区名称 + */ + private String name; + /** + * + */ + private String name_m; + /** + * 楼层信息 + */ + private String caseFloor; + /** + * 面积 + */ + private String area; + /** + * 物业费 + */ + private String managementFee; + /** + * 工位数 + */ + private String seatCount; + /** + * 地址 + */ + private String address; + /** + * 地址 + */ + private String metro; + /** + * 发布日期 + */ + private Date publishDate; + /** + * 房源编号 + */ + private String sourceNo; + /** + * 坐标 + */ + private String lnglat; + private String lng; + private String lat; + /** + * 区域 + */ + private String county; + /** + * 分类(售、租) + */ + private String catalog; + /** + * 来源 + */ + private String source; + /** + * 等级/档次 + */ + private String level; + /** + * 首页 + */ + private String homePageUrl; + /** + * 装修 + */ + private String decoration; + /** + * 类型 + */ + private String type; + /** + * 板块 + */ + private String block; + /** + * 中介 + */ + private String agency; + /** + * 月租金租 + */ + private String rentOfMonthly; + /** + * 标准租金租 + */ + private String rentOfStandard; + + /** + * 得房率 + */ + private String score; + /** + * 总价 + */ + private BigDecimal totalPrice; + /** + * 单价 + */ + private BigDecimal unitPrice; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFloorAreaRatio() { + return floorAreaRatio; + } + + public void setFloorAreaRatio(String floorAreaRatio) { + this.floorAreaRatio = floorAreaRatio; + } + + public String getCaseTotalPrice() { + return caseTotalPrice; + } + + public void setCaseTotalPrice(String caseTotalPrice) { + this.caseTotalPrice = caseTotalPrice; + } + + public String getCaseUnitPrice() { + return caseUnitPrice; + } + + public void setCaseUnitPrice(String caseUnitPrice) { + this.caseUnitPrice = caseUnitPrice; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getName_m() { + return name_m; + } + + public void setName_m(String name_m) { + this.name_m = name_m; + } + + public String getCaseFloor() { + return caseFloor; + } + + public void setCaseFloor(String caseFloor) { + this.caseFloor = caseFloor; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getManagementFee() { + return managementFee; + } + + public void setManagementFee(String managementFee) { + this.managementFee = managementFee; + } + + public String getSeatCount() { + return seatCount; + } + + public void setSeatCount(String seatCount) { + this.seatCount = seatCount; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getMetro() { + return metro; + } + + public void setMetro(String metro) { + this.metro = metro; + } + + public Date getPublishDate() { + return publishDate; + } + + public void setPublishDate(Date publishDate) { + this.publishDate = publishDate; + } + + public String getSourceNo() { + return sourceNo; + } + + public void setSourceNo(String sourceNo) { + this.sourceNo = sourceNo; + } + + public String getLnglat() { + return lnglat; + } + + public void setLnglat(String lnglat) { + this.lnglat = lnglat; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } + + public String getCatalog() { + return catalog; + } + + public void setCatalog(String catalog) { + this.catalog = catalog; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getHomePageUrl() { + return homePageUrl; + } + + public void setHomePageUrl(String homePageUrl) { + this.homePageUrl = homePageUrl; + } + + public String getDecoration() { + return decoration; + } + + public void setDecoration(String decoration) { + this.decoration = decoration; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public String getAgency() { + return agency; + } + + public void setAgency(String agency) { + this.agency = agency; + } + + public String getRentOfMonthly() { + return rentOfMonthly; + } + + public void setRentOfMonthly(String rentOfMonthly) { + this.rentOfMonthly = rentOfMonthly; + } + + public String getRentOfStandard() { + return rentOfStandard; + } + + public void setRentOfStandard(String rentOfStandard) { + this.rentOfStandard = rentOfStandard; + } + + public String getScore() { + return score; + } + + public void setScore(String score) { + this.score = score; + } + + public BigDecimal getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(BigDecimal totalPrice) { + this.totalPrice = totalPrice; + } + + public BigDecimal getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(BigDecimal unitPrice) { + this.unitPrice = unitPrice; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalOfficeCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalOfficeCaseMapper.java new file mode 100644 index 000000000..08e1f6c7c --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/OriginalOfficeCaseMapper.java @@ -0,0 +1,20 @@ +package com.ruoyi.project.data.cases.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; + +@DS("compute") +public interface OriginalOfficeCaseMapper { + /** + * 创建表 + * + * @param yearMonth + */ + void createTable(Integer yearMonth); + + /** + * 创建人工修正表 + * + * @param yearMonth + */ + void createArtificialTable(Integer yearMonth); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalOfficeCaseMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalOfficeCaseMapper.java new file mode 100644 index 000000000..726645a2a --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/project/data/cases/mapper/sync/DownloadOriginalOfficeCaseMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.project.data.cases.mapper.sync; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.ruoyi.project.data.cases.domain.OriginalOfficeCase; + +import java.util.Date; +import java.util.List; + +@DS("test") +public interface DownloadOriginalOfficeCaseMapper { + /** + * 下载案例 + * + * @param startDate + * @param endDate + * @return + */ + List<OriginalOfficeCase> download(Date startDate, Date endDate); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/UltimateOfficeBasePriceController.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/UltimateOfficeBasePriceController.java index 638d01026..2c23ccec9 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/UltimateOfficeBasePriceController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/controller/UltimateOfficeBasePriceController.java @@ -76,15 +76,15 @@ public class UltimateOfficeBasePriceController extends BaseController { return AjaxResult.success(officeBasePriceUltimateService.getById(yearMonth, id)); } - /** - * 修改办公基价 - */ - @PreAuthorize("@ss.hasPermi('system:user:edit')") - @Log(title = "办公基价", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody UltimateOfficeBasePrice officeBasePriceUltimate) { - return toAjax(officeBasePriceUltimateService.update(officeBasePriceUltimate)); - } +// /** +// * 修改办公基价 +// */ +// @PreAuthorize("@ss.hasPermi('system:user:edit')") +// @Log(title = "办公基价", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult update(@RequestBody UltimateOfficeBasePrice officeBasePriceUltimate) { +// return toAjax(officeBasePriceUltimateService.update(officeBasePriceUltimate)); +// } /** * 导出办公基价列表 @@ -99,7 +99,7 @@ public class UltimateOfficeBasePriceController extends BaseController { List<UltimateOfficeBasePrice> list = officeBasePriceUltimateService.selectOfficeBasePriceUltimateList(officeBasePriceUltimate); ExcelUtil<UltimateOfficeBasePrice> util = new ExcelUtil<>(UltimateOfficeBasePrice.class); - return util.exportExcel(list, "办公基价"); + return util.exportExcel(list, "办公基价初始化" + officeBasePriceUltimate.getYearMonth().toString()); } /** 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 f7176dcb2..1a34f0894 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; /** - * 【请填写功能名称】对象 office_base_price_ultimate * * @author ruoyi * @date 2020-05-20 diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateOfficeBasePriceMapper.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateOfficeBasePriceMapper.java index a58806852..c064989db 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateOfficeBasePriceMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/mapper/UltimateOfficeBasePriceMapper.java @@ -63,6 +63,22 @@ public interface UltimateOfficeBasePriceMapper { */ int updateBasePriceStatus(OfficeBasePriceModifyModel officeBasePriceModifyModel); + /** + * 修改状态 + * + * @param officeBasePriceModifyModel + * @return + */ + int updateStatus(OfficeBasePriceModifyModel officeBasePriceModifyModel); + + /** + * 新增状态 + * + * @param officeBasePriceModifyModel + * @return + */ + int insertNewRecord(OfficeBasePriceModifyModel officeBasePriceModifyModel); + /** * 更新当前基价 * diff --git a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateOfficeBasePriceService.java b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateOfficeBasePriceService.java index 664896530..8115463d0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateOfficeBasePriceService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/data/price/service/IUltimateOfficeBasePriceService.java @@ -54,6 +54,12 @@ public interface IUltimateOfficeBasePriceService { */ List<VueSelectModel> getYearMonthList(); + + /** + * 计算 + */ + void compute(); + } 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 0770f2ff8..80a53c796 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 @@ -11,6 +11,9 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.config.UVConfig; import com.ruoyi.project.common.UVResponse; import com.ruoyi.project.common.VueSelectModel; +import com.ruoyi.project.data.cases.domain.OriginalOfficeCase; +import com.ruoyi.project.data.cases.mapper.OriginalOfficeCaseMapper; +import com.ruoyi.project.data.cases.mapper.sync.DownloadOriginalOfficeCaseMapper; import com.ruoyi.project.data.price.domain.OfficeBasePriceModifyModel; import com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice; import com.ruoyi.project.data.price.mapper.UltimateOfficeBasePriceMapper; @@ -20,6 +23,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; +import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -41,6 +48,13 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr private UVConfig uvConfig; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + @Autowired + private DownloadOriginalOfficeCaseMapper downloadOriginalOfficeCaseMapper; + @Autowired + private OriginalOfficeCaseMapper originalOfficeCaseMapper; + private static Integer getLastYearMonth(Integer yearMonth) { Calendar calendar = Calendar.getInstance(); @@ -94,7 +108,7 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr // String url = String.format(uvConfig.getAitificialOfficeBasePriceUrl(), yearMonth, lastYearMonth); // UVResponse<Integer> affectCount = restTemplate.getForObject(url, UVResponse.class); - String rawSql = LoadUtil.loadContent("sql-template/update_office_price.sql"); + String rawSql = LoadUtil.loadContent("sql-template/update_office_price.sql"); Calendar calendar = Calendar.getInstance(); int year = yearMonth / 100; int month = yearMonth % 100; @@ -160,7 +174,7 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr OfficeBasePriceModifyModel officeBasePriceModifyModel = compareYearMonth(inputModel, currentUltimateOfficeBasePrice, lastUltimateOfficeBasePrice); if (null != officeBasePriceModifyModel) { - officeBasePriceUltimateMapper.updateBasePriceStatus(officeBasePriceModifyModel); + officeBasePriceUltimateMapper.updateStatus(officeBasePriceModifyModel); officeBasePriceUltimateMapper.updateBasePriceCopyNew(officeBasePriceModifyModel); } @@ -236,4 +250,61 @@ public class UltimateOfficeBasePriceServiceImpl implements IUltimateOfficeBasePr return officeBasePriceModifyModel; } + + /** + * 计算 + */ + @Override +// @Scheduled(cron = "") + public void compute() { + + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 15); + Date startDate = calendar.getTime(); + Integer lastYearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH) + 1)); + calendar.add(Calendar.MONTH, 1); + Date endDate = calendar.getTime(); + Integer yearMonth = new Integer(String.format("%d%02d", calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH) + 1)); + + before(yearMonth, startDate, endDate); + running(yearMonth, lastYearMonth); + } + + /** + * 创建表 + * + * @param yearMonth + */ + private void before(Integer yearMonth, Date startDate, Date endDate) { + // 创建表 + originalOfficeCaseMapper.createTable(yearMonth); + originalOfficeCaseMapper.createArtificialTable(yearMonth); + // 下载列表 + List<OriginalOfficeCase> downloadList = downloadOriginalOfficeCaseMapper.download(startDate, endDate); + SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(downloadList.toArray()); + namedParameterJdbcTemplate.batchUpdate("insert into dbo.ODS_OFFICECASELISTED_" + yearMonth.toString() + "_RAW" + + "(url, title,容积率,总价售,均价售, 楼盘名称, 楼盘名称_M, 楼层, 面积, 物业费, 工位数, 地址, 地铁, 发布时间, 房源编号, 百度lng, 百度lat, 区域, 分类, " + + "来源, 等级, 楼盘网址, 装修,类型, 板块, 挂牌中介, 月租金租, 标准租金租, 得房率, 总价, 单价) values(:url,:title,:floorAreaRatio," + + ":caseTotalPrice," + + ":caseUnitPrice,:name,:name_m,:caseFloor,:area,:managementFee,:seatCount,:address,:metro," + + ":publishDate,:sourceNo,:lng,:lat,:county,:catalog,:source,:level,:homePageUrl,:decoration," + + ":type,:block,:agency,:rentOfMonthly,:rentOfStandard,:score,:totalPrice,:unitPrice) ", batchParams); + } + + private void running(Integer yearMonth, Integer lastYearMonth) { + + String rawSql = LoadUtil.loadContent("sql-template/compute_office_price.sql"); + String sql = rawSql.replace("#yearMonth#", yearMonth.toString()) + .replace("#lastYearMonth#", lastYearMonth.toString()); + + jdbcTemplate.execute(sql); + } + + private void after() { + + } } diff --git a/ruoyi/src/main/resources/mybatis/data/DownloadOriginalOfficeCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalOfficeCaseMapper.xml new file mode 100644 index 000000000..e10894936 --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/DownloadOriginalOfficeCaseMapper.xml @@ -0,0 +1,49 @@ +<?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.sync.DownloadOriginalOfficeCaseMapper"> + <resultMap id="DownloadMapping" type="com.ruoyi.project.data.cases.domain.OriginalOfficeCase"> + <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="caseFloor" column="楼层"/> + <result property="area" column="面积" javaType="java.math.BigDecimal"/> + <result property="managementFee" column="物业费"/> + <result property="seatCount" column="工位数"/> + <result property="address" column="地址"/> + <result property="metro" column="地铁"/> + <result property="publishDate" column="发布时间" javaType="java.sql.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="score" column="得房率"/> + <result property="totalPrice" column="总价"/> + <result property="unitPrice" column="单价"/> + </resultMap> + <select id="download" resultMap="DownloadMapping"> + select url, title, 容积率, 总价售, 均价售, 楼盘名称, 楼层, 面积, 物业费, 工位数, 地址, 地铁, + 发布时间,房源编号, 百度lng, 百度lat, 区域, 分类, 来源, 等级, 楼盘网址, 装修, + 类型, 板块, 挂牌中介, 月租金租, 标准租金租, 更新时间, 得房率, + case when 分类 = '售' then 总价售 + when 分类 = '租' then 月租金租 end as 总价, + case when 分类 = '售' then 均价售 + when 分类 = '租' then 标准租金租 end as 单价 + from dbo.办公 + where 更新时间 >= #{startDate} and 更新时间 <![CDATA[ < ]]> #{endDate} + </select> +</mapper> \ 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 new file mode 100644 index 000000000..3992a9613 --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/OriginalOfficeCaseMapper.xml @@ -0,0 +1,92 @@ +<?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.OriginalOfficeCaseMapper"> + <update id="createTable"> + <bind name="targetTableName" value="'dbo.ODS_OFFICECASELISTED_' + yearMonth + '_RAW'"/> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + create TABLE ${targetTableName} + ( + ID uniqueidentifier not null primary key, + url varchar (1000) NULL, + title varchar (1000) NULL, + 容积率 varchar (1000) NULL, + 总价售 varchar (1000) NULL, + 均价售 varchar (1000) NULL, + 楼盘名称 varchar (1000) NULL, + 楼盘名称_M nvarchar (512) NULL, + 楼层 varchar (1000) NULL, + 面积 varchar (1000) NULL, + 物业费 varchar (1000) NULL, + 工位数 varchar (1000) NULL, + 地址 varchar (1000) NULL, + 地铁 varchar (1000) NULL, + 发布时间 date NULL, + 房源编号 varchar (1000) NULL, + 百度lng varchar (1000) NULL, + 百度lat varchar (1000) NULL, + 区域 varchar (1000) NULL, + 分类 varchar (1000) NULL, + 来源 varchar (1000) NULL, + 等级 varchar (1000) NULL, + 楼盘网址 varchar (1000) NULL, + 装修 varchar (1000) NULL, + 类型 varchar (1000) NULL, + 板块 varchar (1000) NULL, + 挂牌中介 varchar (1000) NULL, + 月租金租 varchar (1000) NULL, + 标准租金租 varchar (1000) NULL, + 更新时间 varchar (1000) NULL, + 得房率 varchar (1000) NULL, + 总价 decimal (18, 2) NULL, + 单价 decimal (18, 2) NULL + ); + </update> + <!-- 创建人工修正表 --> + <update id="createArtificialTable"> + <bind name="targetTableName" value="'dbo.DWA_PROJECTBASEPRICE_OFFICE_MANU_' + yearMonth"/> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + CREATE TABLE ${targetTableName} + ( + id uniqueidentifier not null, + BuildingID bigint NOT NULL, + UnifiedID bigint NULL, + ProjectID bigint NOT NULL, + BuildingID_P nvarchar (20) NOT NULL, + ProjectID_P bigint NULL, + MainPrice decimal (38, 6) NULL, + MainPriceRent decimal (38, 6) NULL, + MainPricePst decimal (38, 6) NULL, + MainPriceRentPst decimal (38, 6) NULL, + MainPriceType varchar (2) NULL, + MainPriceRentType varchar (2) NULL, + ModifyDate date NULL, + Status nvarchar (30) NULL, + BuildingStd tinyint NULL, + AdjEvd nvarchar (1000) NULL, + MainPrice_1 decimal (38, 6) NULL, + MainPriceRent_1 decimal (38, 6) NULL, + AreaCoff decimal (7, 4) NULL, + YearCoff decimal (7, 4) NULL, + BuildingCoff decimal (7, 4) NULL, + ProjectName nvarchar (1024) NULL, + ProjectAddr nvarchar (1024) NULL, + BuildingAddr nvarchar (1024) NULL, + County nvarchar (512) NULL, + Loop nvarchar (512) NULL, + Block nvarchar (512) NULL, + Street nvarchar (512) NULL, + Year int NULL, + AvgArea decimal (18, 2) NULL, + TotalFloorSum nvarchar (32) NULL, + UpperFloorSum nvarchar (32) NULL, + OfficeClass nvarchar (256) NULL, + Grade nvarchar (64) NULL + ); + </update> +</mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentOpeningCaseMapper.xml b/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentOpeningCaseMapper.xml new file mode 100644 index 000000000..a20ed726d --- /dev/null +++ b/ruoyi/src/main/resources/mybatis/data/OriginalResidenceRentOpeningCaseMapper.xml @@ -0,0 +1,316 @@ +<?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.OriginalResidenceRentOpeningCaseMapper"> + + <update id="createTable"> + <bind name="targetTableName" value="'dbo.original_residence_rent_opening_case_' + yearMonth" /> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + CREATE TABLE ${targetTableName} + ( + case_id varchar (32) NOT NULL, + case_no nvarchar (32) NULL, + case_lianjia_id nvarchar (50) NOT null primary key, + case_lianjia_community_id nvarchar (50) NOT NULL, + case_title nvarchar (500) NOT NULL, + clean_property_type nvarchar (20) NULL, + case_apartment_layout nvarchar (500) NOT NULL, + case_house_structure nvarchar (50) NULL, + case_area decimal (10, 2) NOT NULL, + case_total_area decimal (10, 2) NOT NULL, + case_rent_type nvarchar (20) NULL, + case_status nvarchar (20) NULL, + case_block nvarchar (20) NULL, + case_county nvarchar (20) NULL, + case_loop nvarchar (20) NULL, + case_hall_num int NULL, + case_room_num int NULL, + case_underground_area decimal (10, 2) NULL, + case_toward nvarchar (50) NOT NULL, + clean_toward nvarchar (50) NULL, + case_storey nvarchar (20) NOT NULL, + clean_total_floor int NOT NULL, + clean_current_floor_desc nvarchar (20) NULL, + case_elevator nvarchar (20) NULL, + clean_elevator nvarchar (20) NULL, + case_tihu nvarchar (20) NULL, + case_decoration nvarchar (20) NULL, + clean_decoration nvarchar (50) NULL, + case_year int NOT NULL, + clean_year int NOT NULL, + case_address nvarchar (500) NULL, + case_vid nvarchar (500) NULL, + case_chan_quan_xing_zhi nvarchar (200) NULL, + case_price decimal (18, 2) NOT NULL, + clean_unit_price decimal (18, 2) NOT NULL, + clean_total_price decimal (18, 2) NOT NULL, + case_community_name nvarchar (500) NULL, + case_visited_num int NOT NULL, + case_visited_num_15 int NOT NULL, + case_visited_num_30 int NOT NULL, + case_latest_deal_date date NULL, + case_latest_visited_date date NULL, + case_first_visited_date date NULL, + case_url nvarchar (500) NOT NULL, + case_community_url nvarchar (500) NOT NULL, + case_get_date date NOT NULL, + case_provider nvarchar (50) NOT NULL, + uv_community_name nvarchar (500) NULL, + uv_community_address nvarchar (1024) NULL, + uv_community_id nvarchar (20) NULL, + uv_building_id nvarchar (20) NULL, + uv_county nvarchar (50) NULL, + uv_block nvarchar (50) NULL, + uv_loop nvarchar (50) NULL, + area_coefficient decimal (18, 6) NULL, + toward_coefficient decimal (18, 6) NULL, + floor_coefficient decimal (18, 6) NULL, + decoration_coefficient int NULL, + year_coefficient decimal (18, 6) NULL, + building_coefficient decimal (18, 6) NULL, + adjust_unit_price decimal (18, 2) NULL, + clean_project_level nvarchar (50) NULL, + create_time datetime NOT NULL + ); + </update> + + <update id="createCleanTable"> + <bind name="targetTableName" value="'dbo.ODS_HOUSINGCASELISTED_LJ_' + yearMonth" /> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + CREATE TABLE ${targetTableName} + ( + case_id varchar(32) not null, + HouseholdsID_LJ bigint not null primary key, + ProjectID_LJ bigint null, + ProjectID bigint null, + Roomtype nvarchar(64) null, + Area decimal(18, 2) null, + Towards nvarchar(64) null, + UpperFloorSum nvarchar(32) null, + UpperFloorNum nvarchar(32) null, + Elevator tinyint null, + Decoration nvarchar(64) null, + Year int null, + AreaCoff decimal(7, 4) null, + TowardsCoff decimal(7, 4) null, + FloorCoff decimal(7, 4) null, + DecorationRng int null, + YearCoff decimal(7, 4) null, + BuildingCoff decimal(7, 4) null, + PriceTotal decimal(18, 2) null, + PriceUnit decimal(18, 2) not null, + PriceUnitAdj decimal(18, 2) not null, + Visited_Num int null, + First_Visit_Time date null, + Visited_Num_15 int null, + Visited_Num_30 int null, + Status tinyint null, + AdjustedValue decimal(18, 2) null, + AdjustedPst decimal(18, 6) null, + AdjustedCumValue decimal(18, 2) null, + AdjustedCumPst decimal(18, 6) null, + AdjustedCumValueAbs decimal(18, 2) null, + AdjustedCumPstAbs decimal(18, 6) null, + AdjustedCumNum int null, + PriceTotalIn decimal(18, 2) null, + PriceTotalOut decimal(18, 2) null, + PriceDateIn date null, + PriceDateOut date null + ); + </update> + <update id="createAssembleTable"> + <bind name="targetTableName" value="'dbo.DW_HOUSINGCASE_COMM_' + yearMonth" /> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + create table ${targetTableName} + ( + SID int primary key identity + , case_id varchar(32) not null + , HouseholdsID_LJ bigint + , ProjectID_LJ bigint + , ProjectID bigint --modified + , ProjectName nvarchar(1024) + , ProjectAddr nvarchar(1024) + , County nvarchar(512) + , Block nvarchar(512) + , Loop nvarchar(512) + , Roomtype nvarchar(64) + , Area decimal(18, 2) + , Towards nvarchar(64) + , UpperFloorSum nvarchar(32) + , UpperFloorNum nvarchar(32) + , Elevator tinyint + , Decoration nvarchar(64) + , Year int + , AreaCoff decimal(7, 4) + , TowardsCoff decimal(7, 4) + , FloorCoff decimal(7, 4) + , DecorationRng int + , YearCoff decimal(7, 4) + , BuildingCoff decimal(7, 4) + , BasePrice_1 decimal(18, 2) + , PriceTotal decimal(18, 2) not null + , PriceUnit decimal(18, 2) not null + , PriceUnitAdj decimal(18, 2) not null + , Visited_Num int + , First_Visit_Time date + , Visited_Num_15 int + , Visited_Num_30 int + , Status tinyint + , AdjustedValue decimal(18, 2) + , AdjustedPst decimal(18, 6) + , AdjustedCumValue decimal(18, 2) + , AdjustedCumPst decimal(18, 6) + , AdjustedCumValueAbs decimal(18, 2) + , AdjustedCumPstAbs decimal(18, 6) + , AdjustedCumNum int + , PriceTotalIn decimal(18, 2) + , PriceDateIn date + , CaseType int + , RangeFlag int + ); + </update> + <update id="createComputePriceTable"> + <bind name="targetTableName" value="'dbo.DWA_PROJECTBASEPRICE_IMDT_' + yearMonth" /> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + + create table ${targetTableName} + ( + SID int not null identity(1,1) + , ProjectID nvarchar(20) primary key + , ProjectName nvarchar(1024) + , ProjectAddr nvarchar(1024) + , County nvarchar(512) + , Block nvarchar(512) + , Loop nvarchar(512) + , IsIndxGen tinyint + , IsPstCalc tinyint + , StatusRun tinyint + , ProjectSPLabel nvarchar(64) + , PropertyType nvarchar(256) + , ProjectType nvarchar(256) + , ProjectTypeDtl nvarchar(256) + , ProjectLevel nvarchar(64) + , Year int + , MainArea decimal(18, 2) + , AreaCoff decimal(7, 4) + , YearCoff decimal(7, 4) + , PriceNote nvarchar(1024) + , BasePriceDft decimal(18, 2) + , MainPriceDft decimal(18, 2) + , BasePrice_1 decimal(18, 2) + , PriceUnitAdj decimal(18, 2) + , Visited_Num int + , First_Visit_Time date + , Visited_Num_15 int + , Visited_Num_30 int + , PriceDealMean_1 decimal(18, 2) + , PriceDealMax_1 decimal(18, 2) + , SumDeal_1 int + , PriceDealMean decimal(18, 2) + , PriceDealMax decimal(18, 2) + , SumDeal int + , PriceListedMin decimal(18, 2) + , PriceCase1_ToAI_Pst decimal(18, 6) + , PriceCase2_ToAI_Pst decimal(18, 6) + , PriceCase1_ToLst_Pst decimal(18, 6) + , PriceCase2_ToLst_Pst decimal(18, 6) + , PriceCase1 decimal(18, 2) + , PriceCase1AdjPst decimal(18, 6) + , SumCase1 int + , PriceCase2 decimal(18, 2) + , PriceCase2AdjPst decimal(18, 6) + , SumCase2 int + , VOPPBT varchar(64) + , VOPPB decimal(18, 6) + , BindProjID int + , Bind_Proj_Pst decimal(18, 6) + , Bind_Block_Class nvarchar(128) + , Bind_Block_Class_Pst decimal(18, 6) + , Bind_Block_Plevel nvarchar(128) + , Bind_Block_Plevel_Pst decimal(18, 6) + , Bind_Block_PType nvarchar(128) + , Bind_Block_Ptype_Pst decimal(18, 6) + , Bind_County_PType nvarchar(128) + , Bind_County_Ptype_Pst decimal(18, 6) + , VOPPAT varchar(64) + , VOPPA decimal(18, 6) + ); + </update> + + <!-- 人工修正价格表和作价表一摸一样 --> + <update id="createArtificialPriceTable"> + <bind name="targetTableName" value="'dbo.DWA_PROJECTBASEPRICE_MANU_' + yearMonth" /> + IF OBJECT_ID(#{targetTableName}, 'U') IS NOT NULL + drop table ${targetTableName}; + create table ${targetTableName} + ( + SID int not null identity(1,1) + , ProjectID nvarchar(20) primary key + , ProjectName nvarchar(1024) + , ProjectAddr nvarchar(1024) + , County nvarchar(512) + , Block nvarchar(512) + , Loop nvarchar(512) + , IsIndxGen tinyint + , IsPstCalc tinyint + , StatusRun tinyint + , ProjectSPLabel nvarchar(64) + , PropertyType nvarchar(256) + , ProjectType nvarchar(256) + , ProjectTypeDtl nvarchar(256) + , ProjectLevel nvarchar(64) + , Year int + , MainArea decimal(18, 2) + , AreaCoff decimal(7, 4) + , YearCoff decimal(7, 4) + , PriceNote nvarchar(1024) + , BasePriceDft decimal(18, 2) + , MainPriceDft decimal(18, 2) + , BasePrice_1 decimal(18, 2) + , PriceUnitAdj decimal(18, 2) + , Visited_Num int + , First_Visit_Time date + , Visited_Num_15 int + , Visited_Num_30 int + , PriceDealMean_1 decimal(18, 2) + , PriceDealMax_1 decimal(18, 2) + , SumDeal_1 int + , PriceDealMean decimal(18, 2) + , PriceDealMax decimal(18, 2) + , SumDeal int + , PriceListedMin decimal(18, 2) + , PriceCase1_ToAI_Pst decimal(18, 6) + , PriceCase2_ToAI_Pst decimal(18, 6) + , PriceCase1_ToLst_Pst decimal(18, 6) + , PriceCase2_ToLst_Pst decimal(18, 6) + , PriceCase1 decimal(18, 2) + , PriceCase1AdjPst decimal(18, 6) + , SumCase1 int + , PriceCase2 decimal(18, 2) + , PriceCase2AdjPst decimal(18, 6) + , SumCase2 int + , VOPPBT varchar(64) + , VOPPB decimal(18, 6) + , BindProjID int + , Bind_Proj_Pst decimal(18, 6) + , Bind_Block_Class nvarchar(128) + , Bind_Block_Class_Pst decimal(18, 6) + , Bind_Block_Plevel nvarchar(128) + , Bind_Block_Plevel_Pst decimal(18, 6) + , Bind_Block_PType nvarchar(128) + , Bind_Block_Ptype_Pst decimal(18, 6) + , Bind_County_PType nvarchar(128) + , Bind_County_Ptype_Pst decimal(18, 6) + , VOPPAT varchar(64) + , VOPPA decimal(18, 6) + ); + </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 da5a98e2d..10b23c4c1 100644 --- a/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml +++ b/ruoyi/src/main/resources/mybatis/data/UltimateOfficeBasePriceMapper.xml @@ -122,13 +122,13 @@ <update id="updateBasePrice" parameterType="com.ruoyi.project.data.price.domain.OfficeBasePriceModifyModel"> update ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} set Status=0 where id=#{id}; </update> - <insert id="batchInsertArtificialOfficeBase" > + <insert id="batchInsertArtificialOfficeBase"> insert into dbo.DWA_PROJECTBASEPRICE_OFFICE_MANU_${yearMonth}(ID,BuildingID,ProjectID,County,"Loop",Block,ProjectAddr,ProjectName,Year,AvgArea,TotalFloorSum,UpperFloorSum,OfficeClass,Grade,MainPrice_1,MainPriceRent_1,MainPrice,MainPriceRent,ModifyDate) values - <foreach collection="list" item="item" separator="," > - (#{item.id},#{item.buildingId},#{item.communityId},#{item.countyName},#{item.loopName},#{item.blockName},#{item.communityAddress},#{item.communityName},#{item.year},#{item.avgArea},#{item.totalFloorSum},#{item.upperFloorSum},#{item.officeClass},#{item.officeLevel},#{item.mainPrice_1},#{item.mainPriceRent_1},#{item.mainPrice},#{item.mainPriceRent},getdate()) - </foreach> + <foreach collection="list" item="item" separator=","> + (#{item.id},#{item.buildingId},#{item.communityId},#{item.countyName},#{item.loopName},#{item.blockName},#{item.communityAddress},#{item.communityName},#{item.year},#{item.avgArea},#{item.totalFloorSum},#{item.upperFloorSum},#{item.officeClass},#{item.officeLevel},#{item.mainPrice_1},#{item.mainPriceRent_1},#{item.mainPrice},#{item.mainPriceRent},getdate()) + </foreach> </insert> <!-- 更新基价 --> <insert id="updateBasePriceCopyNew" parameterType="com.ruoyi.project.data.price.domain.OfficeBasePriceModifyModel"> @@ -214,4 +214,82 @@ insert into dbo.DWA_PROJECTBASEPRICE_OFFICE_MANU_${yearMonth}(ID,BuildingID,ProjectID,County,"Loop",Block,ProjectAddr,ProjectName,Year,AvgArea,TotalFloorSum,UpperFloorSum,OfficeClass,Grade,MainPrice_1,MainPriceRent_1,MainPrice,MainPriceRent,ModifyDate) values(#{id},#{buildingId},#{communityId},#{countyName},#{loopName},#{blockName},#{communityAddress},#{communityName},#{year},#{avgArea},#{totalFloorSum},#{upperFloorSum},#{officeClass},#{officeLevel},#{mainPrice_1},#{mainPriceRent_1},#{mainPrice},#{mainPriceRent},getdate()) </insert> + <!-- 更新状态 --> + <update id="updateStatus"> + update ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} set Status=0 where id=#{id}; + </update> + <!-- 新增记录 --> + <update id="insertNewRecord"> + insert into dbo.ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} + ( + BuildingID + , UnifiedID + , ProjectID + , BuildingID_P + , ProjectID_P + , MainPrice + , MainPriceRent + , MainPricePst + , MainPriceRentPst + , MainPriceType + , MainPriceRentType + , ModifyDate + , Status + , BuildingStd + , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade + ) + select BuildingID + , UnifiedID + , ProjectID + , BuildingID_P + , ProjectID_P + , #{mainPrice} + , #{mainPriceRent} + , #{mainPricePst} + , #{mainPriceRentPst} + , #{mainPriceType} + , #{mainPriceRentType} + , getdate() + , 1 + , BuildingStd + , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade + from ODS_OFFICE_BUILDING_PRICE_INFO_${yearMonth} + where id=#{id}; + </update> </mapper> \ No newline at end of file diff --git a/ruoyi/src/main/resources/sql-template/compute_office_price.sql b/ruoyi/src/main/resources/sql-template/compute_office_price.sql new file mode 100644 index 000000000..686f15e3b --- /dev/null +++ b/ruoyi/src/main/resources/sql-template/compute_office_price.sql @@ -0,0 +1,328 @@ + --区县处理 +update ODS_OFFICECASELISTED_#yearMonth#_RAW +set [区域] = left([区域],2); + +--楼盘名称中括号处理 +update ODS_OFFICECASELISTED_#yearMonth#_RAW +set [楼盘名称_M] = STUFF([楼盘名称], patindex('%(%',[楼盘名称]),patindex('%)%',[楼盘名称])-patindex('%(%',[楼盘名称])+1,'') + +----索引匹配 +--搜房 +---(2019.07.09)删除DIM_OFFICE_PROJECTID_SF2AI 中同一BuildingID对应不同UnifiedID的记录 +select distinct a.SID, + case when b.BuildingID_P is not null then b.BuildingID_P + when c.BuildingID_P is not null then c.BuildingID_P + else d.BuildingID_P end as BuildingID_P, + case when b.ProjectID_P is not null then b.ProjectID_P + when c.ProjectID_P is not null then c.ProjectID_P + else d.ProjectID_P end as ProjectID_P +into #AddressMatchSF +from ODS_OFFICECASELISTED_#yearMonth#_RAW a +left join DIM_OFFICE_PROJECTID_SF2AI_201909 b +on a.[来源]='房天下' and (a.[楼盘名称] = b.ProjectName_SF or a.[楼盘名称_M] = b.ProjectName_SF) and (a.[地址] = b.Address_SF or a.[地址] = b.AddressF_SF) and a.[区域] = b.Area_SF +left join DIM_OFFICE_PROJECTID_SF2AI_201909 c +on a.[来源]='房天下' and 'http:'+a.[楼盘网址] = c.Curl +left join DIM_OFFICE_PROJECTID_SF2AI_201909 d +on a.[来源]='房天下' and (a.[地址] =d.Address_SF or a.[地址] =d.AddressF_SF) and a.[区域] = d.Area_SF and a.[板块] = d.Block_SF +where b.ID_SF is not null or c.ID_SF is not null or d.ID_SF is not null + +--安居客 +select distinct a.SID, b.BuildingID_P, b.ProjectID_P +into #AddressMatchAJK +from ODS_OFFICECASELISTED_#yearMonth#_RAW a +left join DIM_OFFICE_PROJECTID_AJK2AI_201909 b +on a.[来源]='安居客' and (a.[楼盘名称] = b.ProjectName_AJK or a.[楼盘名称_M] = b.ProjectName_AJK or a.[地址] = b.Address_AJK or a.[地址] = b.AddressF_AJK) and (a.[区域] = b.Area_AJK or a.[板块] = b.Block_AJK) +where b.ID_AJK is not null; + +----修正系数匹配及修正 +----价格(主力基价或租金)偏离幅度q: +----1)有基价的案例:q=修正后案例单价/上期基价-1; +--- 2)无基价的案例:q=修正后案例单价/(AVERAGE(上期修正案例均价,当期修正案例均价))-1 +--- //////20190620优化:1) 可用案例偏离幅度修改为6%。 2) 剔除不在DIM_OFFICE_PROJECT_BUILDING_201909 中的楼栋 +--- //////20200325优化:案例整合表中新增没有地址匹配到的案例 + +with ListedPriceAvg_1 as( + select BuildingID_P, ProjectID_P, avg(ListedPrice) as ListedPrice_1, avg(ListedPriceRent) as ListedPriceRent_1 + from DW_OFFICECASE_COMM_#lastYearMonth# + group by BuildingID_P, ProjectID_P +), +coff as( + select a.*, b.BuildingID_P, b.ProjectID_P, c.TotalFloorSum , + cast(case when a.[楼层]='低区' then 0.96 + when c.TotalFloorSum>=30 then 1.04 + else 1 end as DECIMAL(7,4)) as FloorCoff, + cast(case when a.[装修]='精装修' then 1.04 + else 1 end as DECIMAL(7,4)) as DecorationCoff + from ODS_OFFICECASELISTED_#yearMonth#_RAW a + left join (select * from #AddressMatchSF union select * from #AddressMatchAJK) b + on a.SID = b.SID + left join DIM_OFFICE_PROJECT_BUILDING_201909 c + on b.BuildingID_P = c.BuildingID_P and c.EffDate <= getdate() AND c.ExpirDate > getdate() +), +ListedPriceAvg as( + select BuildingID_P, ProjectID_P, + avg(case when [分类]='售' then [单价] end) as ListedPrice, + avg(case when [分类]='租' then [单价] end) as ListedPriceRent + from coff group by BuildingID_P, ProjectID_P +), +ListedPriceAvg_0_1 as( + select BuildingID_P, ProjectID_P, avg(Price) as ListedPrice_0_1, avg(PriceRent) as ListedPriceRent_0_1 + from ( + select BuildingID_P, ProjectID_P, ListedPrice_1 as Price, ListedPriceRent_1 as PriceRent from ListedPriceAvg_1 + union + select BuildingID_P, ProjectID_P, ListedPrice as Price, ListedPriceRent as PriceRent from ListedPriceAvg + ) a group by BuildingID_P, ProjectID_P +) +select a.*, isnull(a.[单价],0)*1.0/FloorCoff/DecorationCoff as PriceAmend, + b.MainPrice MainPrice_1, b.MainPriceRent MainPriceRent_1, + e.ListedPrice_1, e.ListedPriceRent_1, d.ListedPrice, d.ListedPriceRent, + case when a.[分类]='售' and isnull(b.MainPrice,0)<>0 then isnull(a.[单价],0)*1.0/FloorCoff/DecorationCoff/b.MainPrice-1 + when a.[分类]='售' and isnull(b.MainPrice,0)= 0 then isnull(a.[单价],0)*1.0/FloorCoff/DecorationCoff/isnull(c.ListedPrice_0_1, 1)-1 + when a.[分类]='租' and isnull(b.MainPriceRent,0)<>0 then isnull(a.[单价],0)*1.0/FloorCoff/DecorationCoff/b.MainPriceRent-1 + when a.[分类]='租' and isnull(b.MainPriceRent,0)= 0 then isnull(a.[单价],0)*1.0/FloorCoff/DecorationCoff/isnull(c.ListedPriceRent_0_1, 1)-1 + end as VOPP +into DW_OFFICECASE_COMM_#yearMonth# +from coff a +left join (select BuildingID_P, ProjectID_P, MainPrice, MainPriceRent from ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# where Status = 1 and BuildingStd = 1) b ---BuildingStd=1:取5000左右的活跃的楼栋(标准楼栋); Status=1当前有效 +on a.BuildingID_P = b.BuildingID_P +left join ListedPriceAvg_0_1 c on a.BuildingID_P = c.BuildingID_P +left join ListedPriceAvg d on a.BuildingID_P = d.BuildingID_P +left join ListedPriceAvg_1 e on a.BuildingID_P = e.BuildingID_P + +alter table DW_OFFICECASE_COMM_#yearMonth# add VOPPT nvarchar(32); + +update DW_OFFICECASE_COMM_#yearMonth# + set VOPPT = + case when [分类]='售' and abs(VOPP)>0.3 then 's:gt:30%' + when [分类]='售' and abs(VOPP)>0.2 then 's:gt:20%' + when [分类]='售' and abs(VOPP)>0.1 then 's:gt:10%' + when [分类]='售' and abs(VOPP)>0.06 then 's:gt:6%' + when [分类]='售' then 's:lte:6%' + when [分类]='租' and abs(VOPP)>0.3 then 'r:gt:30%' + when [分类]='租' and abs(VOPP)>0.2 then 'r:gt:20%' + when [分类]='租' and abs(VOPP)>0.1 then 'r:gt:10%' + when [分类]='租' and abs(VOPP)>0.06 then 'r:gt:6%' + when [分类]='租' then 'r:lte:6%' end; + +---根据楼栋汇总 +select BuildingID_P, ProjectID_P, + MainPrice_1, --上期基价 + MainPriceRent_1, --上期租金 + cast(avg(case when a.VOPPT='s:lte:6%' and a.PriceAmend<>0 then a.PriceAmend end) as decimal(18,2)) as MainPrice, --剔除案例修正价格为0的和空的(avg函数自动剔除空值不参与运算) + cast(avg(case when a.VOPPT='r:lte:6%' and a.PriceAmend<>0 then a.PriceAmend end) as decimal(18,2)) as MainPriceRent, + cast(avg(case when a.VOPPT='s:lte:6%' then a.VOPP end) as DECIMAL(18,6)) as MainPricePst, + cast(avg(case when a.VOPPT='r:lte:6%' then a.VOPP end) as DECIMAL(18,6)) as MainPriceRentPst +Into #BuildingPriceWithCase +from DW_OFFICECASE_COMM_#yearMonth# a +where VOPPT in ('s:lte:6%','r:lte:6%') +group by BuildingID_P, ProjectID_P, MainPrice_1, MainPriceRent_1 + +---绑定涨跌幅 +--绑定同一办公项目 +select a.BuildingID_P, a.ProjectID_P, a.ProjectName, a.ProjectAddr, a.BuildingAddr, a.County, a.Loop, a.Block, a.Street, + a.[Year], a.AvgArea, a.TotalFloorSum, a.UpperFloorSum, a.OfficeClass, a.Grade, + case when c.MainPricePst is not null then c.MainPricePst + when b.MainPricePst is not null then b.MainPricePst end as MainPricePst, + case when c.MainPriceRentPst is not null then c.MainPriceRentPst + when b.MainPriceRentPst is not null then b.MainPriceRentPst end as MainPriceRentPst, + case when c.MainPricePst is not null then 't' + when b.MainPricePst is not null then 't0' end as MainPriceType, + case when c.MainPriceRentPst is not null then 't' + when b.MainPriceRentPst is not null then 't0' end as MainPriceRentType +into #TempBindUnifiedID +from DIM_OFFICE_PROJECT_BUILDING_201909 a +left join ( + select ProjectID_P, avg(MainPricePst) MainPricePst, avg(MainPriceRentPst) MainPriceRentPst + from #BuildingPriceWithCase group by ProjectID_P +)b on a.ProjectID_P = b.ProjectID_P +left join #BuildingPriceWithCase c +on a.BuildingID_P= c.BuildingID_P +where (b.ProjectID_P is not null or c.BuildingID_P is not null) and a.EffDate <= getdate() AND a.ExpirDate > getdate() +go + +--竣工日期<=5年+同一办公分类+ 同一街道 +with BindStreet as( + select a.*, b.BuildingID_P BuildingID_B, b.ProjectID_P ProjectID_B, b.MainPricePst, b.MainPriceRentPst, b.MainPriceType, b.MainPriceRentType + from DIM_OFFICE_PROJECT_BUILDING_201909 a + inner join #TempBindUnifiedID b + on abs(a.[Year]-b.[Year])<=5 and a.OfficeClass = b.OfficeClass and (a.OfficeClass is not null and a.OfficeClass<>'未确定') and a.Street = b.Street +) +select a.BuildingID_P, a.ProjectID_P, a.ProjectName, a.ProjectAddr, a.BuildingAddr, a.County, a.Loop, a.Block, a.Street, + a.[Year], a.AvgArea, a.TotalFloorSum, a.UpperFloorSum, a.OfficeClass, a.Grade, + case when c.MainPricePst is not null then c.MainPricePst + when b.MainPricePst is not null then b.MainPricePst end as MainPricePst, + case when c.MainPriceRentPst is not null then c.MainPriceRentPst + when b.MainPriceRentPst is not null then b.MainPriceRentPst end as MainPriceRentPst, + case when c.MainPricePst is not null then c.MainPriceType + when b.MainPricePst is not null then 't1' end as MainPriceType, + case when c.MainPriceRentPst is not null then c.MainPriceRentType + when b.MainPriceRentPst is not null then 't1' end as MainPriceRentType +into #TempBindStreet +from DIM_OFFICE_PROJECT_BUILDING_201909 a +left join ( + select BuildingID_P, ProjectID_P, avg(MainPricePst) MainPricePst, avg(MainPriceRentPst) MainPriceRentPst + from BindStreet group by BuildingID_P, ProjectID_P +) b on a.BuildingID_P = b.BuildingID_P +left join #TempBindUnifiedID c +on a.BuildingID_P= c.BuildingID_P +where (b.ProjectID_P is not null or c.BuildingID_P is not null) and a.EffDate <= getdate() AND a.ExpirDate > getdate() +go + +--竣工日期<=5年+同一办公分类+ 同一板块 +with BindBlock as( + select a.*, b.BuildingID_P BuildingID_B, b.ProjectID_P ProjectID_B, b.MainPricePst, b.MainPriceRentPst, b.MainPriceType, b.MainPriceRentType + from DIM_OFFICE_PROJECT_BUILDING_201909 a + inner join #TempBindStreet b + on abs(a.[Year]-b.[Year])<=5 and a.OfficeClass = b.OfficeClass and (a.OfficeClass is not null and a.OfficeClass<>'未确定') and a.Block = b.Block +) +select a.BuildingID_P, a.ProjectID_P, a.ProjectName, a.ProjectAddr, a.BuildingAddr, a.County, a.Loop, a.Block, a.Street, + a.[Year], a.AvgArea, a.TotalFloorSum, a.UpperFloorSum, a.OfficeClass, a.Grade, + case when c.MainPricePst is not null then c.MainPricePst + when b.MainPricePst is not null then b.MainPricePst end as MainPricePst, + case when c.MainPriceRentPst is not null then c.MainPriceRentPst + when b.MainPriceRentPst is not null then b.MainPriceRentPst end as MainPriceRentPst, + case when c.MainPricePst is not null then c.MainPriceType + when b.MainPricePst is not null then 't2' end as MainPriceType, + case when c.MainPriceRentPst is not null then c.MainPriceRentType + when b.MainPriceRentPst is not null then 't2' end as MainPriceRentType +into #TempBindBlock +from DIM_OFFICE_PROJECT_BUILDING_201909 a +left join ( + select BuildingID_P, ProjectID_P, avg(MainPricePst) MainPricePst, avg(MainPriceRentPst) MainPriceRentPst + from BindBlock group by BuildingID_P, ProjectID_P +) b on a.BuildingID_P = b.BuildingID_P +left join #TempBindStreet c +on a.BuildingID_P= c.BuildingID_P +where(b.ProjectID_P is not null or c.BuildingID_P is not null) and a.EffDate <= getdate() AND a.ExpirDate > getdate() +go + +--竣工日期<=5年+同一办公分类+ 同一区域 +with BindCounty as( + select a.*, b.BuildingID_P BuildingID_B, b.ProjectID_P ProjectID_B, b.MainPricePst, b.MainPriceRentPst, b.MainPriceType, b.MainPriceRentType + from DIM_OFFICE_PROJECT_BUILDING_201909 a + inner join #TempBindBlock b + on abs(a.[Year]-b.[Year])<=5 and a.OfficeClass = b.OfficeClass and (a.OfficeClass is not null and a.OfficeClass<>'未确定') and a.County = b.County +) +select a.BuildingID_P, a.ProjectID_P, a.ProjectName, a.ProjectAddr, a.BuildingAddr, a.County, a.Loop, a.Block, a.Street, + a.[Year], a.AvgArea, a.TotalFloorSum, a.UpperFloorSum, a.OfficeClass, a.Grade, + case when c.MainPricePst is not null then c.MainPricePst + when b.MainPricePst is not null then b.MainPricePst end as MainPricePst, + case when c.MainPriceRentPst is not null then c.MainPriceRentPst + when b.MainPriceRentPst is not null then b.MainPriceRentPst end as MainPriceRentPst, + case when c.MainPricePst is not null then c.MainPriceType + when b.MainPricePst is not null then 't3' end as MainPriceType, + case when c.MainPriceRentPst is not null then c.MainPriceRentType + when b.MainPriceRentPst is not null then 't3' end as MainPriceRentType +into #TempBindCounty +from DIM_OFFICE_PROJECT_BUILDING_201909 a +left join ( + select BuildingID_P, ProjectID_P, avg(MainPricePst) MainPricePst, avg(MainPriceRentPst) MainPriceRentPst + from BindCounty group by BuildingID_P, ProjectID_P +) b on a.BuildingID_P = b.BuildingID_P +left join #TempBindBlock c +on a.BuildingID_P= c.BuildingID_P +where (b.ProjectID_P is not null or c.BuildingID_P is not null) and a.EffDate <= getdate() AND a.ExpirDate > getdate() +go + +--竣工日期<=5年+同一办公分类+ 同一环线 +with BindLoop as( + select a.*, b.BuildingID_P BuildingID_B, b.ProjectID_P ProjectID_B, b.MainPricePst, b.MainPriceRentPst, b.MainPriceType, b.MainPriceRentType + from DIM_OFFICE_PROJECT_BUILDING_201909 a + inner join #TempBindCounty b + on abs(a.[Year]-b.[Year])<=5 and a.OfficeClass = b.OfficeClass and (a.OfficeClass is not null and a.OfficeClass<>'未确定') and a.Loop = b.Loop +) +select a.BuildingID_P, a.ProjectID_P, a.ProjectName, a.ProjectAddr, a.BuildingAddr, a.County, a.Loop, a.Block, a.Street, + a.[Year], a.AvgArea, a.TotalFloorSum, a.UpperFloorSum, a.OfficeClass, a.Grade, + case when c.MainPricePst is not null then c.MainPricePst + when b.MainPricePst is not null then b.MainPricePst end as MainPricePst, + case when c.MainPriceRentPst is not null then c.MainPriceRentPst + when b.MainPriceRentPst is not null then b.MainPriceRentPst end as MainPriceRentPst, + case when c.MainPricePst is not null then c.MainPriceType + when b.MainPricePst is not null then 't4' end as MainPriceType, + case when c.MainPriceRentPst is not null then c.MainPriceRentType + when b.MainPriceRentPst is not null then 't4' end as MainPriceRentType +into #TempBindLoop +from DIM_OFFICE_PROJECT_BUILDING_201909 a +left join ( + select BuildingID_P, ProjectID_P, avg(MainPricePst) MainPricePst, avg(MainPriceRentPst) MainPriceRentPst + from BindLoop group by BuildingID_P, ProjectID_P +) b on a.BuildingID_P = b.BuildingID_P +left join #TempBindCounty c +on a.BuildingID_P= c.BuildingID_P +where (b.ProjectID_P is not null or c.BuildingID_P is not null) and a.EffDate <= getdate() AND a.ExpirDate > getdate() +go + +---添加上期基价 +---///非t~t4,且上期价格非空,且上期价格类型非t5,则另当期基价类型为t5 +select newid() as id + , a.BuildingID + , a.UnifiedID + , a.ProjectID + , a.BuildingID_P + , a.ProjectID_P + , c.MainPrice * (1 + isnull(b.MainPricePst, 0)) as MainPrice + , c.MainPriceRent * (1 + isnull(b.MainPriceRentPst, 0)) as MainPriceRent + , case + when b.MainPricePst is not null then + b.MainPricePst + when c.MainPrice is not null then + 0 + end MainPricePst + , case + when b.MainPriceRentPst is not null then + b.MainPriceRentPst + when c.MainPriceRent is not null then + 0 + end MainPriceRentPst + , case + when b.MainPriceType is not null then + b.MainPriceType + when c.MainPrice is not null then + 't5' + end as MainPriceType + , case + when b.MainPriceRentType is not null then + b.MainPriceRentType + when c.MainPriceRent is not null then + 't5' + end as MainPriceRentType + , cast(getdate() as date) ModifyDate + , cast(1 as nvarchar) Status + , a.BuildingStd + , cast(null as nvarchar(1000)) as AdjEvd + , c.MainPrice as MainPrice_1 + , c.MainPriceRent as MainPriceRent_1 + , a.AreaCoff as AreaCoff + , a.YearCoff as YearCoff + , a.BuildingCoff as BuildingCoff + , a.ProjectName as ProjectName + , a.ProjectAddr as ProjectAddr + ,a.BuildingAddr as BuildingAddr + ,a.County as County + ,a.Loop as Loop + ,a.Block as Block + ,a.Street as Street + ,a.Year as Year + ,a.AvgArea as AvgArea + ,a.TotalFloorSum as TotalFloorSum + ,a.UpperFloorSum as UpperFloorSum + ,a.OfficeClass as OfficeClass + ,a.Grade as Grade +into ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# +from DIM_OFFICE_PROJECT_BUILDING_201909 a + left join #TempBindLoop b + on a.BuildingID_P = b.BuildingID_P + left join ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# c + on a.BuildingID_P = c.BuildingID_P +where a.EffDate <= getdate() + and a.ExpirDate > getdate() + and c.Status = 1; + +drop table #AddressMatchSF +drop table #AddressMatchAJK +drop table #BuildingPriceWithCase +drop table #TempBindUnifiedID +drop table #TempBindStreet +drop table #TempBindBlock +drop table #TempBindCounty +drop table #TempBindLoop \ No newline at end of file diff --git a/ruoyi/src/main/resources/sql-template/update_office_price.sql b/ruoyi/src/main/resources/sql-template/update_office_price.sql index fd008d2e5..a9d70da37 100644 --- a/ruoyi/src/main/resources/sql-template/update_office_price.sql +++ b/ruoyi/src/main/resources/sql-template/update_office_price.sql @@ -1,105 +1,45 @@ -select a.BuildingID as BuildingID_P - , a.ProjectID as ProjectID_P - , a.MainPrice - , a.MainPriceRent - , a.MainPrice_1 - , a.MainPriceRent_1 - , getdate() as ModifyDate - , case - when b.BuildingID is not null - and cast(a.MainPrice as decimal(18, 1)) <> cast(isnull(b.MainPrice, 0) as decimal(18, 1)) then - 1 - else - 0 - end as MainPriceChg - , case - when b.BuildingID is not null - and cast(a.MainPriceRent as decimal(18, 1)) <> cast(isnull(b.MainPriceRent, 0) as decimal(18, 1)) then - 1 - else - 0 - end as MainPriceRentChg - , case - when c.BuildingID is not null - and cast(a.MainPrice_1 as decimal(18, 1)) <> cast(isnull(c.MainPrice, 0) as decimal(18, 1)) then - 1 - else - 0 - end as MainPrice_1Chg - , case - when c.BuildingID is not null - and cast(a.MainPriceRent_1 as decimal(18, 1)) <> cast(isnull(c.MainPriceRent, 0) as decimal(18, 1)) then - 1 - else - 0 - end as MainPriceRent_1Chg +select a.BuildingID_p, a.ProjectID_p, a.MainPrice, a.MainPriceRent, a.MainPrice_1, a.MainPriceRent_1, + getdate() as ModifyDate, + case when b.BuildingID is not null and cast(a.MainPrice as decimal(18,1)) <> cast(isnull(b.MainPrice, 0) as decimal(18,1)) then 1 else 0 end as MainPriceChg, --指当期基价变化 + case when b.BuildingID is not null and cast(a.MainPriceRent as decimal(18,1)) <> cast(isnull(b.MainPriceRent, 0) as decimal(18,1)) then 1 else 0 end as MainPriceRentChg, --指当期租金变化 + case when c.BuildingID is not null and cast(a.MainPrice_1 as decimal(18,1)) <> cast(isnull(c.MainPrice, 0) as decimal(18,1)) then 1 else 0 end as MainPrice_1Chg, --指上期基价变化 + case when c.BuildingID is not null and cast(a.MainPriceRent_1 as decimal(18,1)) <> cast(isnull(c.MainPriceRent, 0) as decimal(18,1)) then 1 else 0 end as MainPriceRent_1Chg --指上期租金变化 into #InfoChg -from dbo.DWA_PROJECTBASEPRICE_OFFICE_MANU_#yearMonth# a - left join ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# b - on a.BuildingID = b.BuildingID_P - and b.Status = 1 - and - ( - cast(a.MainPrice as decimal(18, 1)) <> cast(isnull(b.MainPrice, 0) as decimal(18, 1)) - or cast(a.MainPriceRent as decimal(18, 1)) <> cast(isnull(b.MainPriceRent, 0) as decimal(18, 1)) - ) - left join ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# c - on a.BuildingID = c.BuildingID_P - and c.Status = 1 - and - ( - cast(a.MainPrice_1 as decimal(18, 1)) <> cast(isnull(c.MainPrice, 0) as decimal(18, 1)) - or cast(a.MainPriceRent_1 as decimal(18, 1)) <> cast(isnull(c.MainPriceRent, 0) as decimal(18, 1)) - ) -where b.BuildingID_P is not null - or c.BuildingID_P is not null; +from DWA_PROJECTBASEPRICE_OFFICE_MANU_#yearMonth# a +left join ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# b +on a.BuildingID = b.BuildingID and b.status=1 and ( + cast(a.MainPrice as decimal(18,1)) <> cast(isnull(b.MainPrice, 0) as decimal(18,1)) or + cast(a.MainPriceRent as decimal(18,1)) <> cast(isnull(b.MainPriceRent, 0) as decimal(18,1))) +left join ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# c +on a.BuildingID = c.BuildingID and c.status=1 and ( + cast(a.MainPrice_1 as decimal(18,1)) <> cast(isnull(c.MainPrice, 0) as decimal(18,1)) or + cast(a.MainPriceRent_1 as decimal(18,1)) <> cast(isnull(c.MainPriceRent, 0) as decimal(18,1))) +where b.BuildingID is not null or c.BuildingID is not null; - -select a.UnifiedID - , a.BuildingID_P - , a.ProjectID_P - , b.MainPrice_1 - , b.MainPriceRent_1 - , a.MainPricePst - , a.MainPriceRentPst - , a.MainPriceType - , a.MainPriceRentType - , b.ModifyDate - , 1 as Status - , a.BuildingStd - , case - when MainPrice_1Chg = 0 then - '' - else - 'MainPrice_1Chg|' - end + case - when MainPriceRent_1Chg = 0 then - '' - else - 'MainPriceRent_1Chg|' - end as AdjEvd +--价格调整 +select a.BuildingID, a.UnifiedID, a.ProjectID, a.BuildingID_P, a.ProjectID_P, b.MainPrice_1, b.MainPriceRent_1, + a.MainPricePst, a.MainPriceRentPst, + a.MainPriceType, a.MainPriceRentType, b.ModifyDate, 1 as Status, a.BuildingStd, + case when MainPrice_1Chg=0 then '' else 'MainPrice_1Chg|' end + case when MainPriceRent_1Chg=0 then '' else 'MainPriceRent_1Chg|' end as AdjEvd into #InfoChgLst from ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# a - inner join #InfoChg b - on a.BuildingID_P = b.BuildingID_P -where ( - b.MainPrice_1Chg = 1 - or b.MainPriceRent_1Chg = 1 - ) - and a.Status = 1; +inner join #InfoChg b +on a.BuildingID_p = b.BuildingID_p +where (b.MainPrice_1Chg=1 or b.MainPriceRent_1Chg=1) and a.status=1; update a set a.Status = 0 from ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# a - left join #InfoChgLst b - on a.BuildingID_P = b.BuildingID_P -where b.BuildingID_P is not null - and a.Status = 1; +left join #InfoChgLst b +on a.BuildingID_p = b.BuildingID_P +where b.BuildingID_p is not null and a.status=1; -insert into dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# +insert into ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# ( - ID + id + , BuildingID , UnifiedID + , ProjectID , BuildingID_P , ProjectID_P , MainPrice @@ -112,71 +52,88 @@ insert into dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# , Status , BuildingStd , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade ) -select newid() - , UnifiedID - , BuildingID_P - , ProjectID_P - , MainPrice_1 - , MainPriceRent_1 - , MainPricePst - , MainPriceRentPst - , MainPriceType - , MainPriceRentType - , getdate() - , Status - , BuildingStd - , AdjEvd +select + newid() + , BuildingID + , UnifiedID + , ProjectID + , BuildingID_P + , ProjectID_P + , MainPrice + , MainPriceRent + , MainPricePst + , MainPriceRentPst + , MainPriceType + , MainPriceRentType + , ModifyDate + , Status + , BuildingStd + , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade from #InfoChgLst; -select a.UnifiedID - , a.BuildingID_P - , a.ProjectID_P - , b.MainPrice - , b.MainPriceRent - , b.MainPrice * 1.0 / c.MainPrice as MainPricePst - , b.MainPriceRent * 1.0 / c.MainPriceRent as MainPriceRentPst - , a.MainPriceType - , a.MainPriceRentType - , b.ModifyDate - , 1 as Status - , a.BuildingStd - , case - when MainPriceChg = 0 then - '' - else - 'MainPriceChg|' - end + case - when MainPriceRentChg = 0 then - '' - else - 'MainPriceRentChg|' - end as AdjEvd +--当周期价格调整 +select a.BuildingID, a.UnifiedID, a.ProjectID, a.BuildingID_P, a.ProjectID_P, b.MainPrice, b.MainPriceRent, + b.MainPrice*1.0/c.MainPrice as MainPricePst, b.MainPriceRent*1.0/c.MainPriceRent as MainPriceRentPst, + a.MainPriceType, a.MainPriceRentType, b.ModifyDate, 1 as Status, a.BuildingStd, + case when MainPriceChg=0 then '' else 'MainPriceChg|' end + case when MainPriceRentChg=0 then '' else 'MainPriceRentChg|' end as AdjEvd into #InfoChgCurr -from ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# a - inner join #InfoChg b - on a.BuildingID_P = b.BuildingID_P - left join ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# c - on a.BuildingID = c.BuildingID_P -where ( - b.MainPriceChg = 1 - or b.MainPriceRentChg = 1 - ) - and a.Status = 1 - and c.Status = 1; +from ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# a +inner join #InfoChg b +on a.BuildingID_p = b.BuildingID_p +left join ODS_OFFICE_BUILDING_PRICE_INFO_#lastYearMonth# c +on a.BuildingID_p = c.BuildingID_p +where (b.MainPriceChg=1 or b.MainPriceRentChg=1) and a.status=1 and c.Status=1; update a set a.Status = 0 from ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# a - left join #InfoChgCurr b - on a.BuildingID_P = b.BuildingID_P -where b.BuildingID_P is not null - and a.Status = 1; +left join #InfoChgCurr b +on a.BuildingID_p = b.BuildingID_p +where b.BuildingID_p is not null and a.status=1; insert into dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# ( - ID + id + , BuildingID , UnifiedID + , ProjectID , BuildingID_P , ProjectID_P , MainPrice @@ -189,76 +146,62 @@ insert into dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# , Status , BuildingStd , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade ) -select newid() - , UnifiedID - , BuildingID_P - , ProjectID_P - , MainPrice - , MainPriceRent - , MainPricePst - , MainPriceRentPst - , MainPriceType - , MainPriceRentType - , getdate() - , Status - , BuildingStd - , AdjEvd -from #InfoChgCurr; - +select + newid() + , BuildingID + , UnifiedID + , ProjectID + , BuildingID_P + , ProjectID_P + , MainPrice + , MainPriceRent + , MainPricePst + , MainPriceRentPst + , MainPriceType + , MainPriceRentType + , ModifyDate + , Status + , BuildingStd + , AdjEvd + , MainPrice_1 + , MainPriceRent_1 + , AreaCoff + , YearCoff + , BuildingCoff + , ProjectName + , ProjectAddr + , BuildingAddr + , County + , Loop + , Block + , Street + , Year + , AvgArea + , TotalFloorSum + , UpperFloorSum + , OfficeClass + , Grade +from #InfoChgCurr drop table #InfoChg; -drop table #InfoChgLst; drop table #InfoChgCurr; - - --- 更新上月基价; -update a -set a.ITEM_MAINAREAPRICE = b.MainPrice_1 -from obpm_LianCheng_Data.dbo.TLK_基价信息 a - join dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# b - on a.ITEM_AIRAID = b.ProjectID_P -where a.ITEM_PROJECTTYPE = 2 - and a.ITEM_PRICETYPE = 1 - and a.ITEM_VALUEPOINT = '#lastMonth#' - and b.Status = 1 - and b.BuildingStd = 1; - -update a -set a.ITEM_MAINAREAPRICE = b.MainPriceRent_1 -from obpm_LianCheng_Data.dbo.TLK_基价信息 a - join dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# b - on a.ITEM_AIRAID = b.ProjectID_P -where a.ITEM_PROJECTTYPE = 2 - and a.ITEM_PRICETYPE = 2 - and a.ITEM_VALUEPOINT = '#lastMonth#' - and b.Status = 1 - and b.BuildingStd = 1 - --- 插入本月新增信息; -insert into obpm_LianCheng_Data.dbo.TLK_基价信息 -(LASTMODIFIED,FORMNAME,AUTHOR,AUTHOR_DEPT_INDEX,CREATED,FORMID,ISTMP,VERSIONS,APPLICATIONID,STATEINT,LASTMODIFIER,DOMAINID,AUDITORLIST,COAUDITORLIST,ID,ITEM_PriceID,ITEM_AIRAID,ITEM_PROJECTTYPE,ITEM_PRICETYPE,ITEM_STANDARDPRICE,ITEM_MAINAREAPRICE,ITEM_VALUEPOINT,ITEM_PRICEEXPLAIN,ITEM_UPDATEPERSON,ITEM_UPDATEDATE,ITEM_PRICECHG) -select getdate(),'物业信息管理/基价信息','amQRUkvYQAsAec1JGLp','Os6qe4Pmq5viTO8lTnW',getdate(),'ybte0OakLV17UzAyoVU',0,1,'Ts7TykYmuEzzZgWhXHj',0,'amQRUkvYQAsAec1JGLp','BclzHtmfLQoAA5ICTb5','{}','{}',newid(),newid(),ProjectID_P,2,1,null,MainPrice,'#today#',AdjEvd,'李贺',getdate(),MainPricePst -from dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# a -join obpm_LianCheng_Data.dbo.TLK_基价信息 b - on a.ProjectID_P=b.ITEM_AIRAID and b.ITEM_VALUEPOINT='#today#' and b.ITEM_PRICETYPE=1 -where Status=1 and BuildingStd=1 and b.ID is null; - -insert into obpm_LianCheng_Data.dbo.TLK_基价信息 -(LASTMODIFIED,FORMNAME,AUTHOR,AUTHOR_DEPT_INDEX,CREATED,FORMID,ISTMP,VERSIONS,APPLICATIONID,STATEINT,LASTMODIFIER,DOMAINID,AUDITORLIST,COAUDITORLIST,ID,ITEM_PriceID,ITEM_AIRAID,ITEM_PROJECTTYPE,ITEM_PRICETYPE,ITEM_STANDARDPRICE,ITEM_MAINAREAPRICE,ITEM_VALUEPOINT,ITEM_PRICEEXPLAIN,ITEM_UPDATEPERSON,ITEM_UPDATEDATE,ITEM_PRICECHG) -select getdate(),'物业信息管理/基价信息','amQRUkvYQAsAec1JGLp','Os6qe4Pmq5viTO8lTnW',getdate(),'ybte0OakLV17UzAyoVU',0,1,'Ts7TykYmuEzzZgWhXHj',0,'amQRUkvYQAsAec1JGLp','BclzHtmfLQoAA5ICTb5','{}','{}',newid(),newid(),ProjectID_P,2,2,null,MainPriceRent,'#today#',AdjEvd,'李贺',getdate(),MainPriceRentPst -from dbo.ODS_OFFICE_BUILDING_PRICE_INFO_#yearMonth# a -join obpm_LianCheng_Data.dbo.TLK_基价信息 b - on a.ProjectID_P=b.ITEM_AIRAID and b.ITEM_VALUEPOINT='#today#' and b.ITEM_PRICETYPE=2 -where Status=1 and BuildingStd=1 and b.ID is null; - --- 插入t_document -insert into obpm_LianCheng_Data.dbo.T_DOCUMENT -(ID,LASTMODIFIED,FORMNAME,AUTHOR,AUTHOR_DEPT_INDEX,CREATED,FORMID,ISTMP,VERSIONS,APPLICATIONID,STATEINT,LASTMODIFIER,DOMAINID,AUDITORLIST,COAUDITORLIST,MAPPINGID) - SELECT a.ID,a.LASTMODIFIED,a.FORMNAME,a.AUTHOR,a.AUTHOR_DEPT_INDEX,a.CREATED,a.FORMID,a.ISTMP,a.VERSIONS,a.APPLICATIONID,a.STATEINT,a.LASTMODIFIER,a.DOMAINID,a.AUDITORLIST,a.COAUDITORLIST,a.ID -from obpm_LianCheng_Data.dbo.TLK_基价信息 a - left join obpm_LianCheng_Data.dbo.T_DOCUMENT b - on a.ID = b.ID -where a.ITEM_VALUEPOINT='#today#' and a.ITEM_PROJECTTYPE=2 and b.id is null; - --- 计算之前,更新上个月的价格; +drop table #InfoChgLst; diff --git a/ruoyi/src/test/java/com/uvaluation/compute/MapperXmlGeneratorTests.java b/ruoyi/src/test/java/com/uvaluation/compute/MapperXmlGeneratorTests.java index 6892a87a8..7afde15cc 100644 --- a/ruoyi/src/test/java/com/uvaluation/compute/MapperXmlGeneratorTests.java +++ b/ruoyi/src/test/java/com/uvaluation/compute/MapperXmlGeneratorTests.java @@ -1,5 +1,6 @@ package com.uvaluation.compute; +import com.ruoyi.project.data.cases.domain.OriginalOfficeCase; import com.ruoyi.project.data.price.domain.ComputeResidenceRentBasePrice; import com.ruoyi.project.data.price.domain.UltimateResidenceRentBasePrice; import org.junit.Assert; @@ -10,6 +11,19 @@ import java.util.*; public class MapperXmlGeneratorTests { + @Test + public void test1(){ + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 15); + Date startDate = calendar.getTime(); + System.out.println(startDate.toString()); + calendar.add(Calendar.MONTH, 1); + Date endDate = calendar.getTime(); + System.out.println(endDate.toString()); + } + @Test public void generateBatchInsertSqL() { Class targetClass = UltimateResidenceRentBasePrice .class; @@ -46,4 +60,24 @@ public class MapperXmlGeneratorTests { calendar.get(Calendar.MONTH) + 1)); System.out.println(computeTableRoute); } + + @Test + public void generateBatchInsertMaoHaoSqL() { + Class targetClass = OriginalOfficeCase .class; + + List<Field> fieldList = new ArrayList<>(); + while (targetClass != null) { + fieldList.addAll(new ArrayList<>(Arrays.asList(targetClass.getDeclaredFields()))); + targetClass = targetClass.getSuperclass(); + } + Field[] fields = new Field[fieldList.size()]; + fieldList.toArray(fields); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < fields.length; i++) { + sb.append(":"); + sb.append(fields[i].getName()); + sb.append(","); + } + System.out.println(sb.toString()); + } } diff --git a/ruoyi/src/test/java/com/uvaluation/compute/ResidenceRentBasePriceTests.java b/ruoyi/src/test/java/com/uvaluation/compute/ResidenceRentBasePriceTests.java new file mode 100644 index 000000000..72bd26795 --- /dev/null +++ b/ruoyi/src/test/java/com/uvaluation/compute/ResidenceRentBasePriceTests.java @@ -0,0 +1,50 @@ +package com.uvaluation.compute; + +import com.ruoyi.RuoYiApplication; +import com.ruoyi.project.data.cases.service.IOriginalResidenceRentOpeningCaseService; +import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleClosingCaseService; +import com.ruoyi.project.data.cases.service.IOriginalResidenceSaleOpeningCaseService; +import com.ruoyi.project.data.price.domain.ComputeResidenceSaleBasePrice; +import com.ruoyi.project.data.price.service.IArtificialResidenceSalePriceService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.math.BigDecimal; +import java.util.LinkedList; +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class) +public class ResidenceRentBasePriceTests { + + @Autowired + private IOriginalResidenceRentOpeningCaseService originalResidenceRentOpeningCaseService; + @Autowired + private IArtificialResidenceSalePriceService artificialResidenceSalePriceService; + @Autowired + private IOriginalResidenceSaleClosingCaseService originalResidenceClosingCaseService; + + @Test + public void testClearOpeningCase() { + originalResidenceRentOpeningCaseService.pullData(); + } + + @Test + public void testClearClosingCase() { + originalResidenceClosingCaseService.pullData(); + } + + @Test + public void testBatchImport() { + List<ComputeResidenceSaleBasePrice> list = new LinkedList<>(); + ComputeResidenceSaleBasePrice computeResidenceSaleBasePrice = new ComputeResidenceSaleBasePrice(); + computeResidenceSaleBasePrice.setCommunityId("10101"); + computeResidenceSaleBasePrice.setBasePriceDraft(new BigDecimal(12222)); + list.add(computeResidenceSaleBasePrice); + artificialResidenceSalePriceService.batchImport(202007, list); + } + +}