Explorar el Código

2024-02-02 13:42:07

xzc hace 1 año
padre
commit
d7e1c60bb6
Se han modificado 9 ficheros con 594 adiciones y 271 borrados
  1. 57 7
      README.md
  2. 84 106
      V2/app/main/views.py
  3. 1 1
      V2/app/models.py
  4. 89 29
      V2/app/tasks/UserActivateDegreeAnalyze.py
  5. 274 117
      V2/app/tasks/tasks.py
  6. 31 8
      V2/downdata.py
  7. 0 0
      V2/fuli_data.json
  8. 25 0
      V2/tests/locustfile.py
  9. 33 3
      V2/tests/test_api.py

+ 57 - 7
README.md

@@ -61,12 +61,18 @@ docker run -d -p 30236:5236 \
 判断当前 url 和 target_url
 
 一般页面跳转条件判断:
-1、设定全局 Url
-2、当前 current_Url 与全局 Url 不一致
-3、日志中找到最近一条 请求地址 和当前 current_Url 相同的日志
-4、该日志为页面跳转点击时间发生记录
+1、假设网络请求按时间顺序发生,设定一个全局 URL
+2、当前 current_Url 与全局 URL 不一致, 则可以判断页面发生变化
+3、日志中找到最近一条 请求地址URL 和当前 current_Url 相同的日志
+4、该日志记录为页面跳转点击时间发生记录,记录此条记录,并将 current_Url 记录为全局 URL
+
+特殊页面的跳转条件判断:
+1、Ajax请求包含功能代码
+2、判断请求参数或表单中是否包含功能代码
+3、包含功能代码的请求为页面跳转请求
+
 无法判断的情况:
-1、Ajax页面请求,URL不变
+1、Ajax页面请求,URL不变,并且无法判断功能代码
 2、请求的url和最终显示的url不完全相同(去除session,去除cookie,如何判断是否可删?)
 3、去除query不可行,页面的区分度就为query字段
 
@@ -74,12 +80,15 @@ docker run -d -p 30236:5236 \
 1、可以判断请求业务目录的起始时间(由请求参数解析),但无法判断是否开始执行具体业务
 2、期间多次页面跳转发生
 3、URL三级标题发生变化,业务目录终止
+
 无法判断的情况:
 1、Ajax页面的业务目录由表单体现,无法完成页面跳转判断
 2、前端插件暂时无法判断请求是否由人工点击按钮产生(判断表单是否是人工提交困难,行为路径需判断人工提交表单的标志)
 
-### 用户操作流程
+### 用户操作流程(行为路径分析)
 根据 业务进入和完成时间 的结果进行统计
+无法判断的情况:
+1、在路径分析时,如果页面的跳转是由重定向产生,发起重定向的请求不是由人工点击的按钮的网络请求造成,则无法判断请求的数据是否为人工填写
 
 ### 用户其他设备操作(暂无技术方案)
 
