Compare commits
7 Commits
077da8878d
...
6dad8a1db5
| Author | SHA1 | Date | |
|---|---|---|---|
| 6dad8a1db5 | |||
| e76bb3db60 | |||
| 66966dbc88 | |||
| c7b51476d3 | |||
| 17331c770a | |||
| 62f1f9d000 | |||
| f1233fe3f5 |
48
init/data.json
Normal file
48
init/data.json
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"appcodes": [
|
||||||
|
{
|
||||||
|
"parentid": "pricing_type",
|
||||||
|
"parentname": "计费类型",
|
||||||
|
"items": [
|
||||||
|
{"k": "per_call", "v": "按次计费"},
|
||||||
|
{"k": "per_token", "v": "按Token计费"},
|
||||||
|
{"k": "subscription", "v": "订阅制"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "pricing_status",
|
||||||
|
"parentname": "定价状态",
|
||||||
|
"items": [
|
||||||
|
{"k": "active", "v": "生效中"},
|
||||||
|
{"k": "expired", "v": "已过期"},
|
||||||
|
{"k": "pending", "v": "待生效"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "capacity_status",
|
||||||
|
"parentname": "供应量状态",
|
||||||
|
"items": [
|
||||||
|
{"k": "active", "v": "正常"},
|
||||||
|
{"k": "paused", "v": "已暂停"},
|
||||||
|
{"k": "exhausted", "v": "已耗尽"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "usage_status",
|
||||||
|
"parentname": "使用状态",
|
||||||
|
"items": [
|
||||||
|
{"k": "success", "v": "成功"},
|
||||||
|
{"k": "failed", "v": "失败"},
|
||||||
|
{"k": "timeout", "v": "超时"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "currency",
|
||||||
|
"parentname": "货币类型",
|
||||||
|
"items": [
|
||||||
|
{"k": "CNY", "v": "人民币"},
|
||||||
|
{"k": "USD", "v": "美元"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
32
json/pipeline_capacity.json
Normal file
32
json/pipeline_capacity.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"tblname": "pipeline_capacity",
|
||||||
|
"title": "产线容量管理",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["pipeline_id"],
|
||||||
|
"logined_userorgid": "org_id",
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": ["id"],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [{"value": "active", "text": "生效中"}, {"value": "disabled", "text": "已停用"}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/pipeline_capacity_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/pipeline_capacity_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/pipeline_capacity_delete.dspy')}}"
|
||||||
|
},
|
||||||
|
"data_filter": {
|
||||||
|
"AND": [
|
||||||
|
{"field": "pipeline_id", "op": "=", "var": "filter_pipeline_id"},
|
||||||
|
{"field": "status", "op": "=", "var": "filter_status"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
json/pipeline_pricing.json
Normal file
36
json/pipeline_pricing.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"tblname": "pipeline_pricing",
|
||||||
|
"title": "产线定价管理",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["effective_date desc"],
|
||||||
|
"logined_userorgid": "org_id",
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": ["id"],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"pricing_type": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [{"value": "per_call", "text": "按次计费"}, {"value": "per_token", "text": "按token计费"}, {"value": "subscription", "text": "订阅制"}]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [{"value": "active", "text": "生效中"}, {"value": "expired", "text": "已过期"}, {"value": "disabled", "text": "已停用"}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/pipeline_pricing_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/pipeline_pricing_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/pipeline_pricing_delete.dspy')}}"
|
||||||
|
},
|
||||||
|
"data_filter": {
|
||||||
|
"AND": [
|
||||||
|
{"field": "pipeline_id", "op": "=", "var": "filter_pipeline_id"},
|
||||||
|
{"field": "status", "op": "=", "var": "filter_status"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
json/pipeline_usage_log.json
Normal file
35
json/pipeline_usage_log.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"tblname": "pipeline_usage_log",
|
||||||
|
"title": "产线调用日志",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["called_at desc"],
|
||||||
|
"logined_userorgid": "",
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": ["id"],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [{"value": "success", "text": "成功"}, {"value": "failed", "text": "失败"}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editexclouded": ["id", "pipeline_id", "user_id", "distributor_id", "call_count", "token_input", "token_output", "amount", "status", "error_message", "called_at"],
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "",
|
||||||
|
"update_data_url": "",
|
||||||
|
"delete_data_url": ""
|
||||||
|
},
|
||||||
|
"data_filter": {
|
||||||
|
"AND": [
|
||||||
|
{"field": "pipeline_id", "op": "=", "var": "filter_pipeline_id"},
|
||||||
|
{"field": "called_at", "op": ">=", "var": "filter_called_at_start"},
|
||||||
|
{"field": "called_at", "op": "<=", "var": "filter_called_at_end"},
|
||||||
|
{"field": "status", "op": "=", "var": "filter_status"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
95
models/pipeline_capacity.json
Normal file
95
models/pipeline_capacity.json
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "pipeline_capacity",
|
||||||
|
"title": "产线容量表",
|
||||||
|
"primary": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "max_concurrent",
|
||||||
|
"title": "最大并发数",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "daily_limit",
|
||||||
|
"title": "每日限额",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "monthly_limit",
|
||||||
|
"title": "每月限额",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "today_usage",
|
||||||
|
"title": "今日用量",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "month_usage",
|
||||||
|
"title": "本月用量",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "uk_capacity_pipeline",
|
||||||
|
"idxtype": "unique",
|
||||||
|
"idxfields": [
|
||||||
|
"pipeline_id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"table": "pipelines",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='capacity_status'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
141
models/pipeline_pricing.json
Normal file
141
models/pipeline_pricing.json
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "pipeline_pricing",
|
||||||
|
"title": "产线定价表",
|
||||||
|
"primary": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_type",
|
||||||
|
"title": "计费方式",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "currency",
|
||||||
|
"title": "货币",
|
||||||
|
"type": "str",
|
||||||
|
"length": 10,
|
||||||
|
"default": "CNY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_config",
|
||||||
|
"title": "定价配置JSON",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "effective_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "expiry_date",
|
||||||
|
"title": "失效日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "idx_pricing_pipeline",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": [
|
||||||
|
"pipeline_id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_pricing_status_date",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": [
|
||||||
|
"status",
|
||||||
|
"effective_date"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"table": "pipelines",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "pricing_type",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='pricing_type'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "currency",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='currency'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='pricing_status'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
119
models/pipeline_usage_log.json
Normal file
119
models/pipeline_usage_log.json
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "pipeline_usage_log",
|
||||||
|
"title": "产线调用日志表",
|
||||||
|
"primary": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "user_id",
|
||||||
|
"title": "用户ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distributor_id",
|
||||||
|
"title": "分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "call_count",
|
||||||
|
"title": "调用次数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_input",
|
||||||
|
"title": "输入Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_output",
|
||||||
|
"title": "输出Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "amount",
|
||||||
|
"title": "金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "error_message",
|
||||||
|
"title": "错误信息",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "called_at",
|
||||||
|
"title": "调用时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "idx_usagelog_pipeline",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": [
|
||||||
|
"pipeline_id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_usagelog_called_at",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": [
|
||||||
|
"called_at"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_usagelog_distributor",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": [
|
||||||
|
"distributor_id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"table": "pipelines",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='usage_status'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
116
mysql.ddl.sql
Normal file
116
mysql.ddl.sql
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
|
||||||
|
-- models/pipeline_capacity.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists pipeline_capacity;
|
||||||
|
CREATE TABLE pipeline_capacity
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键',
|
||||||
|
`pipeline_id` VARCHAR(32) NOT NULL comment '产线ID',
|
||||||
|
`max_concurrent` int comment '最大并发数',
|
||||||
|
`daily_limit` int comment '每日限额',
|
||||||
|
`monthly_limit` int comment '每月限额',
|
||||||
|
`today_usage` int comment '今日用量',
|
||||||
|
`month_usage` int comment '本月用量',
|
||||||
|
`status` VARCHAR(20) DEFAULT 'active' comment '状态',
|
||||||
|
`org_id` VARCHAR(32) DEFAULT '0' comment '所属组织',
|
||||||
|
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '产线容量表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX pipeline_capacity_uk_capacity_pipeline ON pipeline_capacity(pipeline_id);
|
||||||
|
|
||||||
|
-- models/pipeline_pricing.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists pipeline_pricing;
|
||||||
|
CREATE TABLE pipeline_pricing
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键',
|
||||||
|
`pipeline_id` VARCHAR(32) NOT NULL comment '产线ID',
|
||||||
|
`pricing_type` VARCHAR(20) NOT NULL comment '计费方式',
|
||||||
|
`unit_price` double(15,4) NOT NULL DEFAULT '0' comment '单价',
|
||||||
|
`currency` VARCHAR(10) DEFAULT 'CNY' comment '货币',
|
||||||
|
`pricing_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '定价配置JSON',
|
||||||
|
`effective_date` date comment '生效日期',
|
||||||
|
`expiry_date` date comment '失效日期',
|
||||||
|
`status` VARCHAR(20) DEFAULT 'active' comment '状态',
|
||||||
|
`org_id` VARCHAR(32) DEFAULT '0' comment '所属组织',
|
||||||
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||||
|
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '产线定价表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX pipeline_pricing_idx_pricing_pipeline ON pipeline_pricing(pipeline_id);
|
||||||
|
CREATE INDEX pipeline_pricing_idx_pricing_status_date ON pipeline_pricing(status,effective_date);
|
||||||
|
|
||||||
|
-- models/pipeline_usage_log.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists pipeline_usage_log;
|
||||||
|
CREATE TABLE pipeline_usage_log
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键',
|
||||||
|
`pipeline_id` VARCHAR(32) NOT NULL comment '产线ID',
|
||||||
|
`user_id` VARCHAR(32) comment '用户ID',
|
||||||
|
`distributor_id` VARCHAR(32) comment '分销商ID',
|
||||||
|
`call_count` int DEFAULT '1' comment '调用次数',
|
||||||
|
`token_input` int DEFAULT '0' comment '输入Token数',
|
||||||
|
`token_output` int DEFAULT '0' comment '输出Token数',
|
||||||
|
`amount` double(15,4) DEFAULT '0' comment '金额',
|
||||||
|
`status` VARCHAR(20) comment '状态',
|
||||||
|
`error_message` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '错误信息',
|
||||||
|
`called_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '调用时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '产线调用日志表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX pipeline_usage_log_idx_usagelog_pipeline ON pipeline_usage_log(pipeline_id);
|
||||||
|
CREATE INDEX pipeline_usage_log_idx_usagelog_called_at ON pipeline_usage_log(called_at);
|
||||||
|
CREATE INDEX pipeline_usage_log_idx_usagelog_distributor ON pipeline_usage_log(distributor_id);
|
||||||
|
|
||||||
13
pipeline_ops/__init__.py
Normal file
13
pipeline_ops/__init__.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from .init import (
|
||||||
|
create_pipeline_pricing,
|
||||||
|
update_pipeline_pricing,
|
||||||
|
delete_pipeline_pricing,
|
||||||
|
create_pipeline_capacity,
|
||||||
|
update_pipeline_capacity,
|
||||||
|
delete_pipeline_capacity,
|
||||||
|
create_pipeline_usage_log,
|
||||||
|
update_pipeline_usage_log,
|
||||||
|
delete_pipeline_usage_log,
|
||||||
|
increment_usage,
|
||||||
|
load_pipeline_ops,
|
||||||
|
)
|
||||||
213
pipeline_ops/init.py
Normal file
213
pipeline_ops/init.py
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
import json
|
||||||
|
from appPublic.uniqueID import getID
|
||||||
|
from sqlor.dbpools import DBPools
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
from appPublic.log import debug
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
MODULE_NAME = 'pipeline_ops'
|
||||||
|
DBNAME = 'pipeline'
|
||||||
|
|
||||||
|
|
||||||
|
def _get_sor():
|
||||||
|
return DBPools(), DBNAME
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== pipeline_pricing ====================
|
||||||
|
|
||||||
|
async def create_pipeline_pricing(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['id'] = getID()
|
||||||
|
data['created_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.C('pipeline_pricing', data)
|
||||||
|
return json.dumps({'status': 'ok', 'data': data, 'message': '创建成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def update_pipeline_pricing(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.U('pipeline_pricing', data)
|
||||||
|
return json.dumps({'status': 'ok', 'message': '更新成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_pipeline_pricing(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
await sor.D('pipeline_pricing', {'id': params_kw['id']})
|
||||||
|
return json.dumps({'status': 'ok', 'message': '删除成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== pipeline_capacity ====================
|
||||||
|
|
||||||
|
async def create_pipeline_capacity(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['id'] = getID()
|
||||||
|
data['created_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.C('pipeline_capacity', data)
|
||||||
|
return json.dumps({'status': 'ok', 'data': data, 'message': '创建成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def update_pipeline_capacity(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.U('pipeline_capacity', data)
|
||||||
|
return json.dumps({'status': 'ok', 'message': '更新成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_pipeline_capacity(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
await sor.D('pipeline_capacity', {'id': params_kw['id']})
|
||||||
|
return json.dumps({'status': 'ok', 'message': '删除成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== pipeline_usage_log ====================
|
||||||
|
|
||||||
|
async def create_pipeline_usage_log(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['id'] = getID()
|
||||||
|
data['created_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.C('pipeline_usage_log', data)
|
||||||
|
return json.dumps({'status': 'ok', 'data': data, 'message': '创建成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def update_pipeline_usage_log(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
data = params_kw.copy()
|
||||||
|
data.pop('page', None)
|
||||||
|
data.pop('rows', None)
|
||||||
|
data.pop('data_filter', None)
|
||||||
|
data['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
await sor.U('pipeline_usage_log', data)
|
||||||
|
return json.dumps({'status': 'ok', 'message': '更新成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_pipeline_usage_log(params_kw):
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
await sor.D('pipeline_usage_log', {'id': params_kw['id']})
|
||||||
|
return json.dumps({'status': 'ok', 'message': '删除成功'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== Special: increment_usage ====================
|
||||||
|
|
||||||
|
async def increment_usage(params_kw):
|
||||||
|
"""Increment usage for a pipeline. Increments the usage_count field."""
|
||||||
|
try:
|
||||||
|
db, dbname = _get_sor()
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
pipeline_id = params_kw.get('pipeline_id', '')
|
||||||
|
if not pipeline_id:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'pipeline_id is required'})
|
||||||
|
# Get current usage
|
||||||
|
rows = await sor.sqlExe(
|
||||||
|
'select usage_count from pipeline_usage_log where pipeline_id = :pipeline_id order by created_at desc limit 1',
|
||||||
|
{'pipeline_id': pipeline_id}
|
||||||
|
)
|
||||||
|
current_count = 0
|
||||||
|
if rows and len(rows) > 0:
|
||||||
|
current_count = rows[0].get('usage_count', 0) or 0
|
||||||
|
new_count = current_count + 1
|
||||||
|
data = {
|
||||||
|
'id': getID(),
|
||||||
|
'pipeline_id': pipeline_id,
|
||||||
|
'usage_count': new_count,
|
||||||
|
'created_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
'updated_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
}
|
||||||
|
await sor.C('pipeline_usage_log', data)
|
||||||
|
return json.dumps({'status': 'ok', 'data': data, 'message': '使用次数已增加'})
|
||||||
|
except Exception as e:
|
||||||
|
return json.dumps({'status': 'error', 'message': str(e)})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== Module Loader ====================
|
||||||
|
|
||||||
|
def load_pipeline_ops():
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
# pipeline_pricing
|
||||||
|
env.create_pipeline_pricing = create_pipeline_pricing
|
||||||
|
env.create_pipeline_pricings = create_pipeline_pricing
|
||||||
|
env.update_pipeline_pricing = update_pipeline_pricing
|
||||||
|
env.update_pipeline_pricings = update_pipeline_pricing
|
||||||
|
env.delete_pipeline_pricing = delete_pipeline_pricing
|
||||||
|
env.delete_pipeline_pricings = delete_pipeline_pricing
|
||||||
|
|
||||||
|
# pipeline_capacity
|
||||||
|
env.create_pipeline_capacity = create_pipeline_capacity
|
||||||
|
env.create_pipeline_capacitys = create_pipeline_capacity
|
||||||
|
env.update_pipeline_capacity = update_pipeline_capacity
|
||||||
|
env.update_pipeline_capacitys = update_pipeline_capacity
|
||||||
|
env.delete_pipeline_capacity = delete_pipeline_capacity
|
||||||
|
env.delete_pipeline_capacitys = delete_pipeline_capacity
|
||||||
|
|
||||||
|
# pipeline_usage_log
|
||||||
|
env.create_pipeline_usage_log = create_pipeline_usage_log
|
||||||
|
env.create_pipeline_usage_logs = create_pipeline_usage_log
|
||||||
|
env.update_pipeline_usage_log = update_pipeline_usage_log
|
||||||
|
env.update_pipeline_usage_logs = update_pipeline_usage_log
|
||||||
|
env.delete_pipeline_usage_log = delete_pipeline_usage_log
|
||||||
|
env.delete_pipeline_usage_logs = delete_pipeline_usage_log
|
||||||
|
|
||||||
|
# special functions
|
||||||
|
env.increment_usage = increment_usage
|
||||||
|
|
||||||
|
debug(f'{MODULE_NAME} loaded successfully')
|
||||||
|
return True
|
||||||
9
pyproject.toml
Normal file
9
pyproject.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[project]
|
||||||
|
name = "pipeline_ops"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "产线运维模块"
|
||||||
|
dependencies = ["sqlor"]
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
where = ["."]
|
||||||
|
include = ["pipeline_ops*"]
|
||||||
62
scripts/load_path.py
Normal file
62
scripts/load_path.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""RBAC path registration for pipeline_ops module."""
|
||||||
|
import os, sys, subprocess
|
||||||
|
|
||||||
|
MOD = "pipeline_ops"
|
||||||
|
|
||||||
|
PATHS_ANY = [
|
||||||
|
f"/{MOD}/index.ui",
|
||||||
|
]
|
||||||
|
|
||||||
|
PATHS_LOGINED = [
|
||||||
|
f"/{MOD}",
|
||||||
|
f"/{MOD}/api/ops_dashboard_data.dspy",
|
||||||
|
# Pricing
|
||||||
|
f"/{MOD}/pipeline_pricing/index.ui",
|
||||||
|
f"/{MOD}/pipeline_pricing/get_pipeline_pricing.dspy",
|
||||||
|
f"/{MOD}/pipeline_pricing/add_pipeline_pricing.dspy",
|
||||||
|
f"/{MOD}/pipeline_pricing/update_pipeline_pricing.dspy",
|
||||||
|
f"/{MOD}/pipeline_pricing/delete_pipeline_pricing.dspy",
|
||||||
|
# Capacity
|
||||||
|
f"/{MOD}/pipeline_capacity/index.ui",
|
||||||
|
f"/{MOD}/pipeline_capacity/get_pipeline_capacity.dspy",
|
||||||
|
f"/{MOD}/pipeline_capacity/add_pipeline_capacity.dspy",
|
||||||
|
f"/{MOD}/pipeline_capacity/update_pipeline_capacity.dspy",
|
||||||
|
f"/{MOD}/pipeline_capacity/delete_pipeline_capacity.dspy",
|
||||||
|
# Usage Log
|
||||||
|
f"/{MOD}/pipeline_usage_log/index.ui",
|
||||||
|
f"/{MOD}/pipeline_usage_log/get_pipeline_usage_log.dspy",
|
||||||
|
f"/{MOD}/pipeline_usage_log/add_pipeline_usage_log.dspy",
|
||||||
|
f"/{MOD}/pipeline_usage_log/update_pipeline_usage_log.dspy",
|
||||||
|
f"/{MOD}/pipeline_usage_log/delete_pipeline_usage_log.dspy",
|
||||||
|
# API
|
||||||
|
f"/{MOD}/api/pipeline_pricing_create.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_pricing_update.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_pricing_delete.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_capacity_create.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_capacity_update.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_capacity_delete.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_usage_log_create.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_usage_log_update.dspy",
|
||||||
|
f"/{MOD}/api/pipeline_usage_log_delete.dspy",
|
||||||
|
f"/{MOD}/api/get_search_pipeline_id.dspy",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
root = os.path.expanduser("~/pipeline")
|
||||||
|
set_perm = os.path.join(root, "set_role_perm.py")
|
||||||
|
if not os.path.isfile(set_perm):
|
||||||
|
print("ERROR: pipeline root not found"); sys.exit(1)
|
||||||
|
py = sys.executable
|
||||||
|
count = 0
|
||||||
|
for role, paths in [("any", PATHS_ANY), ("logined", PATHS_LOGINED)]:
|
||||||
|
for path in paths:
|
||||||
|
r = subprocess.run([py, set_perm, role, path], capture_output=True, text=True, cwd=root)
|
||||||
|
if r.returncode == 0: count += 1
|
||||||
|
else: print(f" WARN: {path}")
|
||||||
|
print(f"Registered {count}/{len(PATHS_ANY)+len(PATHS_LOGINED)} paths for {MOD}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
8
wwwroot/api/get_search_pipeline_id.dspy
Normal file
8
wwwroot/api/get_search_pipeline_id.dspy
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
data = [{'value': '', 'text': '全部'}]
|
||||||
|
try:
|
||||||
|
async with get_sor_context(request._run_ns, 'pipeline') as sor:
|
||||||
|
rows = await sor.sqlExe('select id as value, name as text from pipelines order by name', {})
|
||||||
|
data.extend(list(rows))
|
||||||
|
except Exception as e:
|
||||||
|
debug('get_search_pipeline_id error: ' + str(e))
|
||||||
|
return json.dumps(data, ensure_ascii=False)
|
||||||
61
wwwroot/api/ops_dashboard_data.dspy
Normal file
61
wwwroot/api/ops_dashboard_data.dspy
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
"""
|
||||||
|
Operations Dashboard Data: task queue, human tasks, stats
|
||||||
|
"""
|
||||||
|
from sqlor.dbpools import DBPools
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
dbname = get_module_dbname('pipeline_core')
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
# Task stats by state
|
||||||
|
task_stats = await sor.sqlExe("""
|
||||||
|
SELECT state, COUNT(*) as cnt FROM pipeline_tasks
|
||||||
|
GROUP BY state ORDER BY cnt DESC
|
||||||
|
""", {})
|
||||||
|
|
||||||
|
stats = {'submitted':0, 'running':0, 'completed':0, 'failed':0, 'cancelled':0}
|
||||||
|
for r in task_stats:
|
||||||
|
stats[r.state] = r.cnt
|
||||||
|
|
||||||
|
# Recent tasks (last 20)
|
||||||
|
tasks = await sor.sqlExe("""
|
||||||
|
SELECT t.id, t.title, t.state, t.pipeline_id, t.created_at
|
||||||
|
FROM pipeline_tasks t
|
||||||
|
ORDER BY t.created_at DESC LIMIT 20
|
||||||
|
""", {})
|
||||||
|
task_list = []
|
||||||
|
for r in tasks:
|
||||||
|
task_list.append({
|
||||||
|
'id': r.id, 'title': r.title, 'state': r.state,
|
||||||
|
'pipeline_id': r.pipeline_id, 'created_at': str(r.created_at)[:19]
|
||||||
|
})
|
||||||
|
|
||||||
|
# Pending human tasks
|
||||||
|
human_tasks = await sor.sqlExe("""
|
||||||
|
SELECT h.id, h.task_id, h.task_type, h.step_name, h.status,
|
||||||
|
h.assignee_role, h.created_at, h.expired_at,
|
||||||
|
t.title as task_title
|
||||||
|
FROM pipeline_human_tasks h
|
||||||
|
LEFT JOIN pipeline_tasks t ON h.task_id = t.id
|
||||||
|
WHERE h.status IN ('pending', 'in_progress')
|
||||||
|
ORDER BY h.created_at DESC LIMIT 20
|
||||||
|
""", {})
|
||||||
|
|
||||||
|
human_list = []
|
||||||
|
for r in human_tasks:
|
||||||
|
human_list.append({
|
||||||
|
'id': r.id, 'task_id': r.task_id, 'task_type': r.task_type,
|
||||||
|
'step_name': r.step_name, 'status': r.status,
|
||||||
|
'assignee_role': r.assignee_role, 'task_title': r.task_title,
|
||||||
|
'created_at': str(r.created_at)[:19],
|
||||||
|
'expired_at': str(r.expired_at)[:19] if r.expired_at else None
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'stats': stats,
|
||||||
|
'tasks': task_list,
|
||||||
|
'human_tasks': human_list,
|
||||||
|
'total_tasks': sum(stats.values()),
|
||||||
|
'active_tasks': stats['running'],
|
||||||
|
'pending_reviews': len(human_list)
|
||||||
|
}
|
||||||
5
wwwroot/api/pipeline_capacity_create.dspy
Normal file
5
wwwroot/api/pipeline_capacity_create.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = create_pipeline_capacity
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_capacity_delete.dspy
Normal file
5
wwwroot/api/pipeline_capacity_delete.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = delete_pipeline_capacity
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_capacity_update.dspy
Normal file
5
wwwroot/api/pipeline_capacity_update.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = update_pipeline_capacity
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_pricing_create.dspy
Normal file
5
wwwroot/api/pipeline_pricing_create.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = create_pipeline_pricing
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_pricing_delete.dspy
Normal file
5
wwwroot/api/pipeline_pricing_delete.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = delete_pipeline_pricing
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_pricing_update.dspy
Normal file
5
wwwroot/api/pipeline_pricing_update.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = update_pipeline_pricing
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_usage_log_create.dspy
Normal file
5
wwwroot/api/pipeline_usage_log_create.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = create_pipeline_usage_log
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_usage_log_delete.dspy
Normal file
5
wwwroot/api/pipeline_usage_log_delete.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = delete_pipeline_usage_log
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
5
wwwroot/api/pipeline_usage_log_update.dspy
Normal file
5
wwwroot/api/pipeline_usage_log_update.dspy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
func = update_pipeline_usage_log
|
||||||
|
if func is None:
|
||||||
|
return json.dumps({'status': 'error', 'message': 'function not found'})
|
||||||
|
result = await func(params_kw)
|
||||||
|
return result
|
||||||
123
wwwroot/index.ui
Normal file
123
wwwroot/index.ui
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"width": "100%", "height": "100%", "padding": "24px", "gap": "20px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{
|
||||||
|
"widgettype": "HBox",
|
||||||
|
"options": {"alignItems": "center", "gap": "12px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title2", "options": {"text": "产线运营中心"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "任务队列、审批管理、执行监控", "cfontsize": 1.1, "color": "#888"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "ResponsableBox",
|
||||||
|
"options": {"gap": "16px", "minWidth": "150px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#60a5fa", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "已提交", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#fbbf24", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "运行中", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#4ade80", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "已完成", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#f87171", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "失败", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#a78bfa", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "待审批", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "4px", "border": "1px solid #334155", "cwidth": 16, "alignItems": "center"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "-", "cfontsize": 2, "color": "#e2e8f0", "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "总任务", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "ResponsableBox",
|
||||||
|
"options": {"gap": "16px", "minWidth": "400px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "12px", "border": "1px solid #334155", "cwidth": 60},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title3", "options": {"text": "近期任务"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "暂无任务,提交产线任务后将在此显示", "cfontsize": 0.9, "color": "#64748b", "padding": "20px 0"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"bgcolor": "#1e293b", "padding": "20px", "borderRadius": "12px", "gap": "12px", "border": "1px solid #334155", "cwidth": 40},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title3", "options": {"text": "待审批队列"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "暂无审批任务", "cfontsize": 0.9, "color": "#64748b", "padding": "20px 0"}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "ResponsableBox",
|
||||||
|
"options": {"gap": "16px", "minWidth": "180px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"css": "card", "cwidth": 23, "cheight": 10, "padding": "24px", "cursor": "pointer", "bgcolor": "#1e293b", "border": "1px solid #334155"},
|
||||||
|
"binds": [{"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "app.main_content", "options": {"url": "{{entire_url('/pipeline_ops/pipeline_pricing/')}}"}, "mode": "replace"}],
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title3", "options": {"text": "定价管理", "marginBottom": "4px"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "管理产线计费方式和价格", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"css": "card", "cwidth": 23, "cheight": 10, "padding": "24px", "cursor": "pointer", "bgcolor": "#1e293b", "border": "1px solid #334155"},
|
||||||
|
"binds": [{"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "app.main_content", "options": {"url": "{{entire_url('/pipeline_ops/pipeline_capacity/')}}"}, "mode": "replace"}],
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title3", "options": {"text": "供应量管理", "marginBottom": "4px"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "配置产线并发和调用限额", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"css": "card", "cwidth": 23, "cheight": 10, "padding": "24px", "cursor": "pointer", "bgcolor": "#1e293b", "border": "1px solid #334155"},
|
||||||
|
"binds": [{"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "app.main_content", "options": {"url": "{{entire_url('/pipeline_ops/pipeline_usage_log/')}}"}, "mode": "replace"}],
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Title3", "options": {"text": "使用记录", "marginBottom": "4px"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "查看产线调用和消费记录", "cfontsize": 0.9, "color": "#94a3b8"}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
51
wwwroot/pipeline_capacity/add_pipeline_capacity.dspy
Normal file
51
wwwroot/pipeline_capacity/add_pipeline_capacity.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('pipeline_capacity', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/pipeline_capacity/delete_pipeline_capacity.dspy
Normal file
47
wwwroot/pipeline_capacity/delete_pipeline_capacity.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('pipeline_capacity', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
142
wwwroot/pipeline_capacity/get_pipeline_capacity.dspy
Normal file
142
wwwroot/pipeline_capacity/get_pipeline_capacity.dspy
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_pipeline_capacity.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["pipeline_id"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.pipeline_id_text, c.status_text
|
||||||
|
from (select * from pipeline_capacity where 1=1 [[filterstr]]) a left join (select id as pipeline_id,
|
||||||
|
name as pipeline_id_text from pipelines where 1 = 1) b on a.pipeline_id = b.pipeline_id left join (select k as status,
|
||||||
|
v as status_text from appcodes_kv where parentid='capacity_status') c on a.status = c.status'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
if filterjson and isinstance(filterjson, str):
|
||||||
|
try:
|
||||||
|
filterjson = json.loads(filterjson)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
filterjson = None
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "max_concurrent",
|
||||||
|
"title": "最大并发数",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "daily_limit",
|
||||||
|
"title": "每日限额",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "monthly_limit",
|
||||||
|
"title": "每月限额",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "today_usage",
|
||||||
|
"title": "今日用量",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "month_usage",
|
||||||
|
"title": "本月用量",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
|
||||||
|
# 确保 logined 过滤条件始终生效
|
||||||
|
if filterjson:
|
||||||
|
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
|
||||||
|
filterjson = {'AND': [filterjson] if filterjson else []}
|
||||||
|
|
||||||
|
filterjson['AND'].append({'field': 'org_id', 'op': '=', 'var': '__logined_orgid__'})
|
||||||
|
ns['__logined_orgid__'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
filterdic = ns.copy()
|
||||||
|
filterdic['filterstr'] = ''
|
||||||
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
filterdic['userid'] = '${userid}$'
|
||||||
|
if filterjson:
|
||||||
|
dbf = DBFilter(filterjson)
|
||||||
|
conds = dbf.gen(ns)
|
||||||
|
if conds:
|
||||||
|
ns.update(dbf.consts)
|
||||||
|
conds = f' and {conds}'
|
||||||
|
filterdic['filterstr'] = conds
|
||||||
|
ac = ArgsConvert('[[', ']]')
|
||||||
|
vars = ac.findAllVariables(sql)
|
||||||
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
||||||
|
filterdic.update(NameSpace)
|
||||||
|
sql = ac.convert(sql, filterdic)
|
||||||
|
|
||||||
|
debug(f'{sql=}')
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.sqlPaging(sql, ns)
|
||||||
|
return r
|
||||||
|
return {
|
||||||
|
"total":0,
|
||||||
|
"rows":[]
|
||||||
|
}
|
||||||
227
wwwroot/pipeline_capacity/index.ui
Normal file
227
wwwroot/pipeline_capacity/index.ui
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"pipeline_capacity_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"产线容量表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_pipeline_capacity.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_pipeline_capacity.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_pipeline_capacity.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_pipeline_capacity.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "active",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "disabled",
|
||||||
|
"text": "已停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "产线ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "pipelines",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "name",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "max_concurrent",
|
||||||
|
"title": "最大并发数",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "最大并发数"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "daily_limit",
|
||||||
|
"title": "每日限额",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "每日限额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "monthly_limit",
|
||||||
|
"title": "每月限额",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "每月限额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "today_usage",
|
||||||
|
"title": "今日用量",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "今日用量"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "month_usage",
|
||||||
|
"title": "本月用量",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "本月用量"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active",
|
||||||
|
"label": "状态",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"tblvalue": "k",
|
||||||
|
"tbltext": "v",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"cond": "parentid='capacity_status'"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "active",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "disabled",
|
||||||
|
"text": "已停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "所属组织"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "timestamp",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_pipeline_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
70
wwwroot/pipeline_capacity/update_pipeline_capacity.dspy
Normal file
70
wwwroot/pipeline_capacity/update_pipeline_capacity.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"org_id": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('pipeline_capacity', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('pipeline_capacity', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/pipeline_pricing/add_pipeline_pricing.dspy
Normal file
51
wwwroot/pipeline_pricing/add_pipeline_pricing.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('pipeline_pricing', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/pipeline_pricing/delete_pipeline_pricing.dspy
Normal file
47
wwwroot/pipeline_pricing/delete_pipeline_pricing.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('pipeline_pricing', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
168
wwwroot/pipeline_pricing/get_pipeline_pricing.dspy
Normal file
168
wwwroot/pipeline_pricing/get_pipeline_pricing.dspy
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_pipeline_pricing.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["effective_date desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.pipeline_id_text, c.pricing_type_text, d.currency_text, e.status_text
|
||||||
|
from (select * from pipeline_pricing where 1=1 [[filterstr]]) a left join (select id as pipeline_id,
|
||||||
|
name as pipeline_id_text from pipelines where 1 = 1) b on a.pipeline_id = b.pipeline_id left join (select k as pricing_type,
|
||||||
|
v as pricing_type_text from appcodes_kv where parentid='pricing_type') c on a.pricing_type = c.pricing_type left join (select k as currency,
|
||||||
|
v as currency_text from appcodes_kv where parentid='currency') d on a.currency = d.currency left join (select k as status,
|
||||||
|
v as status_text from appcodes_kv where parentid='pricing_status') e on a.status = e.status'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
if filterjson and isinstance(filterjson, str):
|
||||||
|
try:
|
||||||
|
filterjson = json.loads(filterjson)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
filterjson = None
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_type",
|
||||||
|
"title": "计费方式",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "currency",
|
||||||
|
"title": "货币",
|
||||||
|
"type": "str",
|
||||||
|
"length": 10,
|
||||||
|
"default": "CNY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_config",
|
||||||
|
"title": "定价配置JSON",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "effective_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "expiry_date",
|
||||||
|
"title": "失效日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
|
||||||
|
# 确保 logined 过滤条件始终生效
|
||||||
|
if filterjson:
|
||||||
|
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
|
||||||
|
filterjson = {'AND': [filterjson] if filterjson else []}
|
||||||
|
|
||||||
|
filterjson['AND'].append({'field': 'org_id', 'op': '=', 'var': '__logined_orgid__'})
|
||||||
|
ns['__logined_orgid__'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
filterdic = ns.copy()
|
||||||
|
filterdic['filterstr'] = ''
|
||||||
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
filterdic['userid'] = '${userid}$'
|
||||||
|
if filterjson:
|
||||||
|
dbf = DBFilter(filterjson)
|
||||||
|
conds = dbf.gen(ns)
|
||||||
|
if conds:
|
||||||
|
ns.update(dbf.consts)
|
||||||
|
conds = f' and {conds}'
|
||||||
|
filterdic['filterstr'] = conds
|
||||||
|
ac = ArgsConvert('[[', ']]')
|
||||||
|
vars = ac.findAllVariables(sql)
|
||||||
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
||||||
|
filterdic.update(NameSpace)
|
||||||
|
sql = ac.convert(sql, filterdic)
|
||||||
|
|
||||||
|
debug(f'{sql=}')
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.sqlPaging(sql, ns)
|
||||||
|
return r
|
||||||
|
return {
|
||||||
|
"total":0,
|
||||||
|
"rows":[]
|
||||||
|
}
|
||||||
322
wwwroot/pipeline_pricing/index.ui
Normal file
322
wwwroot/pipeline_pricing/index.ui
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"pipeline_pricing_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"产线定价表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_pipeline_pricing.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_pipeline_pricing.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_pipeline_pricing.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_pipeline_pricing.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"pricing_type": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "per_call",
|
||||||
|
"text": "按次计费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "per_token",
|
||||||
|
"text": "按token计费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "subscription",
|
||||||
|
"text": "订阅制"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "active",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "expired",
|
||||||
|
"text": "已过期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "disabled",
|
||||||
|
"text": "已停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "产线ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "pipelines",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "name",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_type",
|
||||||
|
"title": "计费方式",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "计费方式",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "pricing_type",
|
||||||
|
"textField": "pricing_type_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"tblvalue": "k",
|
||||||
|
"tbltext": "v",
|
||||||
|
"valueField": "pricing_type",
|
||||||
|
"textField": "pricing_type_text",
|
||||||
|
"cond": "parentid='pricing_type'"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "per_call",
|
||||||
|
"text": "按次计费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "per_token",
|
||||||
|
"text": "按token计费"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "subscription",
|
||||||
|
"text": "订阅制"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "单价"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "currency",
|
||||||
|
"title": "货币",
|
||||||
|
"type": "str",
|
||||||
|
"length": 10,
|
||||||
|
"default": "CNY",
|
||||||
|
"label": "货币",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "currency",
|
||||||
|
"textField": "currency_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"tblvalue": "k",
|
||||||
|
"tbltext": "v",
|
||||||
|
"valueField": "currency",
|
||||||
|
"textField": "currency_text",
|
||||||
|
"cond": "parentid='currency'"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pricing_config",
|
||||||
|
"title": "定价配置JSON",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "定价配置JSON"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "effective_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "生效日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "expiry_date",
|
||||||
|
"title": "失效日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "失效日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"default": "active",
|
||||||
|
"label": "状态",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"tblvalue": "k",
|
||||||
|
"tbltext": "v",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"cond": "parentid='pricing_status'"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "active",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "expired",
|
||||||
|
"text": "已过期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "disabled",
|
||||||
|
"text": "已停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "org_id",
|
||||||
|
"title": "所属组织",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "所属组织"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "timestamp",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "timestamp",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "timestamp",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "timestamp",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_pipeline_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
70
wwwroot/pipeline_pricing/update_pipeline_pricing.dspy
Normal file
70
wwwroot/pipeline_pricing/update_pipeline_pricing.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['org_id'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"org_id": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('pipeline_pricing', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('pipeline_pricing', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
37
wwwroot/pipeline_usage_log/add_pipeline_usage_log.dspy
Normal file
37
wwwroot/pipeline_usage_log/add_pipeline_usage_log.dspy
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('pipeline_usage_log', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
33
wwwroot/pipeline_usage_log/delete_pipeline_usage_log.dspy
Normal file
33
wwwroot/pipeline_usage_log/delete_pipeline_usage_log.dspy
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('pipeline_usage_log', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
127
wwwroot/pipeline_usage_log/get_pipeline_usage_log.dspy
Normal file
127
wwwroot/pipeline_usage_log/get_pipeline_usage_log.dspy
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
debug(f'get_pipeline_usage_log.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["called_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.pipeline_id_text, c.status_text
|
||||||
|
from (select * from pipeline_usage_log where 1=1 [[filterstr]]) a left join (select id as pipeline_id,
|
||||||
|
name as pipeline_id_text from pipelines where 1 = 1) b on a.pipeline_id = b.pipeline_id left join (select k as status,
|
||||||
|
v as status_text from appcodes_kv where parentid='usage_status') c on a.status = c.status'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
if filterjson and isinstance(filterjson, str):
|
||||||
|
try:
|
||||||
|
filterjson = json.loads(filterjson)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
filterjson = None
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "user_id",
|
||||||
|
"title": "用户ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distributor_id",
|
||||||
|
"title": "分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "call_count",
|
||||||
|
"title": "调用次数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_input",
|
||||||
|
"title": "输入Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_output",
|
||||||
|
"title": "输出Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "amount",
|
||||||
|
"title": "金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "error_message",
|
||||||
|
"title": "错误信息",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "called_at",
|
||||||
|
"title": "调用时间",
|
||||||
|
"type": "timestamp"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
|
||||||
|
filterdic = ns.copy()
|
||||||
|
filterdic['filterstr'] = ''
|
||||||
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
filterdic['userid'] = '${userid}$'
|
||||||
|
if filterjson:
|
||||||
|
dbf = DBFilter(filterjson)
|
||||||
|
conds = dbf.gen(ns)
|
||||||
|
if conds:
|
||||||
|
ns.update(dbf.consts)
|
||||||
|
conds = f' and {conds}'
|
||||||
|
filterdic['filterstr'] = conds
|
||||||
|
ac = ArgsConvert('[[', ']]')
|
||||||
|
vars = ac.findAllVariables(sql)
|
||||||
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
||||||
|
filterdic.update(NameSpace)
|
||||||
|
sql = ac.convert(sql, filterdic)
|
||||||
|
|
||||||
|
debug(f'{sql=}')
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.sqlPaging(sql, ns)
|
||||||
|
return r
|
||||||
|
return {
|
||||||
|
"total":0,
|
||||||
|
"rows":[]
|
||||||
|
}
|
||||||
265
wwwroot/pipeline_usage_log/index.ui
Normal file
265
wwwroot/pipeline_usage_log/index.ui
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"pipeline_usage_log_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"产线调用日志表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_pipeline_usage_log.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_pipeline_usage_log.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_pipeline_usage_log.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_pipeline_usage_log.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"pipeline_id": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "success",
|
||||||
|
"text": "成功"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "failed",
|
||||||
|
"text": "失败"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"editexclouded":[
|
||||||
|
"id",
|
||||||
|
"pipeline_id",
|
||||||
|
"user_id",
|
||||||
|
"distributor_id",
|
||||||
|
"call_count",
|
||||||
|
"token_input",
|
||||||
|
"token_output",
|
||||||
|
"amount",
|
||||||
|
"status",
|
||||||
|
"error_message",
|
||||||
|
"called_at"
|
||||||
|
],
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pipeline_id",
|
||||||
|
"title": "产线ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "产线ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "pipelines",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "name",
|
||||||
|
"valueField": "pipeline_id",
|
||||||
|
"textField": "pipeline_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('../api/get_search_pipeline_id.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "user_id",
|
||||||
|
"title": "用户ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "用户ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distributor_id",
|
||||||
|
"title": "分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "分销商ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "call_count",
|
||||||
|
"title": "调用次数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "1",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "调用次数"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_input",
|
||||||
|
"title": "输入Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "输入Token数"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_output",
|
||||||
|
"title": "输出Token数",
|
||||||
|
"type": "int",
|
||||||
|
"default": "0",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "输出Token数"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "amount",
|
||||||
|
"title": "金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "金额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "str",
|
||||||
|
"length": 20,
|
||||||
|
"label": "状态",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{'sage'}}",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"tblvalue": "k",
|
||||||
|
"tbltext": "v",
|
||||||
|
"valueField": "status",
|
||||||
|
"textField": "status_text",
|
||||||
|
"cond": "parentid='usage_status'"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "success",
|
||||||
|
"text": "成功"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "failed",
|
||||||
|
"text": "失败"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "error_message",
|
||||||
|
"title": "错误信息",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "错误信息"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "called_at",
|
||||||
|
"title": "调用时间",
|
||||||
|
"type": "timestamp",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "timestamp",
|
||||||
|
"label": "调用时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "pipeline_id",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_pipeline_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "called_at",
|
||||||
|
"op": ">=",
|
||||||
|
"var": "filter_called_at_start"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "called_at",
|
||||||
|
"op": "<=",
|
||||||
|
"var": "filter_called_at_end"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "filter_status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
36
wwwroot/pipeline_usage_log/update_pipeline_usage_log.dspy
Normal file
36
wwwroot/pipeline_usage_log/update_pipeline_usage_log.dspy
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('pipeline_ops')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
r = await sor.U('pipeline_usage_log', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user