浏览代码

********************WX***********************
识别设备类型

zhangweixin 4 年之前
父节点
当前提交
c6446613b8

+ 1 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/objects/Equipment.kt

@@ -86,6 +86,7 @@ open class Equipment : BaseInfo() {
     /** RFID标识 */
     @Schema(description = "RFID标识")
     @Column(name = "rf_id")
+    @JSONField(name = "rFID")
     var rfId: String? = null
 
     /** BIM模型中编码 */

+ 53 - 47
datacenter/src/main/kotlin/com/persagy/server/services/objects/EquipmentService.kt

@@ -66,61 +66,67 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
      * @param   equip   设备对象
      */
     override fun onCreateBefore(equip: Equipment): Boolean {
-        /** 查询准备类型 */
-        if (!equip.id.isNullOrEmpty()) {
-            val isStartsWith = equip.id.toString().startsWith("Eq")
-            if (!isStartsWith) {
+        try {
+            /** 查询准备类型 */
+            if (!equip.id.isNullOrEmpty()) {
+                val isStartsWith = equip.id.toString().startsWith("Eq")
+                if (!isStartsWith) {
+                    /** 资产id */
+                    equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
+                }
+            } else {
                 /** 资产id */
                 equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
             }
-        } else {
-            /** 资产id */
-            equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
-        }
-        /** 项目id */
-        equip.projectId = Opt.projectId
-        if (equip.classCode.isNullOrEmpty()) {
-            return false
-        }
-        if (!Opt.coming.isNullOrEmpty()) {
-            equip.appId = Opt.coming
-        }
-        if(equip.classCode!!.length<6){
-            val entity = defClassService.select(
+            /** 项目id */
+            equip.projectId = Opt.projectId
+
+            if (equip.classCode.isNullOrEmpty()) {
+                logger.debug("33333333333333333333333333333333333")
+                return false
+            }
+            if (!Opt.coming.isNullOrEmpty()) {
+                equip.appId = Opt.coming
+            }
+            if(equip.classCode!!.length<6){
+                val entity = defClassService.select(
+                        SFilter.eq("projectId", equip.projectId!!),
+                        SFilter.endWith("code", equip.classCode!!)
+                ).entity()
+                if (entity!=null&&entity.code!!.length>=6){
+                    equip.classCode = entity.code
+                } else {
+                    return false
+                }
+            } else {
+                val entity = defClassService.select(
                     SFilter.eq("projectId", equip.projectId!!),
                     SFilter.endWith("code", equip.classCode!!)
-            ).entity()
-            if (entity!=null&&equip.classCode!!.length>=6){
-                equip.classCode = entity.code
-            } else {
-                return false
+                ).entity()
+                   if (entity == null) {
+                      return false
+                   }
             }
-        } else {
-            val entity = defClassService.select(
-                SFilter.eq("projectId", equip.projectId!!),
-                SFilter.endWith("code", equip.classCode!!)
-            ).entity()
-               if (entity == null) {
-                  return false
-               }
-        }
-
-        /** 设备名字 */
-        if (equip.name.isNullOrEmpty()) {
-            val entity = defClassService.select(
-                SFilter.eq("projectId", equip.projectId!!),
-                SFilter.eq("code", equip.classCode!!)
-            ).entity()
-            if (entity!=null) {
-                equip.name = ShaftNameUtil.shaftName(entity.name+"-")
-            }else {
-                equip.name = ShaftNameUtil.shaftName("设备-")
+            /** 设备名字 */
+            if (equip.name.isNullOrEmpty()) {
+                val entity = defClassService.select(
+                    SFilter.eq("projectId", equip.projectId!!),
+                    SFilter.eq("code", equip.classCode!!)
+                ).entity()
+                if (entity!=null) {
+                    equip.name = ShaftNameUtil.shaftName(entity.name+"-")
+                }else {
+                    equip.name = ShaftNameUtil.shaftName("设备-")
+                }
             }
+            if (!Opt.account.isNullOrEmpty()){
+                equip.findPeople = Opt.account
+            }
+            equip.codeType = 1
+        } catch (e: Exception) {
+            e.localizedMessage
+            return false
         }
-        if (!Opt.account.isNullOrEmpty()){
-            equip.findPeople = Opt.account
-        }
-        equip.codeType = 1
         return true
     } // Function onCreateBefore()
 

+ 9 - 9
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!@#
@@ -47,13 +47,13 @@ spring:
       max-file-size:                   500MB        # 限制单个文件的最大值
 
     #配置rabbitMq 服务器
-#  rabbitmq:
-#    host: 192.168.64.15
-#    port: 9936
-#    username: admin
-#    password: brzj123456
-#    #虚拟host 可以不设置,使用 server 默认 host
-#    virtual-host: /test
+  rabbitmq:
+    host: 192.168.64.15
+    port: 9936
+    username: admin
+    password: brzj123456
+    #虚拟host 可以不设置,使用 server 默认 host
+    virtual-host: /test
 
 #  rabbitmq:
 #    host: 39.102.43.179