From 979d9cff22806f213b420452ab4a68fcbaf021b6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 31 五月 2021 17:43:49 +0800
Subject: [PATCH] 1. 修复多项可能引起空指针崩溃的bug; 2. 新建子任务时默认执行人员从全体人员改为当前用户; 3. 新建子任务时默认执行时间强制固定为总任务对应的时段内,确保子任务执行时间不会超出总任务范围。

---
 app/src/main/java/cn/flightfeather/thirdapp/module/task/NewSubTaskViewModel.kt |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/task/NewSubTaskViewModel.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/task/NewSubTaskViewModel.kt
index 3e46fba..84d5a5a 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/task/NewSubTaskViewModel.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/task/NewSubTaskViewModel.kt
@@ -5,10 +5,10 @@
 import android.arch.lifecycle.MutableLiveData
 import android.arch.lifecycle.ViewModel
 import cn.flightfeather.thirdapp.CommonApplication
-import cn.flightfeather.thirdapp.bean.Monitorobjectversion
-import cn.flightfeather.thirdapp.bean.Scense
-import cn.flightfeather.thirdapp.bean.Subtask
-import cn.flightfeather.thirdapp.bean.Task
+import cn.flightfeather.thirdapp.bean.entity.Monitorobjectversion
+import cn.flightfeather.thirdapp.bean.entity.Scense
+import cn.flightfeather.thirdapp.bean.entity.Subtask
+import cn.flightfeather.thirdapp.bean.entity.Task
 import cn.flightfeather.thirdapp.bean.vo.TaskVo
 import cn.flightfeather.thirdapp.common.net.ResultCallBack
 import cn.flightfeather.thirdapp.model.event.TopTaskEvent
@@ -169,6 +169,10 @@
      * 鏍规嵁鎵�閫夊満鏅被鍨嬪強鏄惁鐩戠鍒锋柊鍦烘櫙
      */
     fun refreshScene() {
+        //sceneTypeList浼氭牴鎹仈缃戣幏鍙栫殑鍦烘櫙鍙樻洿鍐呭锛屾澶勫垽鏂繚璇佷笅鏍囦笉浼氳秺鐣�
+        if (selectedTypeIndex >= sceneTypeList.size) {
+            selectedTypeIndex = 0
+        }
         //绛涢�夊満鏅被鍨�
         val tmp = ArrayList<Scense>()
         if (selectedTypeIndex == 0) {
@@ -414,16 +418,26 @@
                 tguid = UUIDGenerator.generate16ShortUUID()
                 tsguid = selectedTopTask?.tguid
                 levelnum = null
+
                 val cal = Calendar.getInstance()
-                cal.time = Date()
-                cal.set(Calendar.HOUR_OF_DAY, 0)
-                cal.set(Calendar.MINUTE, 0)
-                cal.set(Calendar.SECOND, 0)
-                starttime = cal.time
-                cal.set(Calendar.HOUR_OF_DAY, 23)
-                cal.set(Calendar.MINUTE, 59)
-                cal.set(Calendar.SECOND, 59)
-                endtime = cal.time
+                // 鍒ゆ柇褰撳墠鏃堕棿涓庢�讳换鍔$殑鏃堕棿娈靛叧绯伙紝涓嶅湪鎬讳换鍔℃椂闂磋寖鍥村唴鏃讹紝浣跨敤鎬讳换鍔″紑濮嬫椂闂翠负榛樿鏃堕棿锛屽惁鍒欑敤褰撳墠鏃堕棿涓洪粯璁ゆ椂闂�
+                if (cal.time < starttime || cal.time > endtime) {
+                    cal.time = starttime
+                    cal.set(Calendar.HOUR_OF_DAY, 23)
+                    cal.set(Calendar.MINUTE, 59)
+                    cal.set(Calendar.SECOND, 59)
+                    endtime = cal.time
+                } else {
+                    cal.set(Calendar.HOUR_OF_DAY, 0)
+                    cal.set(Calendar.MINUTE, 0)
+                    cal.set(Calendar.SECOND, 0)
+                    starttime = cal.time
+                    cal.set(Calendar.HOUR_OF_DAY, 23)
+                    cal.set(Calendar.MINUTE, 59)
+                    cal.set(Calendar.SECOND, 59)
+                    endtime = cal.time
+                }
+
                 plannerguid = application.currentUser.guid
                 plannerusername = application.currentUser.acountname
                 plannerrealname = application.currentUser.realname

--
Gitblit v1.9.3