baoyubo 3 天之前
父節點
當前提交
2378e8e7c7
共有 3 個文件被更改,包括 57 次插入10 次删除
  1. 1 1
      jobs/hkvideo_job.py
  2. 55 8
      routers/api/dutyManagement/schedule.py
  3. 1 1
      routers/api/videoResource/videoinfo.py

+ 1 - 1
jobs/hkvideo_job.py

@@ -114,7 +114,7 @@ def refresh_hkvideo_list(db: Session):
                         region = unitIndexCode_get_video_region_info(db,camera_info['unitIndexCode'])
                         if region is not None:
                             regionPath = region.regionPath
-                        if '84021e2f6eba4e6b8ccc7d750fb833fa' in regionPath:
+                        if '84021e2f6eba4e6b8ccc7d750fb833fa' in regionPath or '44000000002160752825'  in regionPath:
                             continue
                         info = TPVideoInfo(
                             cameraIndexCode=camera_info['cameraIndexCode'],

+ 55 - 8
routers/api/dutyManagement/schedule.py

@@ -49,13 +49,47 @@ def user_id_get_info(db,user_id):
     data = query.first()
     return data
 
+def get_duty_unit_id_list(db):
+    query = db.query(SysDictData)
+    query = query.filter(SysDictData.del_flag != '2')
+    query = query.filter(SysDictData.dict_value=='duty_unit')
+    data = query.all()
+    return [int(i) for i in data]
+
+def dept_id_get_duty_unit_id(db,dept_id,duty_unit_id_list):
+    if dept_id == 0:
+        return 0
+    if dept_id in duty_unit_id_list:
+        return dept_id
+    query = db.query(EmergencyContactDepartment)
+    query = query.filter(EmergencyContactDepartment.del_flag != '2')
+    query = query.filter(EmergencyContactDepartment.id==dept_id)
+    data = query.first()
+    if data:
+        dept_id_get_duty_unit_id(db, data.parent_department_id, duty_unit_id_list)
+    else:
+        return 0
+
+def mobile_phone_get_dept_id(db,mobile_phone,duty_unit_id_list):
+    query = db.query(EmergencyContactUser)
+    query = query.filter(EmergencyContactUser.del_flag != '2')
+    query = query.filter(EmergencyContactUser.mobile_phone==mobile_phone)
+    data = query.first()
+    if data:
+        dept_id = data.department_id
+        dept_id = dept_id_get_duty_unit_id(db, dept_id, duty_unit_id_list)
+        return dept_id
+    else:
+        return 0
+
+
 @router.get('/list')
 async def get_dict_data_by_type(
     keywords:str =Query(None),
     duty_type:str =Query(None),
     start_time:str =Query(None),
     end_time:str =Query(None),
-    duty_unit:str =Query(None),
+    duty_unit:int  =Query(None),
     page: int = Query(1, gt=0),
     pageSize: int = Query(10, gt=0),
     db: Session = Depends(get_db),
@@ -110,8 +144,8 @@ async def get_dict_data_by_type(
                                   "yzy_userid":contact_info.userid})
             data_list.append({
                 "id": d.id,
-                "start_time": d.start_time,
-                "end_time":d.end_time,
+                "start_time": d.start_time.strftime('%Y-%m-%d %H:%M:%S') if d.start_time else '',
+                "end_time":d.end_time.strftime('%Y-%m-%d %H:%M:%S') if d.end_time else '',
                 "duty_date": d.duty_date,
                 "shift_type":d.shift_type,
                 "duty_unit": d.duty_unit,
@@ -146,7 +180,7 @@ async def get_dict_data_by_type(
     keywords:str =Query(None),
     start_time:str =Query(None),
     end_time:str =Query(None),
-    duty_unit:str =Query(None),
+    duty_unit:int =Query(None),
     page: int = Query(1, gt=0),
     pageSize: int = Query(10, gt=0),
     db: Session = Depends(get_db),
@@ -172,7 +206,20 @@ async def get_dict_data_by_type(
             query = query.filter(DutySchedule.duty_date<=end_time)
         if duty_unit:
             query = query.filter(DutySchedule.duty_unit==duty_unit)
-
+        else:
+            now_user_info=user_id_get_user_info(db,user_id)
+            if now_user_info:
+                query = query.filter(DutySchedule.duty_unit==mobile_phone_get_dept_id(db,now_user_info.phonenumber,get_duty_unit_id_list(db)))
+            else:
+                return {
+                    "total": 0,
+                    "page": page,
+                    "pageSize": pageSize,
+                    "totalPages": (0 + pageSize - 1) // pageSize,
+                    "data": [],
+                    "code": 200,
+                    "msg": "查询成功"
+                }
         subquery = db.query(
             DutySchedule.duty_date,
             DutySchedule.shift_type,
@@ -212,11 +259,11 @@ async def get_dict_data_by_type(
                                   "mobile_phone":contact_info.mobile_phone,
                                   "office_phone":contact_info.office_phone,
                                   "department_id":contact_info.department_id,
-                                  "yzy_userid":contact_info.yzy_userid})
+                                  "yzy_userid":contact_info.userid})
             data_list.append({
                 "id": d.id,
-                "start_time": d.start_time,
-                "end_time":d.end_time,
+                "start_time": d.start_time.strftime('%Y-%m-%d %H:%M:%S') if d.start_time else '',
+                "end_time":d.end_time.strftime('%Y-%m-%d %H:%M:%S') if d.end_time else '',
                 "duty_date": d.duty_date,
                 "shift_type":d.shift_type,
                 "duty_unit": d.duty_unit,

+ 1 - 1
routers/api/videoResource/videoinfo.py

@@ -46,7 +46,7 @@ def read_all_regions(parent_id:str = '0',
             isShowSelect1 = True
             if parent_id_get_region_info(info.indexCode) or unint_id_get_video_list(info.indexCode):
                 isShowSelect1=False
-            if info.indexCode=='84021e2f6eba4e6b8ccc7d750fb833fa':
+            if info.indexCode=='84021e2f6eba4e6b8ccc7d750fb833fa' or info.indexCode=='44000000002160752825':
                 continue
 
             data.append({'id': info.indexCode,