Browse Source

add:增加gis支持。

plx 3 years ago
parent
commit
ce65291162

+ 4 - 4
gradle.properties

@@ -25,7 +25,7 @@
 #
 
 PERSAGY_URL = http://www.persagy.com/
-PERSAGY_KOTLIN_VERSION = 1.5.3
+PERSAGY_KOTLIN_VERSION = 1.5.8
 # android
 # SYBOTAN_KOTLIN_VERSION = 1.4.63
 
@@ -49,20 +49,20 @@ DOKKA_VERSION = 0.9.16
 # https://mvnrepository.com/artifact/com.alibaba/druid
 DRUID_VERSION = 1.1.21
 # https://mvnrepository.com/artifact/com.alibaba/fastjson
- FASTJSON_VERSION = 1.2.60
+FASTJSON_VERSION = 1.2.60
 #FASTJSON_VERSION = 1.1.70.android
 # https://mvnrepository.com/artifact/org.hidetake/gradle-ssh-plugin
 GRADLE_SSH_VERSION = 2.10.1
 # https://mvnrepository.com/artifact/ca.coglinc/javacc-gradle-plugin
 JAVACC_GRACLE_VERSION = 2.4.0
 # https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk8
-KOTLIN_VERSION = 1.3.61
+KOTLIN_VERSION = 1.4.32
 # https://mvnrepository.com/artifact/org.mybatis/mybatis
 MYBATIS_VERSION = 3.5.3
 # https://mvnrepository.com/artifact/mysql/mysql-connector-java
 MYSQL_VERSION = 8.0.18
 # https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
-OKHTTP_VERSION = 3.14.4
+OKHTTP_VERSION = 4.9.0
 # https://mvnrepository.com/artifact/javax.persistence/persistence-api
 PERSISTENCE_VERSION = 1.0.2
 # https://mvnrepository.com/artifact/org.postgresql/postgresql

BIN
gradle/wrapper/gradle-wrapper.jar


+ 5 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 3 - 8
persagy-kotlin-base/build.gradle

@@ -57,8 +57,9 @@ dependencies {
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // JSON解析
-    // https://mvnrepository.com/artifact/com.alibaba/fastjson
-    compile group: "com.alibaba", name: "fastjson", version: FASTJSON_VERSION
+    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
+    implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: JACKSON_VERSION
+    implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: JACKSON_VERSION
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -124,9 +125,3 @@ uploadArchives {
         }
     }
 }
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 自动化测试
-test {
-    useTestNG()
-}

+ 39 - 41
persagy-kotlin-base/src/main/kotlin/com/persagy/base/extensions/SAnyExtension.kt

@@ -26,13 +26,13 @@
 
 package com.persagy.base.extensions
 
-import com.alibaba.fastjson.PropertyNamingStrategy
-import com.persagy.base.utils.SJsonUtil
+import com.fasterxml.jackson.databind.PropertyNamingStrategy
+import com.persagy.base.utils.SJacksonUtil
 import java.lang.Exception
 import java.lang.reflect.ParameterizedType
 
 /**
- * Any 扩展,获得类的泛型类
+ * Any扩展。获得类的泛型类
  *
  * @return  类的泛型类
  */
