|
@@ -26,24 +26,33 @@
|
|
|
|
|
|
package com.persagy.server.services.graphtype
|
|
|
|
|
|
+import com.persagy.base.extensions.toJson
|
|
|
import com.persagy.database.SFilter
|
|
|
import com.persagy.mybatis.SMybatisDao
|
|
|
import com.persagy.server.Opt
|
|
|
import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
|
|
|
+import com.persagy.server.datacenter.models.entities.objects.Equipment
|
|
|
import com.persagy.server.mappers.IRelationExcelExportMapper
|
|
|
import com.persagy.server.mappers.IRelationExcelImportMapper
|
|
|
import com.persagy.server.services.base.RService
|
|
|
+import com.persagy.server.services.objects.EquipmentService
|
|
|
import com.persagy.server.utils.IdUtils
|
|
|
import com.persagy.service.SObjectService
|
|
|
import com.persagy.service.SPageContext
|
|
|
import com.persagy.service.models.enums.SResponseType
|
|
|
+import com.persagy.service.models.requests.SUpdateRequest
|
|
|
import com.persagy.service.models.responses.SBaseResponse
|
|
|
import com.persagy.service.utils.SSpringContextUtil
|
|
|
+import org.apache.poi.ss.usermodel.CellType
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
|
|
import org.slf4j.LoggerFactory
|
|
|
import org.springframework.web.multipart.MultipartFile
|
|
|
import java.io.File
|
|
|
+import java.io.FileOutputStream
|
|
|
+import java.io.OutputStream
|
|
|
+import java.time.LocalDateTime
|
|
|
+import java.time.format.DateTimeFormatter
|
|
|
import javax.servlet.http.HttpServletResponse
|
|
|
|
|
|
/**
|
|
@@ -91,6 +100,7 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
|
|
|
|
|
|
val itemList = arrayOf("_sbm", "abc", "name", "id", "local_id", "local_name", "object_type", "building_floor",
|
|
|
"_sbm", "_abc", "_name", "_id", "_local_id", "_local_name","_object_type", "_building_floor")
|
|
|
+ val itemListTwo = arrayOf( "id", "local_id", "local_name","category")
|
|
|
|
|
|
/** 关系记录启始行 */
|
|
|
private const val rowStart = 5
|
|
@@ -183,54 +193,92 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
|
|
|
*/
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
private fun writeExcelRelation(sheet: XSSFSheet, projectId: String, relType: String, code: String, zoneType: String? = null) {
|
|
|
- val len = relType.indexOf("_")
|
|
|
- val cmd = if (len > 0) {
|
|
|
- relType.substring(0, len)
|
|
|
- } else {
|
|
|
- relType
|
|
|
- }
|
|
|
- val type = relType
|
|
|
+ try {
|
|
|
+ val len = relType.indexOf("_")
|
|
|
+ var cmd = if (len > 0) {
|
|
|
+ relType.substring(0, len)
|
|
|
+ } else {
|
|
|
+ relType
|
|
|
+ }
|
|
|
+ val type = relType
|
|
|
// val type = if (len > 0) {
|
|
|
// relType.substring(len + 1)
|
|
|
// } else {
|
|
|
// ""
|
|
|
// }
|
|
|
-
|
|
|
- val list = if (relType == "eq2bd" || relType == "pe2bd") {
|
|
|
- val exportMethod = excelExport.javaClass.getDeclaredMethod("${relType}In", String::class.java)
|
|
|
- exportMethod!!.invoke(excelExport, projectId) as List<HashMap<String, Any?>>
|
|
|
- } else if (relType == "eq2fl" || relType == "pe2fl") {
|
|
|
- val exportMethod = excelExport.javaClass.getDeclaredMethod("${relType}In", String::class.java)
|
|
|
- exportMethod!!.invoke(excelExport, projectId) as List<HashMap<String, Any?>>
|
|
|
- } else {
|
|
|
- if(zoneType.isNullOrEmpty()) {
|
|
|
- val exportMethod = excelExport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java)
|
|
|
- exportMethod!!.invoke(excelExport, projectId, type) as List<HashMap<String, Any?>>
|
|
|
+ logger.debug("type= ${relType}")
|
|
|
+ val list = if (relType == "eq2bd" || relType == "pe2bd") {
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod("${relType}In", String::class.java)
|
|
|
+ exportMethod!!.invoke(excelExport, projectId) as List<HashMap<String, Any?>>
|
|
|
+ } else if (relType == "eq2fl" || relType == "pe2fl") {
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod("${relType}In", String::class.java)
|
|
|
+ exportMethod!!.invoke(excelExport, projectId) as List<HashMap<String, Any?>>
|
|
|
+ } else if (relType == "eq2bd_for"||relType == "eq2fl_for"||relType == "eq2sh_for"||relType =="sy2bd_for"||relType =="sy2fl_for"
|
|
|
+ ||relType =="sy2sh_for"||relType =="sy2sp_for"){
|
|
|
+ logger.debug("type= **************************************************************************************")
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod("${relType}", String::class.java)
|
|
|
+ exportMethod!!.invoke(excelExport, projectId) as List<HashMap<String, Any?>>
|
|
|
} else {
|
|
|
- val exportMethod = excelExport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java, String::class.java)
|
|
|
- exportMethod!!.invoke(excelExport, projectId, type, zoneType) as List<HashMap<String, Any?>>
|
|
|
+ if (relType == "eq2sp_SensorRelationship_ss2sp"){
|
|
|
+ cmd = "eq2spIn"
|
|
|
+ }
|
|
|
+ if(zoneType.isNullOrEmpty()) {
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java)
|
|
|
+ exportMethod!!.invoke(excelExport, projectId, type) as List<HashMap<String, Any?>>
|
|
|
+ } else {
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java, String::class.java)
|
|
|
+ exportMethod!!.invoke(excelExport, projectId, type, zoneType) as List<HashMap<String, Any?>>
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ var rowNum = rowStart
|
|
|
+ logger.debug("数据长度= ${list.toJson()} ****************************************************************")
|
|
|
+ // 填写识别码对应
|
|
|
+ sheet.getRow(2).getCell(1).setCellValue(code)
|
|
|
|
|
|
- var rowNum = rowStart
|
|
|
+ for (it in list) {
|
|
|
+ val row = sheet.createRow(rowNum)
|
|
|
+ for ((i, item) in itemList.withIndex()) {
|
|
|
+ val cellValue = it[item]
|
|
|
+ if (item == "building_floor"){
|
|
|
+ val buildingName = it["building_name"]
|
|
|
+ val floorName = it["floor_name"]
|
|
|
+ if (buildingName!=null&&floorName!=null&&!buildingName.toString().isEmpty()&&!floorName.toString().isEmpty()){
|
|
|
+ val cells = row.createCell(i)
|
|
|
+ cells.setCellValue(buildingName.toString()+"-"+floorName.toString())
|
|
|
+ }else if (buildingName!=null&&!buildingName.toString().isEmpty()) {
|
|
|
+ val cells = row.createCell(i)
|
|
|
+ cells.setCellValue(buildingName.toString())
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if(item == "_building_floor"){
|
|
|
+ val buildingName = it["_building_name"]
|
|
|
+ val floorName = it["_floor_name"]
|
|
|
+ if (buildingName!=null&&floorName!=null&&!buildingName.toString().isNullOrEmpty()&&!floorName.toString().isNullOrEmpty()){
|
|
|
+ val cells = row.createCell(i)
|
|
|
+ cells.setCellValue(buildingName.toString()+"-"+floorName.toString())
|
|
|
+ }else if (buildingName!=null&&!buildingName.toString().isNullOrEmpty()) {
|
|
|
+ val cells = row.createCell(i)
|
|
|
+ cells.setCellValue(buildingName.toString())
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val cell = row.createCell(i)
|
|
|
+ if (cellValue != null) {
|
|
|
+ cell.setCellValue(cellValue.toString())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.debug("数据item= ${item?.toString()}")
|
|
|
+ logger.debug("数据= ${cellValue?.toString()}")
|
|
|
|
|
|
- // 填写识别码对应
|
|
|
- sheet.getRow(2).getCell(1).setCellValue(code)
|
|
|
|
|
|
- for (it in list) {
|
|
|
- val row = sheet.createRow(rowNum)
|
|
|
- for ((i, item) in itemList.withIndex()) {
|
|
|
- val cellValue = it[item]
|
|
|
- val cell = row.createCell(i)
|
|
|
- if (cellValue != null) {
|
|
|
- cell.setCellValue(cellValue.toString())
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 添加识别码
|
|
|
- row.createCell(0).setCellValue(row.getCell(id1Col).toString())
|
|
|
- row.createCell(8).setCellValue(row.getCell(id2Col).toString())
|
|
|
- rowNum++
|
|
|
+ // 添加识别码
|
|
|
+ row.createCell(0).setCellValue(row.getCell(id1Col).toString())
|
|
|
+ row.createCell(8).setCellValue(row.getCell(id2Col).toString())
|
|
|
+ rowNum++
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
}
|
|
|
} // Fun writeExcelRelation()
|
|
|
|
|
@@ -420,5 +468,605 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
|
|
|
}
|
|
|
} // Fun readExcelRelation()
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出 exportExcelPoint
|
|
|
+ *
|
|
|
+ * @param response 应答体
|
|
|
+ * @param relType 关系类型
|
|
|
+ * @param code 识别码类型
|
|
|
+ * @param zoneType 业务空间类型
|
|
|
+ */
|
|
|
+ fun exportExcelPoint(response: HttpServletResponse,buildingId: String,floorId: String,category: String) {
|
|
|
+ val projectId = SPageContext.getHeader("ProjectId")
|
|
|
+ val workbook = XSSFWorkbook(RelationTypeProjectService::class.java.classLoader.getResourceAsStream("excel/point_infos.xlsx"))
|
|
|
+ response.contentType = "application/octet-stream"
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=${projectId}-${category}.xlsx")
|
|
|
+ response.flushBuffer()
|
|
|
+
|
|
|
+ val sheet = workbook.getSheet("信息点")
|
|
|
+
|
|
|
+// val projectId = SPageContext.getHeader("ProjectId")
|
|
|
+
|
|
|
+ try {
|
|
|
+ writeExcelPoint(sheet, projectId!!, buildingId, floorId, category)
|
|
|
+ }catch (e: Exception) {
|
|
|
+ // DO NOTHING
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ workbook.write(response.outputStream)
|
|
|
+ } // Function exportExcel()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 向excel表中写关系
|
|
|
+ *
|
|
|
+ * @param sheet Excel Sheet
|
|
|
+ * @param projectId 项目ID
|
|
|
+ * @param relType 关系类型
|
|
|
+ * @param code 识别码类型
|
|
|
+ * @param zoneType 业务空间类型
|
|
|
+ */
|
|
|
+ @Suppress("UNCHECKED_CAST")
|
|
|
+ private fun writeExcelPoint(sheet: XSSFSheet, projectId: String, buildingId: String,floorId: String,category: String) {
|
|
|
+ val exportMethod = excelExport.javaClass.getDeclaredMethod("equipPoint", String::class.java,String::class.java, String::class.java, String::class.java)
|
|
|
+ val list = exportMethod!!.invoke(excelExport, projectId,buildingId,floorId,category) as List<HashMap<String, Any?>>
|
|
|
+
|
|
|
+
|
|
|
+ var rowNum = 1
|
|
|
+ // 填写识别码对应
|
|
|
+// sheet.getRow(2).getCell(1).setCellValue(code)
|
|
|
+
|
|
|
+ for (it in list) {
|
|
|
+ val row = sheet.createRow(rowNum)
|
|
|
+ for ((i, item) in itemListTwo.withIndex()) {
|
|
|
+ logger.debug("数据= ${i?.toString()}")
|
|
|
+ val cellValue = it[item]
|
|
|
+ val cell = row.createCell(i)
|
|
|
+ if (cellValue != null) {
|
|
|
+ cell.setCellValue(cellValue.toString())
|
|
|
+ }
|
|
|
+ logger.debug("数据= ${cellValue?.toString()}")
|
|
|
+ }
|
|
|
+ // 添加识别码
|
|
|
+// row.createCell(0).setCellValue(row.getCell(id1Col).toString())
|
|
|
+// row.createCell(8).setCellValue(row.getCell(id2Col).toString())
|
|
|
+ rowNum++
|
|
|
+ }
|
|
|
+ } // Fun writeExcelRelation()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入excel
|
|
|
+ *
|
|
|
+ * @param file 上传的Excel文件
|
|
|
+ * @param relType 关系类型
|
|
|
+ * @param zoneType 业务空间类型
|
|
|
+ * @return 应答体
|
|
|
+ */
|
|
|
+ fun importExcelPoint(file: MultipartFile): SBaseResponse {
|
|
|
+ try {
|
|
|
+ if (file.isEmpty) {
|
|
|
+ throw Exception("未选择文件")
|
|
|
+ }
|
|
|
+
|
|
|
+ val projectId = SPageContext.getHeader("ProjectId")
|
|
|
+ // 转为 XSSFWorkbook 对象
|
|
|
+ val workbook = XSSFWorkbook(file.inputStream)
|
|
|
+ // 读取第一个 sheet
|
|
|
+ val sheet = workbook.getSheetAt(0)
|
|
|
+
|
|
|
+ readExcelPoint(sheet, projectId!!)
|
|
|
+ // 时间
|
|
|
+ val date: String = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
|
|
|
+ var path:String
|
|
|
+ // Tomcat 路径
|
|
|
+ val tomcat_path = System.getProperty("user.dir")
|
|
|
+ // 上传的文件名
|
|
|
+ val myFileName = file.originalFilename
|
|
|
+ // 重组文件名
|
|
|
+ val fileName = projectId + date + "." + myFileName.substring(myFileName.lastIndexOf(".") + 1)
|
|
|
+ //获取tomcat中项目同级路径
|
|
|
+ val bin_path = tomcat_path.substring(tomcat_path.lastIndexOf("/") + 1, tomcat_path.length)
|
|
|
+ if ("bin" == bin_path) {
|
|
|
+ path = tomcat_path.substring(0, System.getProperty("user.dir").lastIndexOf("/")) + "/temp/" + "/upload/"
|
|
|
+ } else {
|
|
|
+ path = "$tomcat_path/temp/upload/"
|
|
|
+ }
|
|
|
+ val fileDir = File(path)
|
|
|
+ //如果不存在 则创建
|
|
|
+ if (!fileDir.exists()) {
|
|
|
+ fileDir.mkdirs()
|
|
|
+ }
|
|
|
+ // 文件
|
|
|
+ val files = File(path,fileName)
|
|
|
+ // 文件流
|
|
|
+ val os: OutputStream = FileOutputStream(files)
|
|
|
+ // 写入
|
|
|
+ workbook.write(os)
|
|
|
+ os.flush()
|
|
|
+ os.close()
|
|
|
+ return SBaseResponse(SResponseType.success,fileName)
|
|
|
+// return SBaseResponse(SResponseType.success)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ return SBaseResponse(SResponseType.failure, e.message!!)
|
|
|
+ }
|
|
|
+ return SBaseResponse(SResponseType.success)
|
|
|
+ } // Fun importExcel()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从Excel读取关系并存入数据库中
|
|
|
+ *
|
|
|
+ * @param sheet Excel Sheet
|
|
|
+ * @param projectId 项目ID
|
|
|
+ * @param relType 关系类型
|
|
|
+ * @param zoneType 业务空间类型
|
|
|
+ */
|
|
|
+ private fun readExcelPoint(sheet: XSSFSheet, projectId: String) = try {
|
|
|
+
|
|
|
+ logger.debug("id3= ***************************************************")
|
|
|
+ val rowNum = 1
|
|
|
+ for (i in rowNum .. sheet.lastRowNum) {
|
|
|
+ val row = sheet.getRow(i)
|
|
|
+ try {
|
|
|
+ if (row == null){
|
|
|
+ sheet.getRow(0).createCell(stateCol).setCellValue("第$i 行数据为空")
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if (row != null){
|
|
|
+ val cell = row.getCell(0)
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ val cell1 = row.getCell(1)
|
|
|
+ cell1.setCellType(CellType.STRING);
|
|
|
+ val cell2 = row.getCell(2)
|
|
|
+ cell2.setCellType(CellType.STRING);
|
|
|
+ val cell3 = row.getCell(3)
|
|
|
+ cell3.setCellType(CellType.STRING);
|
|
|
+ val id0 =cell.toString().trim()
|
|
|
+ val id1 = cell1.toString().trim()
|
|
|
+ val id2 = cell2.toString().trim()
|
|
|
+ val id3 = cell3.toString().trim()
|
|
|
+ logger.debug("id0= $id0")
|
|
|
+ logger.debug("id1= $id1")
|
|
|
+ logger.debug("id2= $id2")
|
|
|
+ logger.debug("id3= $id3")
|
|
|
+ if (!id0.isNullOrEmpty()&&!id1.isNullOrEmpty()&&!id2.isNullOrEmpty()&&!id3.isNullOrEmpty()) {
|
|
|
+
|
|
|
+ val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.eq("localId", id0.trim())).exec()
|
|
|
+ if (equipmentList.isEmpty()){
|
|
|
+ row.createCell(4).setCellValue("不存在")
|
|
|
+ }else if (equipmentList.size>1) {
|
|
|
+ row.createCell(4).setCellValue("重复")
|
|
|
+ }else {
|
|
|
+
|
|
|
+
|
|
|
+ val equip = equipUpdate(equipmentList[0], id1, id2, id3)
|
|
|
+ val request = SUpdateRequest<Equipment>()
|
|
|
+ request.content = arrayListOf(equip)
|
|
|
+ try {
|
|
|
+ val updateList = EquipmentService.updateList(request)
|
|
|
+ if (updateList.result == SResponseType.success){
|
|
|
+ row.createCell(4).setCellValue("成功")
|
|
|
+ }else{
|
|
|
+ row.createCell(4).setCellValue("失败")
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ row.createCell(4).setCellValue("失败")
|
|
|
+ }
|
|
|
+ row.createCell(4).setCellValue("成功")
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ row.createCell(4).setCellValue("信息不全")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ row.createCell(4).setCellValue("失败")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ } // Fun readExcelRelation()
|
|
|
+
|
|
|
+ fun equipUpdate(equipment: Equipment,id1: String,id2: String,id3: String):Equipment {
|
|
|
+// val entity = dPropertyDefProjectservice.select(SFilter.eq("type", equipment.category!!), SFilter.eq("infoPointCode", id1)).entity()
|
|
|
+// logger.debug("信息点1=${equipment.category}")
|
|
|
+// logger.debug("信息点=${entity?.toJson()}")
|
|
|
+// if (entity!=null){
|
|
|
+//
|
|
|
+// if (entity.firstTag == "LedgerParam"){
|
|
|
+// if (equipment.ledgerParam.isNullOrEmpty()){
|
|
|
+// equipment.ledgerParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.ledgerParam!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.ledgerParam!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.ledgerParam!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.ledgerParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "CommParam") {
|
|
|
+// /** 通讯参数 */
|
|
|
+// if (equipment.commParam.isNullOrEmpty()){
|
|
|
+// equipment.commParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.commParam!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.commParam!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.commParam!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.commParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+// }else if (entity.firstTag == "TechParam") {
|
|
|
+// /** 技术参数 */
|
|
|
+// if (equipment.techParam.isNullOrEmpty()){
|
|
|
+// equipment.techParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.techParam!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.techParam!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.techParam!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.techParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "RunParam") {
|
|
|
+// /** 运行参数 */
|
|
|
+// if (equipment.runParam.isNullOrEmpty()){
|
|
|
+// equipment.runParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.runParam!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.runParam!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.runParam!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.runParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "SettingParam") {
|
|
|
+// /** 设定参数 */
|
|
|
+// if (equipment.settingParam.isNullOrEmpty()){
|
|
|
+// equipment.settingParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.settingParam!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.settingParam!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.settingParam!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.settingParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "Alram") {
|
|
|
+// /** 报警消息 */
|
|
|
+// if (equipment.alram.isNullOrEmpty()){
|
|
|
+// equipment.alram = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// equipment.alram!![id1] = "$id2-$id3"
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "TempSensor") {
|
|
|
+// /** 温度传感器 */
|
|
|
+// if (equipment.tempSensor.isNullOrEmpty()){
|
|
|
+// equipment.tempSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.tempSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.tempSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.tempSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.tempSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "TechParamGeneral") {
|
|
|
+// /** 技术参数-通用 */
|
|
|
+// if (equipment.techParamGeneral.isNullOrEmpty()){
|
|
|
+// equipment.techParamGeneral = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// equipment.techParamGeneral!![id1] = "$id2-$id3"
|
|
|
+// }else if (entity.firstTag == "RunParamGeneral") {
|
|
|
+// /** 运行参数-通用 */
|
|
|
+// if (equipment.runParamGeneral.isNullOrEmpty()){
|
|
|
+// equipment.runParamGeneral = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// equipment.runParamGeneral!![id1] = "$id2-$id3"
|
|
|
+// }else if (entity.firstTag == "SpeedSensor") {
|
|
|
+// /** 速度传感器 */
|
|
|
+// if (equipment.speedSensor.isNullOrEmpty()){
|
|
|
+// equipment.speedSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.speedSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.speedSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.speedSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.speedSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "SoundSensor") {
|
|
|
+// /** 声音传感器 */
|
|
|
+// if (equipment.soundSensor.isNullOrEmpty()){
|
|
|
+// equipment.soundSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.soundSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.soundSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.soundSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.soundSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "HumiditySensor") {
|
|
|
+// /** 湿度传感器 */
|
|
|
+// if (equipment.humiditySensor.isNullOrEmpty()){
|
|
|
+// equipment.humiditySensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.humiditySensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.humiditySensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.humiditySensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.humiditySensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "PressTransd") {
|
|
|
+// /** 压力传感器 */
|
|
|
+// if (equipment.pressTransd.isNullOrEmpty()){
|
|
|
+// equipment.pressTransd = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.pressTransd!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.pressTransd!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.pressTransd!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.pressTransd!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "HeatSensor") {
|
|
|
+// /** 热量传感器 */
|
|
|
+// if (equipment.heatSensor.isNullOrEmpty()){
|
|
|
+// equipment.heatSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.heatSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.heatSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.heatSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.heatSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "FlowSensor") {
|
|
|
+// /** 流量传感器 */
|
|
|
+// if (equipment.flowSensor.isNullOrEmpty()){
|
|
|
+// equipment.flowSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.flowSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.flowSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.flowSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.flowSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "ElectricitySensor") {
|
|
|
+// /** 电度传感器 */
|
|
|
+// if (equipment.electricitySensor.isNullOrEmpty()){
|
|
|
+// equipment.electricitySensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.electricitySensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.electricitySensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.electricitySensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.electricitySensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "DisplSensor") {
|
|
|
+// /** 位移传感器 */
|
|
|
+// if (equipment.displSensor.isNullOrEmpty()){
|
|
|
+// equipment.displSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.displSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.displSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.displSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.displSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "ConcentSensor") {
|
|
|
+// /** 浓度传感器 */
|
|
|
+// if (equipment.concentSensor.isNullOrEmpty()){
|
|
|
+// equipment.concentSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.concentSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.concentSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.concentSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.concentSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else if (entity.firstTag == "ImageSensor") {
|
|
|
+// /** 图像传感器 */
|
|
|
+// if (equipment.imageSensor.isNullOrEmpty()){
|
|
|
+// equipment.imageSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.imageSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.imageSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.imageSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.imageSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+// }else if (entity.firstTag =="ManFlowSensor"){
|
|
|
+// /** 人流量传感器 */
|
|
|
+// if (equipment.manFlowSensor.isNullOrEmpty()){
|
|
|
+// equipment.manFlowSensor = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// if (!entity.secondTag.isNullOrEmpty()){
|
|
|
+// val containsKey = equipment.manFlowSensor!!.containsKey(entity.secondTag!!)
|
|
|
+// if (containsKey){
|
|
|
+// val photoDocMap = equipment.manFlowSensor!![entity.secondTag!!] as JSONObject
|
|
|
+// photoDocMap[id1] = "$id2-$id3"
|
|
|
+// }else{
|
|
|
+// val mapPic = HashMap<String,Any>()
|
|
|
+// mapPic[id1] = "$id2-$id3"
|
|
|
+// equipment.manFlowSensor!![entity.secondTag!!] = mapPic
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// equipment.manFlowSensor!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// /** 自定义 */
|
|
|
+// if (equipment.customParam.isNullOrEmpty()){
|
|
|
+// equipment.customParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// equipment.customParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else{
|
|
|
+// /** 自定义 */
|
|
|
+// if (equipment.customParam.isNullOrEmpty()){
|
|
|
+// equipment.customParam = HashMap<String,Any?>()
|
|
|
+// }
|
|
|
+// equipment.customParam!![id1] = "$id2-$id3"
|
|
|
+// }
|
|
|
+ return equipment
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载报告
|
|
|
+ *
|
|
|
+ * @param response 应答体
|
|
|
+ * @param relType 关系类型
|
|
|
+ * @param zoneType 业务空间类型
|
|
|
+ */
|
|
|
+ fun reportDownloadsPoint(response: HttpServletResponse,key:String) {
|
|
|
+ var path:String
|
|
|
+ val projectId = SPageContext.getHeader("projectId")
|
|
|
+
|
|
|
+
|
|
|
+ val tomcat_path = System.getProperty("user.dir")
|
|
|
+
|
|
|
+ //获取tomcat中项目同级路径
|
|
|
+ val bin_path = tomcat_path.substring(tomcat_path.lastIndexOf("/") + 1, tomcat_path.length)
|
|
|
+ if ("bin" == bin_path) {
|
|
|
+ path = tomcat_path.substring(0, System.getProperty("user.dir").lastIndexOf("/")) + "/temp/" + "/upload/"
|
|
|
+ } else {
|
|
|
+ path = "$tomcat_path/temp/upload/"
|
|
|
+ }
|
|
|
+ val file = File(path+key)
|
|
|
+ val workbook = if (file.exists()) {
|
|
|
+ XSSFWorkbook(file)
|
|
|
+ } else {
|
|
|
+ XSSFWorkbook(RelationTypeProjectService::class.java.classLoader.getResourceAsStream("excel/relation-template.xlsx"))
|
|
|
+ }
|
|
|
+ response.contentType = "application/octet-stream"
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=${key}")
|
|
|
+ response.flushBuffer()
|
|
|
+ workbook.write(response.outputStream)
|
|
|
+ } // Function templateDownloads()
|
|
|
+
|
|
|
} // Class RelationTypeProjectService
|
|
|
|