add:初始化工程
This commit is contained in:
52
utilities/960010-960011.xml
Normal file
52
utilities/960010-960011.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="GBK"?>
|
||||
<!--ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-->
|
||||
<TEST_PACK>
|
||||
<Test>
|
||||
<sub block="1" livetime="5000" pri="8" pack_ver="32" id="960001" interface_flag="" note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬">
|
||||
<route system="" sub_system="" branch="" esb_name="" esb_no="0" neighbor="" plugin=""/>
|
||||
<inparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬"/>
|
||||
<outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬"/>
|
||||
<err_outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬">
|
||||
<out name="error_no" value="" type="I"/>
|
||||
<out name="error_info" value="" type="S" width="1000"/>
|
||||
<out name="error_pathinfo" value="" type="S" width="500"/>
|
||||
</err_outparams>
|
||||
</sub>
|
||||
<sub block="1" livetime="5000" pri="8" pack_ver="32" id="960002" interface_flag="" note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬">
|
||||
<route system="" sub_system="" branch="" esb_name="" esb_no="0" neighbor="" plugin=""/>
|
||||
<inparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬">
|
||||
<in name="function_no" value="" type="I"/>
|
||||
<in name="exchange_type" value="" type="S" width="4"/>
|
||||
</inparams>
|
||||
<outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬"/>
|
||||
<err_outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>ί<EFBFBD><CEAF>״̬">
|
||||
<out name="error_no" value="" type="I"/>
|
||||
<out name="error_info" value="" type="S" width="1000"/>
|
||||
<out name="error_pathinfo" value="" type="S" width="500"/>
|
||||
</err_outparams>
|
||||
</sub>
|
||||
<sub block="1" livetime="5000" pri="8" pack_ver="32" id="960003" interface_flag="" note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڴ潻<DAB4>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ȡ">
|
||||
<route system="" sub_system="" branch="" esb_name="" esb_no="0" neighbor="" plugin=""/>
|
||||
<inparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڴ潻<DAB4>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ȡ"/>
|
||||
<outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڴ潻<DAB4>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ȡ"/>
|
||||
<err_outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڴ潻<DAB4>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ȡ">
|
||||
<out name="error_no" value="" type="I"/>
|
||||
<out name="error_info" value="" type="S" width="1000"/>
|
||||
<out name="error_pathinfo" value="" type="S" width="500"/>
|
||||
</err_outparams>
|
||||
</sub>
|
||||
<sub block="1" livetime="5000" pri="8" pack_ver="32" id="960004" interface_flag="" note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڵ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>">
|
||||
<route system="" sub_system="" branch="" esb_name="" esb_no="0" neighbor="" plugin=""/>
|
||||
<inparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڵ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>">
|
||||
<in name="partition_no" value="" type="I"/>
|
||||
<in name="umt_node_status" value="" type="I"/>
|
||||
</inparams>
|
||||
<outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڵ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>"/>
|
||||
<err_outparams note="LS_ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ڵ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>">
|
||||
<out name="error_no" value="" type="I"/>
|
||||
<out name="error_info" value="" type="S" width="1000"/>
|
||||
<out name="error_pathinfo" value="" type="S" width="500"/>
|
||||
</err_outparams>
|
||||
</sub>
|
||||
</Test>
|
||||
</TEST_PACK>
|
||||
20
utilities/970016.xml
Normal file
20
utilities/970016.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="GBK"?>
|
||||
<TEST_PACK>
|
||||
<Test>
|
||||
<sub block="1" livetime="5000" pri="8" pack_ver="32" id="970016" interface_flag="" note="LS_֤ȯ<D6A4><C8AF><EFBFBD><EFBFBD>_<EFBFBD>Ϻ<EFBFBD>LOFҵ<46><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>">
|
||||
<route system="" sub_system="" branch="" esb_name="" esb_no="0" neighbor="" plugin="" />
|
||||
<inparams note="LS_֤ȯ<D6A4><C8AF><EFBFBD><EFBFBD>_<EFBFBD>Ϻ<EFBFBD>LOFҵ<46><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>">
|
||||
<in name="main_stockcode" value="508000" type="S" width="8" />
|
||||
<in name="lof_type" value="3" type="C" />
|
||||
<in name="en_business_status" value="1000001 " type="S" width="32" />
|
||||
<in name="business_data" value="[]" type="R" />
|
||||
</inparams>
|
||||
<outparams note="LS_֤ȯ<D6A4><C8AF><EFBFBD><EFBFBD>_<EFBFBD>Ϻ<EFBFBD>LOFҵ<46><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" />
|
||||
<err_outparams note="LS_֤ȯ<D6A4><C8AF><EFBFBD><EFBFBD>_<EFBFBD>Ϻ<EFBFBD>LOFҵ<46><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>">
|
||||
<out name="error_no" value="" type="I" />
|
||||
<out name="error_info" value="" type="S" width="1000" />
|
||||
<out name="error_pathinfo" value="" type="S" width="500" />
|
||||
</err_outparams>
|
||||
</sub>
|
||||
</Test>
|
||||
</TEST_PACK>
|
||||
1223
utilities/AAA根据日志生成测试用例-970001-0422-买卖单位.xml
Normal file
1223
utilities/AAA根据日志生成测试用例-970001-0422-买卖单位.xml
Normal file
File diff suppressed because it is too large
Load Diff
0
utilities/__init__.py
Normal file
0
utilities/__init__.py
Normal file
96
utilities/cest_xml.py
Normal file
96
utilities/cest_xml.py
Normal file
@@ -0,0 +1,96 @@
|
||||
# @time :2025/9/3 20:49
|
||||
# @File :cest_xml.py
|
||||
# Description :
|
||||
# Author :drygrass
|
||||
from flask import Flask, request, jsonify
|
||||
from flask_cors import CORS
|
||||
import xml.etree.ElementTree as ET
|
||||
from io import StringIO
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
|
||||
@app.route('/api/parse-xml', methods=['POST'])
|
||||
def parse_xml():
|
||||
"""
|
||||
解析上传的XML数据,动态提取<inparams>下所有<in>元素的属性
|
||||
"""
|
||||
try:
|
||||
xml_content = request.data.decode('gbk')
|
||||
root = ET.fromstring(xml_content)
|
||||
|
||||
# 核心:使用 findall 查找所有<in>元素,数量未知
|
||||
in_elements = root.findall('.//inparams/in')
|
||||
in_params = []
|
||||
|
||||
# 遍历所有找到的<in>元素
|
||||
for in_element in in_elements:
|
||||
name = in_element.get('name')
|
||||
value = in_element.get('value')
|
||||
param_type = in_element.get('type')
|
||||
width = in_element.get('width', '')
|
||||
|
||||
in_params.append({
|
||||
'name': name,
|
||||
'value': value,
|
||||
'type': param_type,
|
||||
'width': width
|
||||
})
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'data': in_params, # 这是一个包含所有<in>元素信息的列表
|
||||
'originalXml': xml_content
|
||||
})
|
||||
|
||||
except ET.ParseError as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'XML解析失败: {str(e)}。请检查XML格式是否正确,如标签是否闭合、特殊字符是否转义等[1,2](@ref)。'
|
||||
}), 400
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'服务器错误: {str(e)}'
|
||||
}), 500
|
||||
|
||||
|
||||
@app.route('/api/save-xml', methods=['POST'])
|
||||
def save_xml():
|
||||
"""
|
||||
保存修改后的参数值到XML并返回完整XML内容
|
||||
"""
|
||||
try:
|
||||
data = request.json
|
||||
original_xml = data['originalXml']
|
||||
modified_params = data['modifiedParams']
|
||||
|
||||
root = ET.fromstring(original_xml)
|
||||
in_elements = root.findall('.//inparams/in')
|
||||
|
||||
# 根据name属性匹配并更新value
|
||||
for in_element in in_elements:
|
||||
name = in_element.get('name')
|
||||
for modified_param in modified_params:
|
||||
if modified_param['name'] == name:
|
||||
in_element.set('value', modified_param['value'])
|
||||
break # 找到并更新后跳出内层循环
|
||||
|
||||
modified_xml = ET.tostring(root, encoding='gbk').decode('gbk')
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'modifiedXml': modified_xml,
|
||||
'message': '保存成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'保存失败: {str(e)}'
|
||||
}), 500
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=5000)
|
||||
1
utilities/last_ip.txt
Normal file
1
utilities/last_ip.txt
Normal file
@@ -0,0 +1 @@
|
||||
172.24.65.138
|
||||
181
utilities/pushVueIp.py
Normal file
181
utilities/pushVueIp.py
Normal file
@@ -0,0 +1,181 @@
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
from retrying import retry
|
||||
import ctypes
|
||||
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0) # 强制隐藏
|
||||
|
||||
class IPMonitor:
|
||||
"""
|
||||
IP监控与推送服务
|
||||
功能:
|
||||
1. 自动检测hundsun.com局域网的IP变化
|
||||
2. IP变化时自动推送到指定服务器
|
||||
3. 支持失败重试和超时设置
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
server_url="http://10.20.163.101:5535/ldp?Pretty=1&PluginName=ldp_db_listen_plugin&FuncName=SetVueConfig",
|
||||
fixed_port="5173",
|
||||
ip_storage_file="last_ip.txt",
|
||||
request_timeout=5
|
||||
):
|
||||
"""
|
||||
初始化监控器
|
||||
:param server_url: 推送目标URL
|
||||
:param fixed_port: 固定端口号
|
||||
:param ip_storage_file: IP存储文件路径
|
||||
:param request_timeout: 请求超时时间(秒)
|
||||
"""
|
||||
self.server_url = server_url
|
||||
self.fixed_port = fixed_port
|
||||
self.ip_storage_file = ip_storage_file
|
||||
self.request_timeout = request_timeout
|
||||
|
||||
def get_hundsun_ip(self):
|
||||
"""获取hundsun.com局域网的当前IP"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['ipconfig', '/all'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
# pattern = r'hundsun\.com.*?IPv4 地址[^\d]*(\d+\.\d+\.\d+\.\d+)'
|
||||
# 修改后的正确模式(匹配127.24开头的IP)
|
||||
pattern = r'hundsun\.com.*?IPv4 地址[^\d]*(172\.24\.\d+\.\d+)'
|
||||
match = re.search(pattern, result.stdout, re.DOTALL)
|
||||
return match.group(1) if match else None
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 获取IP失败: {e}")
|
||||
return None
|
||||
|
||||
def get_handsome_ip(self):
|
||||
"""获取hs.handsome.com.cn局域网的当前IP"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['ipconfig', '/all'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
# 修改模式以匹配hs.handsome.com.cn后缀和IPv4地址
|
||||
pattern = r'hs\.handsome\.com\.cn.*?IPv4 地址[^\d]*(10\.\d+\.\d+\.\d+)'
|
||||
match = re.search(pattern, result.stdout, re.DOTALL)
|
||||
return match.group(1) if match else None
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 获取IP失败: {e}")
|
||||
return None
|
||||
|
||||
@retry(stop_max_attempt_number=3, wait_fixed=2000)
|
||||
def _send_ip(self, ip_address):
|
||||
"""内部方法:发送IP到服务器(自动重试)"""
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
data = {
|
||||
"Request": {
|
||||
"vueHost": ip_address,
|
||||
"vuePort": self.fixed_port
|
||||
}
|
||||
}
|
||||
try:
|
||||
response = requests.post(
|
||||
self.server_url,
|
||||
headers=headers,
|
||||
data=json.dumps(data),
|
||||
timeout=self.request_timeout
|
||||
)
|
||||
if not response.ok:
|
||||
raise Exception(f"服务器返回 {response.status_code}: {response.text}")
|
||||
return True
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise Exception(f"网络请求失败: {e}")
|
||||
|
||||
def push_current_ip(self):
|
||||
"""
|
||||
强制推送当前IP到服务器
|
||||
:return: (success, ip) 元组
|
||||
"""
|
||||
current_ip = self.get_hundsun_ip()
|
||||
if not current_ip:
|
||||
return (False, None)
|
||||
|
||||
try:
|
||||
if self._send_ip(current_ip):
|
||||
self._save_ip(current_ip)
|
||||
return (True, current_ip)
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 推送失败: {e}")
|
||||
pass
|
||||
return (False, current_ip)
|
||||
|
||||
def check_and_push(self):
|
||||
"""
|
||||
检查IP变化并自动推送
|
||||
:return: (changed, success, ip) 元组
|
||||
"""
|
||||
current_ip = self.get_hundsun_ip()
|
||||
if current_ip == None:
|
||||
current_ip = self.get_handsome_ip()
|
||||
last_ip = self._load_ip()
|
||||
|
||||
if not current_ip:
|
||||
return (False, False, None)
|
||||
|
||||
if current_ip != last_ip:
|
||||
try:
|
||||
if self._send_ip(current_ip):
|
||||
self._save_ip(current_ip)
|
||||
return (True, True, current_ip)
|
||||
return (True, False, current_ip)
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 推送失败: {e}")
|
||||
return (True, False, current_ip)
|
||||
return (False, True, current_ip)
|
||||
|
||||
def _save_ip(self, ip):
|
||||
"""内部方法:保存IP到文件"""
|
||||
try:
|
||||
with open(self.ip_storage_file, 'w') as f:
|
||||
f.write(ip)
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 保存IP失败: {e}")
|
||||
pass
|
||||
|
||||
def _load_ip(self):
|
||||
"""内部方法:从文件加载IP"""
|
||||
if not os.path.exists(self.ip_storage_file):
|
||||
return None
|
||||
try:
|
||||
with open(self.ip_storage_file, 'r') as f:
|
||||
return f.read().strip()
|
||||
except Exception as e:
|
||||
# print(f"[IPMonitor] 读取IP失败: {e}")
|
||||
return None
|
||||
|
||||
|
||||
# 示例使用方式
|
||||
if __name__ == "__main__":
|
||||
# 初始化监控器(可自定义参数)
|
||||
monitor = IPMonitor()
|
||||
|
||||
# 示例1:单次检查并推送
|
||||
# changed, success, ip = monitor.check_and_push()
|
||||
# print(f"\n检查结果: 变化={changed}, 成功={success}, IP={ip}")
|
||||
|
||||
# 示例2:强制推送当前IP
|
||||
# success, ip = monitor.push_current_ip()
|
||||
# print(f"强制推送结果: 成功={success}, IP={ip}")
|
||||
|
||||
# 示例3:定时任务集成
|
||||
import schedule
|
||||
def job():
|
||||
monitor.check_and_push()
|
||||
schedule.every(5).minutes.do(job)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
Reference in New Issue
Block a user