Browse Source

********************WX************************
蜡笔森林:<wip>> <修改服务接口>
数据中心:<wip>> <添加MQ>
数据中同步:<wip>> <添加MQ>

zhangweixin 4 years ago
parent
commit
b97816ff82
29 changed files with 707 additions and 218 deletions
  1. 15 0
      datacenter/src/main/kotlin/com/persagy/server/Opt.kt
  2. 38 0
      datacenter/src/main/kotlin/com/persagy/server/controllers/TestController.kt
  3. 158 0
      datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqBaseService.kt
  4. 61 0
      datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqConfig.java
  5. 74 0
      datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqService.kt
  6. 22 0
      datacenter/src/main/kotlin/com/persagy/server/jms/TopicReceiver.kt
  7. 24 0
      datacenter/src/main/kotlin/com/persagy/server/jms/TopicSender.kt
  8. 10 0
      datacenter/src/main/kotlin/com/persagy/server/jms/bean/MessageNotice.kt
  9. 8 0
      datacenter/src/main/kotlin/com/persagy/server/jms/bean/SBaseNotice.kt
  10. 14 5
      datacenter/src/main/resources/application-dev.yml
  11. 4 2
      datasyn/build.gradle
  12. 28 0
      datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt
  13. 8 9
      datasyn/src/main/resources/application-dev.yml
  14. 7 30
      datasyn/src/main/resources/application.yml
  15. 1 0
      labsl/src/main/kotlin/com/persagy/server/labsl/models/entities/Anchor.kt
  16. 5 4
      labsl/src/main/kotlin/com/persagy/server/labsl/models/entities/Node.kt
  17. 142 137
      labsl/src/main/kotlin/com/persagy/server/labsl/services/GraphService.kt
  18. 2 1
      labsl/src/main/resources/application-dev.yml
  19. 2 1
      labsl/src/main/resources/application-prod.yml
  20. 15 0
      meiku/src/main/kotlin/com/persagy/server/meiku/MeiKuApp.kt
  21. 1 1
      meiku/src/main/kotlin/com/persagy/server/meiku/controller/MeiKuController.kt
  22. 4 6
      meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKu.kt
  23. 1 1
      meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKuAnchor.kt
  24. 6 1
      meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKuState.kt
  25. 0 1
      meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/ObjectCategory.kt
  26. 25 0
      meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/Pos.kt
  27. 19 13
      meiku/src/main/kotlin/com/persagy/server/meiku/services/MeiKuService.kt
  28. 7 5
      meiku/src/main/resources/application-dev.yml
  29. 6 1
      meiku/src/main/resources/application-prod.yml

+ 15 - 0
datacenter/src/main/kotlin/com/persagy/server/Opt.kt

@@ -0,0 +1,15 @@
+package com.persagy.server
+
+/**
+ * 常量池
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/27 21:07
+ */
+object Opt {
+    /** 交换机名 */
+    const val exchange = "exchange-dmp"
+    /** key */
+    const val routingKey = "routing-center-adm"
+
+}

+ 38 - 0
datacenter/src/main/kotlin/com/persagy/server/controllers/TestController.kt

@@ -0,0 +1,38 @@
+package com.persagy.server.controllers
+
+import com.persagy.server.jms.TopicSender
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+
+
+/**
+ * 测试消息
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/27 19:35
+ */
+@Api(tags = ["0000、测试消息"])
+@RestController
+@RequestMapping("/tests")
+class TestController {
+
+    @Autowired
+    lateinit var topicSender: TopicSender
+
+    /**
+     * 创建设备
+     *
+     * @param   request         设备对象
+     * @return                  创建结果信息
+     */
+    @ApiOperation(value = "测试消息", notes = "")
+    @PostMapping(value = ["/test"])
+    fun create() {
+        topicSender!!.sendMessage()
+    } // Function create()
+
+}

+ 158 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqBaseService.kt

