From a5d862051462a5fcc2717b405896a6d424002e54 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 22 十二月 2020 15:43:06 +0800
Subject: [PATCH] 1. 调整了数控实体的存储位置; 2. 新增数据表“媒体文件类型别名表”; 3. 修改任意拍模块,将图片分类改为根据场景类型动态生成,同时新增修改分类别名功能; 4. 优化子任务选择界面的任务排序方式,按照“待开始”、“执行中”、“未执行”的顺序进行排序;

---
 app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceViewModel.kt |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceViewModel.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceViewModel.kt
index 9959bdd..5966184 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceViewModel.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuEvidenceViewModel.kt
@@ -1,7 +1,8 @@
 package cn.flightfeather.thirdapp.module.inspection
 
 import android.arch.lifecycle.MutableLiveData
-import cn.flightfeather.thirdapp.bean.*
+import cn.flightfeather.thirdapp.bean.entity.*
+import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
 import cn.flightfeather.thirdapp.common.net.ResultCallBack
 import cn.flightfeather.thirdapp.model.event.ProblemEvent
 import cn.flightfeather.thirdapp.module.base.BaseViewModel
@@ -9,6 +10,7 @@
 import okhttp3.ResponseBody
 import org.greenrobot.eventbus.EventBus
 import org.jetbrains.anko.toast
+import java.io.File
 
 /**
  * @author riku
@@ -31,6 +33,13 @@
 
     val problemMap = HashMap<String, ArrayList<Problemtype>>()
 
+    val mediaFileList = MutableLiveData<List<Mediafile>>()
+
+    //鎵�鏈夋暟鎹姞杞藉畬鎴愰�氱煡
+    val loadingOver = MutableLiveData<Boolean>()
+    //璁板綍鍚勪釜鏁版嵁鍔犺浇鏄惁瀹屾垚鐨勭姸鎬�
+    private val loadingStatus = BooleanArray(2)
+
     /**
      * 鑾峰彇鍦烘櫙闂鍙�変綅缃紙鐩墠鍙湁宸ュ湴锛屼絾鎵�鏈夊満鏅兘浣跨敤锛�
      */
@@ -39,6 +48,7 @@
             override fun onSuccess(result: ArrayList<Domainitem>?) {
                 result?.let {
                     locationList.value = it
+                    onLoaded(0)
                 }
             }
 
@@ -59,8 +69,8 @@
                     if (it.isEmpty()) {
                         it.add(Problemtype().apply {
                             guid = "0"
-                            typename = "鏃�"
-                            name = "鏃�"
+                            typename = "鍏朵粬"
+                            name = "鍏朵粬"
                         })
                     }
 
@@ -76,6 +86,8 @@
                     }
 
                     problemFatherType.value = typeList
+
+                    onLoaded(1)
                 }
             }
 
@@ -98,6 +110,7 @@
                     }
                     advices.add("鏆傛棤寤鸿")
                     suggestionList.value = advices
+
                 }
             }
 
@@ -105,6 +118,57 @@
             }
 
         })
+    }
+
+    /**
+     * 鏍规嵁闂鎵惧埌鏈嶅姟鍣ㄥ拰鏈湴鐨勬墍鏈夊浘鐗�
+     */
+    fun getMediaFileList(p: ProblemlistVo) {
+        problemRepository.getMediaFileLocal(p.guid, object : ResultCallBack<List<Mediafile>> {
+            override fun onSuccess(result: List<Mediafile>?) {
+                result?.let {
+                    p.mediafileList.addAll(it)
+                    mediaFileList.value = p.mediafileList
+                }
+            }
+
+            override fun onFailure() {
+            }
+        })
+    }
+
+    /**
+     * 涓嬭浇闂鍥剧墖
+     *  fixme: 2020/8/6 鐩墠鐢变簬鍘熺▼搴忚缃浘鐗囩殑鏂瑰紡涓烘墜鍔ㄤ笅杞藉浘鐗囷紝鍥犳娌跨敤锛屼箣鍚庣粺涓�鐢℅lide绛夌涓夋柟搴撲唬鏇�
+     */
+    fun downLoadMediaFile(mediaFile: Mediafile, s: (file: File) -> Unit) {
+        problemRepository.downloadMediaFile(mediaFile, object : ResultCallBack<File> {
+            override fun onSuccess(result: File?) {
+                result?.let {
+                    s(it)
+                }
+            }
+
+            override fun onFailure() {
+
+            }
+        })
+    }
+
+    /**
+     * 鍒犻櫎闂鍥剧墖
+     */
+    fun deleteMediaFile(mediaFile: List<Mediafile>) {
+        mediaFile.forEach {
+            problemRepository.deleteMediaFile(it, object : ResultCallBack<Boolean> {
+                override fun onSuccess(result: Boolean?) {
+
+                }
+
+                override fun onFailure() {
+                }
+            })
+        }
     }
 
     /**
@@ -124,6 +188,24 @@
                 application.toast("鎻愪氦澶辫触")
             }
 
+        })
+    }
+
+    /**
+     * 鏇存柊涓�涓棶棰�
+     */
+    fun updateProblem(problem: ProblemlistVo) {
+        problemRepository.updateProblem(problem, object : ResultCallBack<ResponseBody> {
+            override fun onSuccess(result: ResponseBody?) {
+                result?.let {
+                    application.toast("淇敼鎴愬姛")
+                    EventBus.getDefault().post(ProblemEvent(problem.voToEntity()))
+                }
+            }
+
+            override fun onFailure() {
+                application.toast("淇敼澶辫触锛岃妫�鏌ョ綉缁�")
+            }
         })
     }
 
@@ -151,4 +233,23 @@
             problemType.value = it
         }
     }
+
+    /**
+     * 鍒ゆ柇鏄惁鎵�鏈夌殑鏁版嵁閮藉姞杞藉畬鎴�
+     */
+    fun onLoaded(i: Int) {
+        if (i < loadingStatus.size) {
+            loadingStatus[i] = true
+        }
+        var isLoadOver = true
+        loadingStatus.forEach {
+            isLoadOver = isLoadOver.and(it)
+        }
+        if (isLoadOver) {
+            loadingOver.value = isLoadOver
+            for (y in loadingStatus.indices) {
+                loadingStatus[y] = false
+            }
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3