libushang 2 dienas atpakaļ
vecāks
revīzija
0cdf0876e8
2 mainītis faili ar 96 papildinājumiem un 5 dzēšanām
  1. 94 3
      jobs/yzy_job.py
  2. 2 2
      models/yzy_base.py

+ 94 - 3
jobs/yzy_job.py

@@ -88,15 +88,47 @@ def yzy_unit_queue_proc():
         return
     
     with get_local_db() as db:
-        updatetime = db.query(func.max(YzyOrgUnitEntity.updatetime)).scalar()
+        updatetime = db.query(func.max(YzyOrgUserEntity.updatetime)).scalar()
         if updatetime is None:
             updatetime = datetime(2000, 1, 1, 1, 1, 1)
 
         starttime = updatetime.strftime("%Y-%m-%d %H:%M:%S")
         endtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+        
+        # 这个看起来没用
         # YzyApi.getauthorizedusersbyupdatetime(starttime, endtime)
         
-        # YzyApi.getappusersbyupdatetime(starttime, endtime)
+        YzyApi.getappusersbyupdatetime(starttime, endtime)
+        
+        '''
+        result = {
+            "success" : True,
+            "errcode" : 0,
+            "errmessage" : "请求成功",
+            "data" : [ {
+                "userid" : "imi85r9my4a9h1ls9c1fnz",
+                "username" : "梁文龙",
+                "gender" : 1,
+                "mobile" : "49779889d18a2a9cadf132014e173116",
+                "unitid" : "v5vd6t4zkbd9gz0ijlzj73",
+                "position" : "主任",
+                "priority" : "1",
+                "order" : 1073741825,
+                "status" : 0,
+                "updateTime" : "2025-08-22 16:24:28"
+            }, {
+                "userid" : "28cm254t2kc5hjc70saq8x",
+                "username" : "黄晓东",
+                "gender" : 1,
+                "mobile" : "97651f2cd1206c3ab205cd581606525f",
+                "unitid" : "v5vd6t4zkbd9gz0ijlzj73",
+                "position" : "一级科员",
+                "priority" : "1",
+                "order" : 1073741814,
+                "status" : 0,
+                "updateTime" : "2025-08-22 16:25:18"
+            } ]
+        }
         result = {
             "success" : True,
             "errcode" : 0,
@@ -114,8 +146,67 @@ def yzy_unit_queue_proc():
                 "updateTime" : "2025-08-13 09:18:11"
             } ]
         }
+        '''
+        if result['errcode'] == 0:
+            data = result['data']
+
+            for user_info in data:
+                userid = user_info['userid']
+                username = user_info['username']
+                gender = user_info['gender']
+                mobile = user_info['mobile']
+                unitid = user_info['unitid']
+                position = user_info['position']
+                priority = user_info['priority']
+                order = user_info['order']
+                status = user_info['status']
+                updateTime = user_info['updateTime']
+                
+                telephonenumber = ''    
+                try:
+                    # 敏感数据加密算法(DES 对称加密)
+                    telephonenumber = YzyApi.desDecryptValue(settings.YZY_CORPSECRET, mobile)
+                except:
+                    traceback.print_exc()
 
-        # result = YzyApi.getunitsbyuintidandupdatetime("0751a8jxfqajk90mt022n1", starttime, endtime)
+                unitpath = None
+                unit_row = db.query(YzyOrgUnitEntity).filter(YzyOrgUnitEntity.unitid == unitid).first()
+                if unit_row is not None:
+                    unitpath = unit_row.unitpath
+
+                user_dict = {
+                    "userid": userid,
+                    "username": username,
+                    "displayname": username,
+                    "gender": gender,
+                    "telephonenumber": telephonenumber,
+                    "updatetime": updateTime,
+                    "unitid": unitid,
+                    "position": position,
+                    "priority": priority,
+                    "order": order,
+                    "unitpath": unitpath
+                }
+
+                unit_row = db.query(YzyOrgUserEntity).filter(YzyOrgUserEntity.userid == userid).first()
+                if unit_row is None:
+                    new_unit = YzyOrgUserEntity(**user_dict)
+                    new_unit.createtime = datetime.now()
+                    db.add(new_unit)
+                else:
+                    db.query(YzyOrgUserEntity).filter(YzyOrgUserEntity.userid == userid).update(user_dict)
+                db.commit()
+
+
+        # result = YzyApi.getunitsbyuintidandupdatetime("v5vd6t4zkbd9gz0ijlzj73", starttime, endtime)
+        
+        updatetime = db.query(func.max(YzyOrgUnitEntity.updatetime)).scalar()
+        if updatetime is None:
+            updatetime = datetime(2000, 1, 1, 1, 1, 1)
+
+        starttime = updatetime.strftime("%Y-%m-%d %H:%M:%S")
+        endtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+        
         result = YzyApi.getappunitsbyupdatetime(starttime, endtime)
         '''
         result = {

+ 2 - 2
models/yzy_base.py

@@ -50,8 +50,8 @@ class YzyOrgUserEntity(Base):
     #unitleader = Column(Integer)
     position = Column(String)
     priority = Column(Integer)
-    unitpath = Column(Integer)
-
+    unitpath = Column(String)
+    order = Column(Integer)
 
     class Config:
         orm_mode = True