@@ -0,0 +1,158 @@
+package com.persagy.server.jms
+
+import com.persagy.base.extensions.toJson
+import com.persagy.server.jms.bean.SBaseNotice
+import org.springframework.amqp.core.AmqpTemplate
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Component
+import org.springframework.stereotype.Service
+import java.util.*
+
+/**
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/27 21:05
+ */
+@Component
+@Service
+open class RabbitMqBaseService {
+    /** 指定 AMQP 操作的基本集合 */
+    @Autowired
+    private val amqpTemplate: AmqpTemplate? = null
+    /** 延迟发送时间 */
+    var delaySendTime = 3000L
+    /** 实现迟延相关数据 */
+    private val delayMap = HashMap<String, SDelayData>()
+
+    /**
+     * 发送通知
+     *
+     * @param   exchange     交换机
+     * @param   routingKey   key
+     * @param   notice      通知
+     * @param   delaySend   是否启动延迟发送,默认延迟发送
+     */
+    fun sendMessage(exchange: String,routingKey: String, notice: SBaseNotice, delaySend: Boolean = true) {
+        val delayData = delayMap[routingKey] ?: SDelayData()
+        if (!delayMap.containsKey(routingKey)) {
+            delayMap[routingKey] = delayData
+        }
+
+        // 合并请求
+        if (!mergeNotice(exchange,routingKey, notice)) {
+            if (delayData.lastNotice != null) {
+                sendTopic(exchange,routingKey, delayData.lastNotice!!.toJson())
+            }
+            delayData.lastNotice = notice
+        }
+
+        // 是否延迟发送
+        if (delaySend) {
+            delaySend(exchange,routingKey)
+        } else {
+            flush(exchange,routingKey)
+        }
+
+        return
+    } // Fun sendNotice()
+
+    /**
+     * 发送 topic 消息
+     *
+     * @param   topic       发送标题
+     * @param   data        消息数据
+     */
+    fun sendTopic(exchange: String,routingKey: String, data: String) {
+        amqpTemplate!!.convertAndSend(exchange, routingKey, data)
+    } // Fun sendTopic()
+
+    /**
+     * 合并通知
+     *
+     * @param   lastNotice          缓存的通知
+     * @param   notice              新的通知
+     * @return  成功返回true,否则返回false
+     */
+    open fun mergeNotice(lastNotice: SBaseNotice, notice: SBaseNotice): Boolean {
+        return false
+    } // Function mergeNotice()
+
+    /**
+     * 延迟发送缓存的消息
+     *
+     * @param   topic       发送标题
+     */
+    private fun delaySend(exchange: String,routingKey: String) {
+        val delayData = delayMap[routingKey] ?: return
+
+        // 如果延迟任务不为空,则取消之前的延迟任务。保证延迟任务在最后一次发送后执行。
+        if (delayData.delayTask != null) {
+            delayData.delayTask!!.cancel()
+        }
+
+        // 创建延迟任务
+        delayData.delayTask = object : TimerTask() {
+            override fun run() {
+                // 发送缓存的任务
+                flush(exchange,routingKey)
+            }
+        }
+
+        // 启动延迟发送任务
+        delayData.delayTimer.schedule(delayData.delayTask, delaySendTime)
+
+        return
+    } // Fun delaySend()
+
+    /**
+     * 发送缓存的消息
+     *
+     * @param   topic       发送标题
+     */
+    fun flush(exchange: String,routingKey: String) {
+        val delayData = delayMap[routingKey] ?: return
+        // 如果没有缓存通知
+        if (delayData.lastNotice == null) {
+            return
+        }
+
+        sendTopic(exchange,routingKey, delayData.lastNotice!!.toJson())
+        delayData.lastNotice = null
+
+        return
+    } // Fun flush()
+
+    /**
+     * 合并通知
+     *
+     * @param   topic       发送标题
+     * @param   notice      要合并的通知
+     * @return  成功返回true,否则返回false
+     */
+    private fun mergeNotice(exchange: String,routingKey: String, notice: SBaseNotice): Boolean {
+        val delayData = delayMap[routingKey] ?: return false
+
+        // 如果最后发送的通知为空
+        if (delayData.lastNotice == null) {
+            delayData.lastNotice = notice
+            return true
+        }
+
+        return mergeNotice(delayData.lastNotice!!, notice)
+    } // Fun mergeNotice()
+
+
+
+    /**
+     * 延迟处理数据
+     */
+    inner class SDelayData {
+        /** 最后发送的通知 */
+        var lastNotice: SBaseNotice? = null
+        /** 延迟发送通知定时器 */
+        val delayTimer = Timer()
+        /** 延迟发送通知定时任务 */
+        var delayTask: TimerTask? = null
+    } // Class SDelayData
+
+}

+ 61 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqConfig.java

@@ -0,0 +1,61 @@
+package com.persagy.server.jms;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created by Administrator on 2018/4/10.
+ * 1. yaml
+ * 2. RabbitMqConfig
+ *      a  创建queue
+ *      b. 创建交换机TopicExchange
+ *      c. 根据绑定规则将队列绑定到相应的交换机上
+ * 3. sender
+ * 4. test
+ * 5. receiver
+ */
+
+@Configuration
+public class RabbitMqConfig {
+ 
+    //  a  创建queue
+    @Bean(name = "message") //  指定该参数名是message  见下面Qualifier("message")
+    public Queue queueMessage(){
+        return new Queue("topic.message");  //  topic.message  是rounting-key,匹配规则
+    }
+ 
+    @Bean(name = "notes")
+    public Queue queueMessages(){
+        return new Queue("topic.notes");
+    }
+ 
+    //  b. 创建交换机TopicExchange
+    @Bean
+    public TopicExchange exchange(){
+        return new TopicExchange("topicExchange");
+    }
+ 
+    /*
+      c. 根据绑定规则将队列绑定到相应的交换机上(bindingKey)--Exchange Queues
+ 
+     */
+    @Bean
+    public Binding bindingExchangeMessage(@Qualifier("message") Queue queueMessage, TopicExchange exchange){
+        return BindingBuilder.bind(queueMessage).to(exchange).with("topic.message");
+    }
+ 
+    @Bean
+    /**
+     * 将队列"messages" 绑定到交换机上,绑定规则是 topic.messages
+     *
+     */
+    public  Binding bindingExchangeMessages(@Qualifier("notes")Queue queueMessages,TopicExchange exchange){
+        return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#");
+    }
+ 
+}

+ 74 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqService.kt

