From 1a677d2b4a4bc615602f8c2a22bc07ec1356e5be Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 16 十月 2025 17:39:06 +0800
Subject: [PATCH] 2025.10.16 1. 根据全局响应增强器GlobalResponseAdvice,将原先的BaseResPack接口包装函数统一去除; 2. 新增三种类型的数据产品数据库实体 3. 新增典型问题场景清单中间数据产品接口
---
src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt | 141 +++++++++++++++++++++++++++++++++-------------
1 files changed, 100 insertions(+), 41 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt b/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
index 71e8712..a015e47 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
@@ -3,8 +3,10 @@
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.ExcelUtil
-import cn.flightfeather.supervision.domain.ds1.entity.Scense
+import cn.flightfeather.supervision.domain.ds1.entity.*
import cn.flightfeather.supervision.domain.ds1.repository.RegionRep
+import cn.flightfeather.supervision.lightshare.vo.SceneDetail
+import com.google.gson.Gson
import org.apache.poi.ss.usermodel.CellType
import org.springframework.stereotype.Component
import java.io.InputStream
@@ -17,9 +19,10 @@
class SceneImport(
private val regionRep: RegionRep,
) {
+ // 鍦烘櫙鍏辨湁淇℃伅
private val headers =
listOf(
- ExcelUtil.MyHeader("缂栧彿锛堣嫢涓嶅~鍐欙紝鍒欐寜鐓ч『搴忚嚜鍔ㄦ坊鍔狅級", CellType.NUMERIC),
+ ExcelUtil.MyHeader("缂栧彿锛堝彲鐪佺暐锛�", CellType.NUMERIC, true),
ExcelUtil.MyHeader("鍚嶇О", CellType.STRING),
ExcelUtil.MyHeader("绫诲瀷", CellType.STRING),
ExcelUtil.MyHeader("鍦板潃", CellType.STRING),
@@ -33,51 +36,107 @@
ExcelUtil.MyHeader("鑱旂郴鐢佃瘽", CellType.STRING)
)
+ // 宸ュ湴淇℃伅
+ private val headersType1 = listOf(
+ ExcelUtil.MyHeader("宸ョ▼绫诲瀷", CellType.STRING),
+ ExcelUtil.MyHeader("寤鸿鐘舵��", CellType.STRING),
+ ExcelUtil.MyHeader("鏂藉伐闃舵", CellType.STRING),
+ ExcelUtil.MyHeader("寮�宸ユ椂闂�", CellType.STRING),
+ ExcelUtil.MyHeader("瀹屽伐鏃堕棿", CellType.STRING),
+ ExcelUtil.MyHeader("鍓╀綑宸ユ湡", CellType.STRING),
+ ExcelUtil.MyHeader("鍗犲湴闈㈢Н", CellType.NUMERIC),
+ ExcelUtil.MyHeader("鏂藉伐闈㈢Н", CellType.NUMERIC),
+ ExcelUtil.MyHeader("姣忔湀鏂藉伐闈㈢Н", CellType.NUMERIC),
+ ExcelUtil.MyHeader("涓氫富鍗曚綅", CellType.STRING),
+ ExcelUtil.MyHeader("涓氫富鍗曚綅鑱旂郴浜�", CellType.STRING),
+ ExcelUtil.MyHeader("涓氫富鍗曚綅鑱旂郴鐢佃瘽", CellType.STRING),
+ ExcelUtil.MyHeader("鏂藉伐鍗曚綅", CellType.STRING),
+ ExcelUtil.MyHeader("鏂藉伐鍗曚綅鑱旂郴浜�", CellType.STRING),
+ ExcelUtil.MyHeader("鏂藉伐鍗曚綅鑱旂郴鐢佃瘽", CellType.STRING),
+ ExcelUtil.MyHeader("瀹夊叏鍛�", CellType.STRING),
+ ExcelUtil.MyHeader("瀹夊叏鍛樼數璇�", CellType.STRING),
+ )
+
/**
* 閫氳繃鏂囦欢璇诲彇鍦烘櫙淇℃伅
*/
- fun readFromFile(file: InputStream): List<Scense> {
- val result = mutableListOf<Scense>()
+ fun readFromFile(file: InputStream): List<SceneDetail> {
+ val result = mutableListOf<SceneDetail>()
try {
ExcelUtil.readXLXS(file, headers) {
- val data = Scense().apply {
- guid = null
- name = it.getCell(1)?.stringCellValue?.trim()
- typeid = null
- type = it.getCell(2)?.stringCellValue?.trim()
- scensesubtypeid = null
- scensesubtype = null
- location = it.getCell(3)?.stringCellValue?.trim()
- longitude = it.getCell(4)?.numericCellValue?.toBigDecimal()
- latitude = it.getCell(5)?.numericCellValue?.toBigDecimal()
- provincecode = null
- provincename = it.getCell(6)?.stringCellValue?.trim()
- citycode = null
- cityname = it.getCell(7)?.stringCellValue?.trim()
- districtcode = null
- districtname = it.getCell(8)?.stringCellValue?.trim()
- towncode = null
- townname = it.getCell(9)?.stringCellValue?.trim()
- contactst = it.getCell(11)?.stringCellValue?.trim()
- contactswx = null
- contacts = it.getCell(10)?.stringCellValue?.trim()
- createdate = Date()
- updatedate = Date()
- extension1 = "1"
- extension2 = null
- index = it.getCell(5)?.stringCellValue?.trim()?.toInt()
- remark = null
+ val data = SceneDetail().apply {
+ scense = Scense().apply {
+ guid = null
+ name = it.getCell(1)?.stringCellValue?.trim()
+ typeid = null
+ type = it.getCell(2)?.stringCellValue?.trim()
+ scensesubtypeid = null
+ scensesubtype = null
+ location = it.getCell(3)?.stringCellValue?.trim()
+ longitude = it.getCell(4)?.numericCellValue?.toBigDecimal()
+ latitude = it.getCell(5)?.numericCellValue?.toBigDecimal()
+ provincecode = null
+ provincename = it.getCell(6)?.stringCellValue?.trim()
+ citycode = null
+ cityname = it.getCell(7)?.stringCellValue?.trim()
+ districtcode = null
+ districtname = it.getCell(8)?.stringCellValue?.trim()
+ towncode = null
+ townname = it.getCell(9)?.stringCellValue?.trim()
+ contactst = it.getCell(11)?.stringCellValue?.trim()
+ contactswx = null
+ contacts = it.getCell(10)?.stringCellValue?.trim()
+ createdate = Date()
+ updatedate = Date()
+ extension1 = "1"
+ extension2 = null
+ index = it.getCell(0)?.numericCellValue?.toInt()
+ remark = null
+ }
+ scense?.typeid = Constant.SceneType.getByName(scense?.type)?.value?.toByte()
+ ?: throw BizException(errorStr(it.rowNum + 1, 3, "鍦烘櫙绫诲瀷涓嶅瓨鍦�"))
+ scense?.provincecode = regionRep.findProvince(scense?.provincename)?.provincecode
+ ?: throw BizException(errorStr(it.rowNum + 1, 7, "鐪佷唤閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
+ scense?.citycode = regionRep.findCity(scense?.cityname)?.citycode
+ ?: throw BizException(errorStr(it.rowNum + 1, 8, "鍩庡競閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
+ scense?.districtcode = regionRep.findDistrict(scense?.districtname)?.districtcode
+ ?: throw BizException(errorStr(it.rowNum + 1, 9, "鍖哄幙閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
+ scense?.towncode = regionRep.findTown(scense?.townname)?.towncode
+ ?: throw BizException(errorStr(it.rowNum + 1, 10, "琛楅晣閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
+
+ when (scense?.typeid.toString()) {
+ Constant.SceneType.TYPE1.value -> {
+ subScene = SceneConstructionSite().apply {
+ csProjectType = it.getCell(12)?.stringCellValue?.trim()
+ csStatus = it.getCell(13)?.stringCellValue?.trim()
+ siExtension1 = it.getCell(14)?.stringCellValue?.trim()
+ csStartTime = it.getCell(15)?.stringCellValue?.trim()
+ csEndTime = it.getCell(16)?.stringCellValue?.trim()
+ csLeftTime = it.getCell(17)?.stringCellValue?.trim()
+ csFloorSpace = it.getCell(18)?.numericCellValue?.toString()
+ csConstructionArea = it.getCell(19)?.numericCellValue?.toString()
+ csConstructionAreaPerMonth = it.getCell(20)?.numericCellValue?.toString()
+ csEmployerUnit = it.getCell(21)?.stringCellValue?.trim()
+ csEmployerContacts = it.getCell(22)?.stringCellValue?.trim()
+ csEmployerContactsTel = it.getCell(23)?.stringCellValue?.trim()
+ csConstructionUnit = it.getCell(24)?.stringCellValue?.trim()
+ csConstructionContacts = it.getCell(25)?.stringCellValue?.trim()
+ csConstructionContactsTel = it.getCell(26)?.stringCellValue?.trim()
+ csSecurityOfficer = it.getCell(27)?.stringCellValue?.trim()
+ csSecurityOfficerTel = it.getCell(28)?.stringCellValue?.trim()
+ }
+ }
+ Constant.SceneType.TYPE2.value -> {
+
+ }
+ Constant.SceneType.TYPE3.value -> {
+
+ }
+ Constant.SceneType.TYPE14.value -> {
+
+ }
+ }
}
- data.typeid = Constant.SceneType.getByName(data.type)?.value?.toByte()
- ?: throw BizException(errorStr(it.rowNum + 1, 2, "鍦烘櫙绫诲瀷涓嶅瓨鍦�"))
- data.provincecode = regionRep.findProvince(data.provincename)?.provincecode
- ?: throw BizException(errorStr(it.rowNum + 1, 6, "鐪佷唤閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
- data.citycode = regionRep.findCity(data.cityname)?.citycode
- ?: throw BizException(errorStr(it.rowNum + 1, 7, "鍩庡競閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
- data.districtcode = regionRep.findDistrict(data.districtname)?.districtcode
- ?: throw BizException(errorStr(it.rowNum + 1, 8, "鍖哄幙閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
- data.towncode = regionRep.findTown(data.townname)?.towncode
- ?: throw BizException(errorStr(it.rowNum + 1, 9, "琛楅晣閿欒鎴栫郴缁熸湭鏇鹃厤缃�"))
result.add(data)
}
--
Gitblit v1.9.3