Browse Source

********************WX***********************
关系表格数据重复

zhangweixin 4 years ago
parent
commit
82be3bb58c

File diff suppressed because it is too large
+ 1 - 2
data-core/src/main/kotlin/com/persagy/server/datacenter/dao/mappers/SchemeMapper.kt


+ 33 - 3
datacenter/src/main/kotlin/com/persagy/server/services/graphtype/RelationTypeProjectService.kt

@@ -349,7 +349,7 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
             logger.debug("识别编码:${code}  ******************************************")
             preExcelRelation(sheet, projectId!!, relType, code, zoneType)
 
-            readExcelRelation(sheet, projectId, relType, zoneType)
+            readExcelRelation(sheet, projectId, relType, zoneType,code)
 
             val outFile = File("/tmp/relation-$projectId-${relType}${zone}.xlsx")
             workbook.write(outFile.outputStream())
@@ -437,7 +437,7 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
      * @param   relType         关系类型
      * @param   zone           业务空间类型
      */
-    private fun readExcelRelation(sheet: XSSFSheet, projectId: String, relType: String, zone: String? = null) {
+    private fun readExcelRelation(sheet: XSSFSheet, projectId: String, relType: String, zone: String? = null,code: String) {
         try {
             var zoneType = zone
             val len = relType.indexOf("_")
@@ -484,9 +484,39 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
                 }
                 val id1 = row.getCell(id1Col).toString()
                 val id2 = row.getCell(id2Col).toString()
+//                    if (code.compareTo("对象ID", true) == 0) {
+//
+//                        row.createCell(id1Col).setCellValue(id1)
+//                        row.createCell(id2Col).setCellValue(id2)
+//
+//                    } else  {
+
+                        val id1List = excelImport.findObjectId(projectId, codeTableMap[relType.substring(0, 2)]!!, codeColMap[code]!!, id1)
+                        val id2List = excelImport.findObjectId(projectId, codeTableMap[relType.substring(3, 5)]!!, codeColMap[code]!!, id2)
+
+                        if (id1List.count() < 1) {
+                            row.createCell(stateCol).setCellValue("未找到主对象")
+                            continue
+                        }
+                        if (id1List.count() > 1) {
+                            row.createCell(stateCol).setCellValue("匹配到多个主对象")
+                            continue
+                        }
+                        if (id2List.count() < 1) {
+                            row.createCell(stateCol).setCellValue("未找到从对象")
+                            continue
+                        }
+                        if (id2List.count() > 1) {
+                            row.createCell(stateCol).setCellValue("匹配到多个从对象")
+                            continue
+                        }
+                        row.createCell(id1Col).setCellValue(id1List[0])
+                        row.createCell(id2Col).setCellValue(id2List[0])
+//                    }
+
                 // 任意一个ID为空,则不能导入数据
                 if (id1.isEmpty() || id2.isEmpty()) {
-                    return
+                    continue
                 }
                     if (cmd == "sp2sp"||cmd == "bd2sp"||cmd == "fl2sp"||cmd == "sh2sp"){
                         val space = spaceService.select(SFilter.eq("id", id2)).entity()

+ 2 - 2
datacenter/src/main/resources/application-dev.yml

@@ -34,8 +34,8 @@ spring:
     type:                               com.alibaba.druid.pool.DruidDataSource
     driver-class-name:                  org.postgresql.Driver
 #    url:                                jdbc:postgresql://60.205.177.43:5432/datacenterlabsl
-#    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
-    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
+    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
+#    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
 #    url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
     username:                           postgres
 #    password:                           persagy_2020qwe!@#