@@ -0,0 +1,74 @@
+package com.persagy.server.jms
+
+import com.persagy.server.jms.bean.MessageNotice
+import com.persagy.server.jms.bean.SBaseNotice
+import com.persagy.service.utils.SJsonUtil
+import org.springframework.amqp.rabbit.annotation.RabbitHandler
+import org.springframework.amqp.rabbit.annotation.RabbitListener
+import org.springframework.stereotype.Component
+import org.springframework.stereotype.Service
+
+/**
+ * 消息
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/28 8:43
+ */
+@Component
+@Service
+class RabbitMqService: RabbitMqBaseService() {
+
+    /**
+     * 接收消息
+     *
+     * @param
+     */
+    @RabbitListener(queues = ["queue-adm"])
+    @RabbitHandler
+    fun receiveMessage(message: String) {
+        println("我是监听queue-adm的,仅满足queue-adm的过来 , $message")
+        val messageNotice = SJsonUtil.fromJson(message, MessageNotice::class.java)
+        if (messageNotice!=null){
+            when(messageNotice.objOrRel){
+                    "objects" ->{
+
+                    }
+                    "" ->{
+
+                    }
+            }
+        }
+
+    }
+
+
+    /**
+     * 合并重新
+     *
+     * @param lastNotice 最后一条消息对象
+     * @param notice     当前消息对象
+     * @return 是否合并
+     */
+    override fun mergeNotice(lastNotice: SBaseNotice, notice: SBaseNotice): Boolean {
+        // 对象消息合并
+        if (notice is MessageNotice) {
+            // 如果最后发送对象不是对象消息,则返回false
+            val last = lastNotice as? MessageNotice ?: return false
+            // 操作不同,对象不同,项目不同的通知不合并
+            if (notice.ops != notice.ops || notice.type != last.type || notice.projectId != last.projectId) {
+                return false
+            }
+            // 合并消息
+            last.idList.addAll(notice.idList)
+            return true
+        }
+//        else if (notice is RelationNotice) {  // 关系消息合并
+//            // TODO: 补 关系类型通知合并代码
+//            return true
+//        }
+        return false
+    }
+
+
+
+}

+ 22 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/TopicReceiver.kt

@@ -0,0 +1,22 @@
+package com.persagy.server.jms
+
+import org.springframework.amqp.rabbit.annotation.RabbitHandler
+import org.springframework.amqp.rabbit.annotation.RabbitListener
+import org.springframework.stereotype.Component
+
+/**
+ * 接收消息
+ *
+ * @author wx
+ */
+@Component
+class TopicReceiver {
+
+    @RabbitListener(queues = ["queue-adm"])
+    @RabbitHandler
+    fun receiveMessage1(str: String) {
+        println("我是监听queue-adm的,仅满足queue-adm的过来 , $str")
+    }
+
+
+}

+ 24 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/TopicSender.kt

@@ -0,0 +1,24 @@
+package com.persagy.server.jms
+
+import org.springframework.amqp.core.AmqpTemplate
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Component
+import org.springframework.stereotype.Service
+
+/**
+ * 消息发送类
+ */
+@Component
+@Service
+class TopicSender {
+    @Autowired
+    private val amqpTemplate: AmqpTemplate? = null
+
+
+    // 交换机  rountingkey  发送的内容  发送消息到相应的Exchange
+    fun sendMessage() {
+        amqpTemplate!!.convertAndSend("exchange-dmp", "routing-center-adm", "我是发送消息的内容! ")
+    } /*
+         向   名称为 topicExchange 的交换机 发送满足routingkey规则为 "topic.messages " 的内容为 "我是发送消息的内容"  的消息
+         */
+}

+ 10 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/bean/MessageNotice.kt

@@ -0,0 +1,10 @@
+package com.persagy.server.jms.bean
+
+/**
+ * 对象
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/27 22:24
+ */
+class MessageNotice(var projectId: String, var objOrRel: String, type: String, ops: String, val id: String,var idList: HashSet<String>, val fromId: String, val toId: String?)
+    : SBaseNotice(type,ops)

+ 8 - 0
datacenter/src/main/kotlin/com/persagy/server/jms/bean/SBaseNotice.kt

@@ -0,0 +1,8 @@
+package com.persagy.server.jms.bean
+
+/**
+ * 消息基类
+ *
+ * @author wx
+ */
+open class SBaseNotice(val type: String, val ops: String)

+ 14 - 5
datacenter/src/main/resources/application-dev.yml

@@ -45,9 +45,18 @@ spring:
 
     #配置rabbitMq 服务器
   rabbitmq:
-    host: 192.168.0.190
-    port: 5672
+    host: 39.102.43.179
+    port: 9936
     username: admin
-    password: admin
-      #虚拟host 可以不设置,使用server默认host
-    virtual-host: JCcccHost
+    password: brzj123456
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /test
+
+#  rabbitmq:
+#    host: 192.168.0.190
+#    port: 5672
+#    username: admin
+#    password: admin
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+

+ 4 - 2
datasyn/build.gradle

