feat(core): 重构主应用启动逻辑并改进WITS数据发送

- 将主应用改为同时启动MQTT订阅入库和WITS数据发送两个服务
- 实现WITS发送器的自动重连机制和连接状态管理
- 添加日志记录到log/app.log和错误日志到log/error.log
- 更新WITS通道映射定义并支持字符串类型的日期时间字段
- 修改数据入库逻辑以支持空值处理和类型转换容错
- 移除命令行子命令模式,改为配置文件驱动的参数设置
- 添加.vscode和log目录到.gitignore忽略列表
This commit is contained in:
2026-03-12 13:32:27 +08:00
parent 6557479a2f
commit 0a123ba210
7 changed files with 314 additions and 159 deletions

View File

@@ -1,6 +1,9 @@
from model.config import AppConfig, MqttConfig, TdengineConfig, TmsConfig, WitsConfig
from model.drilling import DrillingRealtimeData
from model.wits import WITS_FIELD_MAPPING, WitsData
from model.wits import WITS_CHANNEL_MAPPING, WitsData
# Backward-compatible alias for older imports.
WITS_FIELD_MAPPING = WITS_CHANNEL_MAPPING
__all__ = [
"AppConfig",
@@ -8,6 +11,7 @@ __all__ = [
"MqttConfig",
"TdengineConfig",
"TmsConfig",
"WITS_CHANNEL_MAPPING",
"WITS_FIELD_MAPPING",
"WitsConfig",
"WitsData",

View File

@@ -8,8 +8,8 @@ class WitsData:
stknum: int
recid: int
seqid: int
actual_date: float
actual_time: float
actual_date: str
actual_time: str
actual_ts: int
actcod: int
actod_label: str
@@ -53,50 +53,40 @@ class WitsData:
space5: float
WITS_FIELD_MAPPING = [
(1, "wellid", "string"),
(2, "stknum", "int"),
(3, "recid", "int"),
(4, "seqid", "int"),
(5, "actual_date", "float"),
(6, "actual_time", "float"),
(7, "actcod", "int"),
(8, "deptbitm", "float"),
(9, "deptbitv", "float"),
(10, "deptmeas", "float"),
(11, "deptvert", "float"),
(12, "blkpos", "float"),
(13, "ropa", "float"),
(14, "hkla", "float"),
(15, "hklx", "float"),
(16, "woba", "float"),
(17, "wobx", "float"),
(18, "torqa", "float"),
(19, "torqx", "float"),
(20, "rpma", "int"),
(21, "sppa", "float"),
(22, "chkp", "float"),
(23, "spm1", "int"),
(24, "spm2", "int"),
(25, "spm3", "int"),
(26, "tvolact", "float"),
(27, "tvolcact", "float"),
(28, "mfop", "int"),
(29, "mfoa", "float"),
(30, "mfia", "float"),
(31, "mdoa", "float"),
(32, "mdia", "float"),
(33, "mtoa", "float"),
(34, "mtia", "float"),
(35, "mcoa", "float"),
(36, "mcia", "float"),
(37, "stkc", "int"),
(38, "lagstks", "int"),
(39, "deptretm", "float"),
(40, "gasa", "float"),
(41, "space1", "float"),
(42, "space2", "float"),
(43, "space3", "float"),
(44, "space4", "float"),
(45, "space5", "float"),
WITS_CHANNEL_MAPPING = [
("0101", "wellid", "string"),
("0102", "stknum", "int"),
("0103", "recid", "int"),
("0104", "seqid", "int"),
("0105", "actual_date", "string"),
("0106", "actual_time", "string"),
("0107", "actcod", "int"),
("0108", "deptbitm", "float6"),
("0109", "deptbitv", "float6"),
("0110", "deptmeas", "float6"),
("0111", "deptvert", "float6"),
("0112", "blkpos", "float6"),
("0113", "ropa", "float6"),
("0114", "hkla", "float6"),
("0116", "woba", "float6"),
("0117", "wobx", "float6"),
("0118", "torqa", "float6"),
("0119", "torqx", "float6"),
("0120", "rpma", "int"),
("0121", "sppa", "float6"),
("0123", "spm1", "int"),
("0124", "spm2", "int"),
("0125", "spm3", "int"),
("0126", "tvolact", "float6"),
("0127", "tvolcact", "float6"),
("0128", "mfop", "int"),
("0130", "mfoa", "float6"),
("0131", "mfia", "float6"),
("0132", "mdoa", "float6"),
("0133", "mdia", "float6"),
("0134", "mtoa", "float6"),
("0135", "mtia", "float6"),
("0136", "mcoa", "float6"),
("0137", "stkc", "int"),
("0139", "deptretm", "float6"),
]