| | |
| | | */ |
| | | 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 -> |
| | |
| | | for_it.dpGuid = dataProduct.guid |
| | | } |
| | | dataProduct.typeId = Constant.DataProductType.PRO_DETAIL_SUMMARY.value |
| | | dataProductProDetailMapper.insertBatch(let_it) |
| | | insertProDetailSpecificInfo(let_it) |
| | | } |
| | | } |
| | | DataProductTownProAnalysis::class -> { |
| | |
| | | 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) |
| | | } |
| | | } |