@@ -45,39 +45,39 @@ fun Any.gennericClass(): Class<*>? {
 }
 
 /**
- * Any 扩展 toJson() 函数
+ * Any扩展toJson()方法。
  *
- * @param namingStrategy        命名规则
- * @return  Json 字符串 (属性为 null 不序列化)
+ * @param   namingStrategy          命名规则
+ * @return  Json字符串(属性为null不序列化)
  */
 fun Any.toJson(namingStrategy: PropertyNamingStrategy? = null): String {
-    return SJsonUtil.toJson(this, namingStrategy)
+    return SJacksonUtil.toJson(this, namingStrategy)
 }
 
 /**
- * Any 扩展 toJson() 函数, 值为 null 也会序列化
+ * Any扩展toJson()方法。
  *
- * @param namingStrategy        命名规则
- * @return Json 字符串 (属性为 null 序列化)
+ * @param   namingStrategy          命名规则
+ * @return  Json字符串(属性为null序列化)
  */
 fun Any.toJsonAll(namingStrategy: PropertyNamingStrategy? = null): String {
-    return SJsonUtil.toJsonAll(this, namingStrategy)
+    return SJacksonUtil.toJsonAll(this, namingStrategy)
 }
 
 /**
- * Any 扩展 toMap() 函数
+ * Any扩展toMap()方法。
  *
- * @return Json 字符串
+ * @return  Json字符串
  */
 fun Any.toMap(): Map<String, Any?> {
     @Suppress("UNCHECKED_CAST")
-    return SJsonUtil.fromJson(this.toJson(), Map::class.java) as Map<String, Any?>
-} // Fun Any.toMap()
+    return SJacksonUtil.fromJson(this.toJson(), Map::class.java) as Map<String, Any?>
+}
 
 /**
- * Any 扩展 toByte() 函数
+ * Any扩展toByte()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toBoolean(): Boolean? {
     return when(this.javaClass.simpleName) {
@@ -93,9 +93,9 @@ fun Any.toBoolean(): Boolean? {
 }
 
 /**
- * Any 扩展 toByte() 函数
+ * Any扩展toByte()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toByte(): Byte? {
     return when(this.javaClass.simpleName) {
@@ -111,9 +111,9 @@ fun Any.toByte(): Byte? {
 }
 
 /**
- * Any 扩展 toDouble() 函数
+ * Any扩展toDouble()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toDouble(): Double? {
     return when(this.javaClass.simpleName) {
@@ -124,14 +124,15 @@ fun Any.toDouble(): Double? {
         "Int", "Integer" ->  (this as Int).toDouble()
         "Long" -> (this as Long).toDouble()
         "Short" -> (this as Short).toDouble()
+        "String" -> (this as String).toDoubleOrNull()
         else -> null
     }
 }
 
 /**
- * Any 扩展 toFloat() 函数
+ * Any扩展toFloat()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toFloat(): Float? {
     return when(this.javaClass.simpleName) {
@@ -142,14 +143,15 @@ fun Any.toFloat(): Float? {
         "Int", "Integer" ->  (this as Int).toFloat()
         "Long" -> (this as Long).toFloat()
         "Short" -> (this as Short).toFloat()
+        "String" -> (this as String).toFloatOrNull()
         else -> null
     }
 }
 
 /**
- * Any 扩展 toInt() 函数
+ * Any扩展toInt()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toInt(): Int? {
     return when(this.javaClass.simpleName) {
@@ -160,21 +162,15 @@ fun Any.toInt(): Int? {
         "Int", "Integer" ->  this as Int
         "Long" -> (this as Long).toInt()
         "Short" -> (this as Short).toInt()
-        "String" -> {
-            try {
-                Integer.parseInt(this as String)
-            }catch (e: Exception) {
-                0
-            }
-        }
+        "String" -> (this as String).toIntOrNull()
         else -> null
     }
 }
 
 /**
- * Any 扩展 toLong() 函数
+ * Any扩展toLong()方法。
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toLong(): Long? {
     return when(this.javaClass.simpleName) {
@@ -185,14 +181,15 @@ fun Any.toLong(): Long? {
         "Int", "Integer" ->  (this as Int).toLong()
         "Long" -> this as Long
         "Short" -> (this as Short).toLong()
+        "String" -> (this as String).toLongOrNull()
         else -> null
     }
-} // Fun Any.toLong()
+}
 
 /**
- * Any 扩展 toShort() 函数
+ * Any扩展toShort()方法
  *
- * @return 将对象转换为 Int 类型
+ * @return  将对象转换为Int类型
  */
 fun Any.toShort(): Short? {
     return when(this.javaClass.simpleName) {
@@ -203,17 +200,17 @@ fun Any.toShort(): Short? {
         "Int", "Integer" ->  (this as Int).toShort()
         "Long" -> (this as Long).toShort()
         "Short" -> this as Short
+        "String" -> (this as String).toShortOrNull()
         else -> null
     }
 }
 
 /**
- * Any 扩展,判断是否为基本类型
+ * Any扩展,判断是否为基本类型
  *
- * @return 如果是则返回 true
+ * @return  如果是则返回true
  */
 fun Any.isBaseType(): Boolean {
-    /** 是 java基本类型返回 true */
     if (this.javaClass.isPrimitive) {
         return true;
     }
@@ -227,8 +224,9 @@ fun Any.isBaseType(): Boolean {
             this is Long ||
             this is Float ||
             this is Double ||
+            this is Void ||
             this is java.sql.Date ||
             this is java.sql.Time ||
             this is java.sql.Timestamp ||
             this is java.util.Date
-}
+}

+ 20 - 12
persagy-kotlin-base/src/main/kotlin/com/persagy/base/extensions/SClassExtension.kt

@@ -26,62 +26,71 @@
 
 package com.persagy.base.extensions
 
-import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonProperty
 import java.lang.reflect.Field
 import java.lang.reflect.Method
 
 /**
- * Class<*> 扩展获得所有包含父对象的定义字段列表。
+ * Class<*> 扩展获得所有包含父对象的定义字段列表。
  *
  * @return  字段列表
  */
 fun Class<*>.getAllDeclaredFields(): ArrayList<Field> {
     val fieldList = ArrayList<Field>()
     var clz: Class<*>? = this
+
+    // 从当前类开始依次取父类的字段列表
     while (clz != null) {
         fieldList.addAll(clz.declaredFields.toList())
+        // 指向父类
         clz = clz.superclass
     }
+
     return fieldList
 }
 
 /**
- * Class<*> 扩展根据名称获得所有包含父对象的定义字段。
+ * Class<*> 扩展根据名称获得所有包含父对象的定义字段。
  *
- * @param name              属性名
- * @param ignoreCase        是否忽略大小写,默认不忽略
- * @param jsonProperty      是否检测 Json 属性
+ * @param   ignoreCase      是否忽略大小写,默认不忽略
+ * @param   jsonProperty    是否检测 Json 属性
  * @return  字段
  */
 fun Class<*>.getAllDeclaredField(name: String, ignoreCase: Boolean = false, jsonProperty: Boolean = false): Field? {
     val list = this.getAllDeclaredFields()
     return list.first {
-        val annName = it.getAnnotation(JSONField::class.java)?.name
+        val annName = it.getAnnotation(JsonProperty::class.java)?.value
         it.name.equals(name, ignoreCase) || (jsonProperty && name.equals(annName, ignoreCase))
     }
 }
 
 /**
- * Class<*> 扩展获得所有包含父对象的定义方法列表。
+ * Class<*> 扩展获得所有包含父对象的定义方法列表。
  *
- * @return 方法列表
+ * @return  方法列表
  */
 fun Class<*>.getAllDeclaredMethods(): ArrayList<Method> {
+    // 方法列表
     val methodList = ArrayList<Method>()
     var clz: Class<*>? = this
+
+    // 从当前类开始依次取父类的方法列表
     while (clz != null) {
         methodList.addAll(clz.declaredMethods.toList())
+        // 指向父类
         clz = clz.superclass
     }
+
     return methodList
 }
 
 /**
  * Class<*> 扩展,判断是否为基本类型
  *
- * @return 如果是则返回 true
+ * @return  如果是则返回 true,否则返回 false
  */
 fun Class<*>.isBaseType(): Boolean {
+    // 如果是 java 基本类型,则返回 true
     if (this.isPrimitive) {
         return true;
     }
@@ -100,5 +109,4 @@ fun Class<*>.isBaseType(): Boolean {
             java.sql.Time::class.java.isAssignableFrom(this) ||
             java.sql.Timestamp::class.java.isAssignableFrom(this) ||
             java.util.Date::class.java.isAssignableFrom(this)
-
-}
+}

+ 69 - 46
persagy-kotlin-base/src/main/kotlin/com/persagy/base/utils/SHttpUtil.kt

@@ -26,15 +26,17 @@
 
 package com.persagy.base.utils
 
-import com.alibaba.fastjson.PropertyNamingStrategy
+import com.fasterxml.jackson.databind.PropertyNamingStrategy
 import com.persagy.base.extensions.toJson
 import okhttp3.*
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.RequestBody.Companion.toRequestBody
 import java.util.concurrent.TimeUnit
 
 /**
- * Http 工具类
+ * Http工具类
  *
- * @author 庞利祥 <sybotan@126.com>
+ * @author  庞利祥 <sybotan@126.com>
  */
 object SHttpUtil {
     /** 连接超时时间 */
@@ -44,7 +46,7 @@ object SHttpUtil {
     /** 写入超时时间 */
     var writeTimeout: Long = 30L
 
-    /** http 客户端 */
+    /** http客户端 */
     private val httpClient: OkHttpClient by lazy {
         OkHttpClient.Builder()
                 .connectTimeout(connectTimeout, TimeUnit.SECONDS)
@@ -54,18 +56,18 @@ object SHttpUtil {
     }
 
     /** 媒体类型 */
-    val ALTERNATIVE     = MediaType.parse("multipart/alternative")
-    val DIGEST          = MediaType.parse("multipart/digest")
-    val FORM            = MediaType.parse("multipart/form-data")
-    val JSON            = MediaType.parse("application/json; charset=utf-8")
-    val MIXED           = MediaType.parse("multipart/mixed")
-    val PARALLEL        = MediaType.parse("multipart/parallel")
+    val ALTERNATIVE     = "multipart/alternative".toMediaType()
+    val DIGEST          = "multipart/digest".toMediaType()
+    val FORM            = "multipart/form-data".toMediaType()
+    val JSON            = "application/json; charset=utf-8".toMediaType()
+    val MIXED           = "multipart/mixed".toMediaType()
+    val PARALLEL        = "multipart/parallel".toMediaType()
 
     /**
-     * 根据扩展名获得 Http  Content-Type
+     * 根据扩展名获得Http的Content-Type
      *
-     * @param extensionName       文件扩展名
-     * @return  扩展名对应的 Content-Type
+     * @param       extensionName       文件扩展名
+     * @return      扩展名对应的Content-Type
      */
     fun contentType(extensionName: String): String {
         val map = mapOf(
@@ -411,10 +413,10 @@ object SHttpUtil {
                 "xap"     to  "application/x-silverlight-app"
         )
 
-        /** 扩展名转换为小写 */
+        // 扩展名转换为小写
         val key = extensionName.toLowerCase()
 
-        /** 如果 map 包含指定的扩展名,则返回对应的 Content-Type, 否则返回二进制流类型 application/octet-stream  */
+        // 如果map包含指定的扩展名,则返回对应的Content-Type, 否则返回二进制流类型"application/octet-stream"
         return if (map.contains(key)) {
             map.getValue(key)
         } else {
@@ -425,8 +427,8 @@ object SHttpUtil {
     /**
      * GET 请求
      *
-     * @param url      地址
-     * @return 服务器返回的应答信息
+     * @param   url     URL 地址
+     * @return  服务器返回的应答信息
      */
     @Throws(Exception::class)
     fun getRequest(url: String): String {
@@ -437,13 +439,13 @@ object SHttpUtil {
 
         val call = httpClient.newCall(request)
         val response = call.execute()
-        return response.body()!!.string()
+        return response.body!!.string()
     }
 
     /**
-     * GET 请求(zip 压缩格式)
+     * GET 请求(zip压缩格式)
      *
-     * @param url      地址
+     * @param   url     URL地址
      * @return  服务器返回的应答信息
      */
     @Throws(Exception::class)
@@ -457,60 +459,82 @@ object SHttpUtil {
         val call = httpClient.newCall(request)
         val response = call.execute()
 
-        return SGzipUtil.uncompressToString(response.body()!!.bytes()) ?: ""
+        return SGzipUtil.uncompressToString(response.body!!.bytes()) ?: ""
     }
 
     /**
-     * 发送 post 对象请求
+     * 发送post对象请求
      *
-     * @param url       地址
-     * @param body      请求体
-     * @return 返回应答体字符串
+     * @param   url     URL地址
+     * @param   body    请求体
+     * @return  返回应答体字符串
      */
     @Throws(Exception::class)
-    fun postRequest(url: String, body: String, type: MediaType = JSON!!): String {
-        val jsonBody = FormBody.create(type, body)
+    fun postRequest(url: String, body: String, type: MediaType = JSON): String {
+        val jsonBody = body.toRequestBody(type)
         val request = createPostRequest(url, jsonBody)
+
         val call = httpClient.newCall(request)
         val response = call.execute()
-        return response.body()!!.string()
+        return response.body!!.string()
     }
 
     /**
-     * 发送 get 对象请求
+     * 发送get对象请求
      *
-     * @param <T>                 请求的返回类型
-     * @param url                 地址
-     * @param namingStrategy      命名规则
-     * @return 接收到的请求体
+     * @param   <T>                 请求的返回类型
+     * @param   url                 URL地址
+     * @param   namingStrategy      命名规则
+     * @return  接收到的请求体
      */
     @Throws(Exception::class)
     inline fun <reified T> getObject(url: String, namingStrategy: PropertyNamingStrategy? = null): T {
         val responseJson = getRequest(url)
-        return SJsonUtil.fromJson(responseJson, namingStrategy)
+        return SJacksonUtil.fromJson<T>(responseJson, namingStrategy)
     }
 
     /**
-     * 发送 post 请求
+     * 发送post请求
      *
-     * @param url                 地址
-     * @param <T>                 请求的返回类型
-     * @param requestBody         发送到服务器的请求体
-     * @param namingStrategy      命名规则
-     * @return 接收到的请求体
+     * @param   url                 URL地址
+     * @param   <T>                 请求的返回类型
+     * @param   requestBody         发送到服务器的请求体
+     * @param   namingStrategy      命名规则
+     * @return  接收到的请求体
      */
     @Throws(Exception::class)
     inline fun <reified T> postObject(url: String, requestBody: Any, namingStrategy: PropertyNamingStrategy? = null): T {
         val responseJson = postRequest(url, requestBody.toJson(namingStrategy))
-        return SJsonUtil.fromJson(responseJson, namingStrategy)
+        return SJacksonUtil.fromJson(responseJson, namingStrategy)
+    }
+
+    /**
+     * 上传文件
+     *
+     * @param   url     上传地址
+     */
+    fun uploadFile(url: String) {
+        /*RequestBody requestBody = new MultipartBody.Builder()
+                .setType(MultipartBody.FORM)
+                .addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/png"), file))
+                .build();*/
+        return
     }
 
     /**
-     * 创建 Http post 请求对象
+     * 下载文件
      *
-     * @param url             地址
-     * @param jsonBody        发送到服务器的请求体
-     * @return 接收到的请求体
+     * @param       url     文件url地址
+     */
+    fun downloadFile(url: String) {
+
+    }
+
+    /**
+     * 创建Http post请求对象
+     *
+     * @param   url             URL地址
+     * @param   jsonBody        发送到服务器的请求体
      */
     private fun createPostRequest(url: String, jsonBody: RequestBody? = null): Request {
         val builder = Request.Builder()
@@ -521,5 +545,4 @@ object SHttpUtil {
 
         return builder.build()
     }
-
 }

+ 165 - 0
persagy-kotlin-base/src/main/kotlin/com/persagy/base/utils/SJacksonUtil.kt

@@ -0,0 +1,165 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *               iFHS7.
+ *              ;BBMBMBMc                  rZMBMBR              BMB
+ *              MBEr:;PBM,               7MBMMEOBB:             BBB                       RBW
+ *     XK:      BO     SB.     :SZ       MBM.       c;;     ir  BBM :FFr       :SSF:    ;xBMB:r   iuGXv.    i:. iF2;
+ *     DBBM0r.  :D     S7   ;XMBMB       GMBMu.     MBM:   BMB  MBMBBBMBMS   WMBMBMBBK  MBMBMBM  BMBRBMBW  .MBMBMBMBB
+ *      :JMRMMD  ..    ,  1MMRM1;         ;MBMBBR:   MBM  ;MB:  BMB:   MBM. RMBr   sBMH   BM0         UMB,  BMB.  KMBv
+ *     ;.   XOW  B1; :uM: 1RE,   i           .2BMBs  rMB. MBO   MBO    JMB; MBB     MBM   BBS    7MBMBOBM:  MBW   :BMc
+ *     OBRJ.SEE  MRDOWOR, 3DE:7OBM       .     ;BMB   RMR7BM    BMB    MBB. BMB    ,BMR  .BBZ   MMB   rMB,  BMM   rMB7
+ *     :FBRO0D0  RKXSXPR. JOKOOMPi       BMBSSWBMB;    BMBB:    MBMB0ZMBMS  .BMBOXRBMB    MBMDE RBM2;SMBM;  MBB   xBM2
+ *         iZGE  O0SHSPO. uGZ7.          sBMBMBDL      :BMO     OZu:BMBK,     rRBMB0;     ,EBMB  xBMBr:ER.  RDU   :OO;
+ *     ,BZ, 1D0  RPSFHXR. xWZ .SMr                  . .BBB
+ *      :0BMRDG  RESSSKR. 2WOMBW;                   BMBMR
+ *         i0BM: SWKHKGO  MBDv
+ *           .UB  OOGDM. MK,                                          Copyright (c) 2015-2020.  斯伯坦机器人
+ *              ,  XMW  ..
+ *                  r                                                                     All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.persagy.base.utils
+
+import com.fasterxml.jackson.annotation.JsonInclude
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.PropertyNamingStrategy
+import java.io.InputStream
+import java.lang.reflect.Type
+
+/**
+ * SJackson 工具类
+ *
+ * @author  庞利祥 <sybotan@126.com>
+ */
+object SJacksonUtil {
+    /** 命名规则 */
+    val propertyNamingStrategy = PropertyNamingStrategy.LOWER_CAMEL_CASE!!
+
+    /**
+     * 转换对象到 JSON 格式字符串
+     *
+     * @param   obj                     被转换对象
+     * @param   namingStrategy          命名规则
+     * @return  JSON 格式字符串
+     */
+    fun toJson(obj: Any, namingStrategy: PropertyNamingStrategy? = null): String {
+        val mapper = genMapper()
+        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+        if (null  != namingStrategy) {
+            mapper.propertyNamingStrategy = namingStrategy
+        }
+
+        return mapper.writeValueAsString(obj)
+    }
+
+    /**
+     * 转换对象到 JSON 格式字符串,包含空字符串
+     *
+     * @param   obj                     被转换对象
+     * @param   namingStrategy          首字母是否大写
+     * @return  json格式字符串
+     */
+    fun toJsonAll(obj: Any, namingStrategy: PropertyNamingStrategy? = null): String {
+        val mapper = genMapper()
+        mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS)
+        if (null  != namingStrategy) {
+            mapper.propertyNamingStrategy = namingStrategy
+        }
+
+        return mapper.writeValueAsString(obj)
+    }
+
+    /**
+     * 将 JSON 数据解析成相应的映射对象
+     *
+     * @param   jsonData                要解析的JSON数据
+     * @param   valueType               转换对象的类型
+     * @return  解析结果
+     */
+    @Throws(Exception::class)
+    fun <T> fromJson(jsonData: String, valueType: Class<T>, namingStrategy: PropertyNamingStrategy? = null): T? {
+        val mapper = genMapper()
+        if (null  != namingStrategy) {
+            mapper.propertyNamingStrategy = namingStrategy
+        }
+
+        return mapper.readValue<T>(jsonData, valueType)
+    }
+
+    /**
+     * 将Json数据解析成相应的映射对象
+     *
+     * @param   jsonData                要解析的JSON数据
+     * @param   type                    Java类型
+     * @return  解析结果
+     */
+    @Throws(Exception::class)
+    fun fromJson(jsonData: String, type: Type): Any? {
+        val mapper = ObjectMapper()
+        return mapper.readValue(jsonData, type.javaClass)
+    }
+
+    /**
+     * 将Json数据解析成相应的映射对象
+     *
+     * @param   input                   要解析的JSON数据输入流
+     * @param   valueType               转换对象的类型
+     * @param   namingStrategy          命名规则
+     * @return  解析结果
+     */
+    @Throws(Exception::class)
+    fun <T> fromJson(input: InputStream, valueType: Class<T>, namingStrategy: PropertyNamingStrategy? = null): T? {
+        val mapper = genMapper()
+        if (null  != namingStrategy) {
+            mapper.propertyNamingStrategy = namingStrategy
+        }
+        return mapper.readValue(input, valueType)
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /**
+     * 将Json数据解析成相应的映射对象
+     *
+     * @param   jsonData                要解析的JSON数据
+     * @param   namingStrategy          命名规则
+     * @return  解析结果
+     */
+    @Throws(Exception::class)
+    inline fun <reified T> fromJson(jsonData: String, namingStrategy: PropertyNamingStrategy? = null): T {
+        val mapper = genMapper()
+        if (null  != namingStrategy) {
+            mapper.propertyNamingStrategy = namingStrategy
+        }
+        return mapper.readValue(jsonData, T::class.java)
+    }
+//
+//    /**
+//     * 将Json数据解析成相应的映射对象
+//     *
+//     * @param   input                   要解析的JSON数据输入流
+//     * @param   namingStrategy          命名规则
+//     * @return  解析结果
+//     */
+//    @Throws(Exception::class)
+//    inline fun <reified T> fromJson(input: InputStream, namingStrategy: PropertyNamingStrategy? = null): T {
+//        val mapper = genMapper()
+//        if (null  != namingStrategy) {
+//            mapper.propertyNamingStrategy = namingStrategy
+//        }
+//        return mapper.readValue(input, T::class.java)
+//    }
+
+    /**
+     * 生成 mapper 对象
+     *
+     * @return  mapper 对象
+     */
+    fun genMapper(): ObjectMapper {
+        val mapper = ObjectMapper()
+        mapper.propertyNamingStrategy = propertyNamingStrategy
+        return mapper
+    }
+}

+ 0 - 164
persagy-kotlin-base/src/main/kotlin/com/persagy/base/utils/SJsonUtil.kt

@@ -1,164 +0,0 @@
-/*
- * *********************************************************************************************************************
- *
- *          !!
- *        .F88X
- *        X8888Y
- *      .}888888N;
- *        i888888N;        .:!              .I$WI:
- *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
- *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
- *            +888888N;  .8888888Y                                  "&&8Y.}8,
- *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
- *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
- *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
- *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
- *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
- *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
- *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
- *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
- *        ~8888'
- *        .!88~                                                                     All rights reserved.
- *
- * *********************************************************************************************************************
- */
-
-package com.persagy.base.utils
-
-import com.alibaba.fastjson.JSON
-import com.alibaba.fastjson.PropertyNamingStrategy
-import com.alibaba.fastjson.serializer.SerializeConfig
-import com.alibaba.fastjson.serializer.SerializerFeature
-import java.io.*
-import java.lang.reflect.Type
-
-/**
- * Json 工具类
- *
- * @author 庞利祥 <sybotan@126.com>
- */
-object SJsonUtil {
-    /** tag 当前类名 */
-    private val TAG = SJsonUtil::class.java.name
-    /** 序列化配置 */
-    val serializeConfig = SerializeConfig()
-
-    /**
-     * 转换对象到 JSON 格式字符串
-     *
-     * @param obj                     被转换对象
-     * @param namingStrategy          命名规则
-     * @return JSON 格式字符串
-     */
-    fun toJson(obj: Any, namingStrategy: PropertyNamingStrategy? = null): String {
-        return if (null == namingStrategy) {
-            JSON.toJSONString(obj, serializeConfig, SerializerFeature.DisableCircularReferenceDetect)
-        } else {
-            val config = SerializeConfig()
-            config.propertyNamingStrategy = namingStrategy
-            JSON.toJSONString(obj, config, SerializerFeature.DisableCircularReferenceDetect)
-        }
-    }
-
-    /**
-     * 转换对象到 JSON 格式字符串,包含空字符串
-     *
-     * @param obj                     被转换对象
-     * @param namingStrategy          首字母是否大写
-     * @return json 格式字符串
-     */
-    fun toJsonAll(obj: Any, namingStrategy: PropertyNamingStrategy? = null): String {
-        return if (null == namingStrategy) {
-            JSON.toJSONString(obj,
-                    serializeConfig,
-                    SerializerFeature.WriteMapNullValue,
-                    SerializerFeature.WriteNullListAsEmpty,
-                    SerializerFeature.DisableCircularReferenceDetect)
-        } else {
-            val config = SerializeConfig()
-            config.propertyNamingStrategy = namingStrategy
-            JSON.toJSONString(obj,
-                    config,
-                    SerializerFeature.WriteMapNullValue,
-                    SerializerFeature.WriteNullListAsEmpty,
-                    SerializerFeature.DisableCircularReferenceDetect)
-        }
-    }
-
-    /**
-     * 将 JSON 数据解析成相应的映射对象
-     *
-     * @param jsonData      要解析的 JSON 数据
-     * @param type          Java 类型
-     * @return 解析结果
-     */
-    @Throws(Exception::class)
-    fun <T> fromJson(jsonData: String, type: Class<T>): T? {
-        return JSON.parseObject(jsonData, type)
-    }
-
-    /**
-     * 将 Json 数据解析成相应的映射对象
-     *
-     * @param jsonData                要解析的 JSON 数据
-     * @param type                    Java 类型
-     * @return 解析结果
-     */
-    @Throws(Exception::class)
-    fun fromJson(jsonData: String, type: Type): Any? {
-        return JSON.parseObject(jsonData, type)
-    } // Fun fromJson()
-
-    /**
-     * 将 Json 数据解析成相应的映射对象
-     *
-     * @param input                 要解析的 JSON 数据输入流
-     * @param type                  Java 类型
-     * @param namingStrategy        命名规则
-     * @return 解析结果
-     */
-    @Throws(Exception::class)
-    fun <T> fromJson(input: InputStream, type: Class<T>): T? {
-        val count = input.available()
-        val buf = ByteArray(count)
-        var readCount = 0
-        while (readCount < count) {
-            readCount += input.read(buf, readCount, count - readCount)
-        }
-
-        return fromJson(String(buf), type)
-    }
-
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    /**
-     * 将 Json 数据解析成相应的映射对象
-     *
-     * @param jsonData                要解析的 JSON 数据
-     * @param namingStrategy          命名规则
-     * @return 解析结果
-     */
-    @Throws(Exception::class)
-    inline fun <reified T> fromJson(jsonData: String, namingStrategy: PropertyNamingStrategy? = null): T {
-        return JSON.parseObject(jsonData, T::class.java)
-    }
-
-    /**
-     * 将 Json 数据解析成相应的映射对象
-     *
-     * @param input                   要解析的 JSON 数据输入流
-     * @param namingStrategy          命名规则
-     * @return 解析结果
-     */
-    @Throws(Exception::class)
-    inline fun <reified T> fromJson(input: InputStream, namingStrategy: PropertyNamingStrategy? = null): T {
-        val count = input.available()
-        val buf = ByteArray(count)
-        var readCount = 0
-        while (readCount < count) {
-            readCount += input.read(buf, readCount, count - readCount)
-        }
-
-        return fromJson(String(buf), namingStrategy)
-    }
-}

+ 6 - 0
persagy-kotlin-database/build.gradle

@@ -59,6 +59,12 @@ dependencies {
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     compile group: "javax.persistence", name: "persistence-api", version: PERSISTENCE_VERSION
 
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // JSON解析
+    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
+    compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: JACKSON_VERSION
+    compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: JACKSON_VERSION
+
 //    // https://mvnrepository.com/artifact/io.swagger/swagger-annotations
 //    compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.22'
 

+ 0 - 1
persagy-kotlin-database/src/main/kotlin/com/persagy/database/extensions/SClassExtension.kt

@@ -27,7 +27,6 @@
 package com.persagy.database.extensions
 
 import com.persagy.base.extensions.getAllDeclaredFields
-import com.persagy.database.SFilter
 import java.lang.reflect.Field
 import javax.persistence.Column
 import javax.persistence.Id

+ 11 - 8
persagy-kotlin-gis/build.gradle

@@ -29,7 +29,6 @@ version rootProject.version
 apply plugin: "kotlin"
 apply plugin: "org.jetbrains.dokka"
 apply plugin: "maven"
-apply plugin: "ca.coglinc.javacc"
 
 sourceCompatibility = JVM_TARGET
 
@@ -40,23 +39,27 @@ compileTestKotlin {
     kotlinOptions.jvmTarget = JVM_TARGET
 }
 
-compileJavacc {
-    inputDirectory = file("src/main/javacc")
-    outputDirectory = file("src/main/java/com/persagy/gis/parser")
-}
-
 dependencies {
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // kotlin 依赖
     compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: KOTLIN_VERSION
     compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: KOTLIN_VERSION
 
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // 单元测试
+    // https://mvnrepository.com/artifact/org.testng/testng
+    testCompile group: "org.testng", name: "testng", version: TESTNG_VERSION
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // http请求
+    // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
+    compile group: "com.squareup.okhttp3", name: "okhttp", version: OKHTTP_VERSION
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // JSON解析
     // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
     implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: JACKSON_VERSION
     implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: JACKSON_VERSION
-
-
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

+ 4 - 4
persagy-kotlin-mybatis/src/main/kotlin/com/persagy/mybatis/SAbstractDriver.kt

@@ -418,14 +418,14 @@ abstract class SAbstractDriver {
      */
     protected fun buildColumns(clazz: Class<*>, fieldList: ArrayList<String>?): String {
         /** 如果不指定字段列表,则查所有记录 */
-        if (fieldList == null || fieldList.size <= 0) {
-            return "*"
-        }
+//        if (fieldList == null || fieldList.size <= 0) {
+//            return "*"
+//        }
         logger.debug("222222222222222222222222222222222222")
         val builder = StringBuilder()
         for (field in clazz.getAllDeclaredFields()) {
             logger.debug("field = ${field.toJson()}")
-            if (!fieldList.contains(field.name)) {
+            if (fieldList != null && fieldList.size > 0 && !fieldList.contains(field.name)) {
                 continue
             }
             val anna = field.getAnnotation(Column::class.java) ?: continue

+ 9 - 9
persagy-kotlin-mybatis/src/main/kotlin/com/persagy/mybatis/SRowParser.kt

@@ -26,9 +26,9 @@
 
 package com.persagy.mybatis
 
-import com.alibaba.fastjson.PropertyNamingStrategy
+import com.fasterxml.jackson.databind.PropertyNamingStrategy
 import com.persagy.base.extensions.*
-import com.persagy.base.utils.SJsonUtil
+import com.persagy.base.utils.SJacksonUtil
 import com.persagy.gis.entity.SAbstractGisGeometry
 import com.persagy.gis.parser.SGisWktParser
 import org.slf4j.LoggerFactory
@@ -74,12 +74,12 @@ open class SRowParser<ENTITY: Any>(entityClazz: Class<ENTITY>) {
                         field.set(entity, value)
                     }
                     Map::class.java.isAssignableFrom(field.type) -> {
-                        field.set(entity, SJsonUtil.fromJson(value.toString(), HashMap::class.java))
+                        field.set(entity, SJacksonUtil.fromJson(value.toString(), HashMap::class.java))
                     }
                     List::class.java.isAssignableFrom(field.type) -> {
                         try {
                             val genericType = field.genericType
-                            val v1 = SJsonUtil.fromJson(value.toString(), genericType!!)
+                            val v1 = SJacksonUtil.fromJson(value.toString(), genericType!!)
                             field.set(entity, v1)
                         } catch (e: Exception) {
                             // DO NOTHING
@@ -91,7 +91,7 @@ open class SRowParser<ENTITY: Any>(entityClazz: Class<ENTITY>) {
                     }
                     else -> {
                         // field.set(entity, SJsonUtil.fromJson(value.toString(), field.type))
-                        field.set(entity, SJsonUtil.fromJson(value.toString(), field.type))
+                        field.set(entity, SJacksonUtil.fromJson(value.toString(), field.type))
                     }
                 }
             } catch (e: Exception) {
@@ -140,9 +140,9 @@ open class SRowParser<ENTITY: Any>(entityClazz: Class<ENTITY>) {
     /**
      * 统记字段名称
      *
-     * @param type        统计类型
-     * @param name        统计字段名
-     * @return 字段名
+     * @param   type        统计类型
+     * @param   name        统计字段名
+     * @return  字段名
      */
     private fun statisticName(type: String, name: String): String {
         val col = if (name.startsWith("_statistics_")) {
@@ -152,7 +152,7 @@ open class SRowParser<ENTITY: Any>(entityClazz: Class<ENTITY>) {
         }
 
         val str = "$col$type"
-        return if (PropertyNamingStrategy.PascalCase == SJsonUtil.serializeConfig.propertyNamingStrategy) {
+        return if (PropertyNamingStrategy.UPPER_CAMEL_CASE == SJacksonUtil.propertyNamingStrategy) {
             str.firstUpperCase();
         } else {
             str.firstLowerCase();