@@ -107,4 +116,45 @@ RUN apk add build-base py3-grpcio
 ```
 
 
-
+操作流程:
+1、先收集原始数据,BaseModel接收,dict传输,HDF缓存,DM存储
+2、URL分解,将URL的地址和参数进行分离
+3、时序排列,将请求按照时间进行排序
+4、功能判定
+5、结果发送
+
+
+需关注:
+1、http://10.10.21.23/gmp/static/hr/peixun/user/index.html
+2、http://10.10.21.23/cbpm/flowTrack/#/
+3、http://10.10.21.23/gmp/static/gmpweb/workbench/personal/index.html
+
+1、http://10.150.23.1:8010/PMS/tdgl/cxgn/tdgljcym.do
+2、http://10.150.23.1:8010/PMS/webhelp/helpframe.jsp
+3、http://10.150.23.1:8010/PMS/index.jsp
+4、http://10.150.23.1:8010/PMS/error.jsp
+5、http://10.150.23.1:8010/KFZX/framework/ajaxdatagrid.do
+
+1、 https://fms.gmp.cloud.hq.iv.csg/fms/accountweb/assets/components/core.workflow.engine/workflow/todo.html
+2、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/assets/components/core.workflow.engine/workflow/todo.html
+3、https://fms.gmp.cloud.hq.iv.csg/fms/accountweb/gris/mapp/accountweb/assets/components/core.workflow.engine/workflow/todo.html
+4、https://fms.gmp.cloud.hq.iv.csg/fms/empreimburseweb/assets/necp/EfNavigateServlet
+5、https://fms.gmp.cloud.hq.iv.csg/fms/empreimburseweb/assets/components/core.workflow.engine/workflow/todo.html
+6、https://fms.gmp.cloud.hq.iv.csg/fms/avmfabusinessweb/assets/components/core.workflow.engine/workflow/todo.html
+7、https://fms.gmp.cloud.hq.iv.csg/fms/taskweb/gris/mapp/taskprocessweb/nwyh/todowj/index.html#/todopage
+8、https://fms.gmp.cloud.hq.iv.csg/fms/accountweb/gris/mapp/accountweb/bill/ViewBill.html
+9、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/assets/components/core.workflow.engine/workflow/start.html
+10、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/gris/mapp/constructfinance/assets/components/core.workflow.engine/workflow/todo.html
+11、https://fms.gmp.cloud.hq.iv.csg/fms/cfsweb/gris/mapp/cfsweb/countervail/cooperation/confirm/xtcl.html
+12、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/gris/mapp/constructfinanceweb/ywdj/NW_ProjectMonthApplyInput_PFM/ywdj_monthapplyJHN_PFM_CW.html
+13、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/gris/mapp/constructfinanceweb/ywdj/NW_ProjectPayApproveInput_PFM/ywdj_payapprove_PFM.html
+14、https://fms.gmp.cloud.hq.iv.csg/fms/budgetauditweb/assets/components/core.workflow.engine/workflow/start.html
+15、https://fms.gmp.cloud.hq.iv.csg/fms/budgetauditweb/assets/components/core.workflow.engine/workflow/todo.html
+16、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/pdf/PdfServlet/
+17、https://fms.gmp.cloud.hq.iv.csg/fms/accountweb/pdf/PdfServlet/
+18、https://fms.gmp.cloud.hq.iv.csg/fms/avmfabusinessweb/pdf/PdfServlet/
+19、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/gris/mapp/constructfinanceweb/ywdj/NW_CostReb_PFM/ywdj_costreb_CW_PFM.html
+20、https://fms.gmp.cloud.hq.iv.csg/fms/pfmweb/gris/mapp/constructfinanceweb/ywdj/scpztydj/ywdj_nwScpztydj.html
+
+1、http://10.10.21.28/gmp/static/sp/operationmanage/prodplan/planmg/PlanMgGmpPlanEditForArrange.html
+2、http://10.10.21.28/gmp/static/gmpweb/workbench/todo/TodoCenter.html

+ 84 - 106
V2/app/main/views.py

@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-08 15:46:48
-# @Last Modified time: 2024-01-23 16:31:07
+# @Last Modified time: 2024-01-31 11:27:23
 import threading
 import pandas as pd
 from typing import Optional
@@ -9,6 +9,7 @@ from datetime import datetime
 from pydantic import BaseModel
 from flask import request, jsonify
 from flask_pydantic import validate
+from multiprocessing.connection import Client
 
 from . import main
 from .preprocess import parse_url
@@ -16,6 +17,7 @@ from .preprocess import parse_url
 from ..models import *
 from ..tasks import tasks
 
+# client = Client(('127.0.0.1', 35010))
 
 g = dict()
 
@@ -25,7 +27,7 @@ class RecodModel(BaseModel):
     full_Url: Optional[str] = None
     sim_Url: Optional[str] = None
     user_Id: str
-    device_Id: str
+    device_Id: Optional[str] = None
     request_Method: str
     event_Type: str
     form_Data: Optional[str] = None
@@ -43,112 +45,88 @@ class RecodModel(BaseModel):
 def record(body: RecodModel):
     """接收采集数据,记录临时表
     """
-    try:
-        # --- 采集原始表 --- #
-        record = Record()
-        record.Record_Time = body.record_Time
-        record.Current_Url = body.current_Url
-        record.Full_Url = body.full_Url
-        record.User_Id = body.user_Id
-        record.Request_Method = body.request_Method
-        record.Event_Type = body.event_Type
-        record.Target_Url = body.target_Url
-        record.Button_Text = body.button_Text
-        db.session.add(record)
-        db.session.commit()
-
-        # print(body.dict())
-        tasks.predict(g, item=body.dict())
-
-        # # --- 采集总量 +1 --- #
-        # try:
-        #     tc = TotalCount.query.filter_by(Name = '采集量').one()
-        #     tc.add_one()
-        #     db.session.add(tc)
-        #     db.session.commit()
-        # except Exception as e:
-        #     db.session.rollback()
-        #     print('--->', e)
-
-        # # --- 登录人数 +1 --- #
-        # pl = PersonLogin.query.filter_by(User_Id = body.user_Id)
-        # if pl.count() == 0:
-        #     try:
-        #         db.session.add(PersonLogin(user_id = body.user_Id))
-        #         db.session.commit()
-        #     except Exception as e:
-        #         db.session.rollback()
-        #         print('--->', e)
-
-        # # --- 解析访问域 --- #
-        # df = pd.DataFrame([body.dict()])
-        # result = parser.process(df)
-        # try:
-        #     if result.get("domain") == "人资域":
-        #         PersonLogin.query.filter_by(User_Id = body.user_Id).update({"RZ_Visit": True})
-        #     elif result.get("domain") == "资产域":
-        #         PersonLogin.query.filter_by(User_Id = body.user_Id).update({"ZC_Visit": True})
-        #     elif result.get("domain") == "财务域":
-        #         PersonLogin.query.filter_by(User_Id = body.user_Id).update({"CW_Visit": True})
-        #     elif result.get("domain") == "营销域":
-        #         PersonLogin.query.filter_by(User_Id = body.user_Id).update({"YX_Visit": True})
-        #     db.session.commit()
-        # except Exception as e:
-        #     db.session.rollback()
-        #     print('--->', e)
-
-    except Exception as e:
-        db.session.rollback()
-        print('--->', e)
-        return jsonify({"status": "failed"})
+    # 1、先收集原始数据,BaseModel接收,dict传输,dataframe缓存,DM存储
+    tasks.predict(g, item=body.dict())
+    # try:
+    #     # --- 采集原始表 --- #
+    #     record = Record()
+    #     record.Record_Time = body.record_Time
+    #     record.Current_Url = body.current_Url
+    #     record.Full_Url = body.full_Url
+    #     record.User_Id = body.user_Id
+    #     record.Request_Method = body.request_Method
+    #     record.Event_Type = body.event_Type
+    #     record.Target_Url = body.target_Url
+    #     record.Button_Text = body.button_Text
+    #     db.session.add(record)
+    #     db.session.commit()
+
+    #     print(body.dict())
+
+    #     client.send(body.dict())
+    #     response = client.recv()
+
+    #     # --- 采集总量 +1 --- #
+    #     try:
+    #         tc = TotalCount.query.filter_by(Name = '采集量').one()
+    #         tc.add_one()
+    #         db.session.add(tc)
+    #         db.session.commit()
+    #     except Exception as e:
+    #         db.session.rollback()
+    #         print('--->', e)
+
+    #     # --- 登录人数 +1 --- #
+    #     pl = PersonLogin.query.filter_by(User_Id = body.user_Id)
+    #     if pl.count() == 0:
+    #         try:
+    #             db.session.add(PersonLogin(user_id = body.user_Id))
+    #             db.session.commit()
+    #         except Exception as e:
+    #             db.session.rollback()
+    #             print('--->', e)
+
+    #     # --- 解析访问域 --- #
+    #     df = pd.DataFrame([body.dict()])
+    #     result = parser.process(df)
+    #     try:
+    #         if result.get("domain") == "人资域":
+    #             PersonLogin.query.filter_by(User_Id = body.user_Id).update({"RZ_Visit": True})
+    #         elif result.get("domain") == "资产域":
+    #             PersonLogin.query.filter_by(User_Id = body.user_Id).update({"ZC_Visit": True})
+    #         elif result.get("domain") == "财务域":
+    #             PersonLogin.query.filter_by(User_Id = body.user_Id).update({"CW_Visit": True})
+    #         elif result.get("domain") == "营销域":
+    #             PersonLogin.query.filter_by(User_Id = body.user_Id).update({"YX_Visit": True})
+    #         db.session.commit()
+    #     except Exception as e:
+    #         db.session.rollback()
+    #         print('--->', e)
+    # except Exception as e:
+    #     db.session.rollback()
+    #     print('--->', e)
+    #     return jsonify({"status": "failed"})
     return jsonify({"status": "success"})
 
-@main.route('/screen1', methods=['GET', 'POST'])
-def screen1():
-    # tc = db.session.execute(db.select(TotalCount.Count).where(TotalCount.Name == '采集总量')).one()
-    result = {
-        "table_1": [i.to_json() for i in db.session.query(TotalCount).filter().all()],
-        "table_2": {},
-        "table_3": {},
-        "table_4": {},
-        "table_5": [i.to_json() for i in db.session.query(PersonLogin).filter().all()],
-        "table_6": {},
-        "table_7": {}
-    }
-    return jsonify(result)
-
-@main.route('/screen2', methods=['GET', 'POST'])
-def screen2():
-    result = {
-        "table_1": {},
-        "table_2": {},
-        "table_3": {},
-        "table_4": {}
-    }
-    return jsonify({})
 
 @main.route('/screen3', methods=['GET', 'POST'])
 def screen3():
-    for item in g['fuli@mz.gd.csg.cn'].getActionByDateRange().itertuples():
-        print(f"""
-            当前时间: {item[0]}
-            起始URL:{item.cur_url[:50]}
-            终点URL:{item.tar_url[:50]}
-            """)
-    result = {
-        "table_1": {},
-        "table_2": {},
-        "table_3": {},
-        "table_4": {},
-        "table_5": {},
-        "table_6": {}
-    }
-    return jsonify({})
-
-@main.route('/show')
-def show():
-    print(g)
-    record = db.session.query(Record).filter().all()
-    # record = db.session.execute(db.select(Record).where(Record.Request_Method == 'GET')).all()
-    print(record)
-    return [r.to_json() for r in record]
+    user_id = request.args.get('user_id') or 'fuli@mz.gd.csg.cn'
+    for item in g[user_id].getActionByDateRange().itertuples():
+        row = {
+            "Record_Time": item[0], "Current_Url": item.cur_url + '?' + item.cur_que,
+            "Target_Url": item.tar_url + '?' + item.tar_que, "User_Id": user_id,
+            "Request_Method": item.req_met, "Form_Data": item.for_dat,
+            "Button_Text": item.but_txt, "Is_Op": item.is_op,
+        }
+
+        print(item.cur_url, item.tar_url)
+        parser = tasks.UrlParser()
+        result = parser.process(row)
+        try:
+            print(tasks.ResultJson(time=result['time'], user_id=result['user'], domain=result['domain'],
+            title1=result['一级标题'], title2=result['二级标题'], title3=result['三级标题'], text=result['text'], is_op=item.is_op, is_bus=False).to_json())
+        except Exception as e:
+            print(e)
+        # tasks.postback(result)
+    return jsonify({})

+ 1 - 1
V2/app/models.py

@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-12 15:23:13
-# @Last Modified time: 2024-01-22 15:10:32
+# @Last Modified time: 2024-01-24 15:53:01
 from datetime import datetime
 import click
 from flask import current_app

+ 89 - 29
V2/app/tasks/UserActivateDegreeAnalyze.py

@@ -1,9 +1,8 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-22 13:47:11
-# @Last Modified time: 2024-01-23 16:46:12
+# @Last Modified time: 2024-02-02 13:20:51
 import pandas as pd
-from pprint import pprint
 
 # 用户活跃度分析
 # 第一个功能:统计指定时间范围内的访问次数最多的10个用户
@@ -19,47 +18,108 @@ class UserActivateDegreeAnalyzeSpace(object):
     def __init__(self, user: str):
         self.user = user
         self.pool_size = 10
-        self.DataStream = pd.DataFrame(columns=['time', 'cur_url', 'tar_url', 'dev_id', 'req_met', 'eve_typ', 'for_dat', 'sta_cod', 'ifr_url', 'but_txt'])
+        self.DataStream = pd.DataFrame(columns=['time', 'cur_url', 'tar_url', 'dev_id', 'req_met', 'eve_typ', 'for_dat', 'sta_cod', 'ifr_url', 'but_txt', 'is_op', 'is_bus', 'is_bias'])
 
+    # 设置变量名称无关化
     def push(self, item: dict) -> None:
-        self.DataStream = self.DataStream.append({
-                "time": item['Record_Time'],
-                "cur_url": item['Current_Url'],
-                "tar_url": item['Target_Url'],
-            },
-            ignore_index=True)
+        self.DataStream.loc[len(self.DataStream.index)] = {
+                "time": item['record_time'],        # 请求时间
+                "cur_url": item['current_url'],     # 当前URL
+                "tar_url": item['target_url'],      # 目标URL
+                "ifr_url": item['iframe_url'],      # 内嵌URL
+                "req_met": item['request_method'],  # 请求方法
+                "for_dat": item['form_data'],       # 表单数据
+                "but_txt": item['button_text'],     # 按钮文本
+                "is_op": False,                     # 是否为人工操作
+                "is_bus": False,                    # 是否为业务项
+                "is_bias": False,                   # 是否偏离
+            }
 
+    # 获取指定日期范围内的用户访问行为数据
     def getActionByDateRange(self) -> pd.DataFrame:
         """获取指定日期范围内的用户访问行为数据
         """
-        current = self.DataStream.iloc[0]['cur_url']
-        target = dict()
-        result = pd.DataFrame()
-        # 拷贝数据,清除数据
+
+        # 1、拷贝数据,保存数据并清除数据
         CopyDataStream = self.DataStream.copy(deep=True)
+        # 清除数据
         self.DataStream.drop(self.DataStream.index, inplace=True)
+        # 保存数据到 HDF
+        # CopyDataStream.to_hdf('DataStream.h5', key=self.user)
+        CopyDataStream.to_json(f'DataStream-{self.user}.h5', orient='records', lines=True, force_ascii=False)
+
+        # 2、URL分解,将URL的地址和参数进行分解
+        # print(CopyDataStream)
+        # 当前URL参数分离
+        CopyDataStream['cur_que'] = CopyDataStream['cur_url'].apply(lambda x: x.split("?")[-1])
+        CopyDataStream['cur_url'] = CopyDataStream['cur_url'].apply(lambda x: x.split("?")[0])
+        # 目标URL参数分离
+        CopyDataStream['tar_que'] = CopyDataStream['tar_url'].apply(lambda x: x.split("?")[-1])
+        CopyDataStream['tar_url'] = CopyDataStream['tar_url'].apply(lambda x: x.split("?")[0])
+        # 内嵌URL参数分离
+        CopyDataStream['ifr_que'] = CopyDataStream['ifr_url'].apply(lambda x: x.split("?")[-1])
+        CopyDataStream['ifr_url'] = CopyDataStream['ifr_url'].apply(lambda x: x.split("?")[0])
+        # print(CopyDataStream)
+
+        # 3、时序排列,将请求按照时间进行排序
         # 设置时间格式
         CopyDataStream['time'] = pd.to_datetime(CopyDataStream['time'])
+        CopyDataStream['idx'] = pd.to_datetime(CopyDataStream['time'])
         # 时间排序
-        CopyDataStream = CopyDataStream.set_index('time')
+        # CopyDataStream = CopyDataStream.sort_values(by='time')
+        # CopyDataStream = CopyDataStream.reset_index()
+        CopyDataStream = CopyDataStream.set_index('idx')
+
+        CopyDataStream.to_csv('debug.csv', index=True, columns=['cur_url', 'tar_url'])
+
+        # 4、功能判定
+        # 设定当前时间
+        curtime = CopyDataStream.iloc[0]['time']
+        # 设定当前URL
+        # current = CopyDataStream.iloc[0]['cur_url']
+        current = ''
+        # 设定目标 URL 集
+        target = dict()
+        # 结果缓存
+        result = pd.DataFrame()
+        # 将第一个请求放入结果
+        result = result.append([CopyDataStream.iloc[0]])
+        result.iloc[ len(result.index) -1 ]['is_op'] = True
+
         # 遍历数据
         for idx, item in enumerate(CopyDataStream.itertuples()):
-            if item.cur_url == current:                     # 当前地址没变,页面无跳转(需判断AJAX)
-                if item.tar_url not in target:              # 目标url不在临时目录
-                    target[item.tar_url] = idx              # 添加目标URL到临时目录
-            else:                                           # 当前地址发生变化,页面跳转
-                current = item.cur_url                      # 当前地址修改
-                if target.get(current):                     # 查看是否有请求当前URL的历史记录
-                    print(target.get(current))
-                    # pprint({
-                    #     "源地址": CopyDataStream.loc[target.get(current)]['cur_url'],
-                    #     "跳转地": CopyDataStream.loc[target.get(current)]['tar_url']
-                    #     })      # 查看历史记录
+            # 判断是否营销域
+            if ('10.150.23.1:8010' in item.cur_url) and ('_INVOKE_FUNC_TITLE_' in item.for_dat):
+                current = item.cur_url
+                result = result.append([CopyDataStream.iloc[idx]])
+            # 判断是否重新上线
+            elif (item.time - curtime).seconds > 300:                   # 请求时间距离上次请求相隔大于300秒,判断上次请求以离线
+                result = result.append([CopyDataStream.iloc[idx -1]])   # 将上次的请求记录下来
+                result.iloc[ len(result.index) -1 ]['is_op'] = True     # 变更记录为人工
+                result = result.append([CopyDataStream.iloc[idx]])      # 将新请求记录下来(新记录为人工操作)
+                result.iloc[ len(result.index) -1 ]['is_op'] = True     # 变更记录为人工
+                current = item.cur_url                                  # 当前地址修改
+                target = dict()                                         # 清除历史记录
+                target[item.tar_url] = idx                              # 添加当前记录
+            elif item.cur_url == current:                               # 当前地址没变,页面无跳转(需判断AJAX,需判断请求时间)
+                if item.tar_url not in target:                          # 目标URL不在临时目录
+                    target[item.tar_url] = idx                          # 添加目标URL到临时目录
+            else:                                                       # 当前地址发生变化,页面跳转
+                if target.get(current):                                 # 查看是否有请求当前URL的历史记录,有历史记录则该历史记录就为页面变更记录
                     result = result.append([CopyDataStream.iloc[target.get(current)]])
-                else:                                       # 为找到历史记录
-                    print("*********非正常跳转*********")    # 非正常跳转
-                target = dict()                             # 清除历史记录
-                target[item.tar_url] = idx                  # 添加当前记录
+                    result.iloc[ len(result.index) -1 ]['is_op'] = True # 变更记录为人工
+                elif '4a.gd.csg.local' in item.cur_url:                 # 未找到历史记录,该页面并非由请求获得,判定是否首次登录
+                    print("*********是首次登录*********")                # 首次登录
+                    result = result.append([CopyDataStream.iloc[idx]])  # 记录当前变更项
+                    result.iloc[ len(result.index) -1 ]['is_op'] = True # 变更记录为人工
+                else:                                                   # 非正常跳转(既不是由统一认证平台进入、也不是直接点击跳转进入)
+                    print("*********非正常跳转*********")                # 非正常跳转
+                target = dict()                                         # 清除历史记录
+                target[item.tar_url] = idx                              # 添加当前记录
+                current = item.cur_url                                  # 当前地址修改
+            curtime = item.time                                         # 修正时间戳
+        # 结果返回
+        print(result)
         return result
 
     def getSession2Action(self):

+ 274 - 117
V2/app/tasks/tasks.py

@@ -1,39 +1,92 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-18 09:47:28
-# @Last Modified time: 2024-01-23 11:53:14
+# @Last Modified time: 2024-02-02 13:37:27
 
-import re
+import re, json
 import datetime
 import dmPython
+import numpy as np
 import pandas as pd
+import requests
 from pandas import DataFrame
 from threading import Thread
 from .preprocess import parse_url
 from .UserActivateDegreeAnalyze import UserActivateDegreeAnalyzeSpace
 
+
+class ResultJson:
+    def __init__(self, time, user_id, domain, title1, title2, title3, device_id=None, text=None, is_op=True, is_bus=False, is_bias=False, status="正常"):
+        # 执行时间
+        self.time = time.strftime('%Y-%m-%d %H:%M:%S')
+        # 执行用户
+        self.user_id = user_id
+        # 执行域
+        self.domain = domain
+        self.title1 = title1
+        self.title2 = title2
+        # 业务项
+        self.title3 = title3
+        # 设备
+        self.device_id = device_id
+        # 操作步骤
+        self.text = text
+        # 是否用户操作
+        self.is_op = is_op
+        # 是否业务
+        self.is_bus = is_bus
+        # 是否偏离
+        self.is_bias = is_bias
+        # 执行结果
+        self.status = status
+
+    def to_json(self):
+        return {
+            "real": {                           # 实时信息
+                "time": self.time,              # 记录时间
+                "userId": self.user_id,         # 用户ID
+                "deviceId": self.device_id,     # 设备ID
+                "domain": self.domain,          # 访问域
+                "business": self.title3,        # 业务类型
+                "option": self.text,            # 执行操作
+                "isOp": self.is_op,             # 是否是一条操作
+                "isBus": self.is_bus,           # 是否是一项业务
+                "isBias": self.is_bias,         # 是否偏离
+                "status": self.status           # 执行结果
+            }, 
+            "base": {                           # 定时信息
+                "用户ID": self.user_id,
+                "常用时段": "",
+                "所在部门": "",
+                "使用设备": "",
+                "操作系统": "",
+                "常用业务": ""
+            }
+        }
+
+
 def func(item):
     print(item)
     session = DM8Session()
     try:
-        result = session.insert("""INSERT INTO FRAGMENT("Time", "User_Id", "Method", "Has_Form", "Dom", "Title1", "Title2", "Title3", "Title4", "Behavior", "Stay") VALUES(?,?,?,?,?,?,?,?,?,?,?)""",
-                        (item['time'],item['user'],item['method'],item['hasform'],item['domain'],item['一级标题'],item['二级标题'],item['三级标题'],item['四级标题'],item['text'], item['stay']))
+        result = session.execute("""INSERT INTO FRAGMENT("Time", "User_Id", "Method", "Has_Form", "Dom", "Title1", "Title2", "Title3", "Title4", "Behavior", "Stay") VALUES(?,?,?,?,?,?,?,?,?,?,?)""",
+                        (item['time'], item['user'], item['method'], item['hasform'], item['domain'], item['一级标题'], item['二级标题'], item['三级标题'], item['四级标题'], item['text'], item['stay']))
     except Exception as e:
         print(e)
 
 
-# class filteredRealTimeLogDStream(object):
-#     time: str
-#     user_id: str
-#     method: str
-#     hasform: bool
-#     domain: str
-#     title1: str
-#     title2: str
-#     title3: str
-#     title4: str
-#     behavior: str
-#     stay: int = 0
+def postback(json_data: dict) -> None:
+    url = 'http://192.168.1.166:8080/statistics/algorithm'
+    data = ResultJson(time=datetime.datetime.now(), user_id="fuli@mz.gd.csg.cn", domain="财务域",
+        title1="计划预算管理", title2="预算查询分析", title3="编制过程查询", text="69", is_op=True, is_bus=True)
+
+    print(data.to_json())
+    response = requests.post(url, json={'parameter': data.to_json()})
+
+    if response.status_code == 200:
+        print('success')
+    else:
+        print(response.text())
 
 
 class DM8Session(object):
@@ -57,7 +110,7 @@ class DM8Session(object):
             self.cursor.close()
         return df
 
-    def insert(self, sql_cmd: str, args):
+    def execute(self, sql_cmd: str, args):
         try:
             self.cursor = self.conn.cursor()
             # 执行sql语句
@@ -73,20 +126,6 @@ class DM8Session(object):
             self.cursor.close()
         return status
 
-    def update(self, sql_cmd: str, args):
-        try:
-            self.cursor = self.conn.cursor()
-            self.cursor.execute(sql_cmd, args)
-            self.conn.commit()
-            status = True
-        except Exception as e:
-            self.conn.rollback()
-            print(e)
-            status = False
-        finally:
-            self.cursor.close()
-        return status
-
     def __del__(self):
         self.conn.close()
 
@@ -107,14 +146,60 @@ class UrlParser(object):
 
     def process_record(self, item: dict):
         i = item['Current_Url']
-        j = item['Target_Url']
 
-        # result = item
         result = None
 
         if i[1] == '10.10.21.23':
             result = {'domain': '人资域'}
-            if i[5].get("appCode"):
+            if i[2] == '/gmp/login.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '人资域',
+                    '一级标题': '人资域登录',
+                    '二级标题': '人资域登录',
+                    '三级标题': '人资域登录',
+                    'text': item['Button_Text'] if item['Button_Text'] else None
+                }
+            elif i[2] == '/gmp/static/gmpweb/hrIndex.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '人资域',
+                    '一级标题': '人资域首页',
+                    '二级标题': '人资域首页',
+                    '三级标题': '人资域首页',
+                    'text': item['Button_Text'] if item['Button_Text'] else None
+                }
+            elif i[2] == '/gmp/static/gmpweb/workbench/todo/TodoCenter.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '人资域',
+                    '一级标题': '人资域',
+                    '二级标题': '公共应用',
+                    '三级标题': '代办中心',
+                    'text': item['Button_Text'] if item['Button_Text'] else None
+                }
+            elif i[2] == 'hrcore_web/labormanagement/contractagreementview/myAgreement.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '人资域',
+                    '一级标题': '人资域',
+                    '二级标题': '个人应用',
+                    '三级标题': '我的协议',
+                    'text': item['Button_Text'] if item['Button_Text'] else None
+                }
+            elif i[5].get("appCode"):
                 task = self.rzdf.query(f'''path == "{i[2]}" & appCode == "{i[5]['appCode'][0]}"''')
                 result = {
                     'time': item['Record_Time'],
@@ -127,9 +212,23 @@ class UrlParser(object):
                     '三级标题': task['三级标题'].values[0],
                     'text': item['Button_Text'] if item['Button_Text'] else None
                 }
+            else: # 后续使用 iframe 处理
+                pass
         elif i[1] == '10.10.21.28':
             result = {'domain': '资产域'}
-            if i[5].get('appCode'):
+            if i[2] == '/gmp/static/gmpweb/index.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '资产域',
+                    '一级标题': '资产域首页',
+                    '二级标题': '资产域首页',
+                    '三级标题': '资产域首页',
+                    'text': item['Button_Text'] if item['Button_Text'] else None
+                }
+            elif i[5].get('appCode'):
                 task = self.zcdf.query(f'''path == "{i[2]}" & appCode == "{i[5]['appCode'][0]}"''')
                 result = {
                     'time': item['Record_Time'],
@@ -144,7 +243,43 @@ class UrlParser(object):
                 }
         elif i[1] == 'fms.gmp.cloud.hq.iv.csg':
             result = {'domain': '财务域'}
-            if i[5].get('appCode'):
+            if i[2] == '/gmp/login.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '财务域',
+                    '一级标题': '登录财务域',
+                    '二级标题': '登录财务域',
+                    '三级标题': '登录财务域',
+                    'text': item['Button_Text']
+                }
+            elif i[2] == '/gmp/index.html':
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '财务域',
+                    '一级标题': '财务域首页',
+                    '二级标题': '财务域首页',
+                    '三级标题': '财务域首页',
+                    'text': item['Button_Text']
+                }
+            elif i[2] == '/gmp/': # 待确认
+                result = {
+                    'time': item['Record_Time'],
+                    'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
+                    'domain': '财务域',
+                    '一级标题': '财务域认证',
+                    '二级标题': '财务域认证',
+                    '三级标题': '财务域认证',
+                    'text': item['Button_Text']
+                }
+            elif i[5].get('appCode'):
                 task = self.cwdf.query(f'''path == "{i[2]}" & appCode == "{i[5]['appCode'][0]}"''')
                 result = {
                     'time': item['Record_Time'],
@@ -155,73 +290,95 @@ class UrlParser(object):
                     '一级标题': task['一级标题'].values[0],
                     '二级标题': task['二级标题'].values[0],
                     '三级标题': task['三级标题'].values[0],
-                    'text': item['Button_Text'] if item['Button_Text'] else None
+                    'text': item['Button_Text']
                 }
         elif i[1] == '10.150.23.1:8010':
             result = {'domain': '营销域'}
-            fd = item['Form_Data']
-            if item['Form_Data'] and item['Form_Data'] != 'None':
-                try:
-                    if item['Form_Data'][0] != "{":
-                        item["Params_Data"] = item['Form_Data']
-                        form_data = None
-                    else:
-                        item['Form_Data'] = item['Form_Data'].replace("\"remark\":\"[", "\"remark\":\"\"[")
-                        item['Form_Data'] = item['Form_Data'].replace("\"[", "[").replace("]\"", "]").replace("\"{", "{").replace("}\"", "}")
-                        item['Form_Data'] = item['Form_Data'].replace("object HTMLInputElement", "").replace("[null]", "[]").replace("\"null\"", "\"\"")
-                        item['Form_Data'] = item['Form_Data'].replace("\n", "")
-                        form_data = json.loads(item['Form_Data'])
-                except Exception as e:
-                    logging.error(item['Form_Data'])
-                    logging.error(fd)
-                    form_data = None
-                    raise e
-            else:
-                form_data = None
-
-            if form_data and '_INVOKE_FUNC_TITLE_' in form_data:
-                title = form_data['_INVOKE_FUNC_TITLE_'][0]
-                appcontext = form_data['_INVOKE_FUNC_URL_'][0].split('/')[1]
-                logging.debug(appcontext)
-                task = self.yxdf.query(f'''四级标题 == "{title}" & appcontext == "{appcontext}"''')
-                if task.empty:
-                    task = self.yxdf.query(f'''三级标题 == "{title}" & appcontext == "{appcontext}"''')
-                if task.empty:
-                    task = self.yxdf.query(f'''四级标题 == "{title}"''')
-                if task.empty:
-                    task = self.yxdf.query(f'''三级标题 == "{title}"''')
-                try:
-                    result = {
-                        'time':    item['Record_Time'],
-                        'user':    item['User_Id'],
-                        'method':  item['Request_Method'],
-                        'hasform': True,
-                        'domain': '营销域',
-                        '一级标题': task['一级标题'].values[0],
-                        '二级标题': task['二级标题'].values[0],
-                        '三级标题': task['三级标题'].values[0],
-                        '四级标题': task['四级标题'].values[0],
-                        'text':    item['Button_Text'] if item['Button_Text'] else None
-                    }
-                except Exception as e:
-                    logging.error(task)
-                    logging.error(item['Form_Data'])
-                    logging.error(title)
-                    logging.error(e)
-                    logging.error(form_data['_INVOKE_FUNC_URL_'][0])
-            else:
+            if i[2] == '/PMS/login.do':
                 result = {
                     'time': item['Record_Time'],
                     'user': item['User_Id'],
+                    'method': item['Request_Method'],
+                    'hasform': True if item['Form_Data'] else False,
                     'domain': '营销域',
-                    'hasform': False,
+                    '一级标题': '营销域登录',
+                    '二级标题': '营销域登录',
+                    '三级标题': '营销域登录',
                     'text': item['Button_Text'] if item['Button_Text'] else None
                 }
+            else:
+                fd = item['Form_Data']
+                if item['Form_Data'] and item['Form_Data'] != 'None':
+                    try:
+                        if item['Form_Data'][0] != "{":
+                            item["Params_Data"] = item['Form_Data']
+                            form_data = None
+                        else:
+                            item['Form_Data'] = item['Form_Data'].replace("\"remark\":\"[", "\"remark\":\"\"[")
+                            item['Form_Data'] = item['Form_Data'].replace("\"[", "[").replace("]\"", "]").replace("\"{", "{").replace("}\"", "}")
+                            item['Form_Data'] = item['Form_Data'].replace("object HTMLInputElement", "").replace("[null]", "[]").replace("\"null\"", "\"\"")
+                            item['Form_Data'] = item['Form_Data'].replace("\n", "")
+                            form_data = json.loads(item['Form_Data'])
+                    except Exception as e:
+                        logging.error(item['Form_Data'])
+                        logging.error(fd)
+                        form_data = None
+                        raise e
+                else:
+                    form_data = None
+                if form_data and '_INVOKE_FUNC_TITLE_' in form_data:
+                    title = form_data['_INVOKE_FUNC_TITLE_'][0]
+                    appcontext = form_data['_INVOKE_FUNC_URL_'][0].split('/')[1]
+                    logging.debug(appcontext)
+                    task = self.yxdf.query(f'''四级标题 == "{title}" & appcontext == "{appcontext}"''')
+                    if task.empty:
+                        task = self.yxdf.query(f'''三级标题 == "{title}" & appcontext == "{appcontext}"''')
+                    if task.empty:
+                        task = self.yxdf.query(f'''四级标题 == "{title}"''')
+                    if task.empty:
+                        task = self.yxdf.query(f'''三级标题 == "{title}"''')
+                    try:
+                        result = {
+                            'time':    item['Record_Time'],
+                            'user':    item['User_Id'],
+                            'method':  item['Request_Method'],
+                            'hasform': True,
+                            'domain': '营销域',
+                            '一级标题': task['一级标题'].values[0],
+                            '二级标题': task['二级标题'].values[0],
+                            '三级标题': task['三级标题'].values[0],
+                            '四级标题': task['四级标题'].values[0],
+                            'text':    item['Button_Text'] if item['Button_Text'] else None
+                        }
+                    except Exception as e:
+                        logging.error(task)
+                        logging.error(item['Form_Data'])
+                        logging.error(title)
+                        logging.error(e)
+                        logging.error(form_data['_INVOKE_FUNC_URL_'][0])
+                else:
+                    result = {
+                        'time': item['Record_Time'],
+                        'user': item['User_Id'],
+                        'method': item['Request_Method'],
+                        'hasform': False,
+                        'domain': '营销域',
+                        '一级标题': '登录门户',
+                        '二级标题': '登录门户',
+                        '三级标题': '登录门户',
+                        'text': item['Button_Text'] if item['Button_Text'] else None
+                    }
         elif i[1] == '4a.gd.csg.local':
             result = {
                 'time': item['Record_Time'],
                 'user': item['User_Id'],
-                '域': '登录门户'
+                'method': item['Request_Method'],
+                'hasform': True if item['Form_Data'] else False,
+                'domain':  '登录门户',
+                '一级标题': '登录门户',
+                '二级标题': '登录门户',
+                '三级标题': '登录门户',
+                'text': item['Button_Text'] if item['Button_Text'] else None
             }
         return result
 
@@ -290,7 +447,7 @@ class UserVisitAnalyzeSpace(object):
         #             index += 1
         #             dt.iloc[index] = d2
         #             session = DM8Session()
-        #             result = session.insert("""INSERT INTO FRAGMENT("Time", "User_Id", "Dom", "Title1", "Title2", "Title3", "Title4", "Behavior", "Stay") VALUES(?,?,?,?,?,?,?,?)""",
+        #             result = session.execute("""INSERT INTO FRAGMENT("Time", "User_Id", "Dom", "Title1", "Title2", "Title3", "Title4", "Behavior", "Stay") VALUES(?,?,?,?,?,?,?,?)""",
         #                     args=(d1['time'], d1['user'], d1['domain'], d1['一级标题'], d1['二级标题'], d1['三级标题'], d1.get('四级标题'), d1['text'], d1['stay']))
         #         else:
         #             dt.iloc[index] = d1
@@ -331,7 +488,7 @@ class UserVisitAnalyzeSpace(object):
         """
         pass
 
-    def getClickCategory2Count(self):# -> DataFrame
+    def getClickCategory2Count(self) -> DataFrame:
         """获取各分类点击次数
         1、过滤出点击行为数据,点击数据只占总数据的一小部分,所以过滤后数据可能不均匀
         """
@@ -392,7 +549,7 @@ class BusinessClickRealTimeSpace(object):
         session = DM8Session()
         for row in self.aggregatedDStream.itertuples():
             try:
-                result = session.insert("""INSERT INTO TOTALVISIT("Name", "Count") VALUES(?,?)""", (row.word, row.count))
+                result = session.execute("""INSERT INTO TOTALVISIT("Name", "Count") VALUES(?,?)""", (row.word, row.count))
             except Exception as e:
                 print(e)
         return self.aggregatedDStream
@@ -408,36 +565,36 @@ class BusinessClickRealTimeSpace(object):
         """
         pass
 
+# 字典键首字母大写
+# def capital_to_higher(dict_info):
+#     new_dict = {}
+#     for i, j in dict_info.items():
+#         new_dict[re.sub("([a-zA-Z])", lambda x: x.groups()[0].upper(), i, 1)] = j
+#     return new_dict
 
-# class PageOneStepSpace(object):
-#     def __init__(self):
-#         pass
-
-#     def getSession2Action(self):
-#         """获取<session,用户访问行为>格式的数据
-#         """
-#         pass
-
-#     def persistConvertRate(self):
-#         """持久转化率
-#         """
-#         pass
-
-
-def capital_to_higher(dict_info):
+# 字典键全改小写
+def capital_to_lower(dict_info):
     new_dict = {}
     for i, j in dict_info.items():
-        new_dict[re.sub("([a-zA-Z])", lambda x: x.groups()[0].upper(), i, 1)] = j
+        new_dict[i.lower()] = j
     return new_dict
 
-
 def predict(g: dict, item: dict):
-    item = capital_to_higher(item)
-    if g.get(item['User_Id']):
-        g[item['User_Id']].push(item)
+    # 字典键全改小写
+    item = capital_to_lower(item)
+    # 放入全局
+    if g.get(item['user_id']):
+        g[item['user_id']].push(item)
     else:
-        g[item['User_Id']] = UserActivateDegreeAnalyzeSpace(item['User_Id'])
-        g[item['User_Id']].push(item)
+        g[item['user_id']] = UserActivateDegreeAnalyzeSpace(item['user_id'])
+        g[item['user_id']].push(item)
+
+    # item = capital_to_higher(item)
+    # if g.get(item['User_Id']):
+    #     g[item['User_Id']].push(item)
+    # else:
+    #     g[item['User_Id']] = UserActivateDegreeAnalyzeSpace(item['User_Id'])
+    #     g[item['User_Id']].push(item)
 
 
     # session = DM8Session()
@@ -446,7 +603,7 @@ def predict(g: dict, item: dict):
     # try:
     #     df = session.query("""SELECT "ID", "Count" FROM TOTALCOUNT WHERE "Name" = ?""", args="采集量")
     #     if df.shape[0] == 1:
-    #         result = session.update("""UPDATE TOTALCOUNT SET "Count"=? WHERE TOTALCOUNT.ID = ?""", (int(df['Count'])+1, int(df['ID'])))
+    #         result = session.execute("""UPDATE TOTALCOUNT SET "Count"=? WHERE TOTALCOUNT.ID = ?""", (int(df['Count'])+1, int(df['ID'])))
     # except Exception as e:
     #     print(e)
 

+ 31 - 8
V2/downdata.py

@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-12 13:25:10
-# @Last Modified time: 2024-01-23 16:38:29
+# @Last Modified time: 2024-02-02 13:32:43
 import pymysql
 import pandas as pd
 
@@ -80,12 +80,35 @@ class MYDATABASE:
 # connect_info = 'mysql+pymysql://{}:{}@{}:{}?charset=utf8'
 # engine = create_engine(connect_info)
 
-sql_cmd = "SELECT record_Time, current_Url, user_Id, request_Method, event_Type, form_Data, target_Url, iframe_Url, button_Text FROM recoder WHERE user_Id = 'fuli@mz.gd.csg.cn' LIMIT 1000;"
-# df = pd.read_sql(sql_cmd, con=engine, index_col="record_Time")
+user_list = [
+# 'liguiwen@mz.gd.csg.cn',
+# 'houhuiteng@mz.gd.csg.cn',
+# 'lijie1013@mz.gd.csg.cn',
+# 'zengjiyi@mz.gd.csg.cn',
+# 'fuli@mz.gd.csg.cn',
+# 'zengjunhao@mz.gd.csg.cn',
+# 'houyue@mz.gd.csg.cn',
+# 'longruifan@mz.gd.csg.cn',
+# 'wangyongqiang@mz.gd.csg.cn',
+# 'liuhuan0828@mz.gd.csg.cn',
+# 'heweiting@mz.gd.csg.cn',
+# 'ganwenfeng@mz.gd.csg.cn',
+# 'chenweichang0607@mz.gd.csg.cn',
+# 'caiwujiancha1@mz.gd.csg.cn',
+# 'wenyongxian@mz.gd.csg.cn'
+]
+
 
 con = pymysql.connect(host='192.168.1.202', user='root', port=13388,  password='zh123456', database='mzinfo', charset='utf8', use_unicode=True)
-df = pd.read_sql(sql_cmd, con)
-df['record_Time'] = pd.to_datetime(df['record_Time'])
-df = df.set_index('record_Time')
-print(df.head)
-df.to_json("fuli_data.json", orient='records', lines=True, force_ascii=False)
+
+for user in user_list:
+    sql_cmd = f"SELECT record_Time, current_Url, user_Id, request_Method, event_Type, form_Data, target_Url, iframe_Url, button_Text FROM recoder WHERE user_Id = '{user}' ORDER BY record_Time LIMIT 1000;"
+
+    # df = pd.read_sql(sql_cmd, con=engine, index_col="record_Time")
+
+    df = pd.read_sql(sql_cmd, con)
+    df['record_Time'] = pd.to_datetime(df['record_Time'])
+    print(df.head)
+    df.to_json(f"{user}_data.json", orient='records', lines=True, force_ascii=False)
+
+

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
V2/fuli_data.json


+ 25 - 0
V2/tests/locustfile.py

@@ -0,0 +1,25 @@
+#!/usr/bin/python
+# -*- coding=utf-8 -*-
+# @Create Time:		2024-01-24 14:35:32
+# @Last Modified time: 2024-01-24 14:47:32
+from locust import HttpUser, task, between
+
+class MyHttpUser(HttpUser):
+    wait_time = between(1, 2)
+    @task
+    def index_page(self):
+        data = {
+            "record_Time": "2024-01-17T05:14:53.632Z",
+            "current_Url": "http://10.10.21.28/gmp/static/gmpweb/workbench/menu/AppNavExpand.html?appCode=eqpitassets&tSession=1703234778559",
+            "full_Url": "http://domain/path",
+            "user_Id": "zhangchijun@mz.gd.csg.cn",
+            "device_Id": "string",
+            "request_Method": "GET",
+            "event_Type": "click",
+            "form_Data": "{}",
+            "value_Data": "string",
+            "status_Code": 200,
+            "target_Url": "http://10.10.21.28/api/jadp/workbench/todos/todoCountByUserId?_=1703234767322",
+            "button_Text": "申领管理"
+        }
+        self.client.post("http://localhost:7788/record", json=data)

+ 33 - 3
V2/tests/test_api.py

@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding=utf-8 -*-
 # @Create Time:		2024-01-18 15:29:28
-# @Last Modified time: 2024-01-23 15:54:23
+# @Last Modified time: 2024-01-31 11:43:10
 # import re
 # import json
 # import unittest
@@ -275,6 +275,20 @@ from datetime import datetime
 import requests
 
 with open("../fuli_data.json", "r", encoding="utf-8") as fp:
+# with open("../liguiwen@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../houhuiteng@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../lijie1013@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../zengjiyi@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../zengjunhao@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../houyue@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../longruifan@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../wangyongqiang@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../liuhuan0828@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../heweiting@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../ganwenfeng@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../chenweichang0607@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../caiwujiancha1@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
+# with open("../wenyongxian@mz.gd.csg.cn_data.json", "r", encoding="utf-8") as fp:
     num = 0
     for line in fp.readlines():
         json_obj = json.loads(line)
@@ -285,5 +299,21 @@ with open("../fuli_data.json", "r", encoding="utf-8") as fp:
         print(response.text)
         time.sleep(0.2)
         num += 1
-        if num > 40:
-            break
+        if num > 100:
+            break
+
+response = requests.get('http://localhost:7788/screen3')
+# response = requests.get('http://localhost:7788/screen3?user_id=liguiwen@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=houhuiteng@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=lijie1013@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=zengjiyi@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=zengjunhao@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=houyue@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=longruifan@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=wangyongqiang@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=liuhuan0828@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=heweiting@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=ganwenfeng@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=chenweichang0607@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=caiwujiancha1@mz.gd.csg.cn')
+# response = requests.get('http://localhost:7788/screen3?user_id=wenyongxian@mz.gd.csg.cn')

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio