libushang 1 месяц назад
Родитель
Сommit
ea762f6119
6 измененных файлов с 27 добавлено и 104 удалено
  1. 3 1
      config.py
  2. 2 2
      routers/api/yst/daiban.py
  3. 4 2
      routers/api/yst/file.py
  4. 1 1
      routers/api/yst/yhpcsb.py
  5. 8 33
      routers/api/yst/yhxx.py
  6. 9 65
      utils/sg_auth.py

+ 3 - 1
config.py

@@ -75,7 +75,9 @@ class DevConfig(Settings):
     YZY_HOST = "https://xtbg.digitalgd.com.cn"
     YZY_API_ROOT = "http://19.15.0.128:8080"
 
-    
+    # 粤商通网关配置
+    YST_PASS_ID = "yst_mmsyjjzhyjxt"
+    YST_PASS_TOKEN = "3AtV4BRgyM8OFGJYlJWGQBhCeQwB0MhN"
 
 
 class ProdConfig(Settings):

+ 2 - 2
routers/api/yst/daiban.py

@@ -136,8 +136,8 @@ def index(
 def new_record(data: dict):
     shixiang = data['sxmc']
     projectNo = data['bzid']
-    systemId = settings.YST_RANQI_PASS_ID
-    sourceSystemId = settings.YST_RANQI_PASS_ID
+    systemId = settings.YST_PASS_ID
+    sourceSystemId = settings.YST_PASS_ID
     taskCodeLocal = shixiang
     applyTime = from_timestamp(data['create_time'])
     update_time = get_datetime_str(data['update_time'])

+ 4 - 2
routers/api/yst/file.py

@@ -127,7 +127,7 @@ def show(
             if os.path.exists(file_type_path) and os.path.isdir(file_type_path):
                 file_list = []
                 for file_name in os.listdir(file_type_path):
-                    file_list.append("/mmh5_yjxm_yst/ebus/yst_mmsyjjzhyjxt/api/yst/file/show?thumb=&file_name={}".format(file_name))    
+                    file_list.append("/mmh5_yjxm_yst/ebus/yst_mmsyjjzhyjxt/api/yst/file/show?thumb=1&file_name={}&rnd={}".format(file_name, new_guid()))    
                 valueMap = {
                     'fileType': file_type,
                     'imageUrls': file_list
@@ -171,8 +171,10 @@ async def show(
         if thumb != '':
             print('thumb !!!')
             image = Image.open(image_filepath)
+            w = image.width
+            h = image.height
             buf = BytesIO()
-            image.thumbnail((64, 64))
+            image.thumbnail((256, h*256/w))
             image.save(buf, 'png')
             img_data = buf.getvalue()
             return StreamingResponse(BytesIO(img_data), media_type="image/png")

+ 1 - 1
routers/api/yst/yhpcsb.py

@@ -134,7 +134,7 @@ async def detail(
         imageUrls = []
         rows = db.query(YssYstUploadFileEntity).filter(and_(YssYstUploadFileEntity.bzid == bzid, YssYstUploadFileEntity.file_type == 'yyzz')).all()
         for row in rows:
-            imageUrls.append("/mmh5_yjxm_yst/ebus/yst_mmsyjjzhyjxt/api/yst/file/show?thumb=&file_name={}".format(row.file_name))
+            imageUrls.append("/mmh5_yjxm_yst/ebus/yst_mmsyjjzhyjxt/api/yst/file/show?thumb=1&file_name={}".format(row.file_name))
 
         if len(imageUrls) > 0:
             qtFile.append({'fileName': '隐患点图片', 'imageUrls': imageUrls})

+ 8 - 33
routers/api/yst/yhxx.py

@@ -24,6 +24,7 @@ def get_yst_user_info(
     x_tif_uinfo: str = Header(None),
     x_tif_ext: str = Header(None),
 ):
+    '''
     return yst_user_info_response(json.dumps({
         "account_type": "human",
         "corp": {
@@ -36,40 +37,9 @@ def get_yst_user_info(
         },
         "tokenid": "ccb7fb65a9ca5a2d74c2afeed928c522"
     }))
-
-    '''
-    {
-        "account": "DGD440782197706290318",
-        "account_type": "human",
-        "cid": "440782197706290318",
-        "corp": {
-            "account": "50b50b6d",
-            "address": "",
-            "cid": "91440705354627820H",
-            "ctype": "49",
-            "level": "L2",
-            "link_person_name": "李步尚",
-            "mobile": "13426789046",
-            "name": "江门市新会区尚软网络科技有限公司",
-            "role_type": "parent_linked",
-            "social_credit_code": "91440705354627820H",
-            "uid": "359a7db835994a7ebd147f09c5b9ae5d"
-        },
-        "ctype": "10",
-        "face_authtime": 1733726217276,
-        "level": "L2",
-        "login_type": "SG-GASMHS",
-        "mobile": "13426789046",
-        "name": "李步尚",
-        "origin": "SG",
-        "sex": "1",
-        "tokenid": "ccb7fb65a9ca5a2d74c2afeed928c522",
-        "uid": "5b8f1a3e774d4ba8b7ccb2b2d51a38cd",
-        "uversion": "10.0"
-    }
     '''
     
-    pass_token = "123" # settings.YST_RANQI_PASS_TOKEN
+    pass_token = settings.YST_PASS_TOKEN
     token_exception = TokenException()
 
     if x_tif_signature is None or x_tif_nonce is None or x_tif_timestamp is None or x_tif_uid is None or x_tif_uinfo is None or x_tif_ext is None:
@@ -94,7 +64,12 @@ def get_yst_user_info(
     corp = x_tif_ext["corp"]
     if corp is not None:
         corp = {
-            "level": x_tif_ext["corp"]["level"]
+            "level": x_tif_ext["corp"]["level"],
+            "qyInfo": {
+                "qymc": x_tif_ext["corp"]["name"],
+                "qyjb": "--",
+                "qydz": "--"
+            }
         }
 
     return yst_user_info_response(json.dumps({

+ 9 - 65
utils/sg_auth.py

@@ -134,52 +134,6 @@ async def sg_request_param(request: Request):
 
     return data
 
-'''
-def sg_pass_sfzh(token: str = ''):
-    if token == '':
-        raise TokenException()
-
-    elif token == 'fb5d86fa-1cf3-11ef-9b67-00ff257b5fc6':
-        return '341181198809150011'
-
-    
-    from services.tifserv import sgtoken_service
-    redis_key = "sg_token_" + token
-    redis_val = redis_get_json(redis_key)
-    if redis_val is None:
-        redis_val = sgtoken_service.get_token_info(token)
-        logger.info('========================>>>>>>>>>>>>>>>>>>>>>>> userinfo: {}', redis_val)
-        redis_set_json(redis_key, redis_val)
-    
-    return redis_val['cid_num']
-
-
-def sg_pass_extinfo(token: str):
-    if token == 'fb5d86fa-1cf3-11ef-9b67-00ff257b5fc6':
-        return {
-            "name": '李步尚',
-            "sfzh": '341181198809150011',
-            "mobile": '13426789046',
-            "appid": "wx82d43fee89cdc7df"
-        }
-
-    redis_key = "sg_token_" + token
-    redis_val = redis_get_json(redis_key)
-    if redis_val is None:
-        sg_pass_sfzh(token)
-        redis_val = redis_get_json(redis_key)
-
-    if 'phone' not in redis_val:
-        redis_val['phone'] = '13800138000'
-
-    return {
-        "name": redis_val['cid_name'],
-        "sfzh": redis_val['cid_num'],
-        "mobile": redis_val['phone'],
-        "appid": "wx82d43fee89cdc7df"
-    }
-'''
-    
 ######################################################################################
 
 class YstModel(BaseModel):
@@ -226,6 +180,7 @@ def yst_pass_ext(
     x_tif_uinfo: str = Header(None),
     x_tif_ext: str = Header(None),
 ):
+    '''
     if token == 'fb5d86fa-1cf3-11ef-9b67-00ff257b5fc6':
         return {
             "account": "DGD440782197706290318",
@@ -256,25 +211,14 @@ def yst_pass_ext(
             "uid": "5b8f1a3e774d4ba8b7ccb2b2d51a38cd",
             "uversion": "1.0"
         }
+    '''
 
-    pass_token = settings.YST_PASS_TOKEN
-    token_exception = TokenException()
-
-    if x_tif_signature is None or x_tif_nonce is None or x_tif_timestamp is None or x_tif_uid is None or x_tif_uinfo is None or x_tif_ext is None:
-        logger.error('========================>>>>>>>>>>>>>>>>>>>>>>> yst authentication err: 1')
-        raise token_exception
-
-    if authentication(x_tif_timestamp, pass_token, x_tif_nonce, x_tif_uid, x_tif_uinfo, x_tif_ext, x_tif_signature) == False:
-        logger.error('========================>>>>>>>>>>>>>>>>>>>>>>> yst authentication err: 2')
-        raise token_exception
-
-    json_str = base64.b64decode(x_tif_ext)
-    json_str = json_str.decode(encoding='utf-8')
-    x_tif_ext = json.loads(json_str) 
-
-    logger.info('========================>>>>>>>>>>>>>>>>>>>>>>> yst authentication ok: {}', x_tif_ext)
-    logger.info('========================>>>>>>>>>>>>>>>>>>>>>>> yst account_type: {}', x_tif_ext['account_type'])
-    return x_tif_ext
+    redis_key = "yst_token_" + token
+    redis_val = redis_get_json(redis_key)
+    if redis_val is None:
+        raise TokenException()
+    else:
+        return redis_val
 
 def yst_response(obj: any):
     logger.info("sp_response: {}", obj)
@@ -328,7 +272,7 @@ def yst_user_info_response(data: str):
     logger.info("yst_user_info_response: {}", data)
     response_nonce = ranstr(20)
     response_timestamp = str(int(time.time()))    
-    response_sign = calcResponseSign(response_timestamp, settings.YST_RANQI_PASS_TOKEN, response_nonce)
+    response_sign = calcResponseSign(response_timestamp, settings.YST_PASS_TOKEN, response_nonce)
     
     response_headers = { 
         "x-tif-signature": response_sign,