libushang 5 miesięcy temu
rodzic
commit
48d76331c6
2 zmienionych plików z 59 dodań i 67 usunięć
  1. 2 2
      common/AvconWebService.py
  2. 57 65
      routers/api/eventManagement/checkin.py

+ 2 - 2
common/AvconWebService.py

@@ -33,8 +33,8 @@ if __name__ == '__main__':
 
     for group in groups:
         print('groupId:', group['groupId'])
-        print('getMonitorDev:', group['groupId'], "001")
-        response = srv.getMonitorDev(group['groupId'], "001", 0, 100)
+        print('getMonitorDev:', group['groupId'], "")
+        response = srv.getMonitorDev(group['groupId'], "", 0, 100)
         print(response)
         
         # response = srv.getMonitorChannel(String devId)

+ 57 - 65
routers/api/eventManagement/checkin.py

@@ -103,7 +103,7 @@ async def getInfo(
     sign_time = ''
     phone = user_info['phonenumber']
 
-    row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.user_id == user_id, EventCheckin.del_flag == '0')).first()
+    row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.phone == phone, EventCheckin.del_flag == '0')).first()
     if row is not None:
         check_info = get_model_dict(row)
         user_name = check_info['user_name']
@@ -136,83 +136,75 @@ async def check(
     request: Request, 
     db: Session = Depends(get_db), 
     body = Depends(remove_xss_json), 
-    user_id = Depends(valid_access_token)
+    # user_id = Depends(valid_access_token)
 ):
-    time.sleep(3)
-
-    row = db.query(SysUser).filter(SysUser.user_id == user_id).first()
-    user_info = get_model_dict(row)
-    dept_id = user_info['dept_id']
-    yzy_account = user_info['yzy_account']
-
-    yzy_account = user_info['yzy_account']
-
-    contact_info = db.query(EmergencyContactInfo).filter(and_(EmergencyContactInfo.del_flag == "0", EmergencyContactInfo.yue_gov_ease_phone == yzy_account)).first()
-    contact_info = get_model_dict(contact_info)
-    nick_name = contact_info['contact_name']
-    dept_id = contact_info['unit_id']
-    dept_name = contact_info['unit_name']
-
-    # row = db.query(SysDept).filter(SysDept.dept_id == dept_id).first()
-    # dept_info = get_model_dict(row)
-    # dept_name = dept_info['dept_name']
-
+    time.sleep(2.0)
+    
     event_id = body['event_id']
+    nick_name = body['nick_name']
+    dept_name = body['dept_name']
     phone = body['phone']
     duties = body['duties']
-
-    row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.user_id == user_id)).first()
-    if row is None:
-        event_checkin = EventCheckin(
-            event_id = event_id,
-            user_id = user_id,
-            user_name = user_info['user_name'],
-            nick_name = nick_name,
-            dept_id = dept_id,
-            dept_name = dept_name,
-            sign_time = datetime.now(),
-            yzy_account = yzy_account,
-            duties = duties,
-            phone = phone,
-            del_flag = '0'
-        )
-        db.add(event_checkin)
-        db.commit()
-
-        return {
-            'code': 200,
-            'msg': '签到成功'
-        }
-    
-    else:
-        if row.del_flag == '0':
-            row.sign_time = datetime.now()
-            row.user_name = user_info['user_name'],
-            row.nick_name = nick_name,
-            row.duties = duties,
-            row.phone = phone,
-            row.del_flag = '1'
+    type_ = body['type']
+
+    dept_id = 0
+    yzy_account = ''
+    contact_info = db.query(EmergencyContactInfo).filter(and_(EmergencyContactInfo.del_flag == "0", EmergencyContactInfo.yue_gov_ease_phone == phone)).first()
+    if contact_info is not None:
+        yzy_account = phone
+        contact_info = get_model_dict(contact_info)
+        dept_id = contact_info['unit_id']
+
+    if type_ == '1':
+        # 签名
+        row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.phone == phone)).first()
+        if row is None:
+            event_checkin = EventCheckin(
+                event_id = event_id,
+                user_id = 0,
+                user_name = '',
+                nick_name = nick_name,
+                dept_id = dept_id,
+                dept_name = dept_name,
+                sign_time = datetime.now(),
+                yzy_account = yzy_account,
+                duties = duties,
+                phone = phone,
+                del_flag = '0'
+            )
+            db.add(event_checkin)
             db.commit()
-
-            return {
-                'code': 200,
-                'msg': '签退成功'
-            }
-            
         else:
             row.sign_time = datetime.now()
-            row.user_name = user_info['user_name'],
-            row.nick_name = nick_name,
-            row.duties = duties,
-            row.phone = phone,
+            row.nick_name = nick_name
+            row.dept_name = dept_name
+            row.duties = duties
+            row.phone = phone
             row.del_flag = '0'
             db.commit()
 
+        return {
+            'code': 200,
+            'msg': '签到成功'
+        }
+
+    elif type_ == '2':
+        # 取消签名
+        row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.phone == phone)).first()
+        if row is None:
             return {
-                'code': 200,
-                'msg': '签到成功'
+                'code': 500,
+                'msg': '用户并未签名,无法签退'
             }
+        
+        row.sign_time = datetime.now()
+        row.del_flag = '1'
+        db.commit()
 
+        return {
+            'code': 200,
+            'msg': '签退成功'
+        }
     
 @router.get('/list')
 async def get_event_list(