Browse Source

@task: timestamp to string, deviceId use UUID

bai 3 years ago
parent
commit
52cc3a9fcf

+ 1 - 0
demo/src/main/java/com/framework/app/Constants.kt

@@ -13,4 +13,5 @@ const val IP = tencentIP
 const val pathDownloadMap = "adm/downloadMap?key="
 
 const val deviceId = "device_id"
+
 const val timestamp = "timestamp"

+ 1 - 1
demo/src/main/java/com/framework/mvvm/model/db/entity/EquipmentEntity.kt

@@ -21,7 +21,7 @@ data class EquipmentEntity(
     @ColumnInfo(name = "parent_code") val parentCode: String?,    // 父编码
     @ColumnInfo(name = "equipment_code") val equipmentCode: String?, // 设备编码
     @ColumnInfo(name = "creator") val creator: String?,           // 创建人
-    @ColumnInfo(name = "creation_time") val creationTime: Long?,  // 创建时间
+    @ColumnInfo(name = "creation_time") val creationTime: String?,  // 创建时间
     @ColumnInfo(name = "modifier") val modifier: String?,            // 修改人
     @ColumnInfo(name = "modified_time") val modifiedTime: String?,   // 修改时间
     @ColumnInfo(name = "alias_code") val aliasCode: String?,      // 编码别名

+ 2 - 2
demo/src/main/java/com/framework/mvvm/model/db/entity/ObjectEntity.kt

@@ -31,9 +31,9 @@ data class ObjectEntity(
     @ColumnInfo(name = "floor_id") val floorId: String?,            // 建筑id
     @ColumnInfo(name = "creator") val creator: String?,             // 创建人
     @ColumnInfo(name = "create_app") val createApp: String?,        // 创建对象的应用
-    @ColumnInfo(name = "creation_time") val creationTime: Long?,  // 创建时间
+    @ColumnInfo(name = "creation_time") val creationTime: String?,  // 创建时间
     @ColumnInfo(name = "modifier") val modifier: String?,           // 修改人
-    @ColumnInfo(name = "modified_time") var modifiedTime: Long?,   // 修改时间
+    @ColumnInfo(name = "modified_time") var modifiedTime: String?,   // 修改时间
     @ColumnInfo(name = "client_device") val clientDevice: String?,  // 标识客户端设备
     @ColumnInfo(name = "client_id") val clientId: String?,          // 客户端生成id
     @ColumnInfo(name = "update_app") val updateApp: String?,        // 更新对象的应用

+ 1 - 1
demo/src/main/java/com/framework/mvvm/model/db/entity/PipeEntity.kt

@@ -25,7 +25,7 @@ data class PipeEntity(
     @ColumnInfo(name = "route") val route: String?,                   // 管道路由(坐标列表格式:[{x:1,y:1,z:1}])
     @ColumnInfo(name = "infos") val infos: String?,                   // 管道的信息点
     @ColumnInfo(name = "creator") val creator: String?,               // 创建人
-    @ColumnInfo(name = "creation_time") val creationTime: Long?,      // 创建时间
+    @ColumnInfo(name = "creation_time") val creationTime: String?,      // 创建时间
     @ColumnInfo(name = "modifier") val modifier: String?,             // 修改人
     @ColumnInfo(name = "modified_time") var modifiedTime: String?,      // 修改时间
     @ColumnInfo(name = "valid") var valid: Int?,                      // 合法标识

+ 2 - 2
demo/src/main/java/com/framework/mvvm/model/db/entity/RelationEntity.kt

@@ -28,9 +28,9 @@ data class RelationEntity(
     @ColumnInfo(name = "create_app") val createApp: String?,         // 创建关系的App
     @ColumnInfo(name = "update_app") val updateApp: String?,         // 更新关系的App
     @ColumnInfo(name = "creator") val creator: String?,              // 创建人
-    @ColumnInfo(name = "creation_time") val creationTime: Long?,   // 创建时间
+    @ColumnInfo(name = "creation_time") val creationTime: String?,   // 创建时间
     @ColumnInfo(name = "modifier") val modifier: String?,            // 更新人
-    @ColumnInfo(name = "modified_time") var modifiedTime: Long?,   // 修改时间
+    @ColumnInfo(name = "modified_time") var modifiedTime: String?,   // 修改时间
     @ColumnInfo(name = "client_id") val clientId: String?,           // 客户端生成id
     @ColumnInfo(name = "client_device") val clientDevice: String?,   // 标识客户端设备
     @ColumnInfo(name = "upload_flag") val uploadFlag: String?,       // app端上传数据标记

+ 1 - 1
demo/src/main/java/com/framework/mvvm/model/db/entity/SystemEntity.kt

@@ -26,7 +26,7 @@ data class SystemEntity(
     @ColumnInfo(name = "equipment_code") val equipmentCode: String?, // 设备编码
     @ColumnInfo(name = "version") val version: String?,              // 版本
     @ColumnInfo(name = "creator") val creator: String?,              // 创建人
-    @ColumnInfo(name = "creation_time") val creationTime: Long?,     // 创建时间
+    @ColumnInfo(name = "creation_time") val creationTime: String?,     // 创建时间
     @ColumnInfo(name = "modifier") val modifier: String?,               // 修改人
     @ColumnInfo(name = "modified_time") val modifiedTime: String?,      // 修改时间
 )

+ 2 - 2
demo/src/main/java/com/framework/mvvm/model/repository/AdmRepository.kt

@@ -406,7 +406,7 @@ class AdmRepository(
                     }
                     objects.forEach {
                         it.state = "2"
-                        it.modifiedTime = result.timestampMillis
+                        it.modifiedTime = result.timestamp
                         objectDao.insObject(it)
                     }
                     qrCodes.forEach {
@@ -416,7 +416,7 @@ class AdmRepository(
                     }
                     relations.forEach {
                         it.state = "2"
-                        it.modifiedTime = result.timestampMillis
+                        it.modifiedTime = result.timestamp
                         relationDao.insRelation(it)
                     }
                     problemArchs.forEach {

+ 16 - 1
demo/src/main/java/com/sybotan/android/demo/DemoApp.kt

@@ -26,21 +26,26 @@ package com.sybotan.android.demo
 import android.annotation.SuppressLint
 import android.app.Application
 import android.content.Context
+import android.content.SharedPreferences
 import android.util.Log
+import androidx.core.content.edit
 import com.arashivision.sdkcamera.InstaCameraSDK
 import com.arashivision.sdkmedia.InstaMediaSDK
+import com.framework.app.deviceId
 import com.framework.di.*
 import com.sybotan.android.demo.tools.AssetsUtil
 import org.kodein.di.DI
 import org.kodein.di.DIAware
 import org.kodein.di.android.x.androidXModule
+import org.kodein.di.instance
 import java.io.File
+import java.util.*
 
 
 class DemoApp : Application(), DIAware {
 
     override val di: DI by DI.lazy {
-       // import(androidCoreModule(this@DemoApp))
+        // import(androidCoreModule(this@DemoApp))
         import(androidXModule(this@DemoApp))
         import(databaseModule)
         import(httpModule)
@@ -50,6 +55,8 @@ class DemoApp : Application(), DIAware {
         //import(factoryModule)
     }
 
+    val sp by instance<SharedPreferences>()
+
     companion object {
         private val TAG = DemoApp::class.java.name
         var sInstance: DemoApp? = null
@@ -82,6 +89,14 @@ class DemoApp : Application(), DIAware {
 
         // Copy sample pictures from assets to local
         copyHdrSourceFromAssets()
+        val deviceId = sp.getString(deviceId, "") ?: ""
+
+        if (deviceId.isEmpty()) {
+            sp.edit {
+                putString(deviceId, "${UUID.randomUUID()}")
+            }
+        }
+
         return
     } // Function onCreate()
 

+ 0 - 22
demo/src/main/java/com/sybotan/android/demo/activities/PocActivity.kt

@@ -6,12 +6,9 @@ import android.content.SharedPreferences
 import android.content.pm.PackageManager
 import android.os.Bundle
 import android.widget.Button
-import androidx.appcompat.app.AppCompatActivity
 import androidx.constraintlayout.widget.ConstraintLayout
 import androidx.core.app.ActivityCompat
-import androidx.core.content.edit
 import androidx.lifecycle.lifecycleScope
-import com.framework.app.tools.MacUtil
 import com.framework.mvvm.model.vo.AdmRequest
 import com.framework.mvvm.mv.AdmViewModel
 import com.sybotan.android.demo.R
@@ -31,9 +28,6 @@ import org.kodein.di.DIAware
 import org.kodein.di.android.closestDI
 import org.kodein.di.android.x.viewmodel.viewModel
 import org.kodein.di.instance
-import java.io.IOException
-import java.net.HttpURLConnection
-import java.net.URL
 
 class PocActivity : BaseActivity(), DIAware {
 
@@ -156,20 +150,4 @@ class PocActivity : BaseActivity(), DIAware {
             )
         }
     }
-
-    override fun onRequestPermissionsResult(
-        requestCode: Int,
-        permissions: Array<out String>,
-        grantResults: IntArray
-    ) {
-        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
-        if (requestCode == 1) {
-            val mac = MacUtil.getMacAddress(this)!!
-            println("deviceId: $mac")
-            sp.edit {
-                putString("deviceId", mac)
-            }
-
-        }
-    }
 }

+ 1 - 2
demo/src/main/java/com/sybotan/android/demo/viewmodel/GraphyVM.kt

@@ -752,8 +752,7 @@ class GraphyVM(
                     floorId = floorId,
                     creator = "Android",
                     createApp = "",
-                    creationTime = SimpleDateFormat("yyyyMMddHHmmss").format(Date(System.currentTimeMillis()))
-                        .toLong(),
+                    creationTime = SimpleDateFormat("yyyyMMddHHmmss").format(Date(System.currentTimeMillis())),
                     modifier = "Android",
                     modifiedTime = null,
                     clientDevice = "",