Bläddra i källkod

******************WX *********************
关系总览,添加关系同步

zhangweixin 4 år sedan
förälder
incheckning
df45ea11c6

+ 2 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/controllers/dict/DictGatherControllers.kt

@@ -39,9 +39,9 @@ class DictGatherControllers {
     /**
      * 同步项目字典
      */
-    @Operation(summary = "同步项目字典", description = "")
+    @Operation(summary = "同步项目字典", description = "sign开关,true 所有项目")
     @GetMapping(value = ["/dict/code/syn"])
-    fun dictSynCode(@RequestParam groupCode: String,@RequestParam projectId: String): SBaseResponse {
+    fun dictSynCode(@RequestParam groupCode: String,@RequestParam projectId: String,sign: Boolean = false): SBaseResponse {
         return DClassDefService.synCodeProject(groupCode,projectId)
     }
 

+ 224 - 199
datasyn/src/main/kotlin/com/persagy/server/syn/services/dict/DClassDefService.kt

@@ -30,6 +30,7 @@ import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.dictnew.*
+import com.persagy.server.datacenter.models.entities.objects.Project
 import com.persagy.server.syn.CustomProperties
 import com.persagy.server.syn.ServiceNameConfig
 import com.persagy.server.syn.models.api.dict.DictTypeApi
@@ -51,7 +52,8 @@ import java.util.concurrent.Executors
 object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.java)) {
 
 
-
+    /** 项目 */
+    private val projectService = SBaseService(SMybatisDao(Project::class.java))
     /** 日志 */
     val logger = LoggerFactory.getLogger(DClassDefService::class.java)
     /** 集团服务 */
@@ -800,35 +802,35 @@ object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.j
             sBaseResponse.result = SResponseType.success
         } else {
 
-        val dictProjectList = dictProjectService.selectAll().exec()
-        if (dictProjectList.size>0){
-            for (project in dictProjectList){
-                val dictGroupList = DictTypeApi.dictProject(project.groupCode!!,project.id!!)
-                if (dictGroupList.size>0){
-                    defClassService.delete(SFilter.eq("type","project"),SFilter.eq("groupCode",project.groupCode!!),SFilter.eq("projectId",project.id!!))
-                    for (dictGroup in dictGroupList){
-                        val defClass = DefClass()
-                        defClass.id = dictGroup.id
-                        defClass.aliasCode = dictGroup.aliasCode
-                        defClass.aliasName = dictGroup.aliasName
-                        defClass.code = dictGroup.code
-                        defClass.equipmentCode = dictGroup.equipmentCode
-                        defClass.groupCode = project.groupCode
-                        defClass.majorCode = dictGroup.majorCode
-                        defClass.name = dictGroup.name
-                        defClass.parentCode = dictGroup.parentCode
-                        defClass.projectId = project.id
-                        defClass.systemCode = dictGroup.systemCode
-                        defClass.type = "project"
-                        defClass.objType = dictGroup.objType
-                        defClassService.replace(defClass)
+            val dictProjectList = dictProjectService.selectAll().exec()
+            if (dictProjectList.size>0){
+                for (project in dictProjectList){
+                    val dictGroupList = DictTypeApi.dictProject(project.groupCode!!,project.id!!)
+                    if (dictGroupList.size>0){
+                        defClassService.delete(SFilter.eq("type","project"),SFilter.eq("groupCode",project.groupCode!!),SFilter.eq("projectId",project.id!!))
+                        for (dictGroup in dictGroupList){
+                            val defClass = DefClass()
+                            defClass.id = dictGroup.id
+                            defClass.aliasCode = dictGroup.aliasCode
+                            defClass.aliasName = dictGroup.aliasName
+                            defClass.code = dictGroup.code
+                            defClass.equipmentCode = dictGroup.equipmentCode
+                            defClass.groupCode = project.groupCode
+                            defClass.majorCode = dictGroup.majorCode
+                            defClass.name = dictGroup.name
+                            defClass.parentCode = dictGroup.parentCode
+                            defClass.projectId = project.id
+                            defClass.systemCode = dictGroup.systemCode
+                            defClass.type = "project"
+                            defClass.objType = dictGroup.objType
+                            defClassService.replace(defClass)
+                        }
                     }
                 }
+                sBaseResponse.result = SResponseType.success
+            }else{
+                sBaseResponse.result = SResponseType.failure
             }
-            sBaseResponse.result = SResponseType.success
-        }else{
-            sBaseResponse.result = SResponseType.failure
-        }
         }
         return sBaseResponse
     } // Fun
@@ -885,190 +887,190 @@ object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.j
             if (dictProject!=null){
 //                for (group in groupList){
 
-                    for (defClass in defClassList){
-                        val dictGroupInfoList = DictTypeApi.dictProjectInfo(dictProject.groupCode!!, defClass.code!!,projectId)
+                for (defClass in defClassList){
+                    val dictGroupInfoList = DictTypeApi.dictProjectInfo(dictProject.groupCode!!, defClass.code!!,projectId)
 
-                        if (dictGroupInfoList.size>0){
+                    if (dictGroupInfoList.size>0){
 //                            defFuncIdService.delete(SFilter.eq("projectId",projectId!!),SFilter.eq("classCode",defClass.code!!))
-                            for (dictGroupInfo in dictGroupInfoList){
-                                /** 开头字母大写转小写 */
-                                val str1: String = dictGroupInfo.code!!.substring(0, 1).toLowerCase() //直接bai将du字符zhi串第一个不管是数字还是字母都小写
-                                val str2: String = dictGroupInfo.code!!.substring(1, dictGroupInfo.code!!.length) //截取字符串第二个以后
-                                var str=str1+str2;
-                                val defFuncId = DefFuncId()
-
-                                if (str == "equipLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "equipLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "sysLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "sysLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "tenantLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str =="tenantLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "roomLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "roomLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "shaftLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "shaftLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "shaftID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "shaftName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "equipID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "equipName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "sysID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "sysName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "tenantID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "tenantName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "roomID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "roomName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "projID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "projName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "projLocalName"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "projLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "flootID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "flootName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "floorLocalName"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "floorLocalName"){
-                                    defFuncId.code = "localName"
-                                }else if (str == "buildID"){
-                                    defFuncId.code = "id"
-                                }else if (str == "buildName"){
-                                    defFuncId.code = "name"
-                                }else if (str == "buildLocalID"){
-                                    defFuncId.code = "localId"
-                                }else if (str == "buildLocalName"){
-                                    defFuncId.code = "localName"
-                                }else{
-                                    defFuncId.code = str
-                                }
-                                defFuncId.code = dictGroupInfo.code
-                                defFuncId.id = dictGroupInfo.id
-                                defFuncId.canSub = dictGroupInfo.canSub
-                                defFuncId.category = dictGroupInfo.category
-                                defFuncId.classCode = defClass.code
+                        for (dictGroupInfo in dictGroupInfoList){
+                            /** 开头字母大写转小写 */
+                            val str1: String = dictGroupInfo.code!!.substring(0, 1).toLowerCase() //直接bai将du字符zhi串第一个不管是数字还是字母都小写
+                            val str2: String = dictGroupInfo.code!!.substring(1, dictGroupInfo.code!!.length) //截取字符串第二个以后
+                            var str=str1+str2;
+                            val defFuncId = DefFuncId()
+
+                            if (str == "equipLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str == "equipLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "sysLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str == "sysLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "tenantLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str =="tenantLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "roomLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str == "roomLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "shaftLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str == "shaftLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "shaftID"){
+                                defFuncId.code = "id"
+                            }else if (str == "shaftName"){
+                                defFuncId.code = "name"
+                            }else if (str == "equipID"){
+                                defFuncId.code = "id"
+                            }else if (str == "equipName"){
+                                defFuncId.code = "name"
+                            }else if (str == "sysID"){
+                                defFuncId.code = "id"
+                            }else if (str == "sysName"){
+                                defFuncId.code = "name"
+                            }else if (str == "tenantID"){
+                                defFuncId.code = "id"
+                            }else if (str == "tenantName"){
+                                defFuncId.code = "name"
+                            }else if (str == "roomID"){
+                                defFuncId.code = "id"
+                            }else if (str == "roomName"){
+                                defFuncId.code = "name"
+                            }else if (str == "projID"){
+                                defFuncId.code = "id"
+                            }else if (str == "projName"){
+                                defFuncId.code = "name"
+                            }else if (str == "projLocalName"){
+                                defFuncId.code = "localId"
+                            }else if (str == "projLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "flootID"){
+                                defFuncId.code = "id"
+                            }else if (str == "flootName"){
+                                defFuncId.code = "name"
+                            }else if (str == "floorLocalName"){
+                                defFuncId.code = "localId"
+                            }else if (str == "floorLocalName"){
+                                defFuncId.code = "localName"
+                            }else if (str == "buildID"){
+                                defFuncId.code = "id"
+                            }else if (str == "buildName"){
+                                defFuncId.code = "name"
+                            }else if (str == "buildLocalID"){
+                                defFuncId.code = "localId"
+                            }else if (str == "buildLocalName"){
+                                defFuncId.code = "localName"
+                            }else{
+                                defFuncId.code = str
+                            }
+                            defFuncId.code = dictGroupInfo.code
+                            defFuncId.id = dictGroupInfo.id
+                            defFuncId.canSub = dictGroupInfo.canSub
+                            defFuncId.category = dictGroupInfo.category
+                            defFuncId.classCode = defClass.code
 //                        defFuncId.code = str
-                                defFuncId.dataSource = dictGroupInfo.dataSource
-                                logger.debug("数据001 = ${dictGroupInfo.dataSource?.toJson()} ***********************************************************")
-                                defFuncId.dataType = dictGroupInfo.dataType
-                                if (!dictGroupInfo.firstTag.isNullOrEmpty()){
-                                    defFuncId.firstTag = ParamTools.TwoLevelCode(dictGroupInfo.firstTag!!)
-                                }
-                                defFuncId.firstName = dictGroupInfo.firstTag
-                                defFuncId.formater = dictGroupInfo.formater
-                                defFuncId.groupCode = dictProject.groupCode
-                                defFuncId.idx = dictGroupInfo.idx
-                                defFuncId.inputMode = dictGroupInfo.inputMode
-                                defFuncId.isMultiple = dictGroupInfo.isMultiple
-                                defFuncId.isRegion = dictGroupInfo.isRegion
-                                defFuncId.name = dictGroupInfo.name
-                                logger.debug("name: ${ dictGroupInfo.name} *******************************************************")
-                                defFuncId.note = dictGroupInfo.note
-                                defFuncId.priority = dictGroupInfo.priority
-                                defFuncId.projectId = projectId
-                                defFuncId.readonly = dictGroupInfo.readonly
-                                if (!dictGroupInfo.secondTag.isNullOrEmpty()){
-                                    defFuncId.secondTag = ParamTools.TwoLevelCode(dictGroupInfo.secondTag!!)
-                                }
-                                defFuncId.secondName = dictGroupInfo.secondTag
-                                defFuncId.subFlag = dictGroupInfo.subFlag
-                                defFuncId.type = "project"
-                                defFuncId.unit = dictGroupInfo.unit
-                                defFuncId.origCode = dictGroupInfo.origCode
-                                defFuncId.origDataType = dictGroupInfo.origDataType
-                                defFuncId.aliasCode = dictGroupInfo.aliasCode
-                                defFuncId.aliasName = dictGroupInfo.aliasName
+                            defFuncId.dataSource = dictGroupInfo.dataSource
+                            logger.debug("数据001 = ${dictGroupInfo.dataSource?.toJson()} ***********************************************************")
+                            defFuncId.dataType = dictGroupInfo.dataType
+                            if (!dictGroupInfo.firstTag.isNullOrEmpty()){
+                                defFuncId.firstTag = ParamTools.TwoLevelCode(dictGroupInfo.firstTag!!)
+                            }
+                            defFuncId.firstName = dictGroupInfo.firstTag
+                            defFuncId.formater = dictGroupInfo.formater
+                            defFuncId.groupCode = dictProject.groupCode
+                            defFuncId.idx = dictGroupInfo.idx
+                            defFuncId.inputMode = dictGroupInfo.inputMode
+                            defFuncId.isMultiple = dictGroupInfo.isMultiple
+                            defFuncId.isRegion = dictGroupInfo.isRegion
+                            defFuncId.name = dictGroupInfo.name
+                            logger.debug("name: ${ dictGroupInfo.name} *******************************************************")
+                            defFuncId.note = dictGroupInfo.note
+                            defFuncId.priority = dictGroupInfo.priority
+                            defFuncId.projectId = projectId
+                            defFuncId.readonly = dictGroupInfo.readonly
+                            if (!dictGroupInfo.secondTag.isNullOrEmpty()){
+                                defFuncId.secondTag = ParamTools.TwoLevelCode(dictGroupInfo.secondTag!!)
+                            }
+                            defFuncId.secondName = dictGroupInfo.secondTag
+                            defFuncId.subFlag = dictGroupInfo.subFlag
+                            defFuncId.type = "project"
+                            defFuncId.unit = dictGroupInfo.unit
+                            defFuncId.origCode = dictGroupInfo.origCode
+                            defFuncId.origDataType = dictGroupInfo.origDataType
+                            defFuncId.aliasCode = dictGroupInfo.aliasCode
+                            defFuncId.aliasName = dictGroupInfo.aliasName
 
 
 
-                                if (!defFuncId.name.isNullOrEmpty()){
-                                    /** 排序 */
-                                    if (defFuncId.name!! == "设备本地编码"||defFuncId.name!! == "楼层本地编码"||defFuncId.name!! == "本地编码"){
-                                        defFuncId.sort = 1
-                                    }else if (defFuncId.name!! == "设备本地名称"|| defFuncId.name!! == "楼层本地名称"||defFuncId.name!! == "本地名称"){
-                                        defFuncId.sort = 2
-                                    }else if (defFuncId.name!! == "设备二维码图片"||defFuncId.name!! == "二维码图片"||defFuncId.name!! == "二维码内容"){
-                                        defFuncId.sort = 3
-                                    }else if (defFuncId.name!! == "设计图纸中编码"){
-                                        defFuncId.sort = 4
-                                    }else if (defFuncId.name!! == "设备ID"||defFuncId.name!! =="编码"){
-                                        defFuncId.sort = 101
-                                    }else if (defFuncId.name!! == "设备名称"||defFuncId.name!! =="名称"){
-                                        defFuncId.sort = 102
-                                    }else if (defFuncId.name!! == "BIM模型中编码"){
-                                        defFuncId.sort = 103
-                                    }else if (defFuncId.name!! == "BIM模型中坐标"){
-                                        defFuncId.sort = 104
-                                    }else if (defFuncId.firstName != null&& defFuncId.firstName == "台账参数"){
-                                        defFuncId.sort = 10
-                                    }else if(defFuncId.firstName != null&& defFuncId.firstName == "通讯参数"){
-                                        defFuncId.sort = 20
-                                    }else {
-                                        defFuncId.sort = 60
-                                    }
-                                }
-
-                                if (defFuncId.code == "id") {
-                                    defFuncId.sort = 101
-                                }else if (defFuncId.code == "name" ) {
-                                    defFuncId.sort = 102
-                                }else if (defFuncId.code == "localId" ) {
+                            if (!defFuncId.name.isNullOrEmpty()){
+                                /** 排序 */
+                                if (defFuncId.name!! == "设备本地编码"||defFuncId.name!! == "楼层本地编码"||defFuncId.name!! == "本地编码"){
                                     defFuncId.sort = 1
-                                }else if (defFuncId.code == "localName" ) {
+                                }else if (defFuncId.name!! == "设备本地名称"|| defFuncId.name!! == "楼层本地名称"||defFuncId.name!! == "本地名称"){
                                     defFuncId.sort = 2
-                                }else if (defFuncId.code == "bimId" ) {
+                                }else if (defFuncId.name!! == "设备二维码图片"||defFuncId.name!! == "二维码图片"||defFuncId.name!! == "二维码内容"){
+                                    defFuncId.sort = 3
+                                }else if (defFuncId.name!! == "设计图纸中编码"){
+                                    defFuncId.sort = 4
+                                }else if (defFuncId.name!! == "设备ID"||defFuncId.name!! =="编码"){
+                                    defFuncId.sort = 101
+                                }else if (defFuncId.name!! == "设备名称"||defFuncId.name!! =="名称"){
+                                    defFuncId.sort = 102
+                                }else if (defFuncId.name!! == "BIM模型中编码"){
                                     defFuncId.sort = 103
-                                }else if (defFuncId.code == "bimLocation" ) {
+                                }else if (defFuncId.name!! == "BIM模型中坐标"){
                                     defFuncId.sort = 104
-                                }else if (defFuncId.code == "bimFamilyName" ) {
-                                    defFuncId.sort = 105
-                                }else if (defFuncId.code == "bimFamilySymbol" ) {
-                                    defFuncId.sort = 106
+                                }else if (defFuncId.firstName != null&& defFuncId.firstName == "台账参数"){
+                                    defFuncId.sort = 10
+                                }else if(defFuncId.firstName != null&& defFuncId.firstName == "通讯参数"){
+                                    defFuncId.sort = 20
+                                }else {
+                                    defFuncId.sort = 60
                                 }
+                            }
 
-                                val dicConfigureEditable = ParamTools.dicConfigureEditable()
-                                val containsKey = dicConfigureEditable.containsKey(defFuncId.code!!)
-                                if (containsKey){
-                                    defFuncId.editable = false
-                                    defFuncId.unDisabled = false
+                            if (defFuncId.code == "id") {
+                                defFuncId.sort = 101
+                            }else if (defFuncId.code == "name" ) {
+                                defFuncId.sort = 102
+                            }else if (defFuncId.code == "localId" ) {
+                                defFuncId.sort = 1
+                            }else if (defFuncId.code == "localName" ) {
+                                defFuncId.sort = 2
+                            }else if (defFuncId.code == "bimId" ) {
+                                defFuncId.sort = 103
+                            }else if (defFuncId.code == "bimLocation" ) {
+                                defFuncId.sort = 104
+                            }else if (defFuncId.code == "bimFamilyName" ) {
+                                defFuncId.sort = 105
+                            }else if (defFuncId.code == "bimFamilySymbol" ) {
+                                defFuncId.sort = 106
+                            }
+
+                            val dicConfigureEditable = ParamTools.dicConfigureEditable()
+                            val containsKey = dicConfigureEditable.containsKey(defFuncId.code!!)
+                            if (containsKey){
+                                defFuncId.editable = false
+                                defFuncId.unDisabled = false
 //                                    defFuncId.visible = false
-                                }
+                            }
 
-                                val dicConfigure = ParamTools.dicConfigure()
-                                if (defFuncId.code!=null){
-                                    val containsKey = dicConfigure.containsKey(defFuncId.code!!)
-                                    if (containsKey){
-                                        defFuncId.editable = true
-                                        defFuncId.unDisabled = false
+                            val dicConfigure = ParamTools.dicConfigure()
+                            if (defFuncId.code!=null){
+                                val containsKey = dicConfigure.containsKey(defFuncId.code!!)
+                                if (containsKey){
+                                    defFuncId.editable = true
+                                    defFuncId.unDisabled = false
 //                                        defFuncId.visible = true
-                                    }
                                 }
-                                defFuncIdService.replace(defFuncId)
                             }
+                            defFuncIdService.replace(defFuncId)
                         }
                     }
+                }
 //                }
                 sBaseResponse.result = SResponseType.success
             }else{
@@ -1694,24 +1696,47 @@ object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.j
     } // Fun dictPlatformInfo()
 
 
-    fun synCodeProject(groupCode: String,projectId: String): SBaseResponse {
+    fun synCodeProject(groupCode: String,projectId: String,sign: Boolean): SBaseResponse {
         try {
             val select = defFuncIdProjectService.select(SFilter.eq("type", "common"))
             select.tableName = "dict.def_funcid"
             val defFuncIdList = select.exec()
+
             if (defFuncIdList.size>0) {
-                for (defFuncId in defFuncIdList) {
+                if (!sign) {
+                    for (defFuncId in defFuncIdList) {
+                        try {
+                            defFuncId.projectId = projectId
+                            defFuncId.type = "project"
+                            defFuncId.groupCode = groupCode
+                            defFuncId.visible = null
+                            defFuncIdProjectService.replace(defFuncId)
+                        } catch (e: Exception) {
+                            e.printStackTrace()
+                        }
+                    }
+                }else {
                     try {
-                        defFuncId.projectId = projectId
-                        defFuncId.type = "project"
-                        defFuncId.groupCode = groupCode
-                        defFuncId.visible = null
-                        defFuncIdProjectService.replace(defFuncId)
+                        val projectList = projectService.selectAll().exec()
+                        for (project in projectList) {
+                            for (defFuncId in defFuncIdList) {
+                                try {
+                                    defFuncId.projectId = project.id
+                                    defFuncId.type = "project"
+                                    defFuncId.groupCode = project.groupCode
+                                    defFuncId.visible = null
+                                    defFuncIdProjectService.replace(defFuncId)
+                                } catch (e: Exception) {
+                                    e.printStackTrace()
+                                }
+                            }
+                        }
                     } catch (e: Exception) {
                         e.printStackTrace()
                     }
                 }
             }
+
         } catch (e: Exception) {
             e.printStackTrace()
         }