Kaynağa Gözat

修改禁止人员下井功能

chensongchao 6 yıl önce
ebeveyn
işleme
a3017796ba
1 değiştirilmiş dosya ile 7 ekleme ve 5 silme
  1. 7 5
      forbid_staff_down_mine.cpp

+ 7 - 5
forbid_staff_down_mine.cpp

@@ -42,9 +42,10 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         int state;
         DBRes.GetField("status", state, Error);
 
+        std::shared_ptr<SForbidStaffList> s = nullptr;
         if (id != -1)
         {
-            auto s = forbid_staff_down_mine::instance()->get(s_id);
+            s = forbid_staff_down_mine::instance()->get(s_id);
             if (s != nullptr)
             {
                 for (SForbidStaffInfo &info : s->forbidList)
@@ -54,14 +55,15 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
                         info.start_time = tool_time::to_time(start_time);
                         info.end_time = tool_time::to_time(end_time);
                         info.state = state;
-                        break;
+                        return;
                     }
                 }
-                return;
             }
         }
-
-        std::shared_ptr<SForbidStaffList> s = std::make_shared<SForbidStaffList>();
+        if (s == nullptr)
+        {
+            s = std::make_shared<SForbidStaffList>();
+        }
         s->staff_id = s_id;
         SForbidStaffInfo info ;
         info.staff_id = s_id;