@@ -51,14 +51,16 @@ dependencies {
     compile group: "org.springframework.boot", name: "spring-boot-starter-actuator", version: SPRING_BOOT_VERSION
     compile group: "org.springframework.boot", name: "spring-boot-starter-logging", version: SPRING_BOOT_VERSION
     //消息
-    compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
+//    compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
+    // RabbitMQ
+    compile group: 'org.springframework.boot',    name: 'spring-boot-starter-amqp', version: SPRING_BOOT_VERSION
     providedCompile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
     // spring boot 缓存
     compile group:"org.springframework.boot", name:"spring-boot-starter-cache", version: SPRING_BOOT_VERSION
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // spring cloud 依赖
-    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
+//    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // MySQL

+ 28 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt

@@ -0,0 +1,28 @@
+package com.persagy.server.syn.jms
+
+import org.slf4j.LoggerFactory
+import org.springframework.amqp.rabbit.annotation.RabbitHandler
+import org.springframework.amqp.rabbit.annotation.RabbitListener
+import org.springframework.stereotype.Component
+
+
+/**
+ * 消息的接收者
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/10/27 17:25
+ */
+@Component
+class MessageReceiver {
+    companion object {
+        // 日志
+        private val logger = LoggerFactory.getLogger(MessageReceiver::class.java)
+    } // Companion object
+
+    @RabbitListener(queues = ["queue-zwx"])
+    @RabbitHandler
+    fun process(mess: String) {
+        println("我是topic.qune的消费者接收到的消息为 :$mess")
+        logger.debug("接收消息:${mess}")
+    }
+
+}

+ 8 - 9
datasyn/src/main/resources/application-dev.yml

@@ -10,15 +10,14 @@ spring:
     username:                           postgres
     password:                           persagy_2020qwe!@#
 
-  activemq:
-    broker-url:                         tcp://172.16.42.210:61616
-
-  kafka:
-#    bootstrap-servers:                      127.0.0.1:9092
-    bootstrap-servers:                      192.168.20.236:9092
-
-    consumer:
-      group-id:                             datacenter-consumer-group
+    #配置rabbitMq 服务器
+  rabbitmq:
+    host: 39.102.43.179
+    port: 9936
+    username: admin
+    password: brzj123456
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /test
 
 saga:
   dataPlatform:                        http://39.102.54.110:9002

+ 7 - 30
datasyn/src/main/resources/application.yml

@@ -1,6 +1,7 @@
 
 spring:
-
+  application:
+    name:                               datasyn
   kafka:
     producer:
       retries:                              0
@@ -24,22 +25,15 @@ spring:
     favicon:
       enabled:                          true
   jmx:
-    default-domain:                     dataplatform-sync
-#    default-domain:                     dataplatform-sync-project
+    default-domain:                     datasyn
+
 
   datasource:
-    name:                               dataplatform-sync
-#    name:                               dataplatform-sync-project
+    name:                               datasyn
     type:                               com.alibaba.druid.pool.DruidDataSource
     #测试服务
     driver-class-name:                  org.postgresql.Driver
-#    url:                                jdbc:postgresql://10.30.128.200:5432/datacenter
-#    username:                           postgres
-#    password:                           123qwe!@#
-#  datasource:
-#    url:                                jdbc:postgresql://47.93.187.165:5432/datacenter
-#    username:                           postgres
-#    password:                           123qwe\!@#
+
 
   jackson:
     date-format:                        yyyy-MM-dd HH:mm:ss
@@ -53,27 +47,10 @@ spring:
           # 属性按字母顺序输出
           sort_properties_alphabetically:   true
 
-  activemq:
-    in-memory:                          true
-    pool.enabled:                       false
-    user:                               admin
-    password:                           admin
-    broker-url:                         tcp://172.16.42.210:61616
-  jms:
-    pub-sub-domain: true
 
-topic:                                 datacenter.broadcast
 
 mybatis:
   typeAliasesPackage:                   cn.sagacloud.server.datacenter.entities
 
 
-## 分页插件配置
-#pagehelper:
-#  helperDialect:                        mysql
-#  reasonable:                           true
-#  supportMethodsArguments:              true
-#  params:                               count=countSql
-#saga:
-#  dataPlatform:                         http://47.93.187.165:9909/data-platform-3
-#  scanBuilding:                         http://mbi.sagacloud.cn:8080/ScanBuilding
+

+ 1 - 0
labsl/src/main/kotlin/com/persagy/server/labsl/models/entities/Anchor.kt

@@ -31,6 +31,7 @@ open class Anchor : SBaseEntity(), Serializable {
 
     /** 图id */
     @ApiModelProperty(value = "图id")
+    @Id
     @Column(name = "graph_id")
     var graphId: String? = null
 

+ 5 - 4
labsl/src/main/kotlin/com/persagy/server/labsl/models/entities/Node.kt

@@ -44,10 +44,10 @@ open class Node : SBaseEntity(), Serializable {
     @Column(name = "graph_element_id")
     var graphElementId: String? = null
 
-    /** 图例数量 */
-    @ApiModelProperty(value = "图例数量")
-    @Column(name = "num")
-    var num: Int? = null
+//    /** 图例数量 */
+//    @ApiModelProperty(value = "图例数量")
+//    @Column(name = "num")
+//    var num: Int? = null
 
     /** 节点类型(image / zone) */
     @ApiModelProperty(value = "节点类型(image / zone)")
@@ -85,6 +85,7 @@ open class Node : SBaseEntity(), Serializable {
 
     /** 系统图 id */
     @ApiModelProperty(value = "系统图 id",required = true)
+    @Id
     @Column(name = "graph_id")
     var graphId: String? = null
 

+ 142 - 137
labsl/src/main/kotlin/com/persagy/server/labsl/services/GraphService.kt

@@ -202,159 +202,164 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
      * @return 已发布的图对象列表
      */
     fun pubDrawings(graphPub: GraphPub): SCreateResponse<GraphPub> {
-        val sCreateResponse = SCreateResponse<GraphPub>()
-        /** 项目id */
-        val projectId = SPageContext.getHeader("projectId")
-        val graph1 = Graph()
-        graph1.projectId = projectId!!
-        graph1.id = graphPub.id
-        graph1.graphId = graphPub.graphId
-        /** 查询草稿箱 */
-        val squeryBuilder = GraphPubService.select(
-            SFilter.eq("projectId", projectId!!),
-            SFilter.eq("id", graphPub.id!!),
-            SFilter.eq("graphId", graphPub.graphId!!),
-            SFilter.eq("state", 1)
-        )
-        val graph = squeryBuilder.table("labsl.graph").entity()
-        if (graph!=null){
-            //开启事务
-            openTransaction()
-            /** 清除已发布的老数据 */
-            delOldDataPub(graph1)
-            /** 版本号 */
-            val listVersion = graph.version!!.split(".")
-            val num = listVersion[1].toInt() + 1
-            graph.version = listVersion[0] + "." + num + "." + 0
-            graph.state = 0
-            graph.isAvailable = true
-//            graph.isPub = true
-            val insert = GraphPubService.insert(graph)
-            if (!insert) {
-                // 回滚
-                backTransaction()
-                sCreateResponse.result = SResponseType.failure
-                return  sCreateResponse
-            }
-            /** 子节点 */
-            val nodebuilder = nodePubService.select(
-//                SFilter.eq("projectId", projectId!!),
-                SFilter.eq("graphId", graph.graphId!!),
+        return try {
+            val sCreateResponse = SCreateResponse<GraphPub>()
+            /** 项目id */
+            val projectId = SPageContext.getHeader("projectId")
+            val graph1 = Graph()
+            graph1.projectId = projectId!!
+            graph1.id = graphPub.id
+            graph1.graphId = graphPub.graphId
+            /** 查询草稿箱 */
+            val squeryBuilder = GraphPubService.select(
+                SFilter.eq("projectId", projectId!!),
                 SFilter.eq("id", graphPub.id!!),
+                SFilter.eq("graphId", graphPub.graphId!!),
                 SFilter.eq("state", 1)
             )
-            val nodePubList = nodebuilder.table("labsl.node_pub").exec()
-            if (nodePubList.size>0){
-                for (nodePub in nodePubList){
-                    nodePub.id = graph.id
-                    nodePub.graphId = graph.graphId
-                    nodePub.state = 0
-                    val insert1 = nodePubService.insert(nodePub)
-                    if (!insert1){
-                        // 回滚
-                        backTransaction()
-                        sCreateResponse.result = SResponseType.failure
-                        return  sCreateResponse
+            val graph = squeryBuilder.table("labsl.graph").entity()
+            if (graph!=null){
+                //开启事务
+                openTransaction()
+                /** 清除已发布的老数据 */
+                delOldDataPub(graph1)
+                /** 版本号 */
+                val listVersion = graph.version!!.split(".")
+                val num = listVersion[1].toInt() + 1
+                graph.version = listVersion[0] + "." + num + "." + 0
+                graph.state = 0
+                graph.isAvailable = true
+    //            graph.isPub = true
+                val insert = GraphPubService.insert(graph)
+                if (!insert) {
+                    // 回滚
+                    backTransaction()
+                    sCreateResponse.result = SResponseType.failure
+                    return  sCreateResponse
+                }
+                /** 子节点 */
+                val nodebuilder = nodePubService.select(
+    //                SFilter.eq("projectId", projectId!!),
+                    SFilter.eq("graphId", graph.graphId!!),
+                    SFilter.eq("id", graphPub.id!!),
+                    SFilter.eq("state", 1)
+                )
+                val nodePubList = nodebuilder.table("labsl.node").exec()
+                if (nodePubList.size>0){
+                    for (nodePub in nodePubList){
+                        nodePub.id = graph.id
+                        nodePub.graphId = graph.graphId
+                        nodePub.state = 0
+                        val insert1 = nodePubService.insert(nodePub)
+                        if (!insert1){
+                            // 回滚
+                            backTransaction()
+                            sCreateResponse.result = SResponseType.failure
+                            return  sCreateResponse
+                        }
                     }
                 }
-            }
-            val markersbuilder = markersPubService.select(
-//                SFilter.eq("projectId", projectId!!),
-                SFilter.eq("graphId", graph.graphId!!),
-                SFilter.eq("id", graphPub.id!!),
-                SFilter.eq("state", 1)
-            )
-            val markersPubList = markersbuilder.table("labsl.marker_pub").exec()
-            if (markersPubList.size>0){
-                for (markersPub in markersPubList){
-                    markersPub.id = graph.id
-                    markersPub.graphId = graph.graphId
-                    markersPub.state = 0
-                    val insert1 = markersPubService.insert(markersPub)
-                    if (insert1){
-                        // 回滚
-                        backTransaction()
-                        sCreateResponse.result = SResponseType.failure
-                        return  sCreateResponse
+                val markersbuilder = markersPubService.select(
+    //                SFilter.eq("projectId", projectId!!),
+                    SFilter.eq("graphId", graph.graphId!!),
+                    SFilter.eq("id", graphPub.id!!),
+                    SFilter.eq("state", 1)
+                )
+                val markersPubList = markersbuilder.table("labsl.marker").exec()
+                if (markersPubList.size>0){
+                    for (markersPub in markersPubList){
+                        markersPub.id = graph.id
+                        markersPub.graphId = graph.graphId
+                        markersPub.state = 0
+                        val insert1 = markersPubService.insert(markersPub)
+                        if (!insert1){
+                            // 回滚
+                            backTransaction()
+                            sCreateResponse.result = SResponseType.failure
+                            return  sCreateResponse
+                        }
                     }
                 }
-            }
-            val relationBuilder = relationPubService.select(
-//                SFilter.eq("projectId", projectId!!),
-                SFilter.eq("graphId", graph.graphId!!),
-                SFilter.eq("id", graphPub.id!!),
-                SFilter.eq("state", 1)
-            )
-            val relationList = relationBuilder.table("labsl.relation_pub").exec()
-            if (relationList.size>0){
-                for (relation in relationList){
-                    relation.id = graph.id
-                    relation.graphId = graph.graphId
-                    relation.state = 0
-                    val insert1 = relationPubService.insert(relation)
-                    if (!insert1){
-                        // 回滚
-                        backTransaction()
-                        sCreateResponse.result = SResponseType.failure
-                        return  sCreateResponse
+                val relationBuilder = relationPubService.select(
+    //                SFilter.eq("projectId", projectId!!),
+                    SFilter.eq("graphId", graph.graphId!!),
+                    SFilter.eq("id", graphPub.id!!),
+                    SFilter.eq("state", 1)
+                )
+                val relationList = relationBuilder.table("labsl.relation").exec()
+                if (relationList.size>0){
+                    for (relation in relationList){
+                        relation.id = graph.id
+                        relation.graphId = graph.graphId
+                        relation.state = 0
+                        val insert1 = relationPubService.insert(relation)
+                        if (!insert1){
+                            // 回滚
+                            backTransaction()
+                            sCreateResponse.result = SResponseType.failure
+                            return  sCreateResponse
+                        }
                     }
                 }
-            }
-            val anchorBuilder = anchorPubService.select(
-//                SFilter.eq("projectId", projectId!!),
-                SFilter.eq("graphId", graph.graphId!!),
-                SFilter.eq("id", graphPub.id!!),
-                SFilter.eq("state", 1)
-            )
-            val anchorList = anchorBuilder.table("labsl.anchor_pub").exec()
-            if (anchorList.size>0){
-                for (anchor in anchorList){
-                    anchor.id = graph.id
-                    anchor.graphId = graph.graphId
-                    anchor.state = 0
-                    val insert1 = anchorPubService.insert(anchor)
-                    if (!insert1){
-                        // 回滚
-                        backTransaction()
-                        sCreateResponse.result = SResponseType.failure
-                        return  sCreateResponse
+                val anchorBuilder = anchorPubService.select(
+    //                SFilter.eq("projectId", projectId!!),
+                    SFilter.eq("graphId", graph.graphId!!),
+                    SFilter.eq("id", graphPub.id!!),
+                    SFilter.eq("state", 1)
+                )
+                val anchorList = anchorBuilder.table("labsl.anchor").exec()
+                if (anchorList.size>0){
+                    for (anchor in anchorList){
+                        anchor.id = graph.id
+                        anchor.graphId = graph.graphId
+                        anchor.state = 0
+                        val insert1 = anchorPubService.insert(anchor)
+                        if (!insert1){
+                            // 回滚
+                            backTransaction()
+                            sCreateResponse.result = SResponseType.failure
+                            return  sCreateResponse
+                        }
                     }
                 }
-            }
 
-            val attachObjectIdsBuilder = attachObjectIdsPubService.select(
-//                SFilter.eq("projectId", projectId!!),
-                SFilter.eq("graphId", graph.graphId!!),
-                SFilter.eq("id", graphPub.id!!),
-                SFilter.eq("state", 1)
-            )
-            val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids_pub").exec()
-            if (attachObjectIdsList.size>0){
-                for (attachObjectIds in attachObjectIdsList){
-                    attachObjectIds.id = graph.id
-                    attachObjectIds.graphId = graph.graphId
-                    attachObjectIds.state = 0
-                    val insert1 = attachObjectIdsPubService.insert(attachObjectIds)
-                    if (!insert1){
-                        // 回滚
-                        backTransaction()
-                        sCreateResponse.result = SResponseType.failure
-                        return  sCreateResponse
+                val attachObjectIdsBuilder = attachObjectIdsPubService.select(
+    //                SFilter.eq("projectId", projectId!!),
+                    SFilter.eq("graphId", graph.graphId!!),
+                    SFilter.eq("id", graphPub.id!!),
+                    SFilter.eq("state", 1)
+                )
+                val attachObjectIdsList = attachObjectIdsBuilder.table("labsl.attach_object_ids").exec()
+                if (attachObjectIdsList.size>0){
+                    for (attachObjectIds in attachObjectIdsList){
+                        attachObjectIds.id = graph.id
+                        attachObjectIds.graphId = graph.graphId
+                        attachObjectIds.state = 0
+                        val insert1 = attachObjectIdsPubService.insert(attachObjectIds)
+                        if (!insert1){
+                            // 回滚
+                            backTransaction()
+                            sCreateResponse.result = SResponseType.failure
+                            return  sCreateResponse
+                        }
                     }
                 }
-            }
 
-            /** 清除草稿箱图 */
-            delOldData(graph1)
-            // 提交事务
-            commitTransaction()
-            sCreateResponse.entityList = arrayListOf(graph)
-            sCreateResponse.result = SResponseType.success
-        }else{
-            sCreateResponse.result = SResponseType.failure
-            sCreateResponse.message = "草稿箱中没有待发布图形"
+                /** 清除草稿箱图 */
+                delOldData(graph1)
+                // 提交事务
+                commitTransaction()
+                sCreateResponse.entityList = arrayListOf(graph)
+                sCreateResponse.result = SResponseType.success
+            }else{
+                sCreateResponse.result = SResponseType.failure
+                sCreateResponse.message = "草稿箱中没有待发布图形"
+            }
+            return sCreateResponse
+        } catch (e: Exception) {
+            e.printStackTrace()
+            SCreateResponse(SResponseType.failure,e.message!!)
         }
-        return sCreateResponse
     } // Fun pubDrawings()
 
     /**

+ 2 - 1
labsl/src/main/resources/application-dev.yml

@@ -11,7 +11,8 @@ spring:
 #   password:                           123qwe!@#
     url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
     username:                           postgres
-    password:                           persagy_2020qwe!@#
+#    password:                           persagy_2020qwe!@#
+    password:                           cGVyc2FneV8yMDIwcXdlIUAj
 
   activemq:
     broker-url:                         tcp://172.16.42.210:61616

+ 2 - 1
labsl/src/main/resources/application-prod.yml

@@ -10,7 +10,8 @@ spring:
   datasource:
     url:                                jdbc:postgresql://172.17.100.16:5432/datacenter
     username:                           postgres
-    password:                           persagy_2020qwe!@#
+#    password:                           persagy_2020qwe!@#
+    password:                           cGVyc2FneV8yMDIwcXdlIUAj
 
   activemq:
     broker-url:                         tcp://activemq:61616

+ 15 - 0
meiku/src/main/kotlin/com/persagy/server/meiku/MeiKuApp.kt

@@ -20,12 +20,14 @@
 
 package com.persagy.server.meiku
 
+import com.persagy.service.json.SJsonHttpMessageConverter
 import org.mybatis.spring.annotation.MapperScan
 import org.slf4j.LoggerFactory
 import org.springframework.boot.SpringApplication
 import org.springframework.boot.autoconfigure.SpringBootApplication
 import org.springframework.boot.builder.SpringApplicationBuilder
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
+import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.ComponentScan
 
 /**
@@ -51,6 +53,19 @@ open class MeiKuApp : SpringBootServletInitializer() {
         return application.sources(MeiKuApp::class.java)
     } // Function configure
 
+    /**
+     * 配置FastJson
+     *
+     * @return  HttpMessageConverters
+     */
+    @Bean
+    @Suppress("MoveLambdaOutsideParentheses")
+    open fun jsonHttpMessageConverters(): SJsonHttpMessageConverter {
+        val fastConverter = SJsonHttpMessageConverter()
+        fastConverter.propertyNamingStrategy = com.alibaba.fastjson.PropertyNamingStrategy.CamelCase
+        return fastConverter
+    } // Function fastJsonHttpMessageConverters()
+
 } // Class Application
 
 /**

+ 1 - 1
meiku/src/main/kotlin/com/persagy/server/meiku/controller/MeiKuController.kt

@@ -72,7 +72,7 @@ class MeiKuController {
     /**
      * 查询图形信息
      */
-    @ApiOperation(value = "查询图例-批量", notes = "不包含状态和锚点")
+    @ApiOperation(value = "查询图例-批量", notes = " 类型:category   级联:锚点(anchorList)状态:(state)  ")
     @PostMapping(value = ["/query"])
     fun query(@RequestBody request: SQueryRequest): SQueryResponse<MeiKu> {
         return MeiKuService.pageQuery(request)

+ 4 - 6
meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKu.kt

@@ -1,6 +1,7 @@
 package com.persagy.server.meiku.models.entities
 
 import com.persagy.service.models.SBaseEntity
+import com.persagy.service.models.annotations.SCascade
 import io.swagger.annotations.ApiModel
 import io.swagger.annotations.ApiModelProperty
 import java.io.Serializable
@@ -28,11 +29,6 @@ class MeiKu : Serializable, SBaseEntity() {
     @Column(name = "category")
     var category: String? = null
 
-    /** 默认图Key */
-    @ApiModelProperty(value = "默认图Key")
-    @Column(name = "pic")
-    var pic: String? = null
-
     /** 品牌 */
     @ApiModelProperty(value = "品牌")
     @Column(name = "brand")
@@ -45,9 +41,11 @@ class MeiKu : Serializable, SBaseEntity() {
 
     /** 锚点列表 */
     @ApiModelProperty(value = "锚点列表")
+    @SCascade(table="labsl_meiku.meiku_anchor", idColumn="meitu_id", childIdColumn="id")
     var anchorList: ArrayList<MeiKuAnchor>? = null
 
     @ApiModelProperty(value = "状态")
-    var state: MeiKuState? = null
+    @SCascade(table="labsl_meiku.meiku_state", idColumn="meiku_id", childIdColumn="id")
+    var state: ArrayList<MeiKuState>? = null
 
 } // Class MeiKu

+ 1 - 1
meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKuAnchor.kt

@@ -33,6 +33,6 @@ class MeiKuAnchor: Serializable, SBaseEntity() {
     /** 锚点坐标 */
     @ApiModelProperty(value = "锚点坐标")
     @Column(name = "pos")
-    var pos: HashMap<String,Any?>? = null
+    var pos: Pos? = null
 
 } // Class MeiKuAnchor

+ 6 - 1
meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/MeiKuState.kt

@@ -32,6 +32,11 @@ class MeiKuState: Serializable, SBaseEntity() {
     /** 状态内容 */
     @ApiModelProperty(value = "状态内容")
     @Column(name = "state")
-    var state: HashMap<String,Any?>? = null
+    var state: String? = null
+
+    /** 图片key */
+    @ApiModelProperty(value = "图片key")
+    @Column(name = "pic")
+    var pic: String? = null
 
 } // class MeiKuState

+ 0 - 1
meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/ObjectCategory.kt

@@ -1,6 +1,5 @@
 package com.persagy.server.meiku.models.entities
 
-import com.alibaba.fastjson.annotation.JSONField
 import com.persagy.service.models.SBaseEntity
 import io.swagger.annotations.ApiModel
 import io.swagger.annotations.ApiModelProperty

+ 25 - 0
meiku/src/main/kotlin/com/persagy/server/meiku/models/entities/Pos.kt

@@ -0,0 +1,25 @@
+package com.persagy.server.meiku.models.entities
+
+import io.swagger.annotations.ApiModelProperty
+import java.io.Serializable
+
+/**
+ * 位置信息
+ *
+ * @author wx
+ */
+class Pos : Serializable {
+
+    /** X坐标 */
+    @ApiModelProperty(value = "X坐标")
+    var x: Double? = null
+
+    /** Y坐标 */
+    @ApiModelProperty(value = "Y坐标")
+    var y: Double? = null
+
+    /** Z坐标 */
+    @ApiModelProperty(value = "Z坐标")
+    var z: Double? = null
+
+} // Class Pos

+ 19 - 13
meiku/src/main/kotlin/com/persagy/server/meiku/services/MeiKuService.kt

@@ -43,13 +43,16 @@ object MeiKuService : SObjectService<MeiKu>(SMybatisDao(MeiKu::class.java)) {
                     val insert1 = MeiKuAnchorService.insert(anchor)
                 }
             }
-            if (meiKu.state != null) {
-                val state = meiKu.state
-                state!!.meiTuId = meiKu.id
-                if (state!!.id.isNullOrEmpty()) {
-                    state!!.id = UUID.randomUUID().toString().replace("-", "")
+            if (!meiKu.state .isNullOrEmpty()) {
+                val stateList = meiKu.state
+                for (state in stateList!!){
+                    state!!.meiTuId = meiKu.id
+                    if (state!!.id.isNullOrEmpty()) {
+                        state!!.id = UUID.randomUUID().toString().replace("-", "")
+                    }
+                    MeiKuStateService.insert(state)
                 }
-                MeiKuStateService.insert(meiKu.state!!)
+
             }
             sCreateResponse.entityList = arrayListOf(meiKu)
             sCreateResponse.result = SResponseType.success
@@ -81,13 +84,16 @@ object MeiKuService : SObjectService<MeiKu>(SMybatisDao(MeiKu::class.java)) {
                         val insert1 = MeiKuAnchorService.insert(anchor)
                     }
                 }
-                if (meiKu.state != null) {
-                    val state = meiKu.state
-                    state!!.meiTuId = meiKu.id
-                    if (state!!.id.isNullOrEmpty()) {
-                        state!!.id = UUID.randomUUID().toString().replace("-", "")
+                if (!meiKu.state.isNullOrEmpty()) {
+                    val stateList = meiKu.state
+                    for (state in stateList!!){
+                        state!!.meiTuId = meiKu.id
+                        if (state!!.id.isNullOrEmpty()) {
+                            state!!.id = UUID.randomUUID().toString().replace("-", "")
+                        }
+                        val insert1 = MeiKuStateService.insert(state)
                     }
-                    val insert1 = MeiKuStateService.insert(meiKu.state!!)
+
                 }
                 sBaseResponse.result = SResponseType.success
             } else {
@@ -126,7 +132,7 @@ object MeiKuService : SObjectService<MeiKu>(SMybatisDao(MeiKu::class.java)) {
                     if (meiKuAnchorList.size>0){
                         entity.anchorList = meiKuAnchorList
                     }
-                    val meiKuState = MeiKuStateService.select(SFilter.eq("id", meiKu.id!!)).entity()
+                    val meiKuState = MeiKuStateService.select(SFilter.eq("id", meiKu.id!!)).exec()
                     if (meiKuState!=null){
                         entity.state = meiKuState
                     }

+ 7 - 5
meiku/src/main/resources/application-dev.yml

@@ -3,12 +3,14 @@ server:
 
 spring:
   datasource:
-#    url:                                jdbc:postgresql://172.16.44.234:5432/datacenter
-#    username:                           postgres
-#    password:                           123456
-   url:                                jdbc:postgresql://60.205.177.43:5432/datacenter
+#   url:                                jdbc:postgresql://60.205.177.43:5432/datacenter
+#   username:                           postgres
+#   password:                           123qwe!@#
+   url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
    username:                           postgres
-   password:                           123qwe!@#
+#   password:                           persagy_2020qwe!@#
+   password:                           cGVyc2FneV8yMDIwcXdlIUAj
+
 
   activemq:
     broker-url:                         tcp://172.16.42.210:61616

+ 6 - 1
meiku/src/main/resources/application-prod.yml

@@ -10,7 +10,12 @@ spring:
   datasource:
     url:                                jdbc:postgresql://172.17.100.16:5432/datacenter
     username:                           postgres
-    password:                           persagy_2020qwe!@#
+#    password:                           persagy_2020qwe!@#
+    password:                           cGVyc2FneV8yMDIwcXdlIUAj
 
   activemq:
     broker-url:                         tcp://activemq:61616
+
+
+
+  alter user postgres with password 'cGVyc2FneV8yMDIwcXdlIUAj';