feat: 添加获取包装号的 API 接口,更新配置文件以支持新接口,修改相关数据字段名称,优化用户登录和用户信息获取逻辑
This commit is contained in:
parent
0906f188fb
commit
c257150bdd
@ -81,3 +81,22 @@ class GcApi:
|
||||
except Exception as e:
|
||||
logging.error(f"添加订单信息失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def get_xpack(self, order_id):
|
||||
"""
|
||||
获取包装号
|
||||
"""
|
||||
try:
|
||||
# API 配置中的键名
|
||||
api_key = "get_xpack"
|
||||
# 构建 form-data 格式的数据
|
||||
data = {
|
||||
"ddmo": order_id,
|
||||
"data_corp":"JT"
|
||||
}
|
||||
# 将工程号作为参数传递,使用 data 参数传递 form-data 格式数据
|
||||
response = self.api_utils.post(api_key, data=data)
|
||||
return response
|
||||
except Exception as e:
|
||||
logging.error(f"获取包装号失败: {str(e)}")
|
||||
return None
|
||||
@ -14,7 +14,8 @@
|
||||
"get_tray_info": "/apjt/xcsc/tpda/getByTp_note/",
|
||||
"get_gc_info": "/jsjt/xcsc/tprk/getBZGCInfoToWsbz.do",
|
||||
"get_order_info": "/jsjt/xcsc/tprk/getXsddBzrkGridListToWsbz.do",
|
||||
"add_order_info": "/jsjt/xcsc/tprk/bzrkAdd01.do"
|
||||
"add_order_info": "/jsjt/xcsc/tprk/bzrkAdd01.do",
|
||||
"get_xpack":"/jsjt/xcsc/tprk/getXpackToWsbz.do"
|
||||
},
|
||||
"database": {
|
||||
"default": "sqlite",
|
||||
@ -24,11 +25,11 @@
|
||||
"description": "默认SQLite数据库"
|
||||
},
|
||||
"postgresql": {
|
||||
"host": "localhost",
|
||||
"port": "5432",
|
||||
"user": "postgres",
|
||||
"password": "",
|
||||
"name": "jtDB",
|
||||
"host": "221.229.106.186",
|
||||
"port": "54321",
|
||||
"user": "tzwalechat",
|
||||
"password": "jsjt@2024",
|
||||
"name": "tz_tzwalechat",
|
||||
"description": "PostgreSQL数据库"
|
||||
},
|
||||
"mysql": {
|
||||
|
||||
@ -244,7 +244,7 @@ class InspectionDAO:
|
||||
data.get("user_id", ""),
|
||||
data.get("user_name", ""),
|
||||
data.get("zx_zl", ""),
|
||||
data.get("note", ""),
|
||||
data.get("mo", ""),
|
||||
data.get("xpack", ""),
|
||||
order_id if order_id else "",
|
||||
data.get("qd", ""),
|
||||
|
||||
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -6,10 +6,17 @@ from widgets.main_window import MainWindow
|
||||
from utils.sql_utils import SQLUtils
|
||||
import logging
|
||||
import threading
|
||||
from utils.app_mode import AppMode
|
||||
|
||||
def check_user_login(user_id, password):
|
||||
"""验证用户登录"""
|
||||
try:
|
||||
if AppMode.is_api():
|
||||
db = SQLUtils(source_name='postgresql')
|
||||
db.execute_query("select user_id from x_userinfo t1 where t1.user_id = %s and t1.user_pwd = md5(%s)", (user_id, password))
|
||||
result = db.fetchone()
|
||||
db.close()
|
||||
return result is not None
|
||||
# 始终使用SQLite数据源验证登录
|
||||
db = SQLUtils(source_name='sqlite')
|
||||
db.execute_query("SELECT id FROM wsbz_user WHERE username = ? AND password = ? AND is_deleted = 0", (user_id, password))
|
||||
@ -23,6 +30,12 @@ def check_user_login(user_id, password):
|
||||
def get_user_info(user_id):
|
||||
"""获取用户信息"""
|
||||
try:
|
||||
if AppMode.is_api():
|
||||
db = SQLUtils(source_name='postgresql')
|
||||
db.execute_query("select t1.user_id,t2.corp_name,t1.corp_id from x_userinfo t1 left join x_corp t2 on t1.corp_id = t2.corp_id where user_id = %s", (user_id,))
|
||||
result = db.fetchone()
|
||||
db.close()
|
||||
return result
|
||||
# 始终使用SQLite数据源获取用户信息
|
||||
db = SQLUtils(source_name='sqlite')
|
||||
db.execute_query("SELECT username, corp_id as corp_name, corp_id FROM wsbz_user WHERE username = ?", (user_id,))
|
||||
|
||||
@ -1139,7 +1139,6 @@ class MainWindow(MainWindowUI):
|
||||
pass
|
||||
|
||||
# 加载包装记录
|
||||
self.show_pack_item()
|
||||
return
|
||||
|
||||
logging.info(f"已加载未完成的检验数据,共 {len(unfinished_data)} 条记录")
|
||||
@ -1865,7 +1864,10 @@ class MainWindow(MainWindowUI):
|
||||
info = {}
|
||||
order_info = inspection_dao.get_order_info(order_id)
|
||||
info.update(order_info)
|
||||
|
||||
# 获取包装号
|
||||
xpack = gc_api.get_xpack(order_info["ddmo"])
|
||||
info['xpack'] = xpack['xpack']
|
||||
info['spack'] = xpack['spack']
|
||||
order_others_info = inspection_dao.get_order_others_info(order_id, tray_id)
|
||||
info.update(order_others_info)
|
||||
info['data_corp'] = 'T'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user