From 09c8120288ea7df454c10d67911ab8643f2f4235 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期二, 17 十二月 2024 11:06:33 +0800 Subject: [PATCH] 1. 完成数据产品中间结果基本信息和具体信息入库 --- src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DataProductRep.kt | 65 +++++++++++++++++++------------- 1 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DataProductRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DataProductRep.kt index bd282a9..edc336f 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DataProductRep.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DataProductRep.kt @@ -25,7 +25,7 @@ */ fun insertDataProduct(dataProduct: DataProduct, specificEntities: List<Any>) { // 鏍规嵁绫诲瀷鎻掑叆鎸囧畾鏁版嵁搴撹〃 - if (!ObjectUtils.isEmpty(specificEntities)) { + if (specificEntities.isNotEmpty()) { when (specificEntities.first()::class) { DataProductProDetail::class -> { (specificEntities as? List<DataProductProDetail>)?.let { let_it -> @@ -33,7 +33,7 @@ for_it.dpGuid = dataProduct.guid } dataProduct.typeId = Constant.DataProductType.PRO_DETAIL_SUMMARY.value - dataProductProDetailMapper.insertBatch(let_it) + insertProDetailSpecificInfo(let_it) } } DataProductTownProAnalysis::class -> { @@ -42,33 +42,46 @@ for_it.dpGuid = dataProduct.guid } dataProduct.typeId = Constant.DataProductType.PRO_ANALYSIS_SUMMARY.value - dataProductTownProAnalysisMapper.insertBatch(let_it) + insertTownProAnalysisSpecificInfo(let_it) } } } } - // 琛屾斂鍖哄煙name濉厖 - if (dataProduct.townCode != null) { - townMapper.selectByExample(Example(Town::class.java).apply { - createCriteria().andEqualTo("towncode", dataProduct.townCode) - })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.townName = it.townname ?: "" } - } - if (dataProduct.provinceCode != null) { - provinceMapper.selectByExample(Example(Province::class.java).apply { - createCriteria().andEqualTo("provincecode", dataProduct.provinceCode) - })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.provinceName = it.provincename ?: "" } - } - if (dataProduct.cityCode != null) { - cityMapper.selectByExample(Example(City::class.java).apply { - createCriteria().andEqualTo("citycode", dataProduct.cityCode) - })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.cityName = it.cityname ?: "" } - } - if (dataProduct.districtCode != null) { - districtMapper.selectByExample(Example(District::class.java).apply { - createCriteria().andEqualTo("districtcode", dataProduct.districtCode) - })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.districtName = it.districtname ?: "" } - } - dataProduct.createTime = Date() - dataProductMapper.insert(dataProduct) + insertDataProductBaseInfo(dataProduct) + } + + private fun insertProDetailSpecificInfo(specificEntities: List<DataProductProDetail>) { + dataProductProDetailMapper.insertList(specificEntities) + } + + private fun insertTownProAnalysisSpecificInfo(specificEntities: List<DataProductTownProAnalysis>) { + dataProductTownProAnalysisMapper.insertList(specificEntities) + } + + + private fun insertDataProductBaseInfo(dataProduct: DataProduct) { + // 琛屾斂鍖哄煙name濉厖 + if (dataProduct.townCode != null) { + townMapper.selectByExample(Example(Town::class.java).apply { + createCriteria().andEqualTo("towncode", dataProduct.townCode) + })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.townName = it.townname ?: "" } + } + if (dataProduct.provinceCode != null) { + provinceMapper.selectByExample(Example(Province::class.java).apply { + createCriteria().andEqualTo("provincecode", dataProduct.provinceCode) + })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.provinceName = it.provincename ?: "" } + } + if (dataProduct.cityCode != null) { + cityMapper.selectByExample(Example(City::class.java).apply { + createCriteria().andEqualTo("citycode", dataProduct.cityCode) + })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.cityName = it.cityname ?: "" } + } + if (dataProduct.districtCode != null) { + districtMapper.selectByExample(Example(District::class.java).apply { + createCriteria().andEqualTo("districtcode", dataProduct.districtCode) + })?.takeIf { it.isNotEmpty() }?.get(0)?.let { dataProduct.districtName = it.districtname ?: "" } + } + dataProduct.createTime = Date() + dataProductMapper.insert(dataProduct) } } \ No newline at end of file -- Gitblit v1.9.3