Browse Source

****************************************提交分类************************************

weixinVSjinlai 4 years ago
parent
commit
f4565fe6dc

+ 51 - 46
equip-component/src/main/kotlin/com/persagy/server/service/dict/DictDefClassService.kt

@@ -94,64 +94,69 @@ object DefFuncIdService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.
      */
     fun dictEquipInfoQuery(category: String): DictInfoResponse {
         val dictInfoResponse = DictInfoResponse()
-//        val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
+        try {//        val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
 //                ,SFilter.eq("classCode", category)).exec()
 //        val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)
 //                ,SFilter.eq("classCode", category)).exec()
-        var defFuncIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),
-                SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
-        if (defFuncIdList.size == 0 ) {
-            defFuncIdList = DefFuncIdService.select(SFilter.eq("type","group"),
+            var defFuncIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),
                     SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
-            if (defFuncIdList.size == 0) {
-                defFuncIdList = DefFuncIdService.select(SFilter.eq("type","common"),
+            if (defFuncIdList.size == 0 ) {
+                defFuncIdList = DefFuncIdService.select(SFilter.eq("type","group"),
                         SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
+                if (defFuncIdList.size == 0) {
+                    defFuncIdList = DefFuncIdService.select(SFilter.eq("type","common"),
+                            SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
+                }
             }
-        }
-        for (defFuncId in defFuncIdList) {
-            if (defFuncId.code == "name"){
-                defFuncId.code = "systemCategory"
-                defFuncId.name = "系统分类"
-                defFuncId.aliasCode = "systemCategory"
-                defFuncId.aliasName = "系统分类"
-            } else if (defFuncId.code == "localName"){
-                defFuncId.code = "codeName"
-                defFuncId.name = "设备类型名称"
-                defFuncId.aliasCode = "codeName"
-                defFuncId.aliasName = "设备类型名称"
+            for (defFuncId in defFuncIdList) {
+                if (defFuncId.code == "name"){
+                    defFuncId.code = "systemCategory"
+                    defFuncId.name = "系统分类"
+                    defFuncId.aliasCode = "systemCategory"
+                    defFuncId.aliasName = "系统分类"
+                } else if (defFuncId.code == "localName"){
+                    defFuncId.code = "codeName"
+                    defFuncId.name = "设备类型名称"
+                    defFuncId.aliasCode = "codeName"
+                    defFuncId.aliasName = "设备类型名称"
+                }
             }
-        }
 
-        val dictStageList = dictStageService.selectAll().exec()
-        for (dictStage in dictStageList) {
-            val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
-                    ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
-            val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)
-                    ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
-            if (dictInfosWanDaProjectList.size>0){
-                dictInfosWanDaGroupList.addAll(dictInfosWanDaProjectList)
-            }
-            var setCode = HashSet<String>()
-            for (dictInfosWanDaGroup in dictInfosWanDaGroupList){
-                setCode.add(dictInfosWanDaGroup.code!!)
-            }
-            var funcIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),SFilter.eq("classCode", category),
-                    SFilter.inList("code", setCode.toList())).order("code").exec()
-            if (funcIdList.size == 0 ) {
-                funcIdList = DefFuncIdService.select(SFilter.eq("type","group"),
-                         SFilter.eq("groupCode",Opt.groupCode!!),SFilter.eq("classCode", category),
+            val dictStageList = dictStageService.selectAll().exec()
+            for (dictStage in dictStageList) {
+                val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
+                        ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
+                val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)
+                        ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
+                if (dictInfosWanDaProjectList.size>0){
+                    dictInfosWanDaGroupList.addAll(dictInfosWanDaProjectList)
+                }
+                var setCode = HashSet<String>()
+                for (dictInfosWanDaGroup in dictInfosWanDaGroupList){
+                    setCode.add(dictInfosWanDaGroup.code!!)
+                }
+                var funcIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),SFilter.eq("classCode", category),
                         SFilter.inList("code", setCode.toList())).order("code").exec()
-                if (funcIdList.size == 0) {
-                    funcIdList = DefFuncIdService.select(SFilter.eq("type","common"),SFilter.eq("classCode", category),
-                            SFilter.inList("code",  setCode.toList())).order("code").exec()
+                if (funcIdList.size == 0 ) {
+                    funcIdList = DefFuncIdService.select(SFilter.eq("type","group"),
+                             SFilter.eq("groupCode",Opt.groupCode!!),SFilter.eq("classCode", category),
+                            SFilter.inList("code", setCode.toList())).order("code").exec()
+                    if (funcIdList.size == 0) {
+                        funcIdList = DefFuncIdService.select(SFilter.eq("type","common"),SFilter.eq("classCode", category),
+                                SFilter.inList("code",  setCode.toList())).order("code").exec()
+                    }
                 }
+                dictStage.infos = funcIdList
             }
-            dictStage.infos = funcIdList
-        }
 
-        dictInfoResponse.basicInfos = defFuncIdList
-        dictInfoResponse.dictStages = dictStageList
-        dictInfoResponse.result = SResponseType.success
+            dictInfoResponse.basicInfos = defFuncIdList
+            dictInfoResponse.dictStages = dictStageList
+            dictInfoResponse.result = SResponseType.success
+        } catch (e: Exception) {
+            e.printStackTrace()
+            dictInfoResponse.result = SResponseType.failure
+            dictInfoResponse.message = "错误"
+        }
         return dictInfoResponse
 
     }