From d40083b09626a01500cd1efce916ca928c51528a Mon Sep 17 00:00:00 2001 From: zhu-mengmeng <15588200382@163.com> Date: Wed, 23 Jul 2025 15:15:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=8C=85=E8=A3=85=E7=BB=9F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=80=BB=E8=BE=91=E5=8F=8A=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/gc_api.py | 49 +++++++++++++++++++++++++++++++- config/app_config.json | 5 ++-- db/jtDB.db | Bin 262144 -> 262144 bytes ui/main_window_ui.py | 12 ++++---- widgets/main_window.py | 62 +++++++++++++++++++++++++++++++++-------- 5 files changed, 108 insertions(+), 20 deletions(-) diff --git a/apis/gc_api.py b/apis/gc_api.py index 398a2a6..9a18447 100644 --- a/apis/gc_api.py +++ b/apis/gc_api.py @@ -355,4 +355,51 @@ class GcApi: return response except Exception as e: logging.error(f"通过托盘号获取订单信息失败: {str(e)}") - return None \ No newline at end of file + return None + + def get_package_statistics(self, order_id, corp_id): + """ + 获取订单包装统计数据 + + Args: + order_id: 订单号 + corp_id: 公司ID + + Returns: + dict: 包含总包装轴数和已包装数量的字典 + """ + try: + # API 配置中的键名 + api_key = "get_package_statistics" + + # 构建GET请求参数 + params = { + "orderId": order_id, + "data_corp": corp_id + } + + # 发送GET请求 + response = self.api_utils.get(api_key, params=params) + + # 检查响应状态 + if response.get("status", False): + return { + "status": True, + "data": response.get("data", {}), + "message": "获取包装统计数据成功" + } + else: + logging.warning(f"获取包装统计数据失败: {response.get('message', '未知错误')}") + return { + "status": False, + "data": {}, + "message": response.get("message", "获取包装统计数据失败") + } + + except Exception as e: + logging.error(f"获取包装统计数据失败: {str(e)}") + return { + "status": False, + "data": {}, + "message": f"获取包装统计数据失败: {str(e)}" + } \ No newline at end of file diff --git a/config/app_config.json b/config/app_config.json index 6cbd52d..70fa33a 100644 --- a/config/app_config.json +++ b/config/app_config.json @@ -20,7 +20,8 @@ "ismt_option": "/jsjt/xcsc/tprk/ismtOptioTonWsbz.do", "get_params": "/select/getcombcodeWsbz.do", "get_luno": "/common/luno/getLunoListWsbz.do", - "get_order_info_by_xpack": "/jsjt/xcsc/tprk/getXsddBzrkGridListByXpackToWsbz.do" + "get_order_info_by_xpack": "/jsjt/xcsc/tprk/getXsddBzrkGridListByXpackToWsbz.do", + "get_package_statistics": "/jsjt/xcsc/tprk/getBzNumWszb.do" }, "database": { "default": "sqlite", @@ -120,7 +121,7 @@ } }, "electricity": { - "auto_start": false, + "auto_start": true, "interval_minutes": 30 } } \ No newline at end of file diff --git a/db/jtDB.db b/db/jtDB.db index 4d6151074ce6537f98d53b71e05e6cf159586aae..04a2d93042146a5404c98a0aab2aa1015c350d22 100644 GIT binary patch delta 1163 zcmb7??@Lor7{~9<8PnX(oaps(nM2cxn%v7d=bpQ(H*(Q1YgtHaP`&8a>p-M8{ZJh0 z9Oy!0gDY8J7%EXxC@e%B^ggLx^cQr;>W$!=g2=iPvTgdJo>%AaefaQv&U0chPb}t{ z^x8HaHiT>&udn~?u%Xn|;HYCjL{J5(Nk`rAb}+FWv}Lw~0G<@87*`2LIQI&|&UrXe zIakr`Xt94^s`1={^+SFB)*4@HE!Tq3VT2mJ{COn$jPMwUS4u?FWTvUcr!nxsKXgpq@6h}VXP@RW5rw&E1Ut9i?cwjzBn8}!R%`GkDMkdVo3p2Br zPY#>Y%l$(~q!J(RULT>{r_S;ryFQ^FjN2*MD?{-g8Hx)sO@2(UOtJc}GWdUGGTjM~ z2X>CL-M04HYlFj%V@B^Z;1k(#kjak2&O=Z}%|^v5c-f99YPP!8T}EsWI{Ctm@Mp}uqLaj7GQ1Vb71{%RKlPza@Xja2jU4!n(1mlSBcCpW~7u+ z7L_na^v=#0ne02**$mz8bgJUL&$u}Q=u(rX!#yaZk)2a2%ifn*%0k+;Z=$pbX=iz2 c&7kQ_71CAvBmtdZA$?%K1nQU>^}pcP-{?6r85@_Hg93#II503WE;lrnCximg1A_)Bmv5T_6^Flz0=K`514SeQEDb`J2e1QK zvk?&D43~g^0|~cFy#u)d5(f>W01v7UR1W?Qs18yM`wgVC5fF|I0#$gIprHa8x4+E; mMIsgn4;BCq<`2vdvJaRKeh*|1N)Ip(7PAo${0^5E{{!l_07dKo diff --git a/ui/main_window_ui.py b/ui/main_window_ui.py index ae9195a..10464b1 100644 --- a/ui/main_window_ui.py +++ b/ui/main_window_ui.py @@ -229,22 +229,22 @@ class MainWindowUI(QMainWindow): # 设置列宽均等 self.task_table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) - # 第一行:订单量和完成量 (一级标题) - self.task_table.setSpan(0, 0, 1, 2) # 订单量跨2列 - self.task_table.setSpan(0, 2, 1, 2) # 完成量跨2列 + # 第一行:总完成和已完成 (一级标题) + self.task_table.setSpan(0, 0, 1, 2) # 总完成跨2列 + self.task_table.setSpan(0, 2, 1, 2) # 已完成跨2列 - order_item = QTableWidgetItem("订单量") + order_item = QTableWidgetItem("订单完成") order_item.setTextAlignment(Qt.AlignCenter) order_item.setFont(self.normal_font) self.task_table.setItem(0, 0, order_item) - completed_item = QTableWidgetItem("完成量") + completed_item = QTableWidgetItem("托盘完成") completed_item.setTextAlignment(Qt.AlignCenter) completed_item.setFont(self.normal_font) self.task_table.setItem(0, 2, completed_item) # 第二行:二级标题 - headers = ["总生产数量", "总生产公斤", "已完成数量", "已完成公斤"] + headers = ["订单完成轴数", "订单完成数量", "托盘完成轴数", "托盘完成数量"] for col, header in enumerate(headers): item = QTableWidgetItem(header) item.setTextAlignment(Qt.AlignCenter) diff --git a/widgets/main_window.py b/widgets/main_window.py index 423db0d..7841a92 100644 --- a/widgets/main_window.py +++ b/widgets/main_window.py @@ -1803,32 +1803,72 @@ class MainWindow(MainWindowUI): def update_package_statistics(self): """更新包装记录统计数据""" try: - # 使用DAO获取包装记录统计数据 + # 获取本地数据库统计数据(用于已完成数量和已完成公斤) from dao.inspection_dao import InspectionDAO inspection_dao = InspectionDAO() - stats = inspection_dao.get_package_statistics(self._current_order_code) + local_stats = inspection_dao.get_package_statistics(self._current_order_code) - # 更新任务表格中的总生产数量(总数量) - total_count_item = QTableWidgetItem(str(stats['count_all'])) + # 初始化API统计数据(用于总完成轴数和总完成数量) + api_stats = { + 'count_all': 0, # 总轴数默认值 + 'weight_all': 0 # 总包装数量默认值 + } + + # 检查是否开启API模式,获取总完成轴数和总完成数量 + if AppMode.is_api() and self._current_order_code: + # 使用API获取包装统计数据 + from apis.gc_api import GcApi + gc_api = GcApi() + response = gc_api.get_package_statistics(self._current_order_code, self.corp_id) + + if response.get("status", True): + stats_data = response.get("data", {}) + api_stats = { + 'count_all': stats_data.get("zzs", 0), # 总轴数 + 'weight_all': float(stats_data.get("ybzsl", 0)) # 总包装数量 + } + logging.info(f"从API获取总完成统计数据成功: {api_stats}") + else: + # API调用失败,仍使用本地数据库的count_all和weight_all + logging.warning(f"从API获取总完成统计数据失败: {response.get('message', '未知错误')}") + api_stats = { + 'count_all': 0, + 'weight_all': 0 + } + else: + # 非API模式,使用本地数据库的count_all和weight_all + api_stats = { + 'count_all': local_stats['count_all'], + 'weight_all': local_stats['weight_all'] + } + + # 更新任务表格中的总完成轴数(第一列) + total_count_item = QTableWidgetItem(str(api_stats['count_all'])) total_count_item.setTextAlignment(Qt.AlignCenter) self.task_table.setItem(2, 0, total_count_item) - # 更新任务表格中的总生产公斤(总重量) - total_kg_item = QTableWidgetItem(f"{stats['weight_all']:.2f}") + # 更新任务表格中的总完成数量(第二列) + total_kg_item = QTableWidgetItem(f"{api_stats['weight_all']:.2f}") total_kg_item.setTextAlignment(Qt.AlignCenter) self.task_table.setItem(2, 1, total_kg_item) - # 更新任务表格中的已完成数量(当前订单数量) - completed_item = QTableWidgetItem(str(stats['count'])) + # 更新任务表格中的已完成数量(第三列)- 使用本地统计 + completed_item = QTableWidgetItem(str(local_stats['count'])) completed_item.setTextAlignment(Qt.AlignCenter) self.task_table.setItem(2, 2, completed_item) - # 更新任务表格中的已完成公斤(当前订单重量) - completed_kg_item = QTableWidgetItem(f"{stats['weight']:.2f}") + # 更新任务表格中的已完成公斤(第四列)- 使用本地统计 + completed_kg_item = QTableWidgetItem(f"{local_stats['weight']:.2f}") completed_kg_item.setTextAlignment(Qt.AlignCenter) self.task_table.setItem(2, 3, completed_kg_item) - logging.info(f"已更新包装记录统计数据: 总生产数量={stats['count_all']}, 总生产公斤={stats['weight_all']:.2f}, 已完成数量={stats['count']}, 已完成公斤={stats['weight']:.2f}") + # 更新表头显示(确保表头显示正确) + self.task_table.horizontalHeaderItem(0).setText("订单完成轴数") + self.task_table.horizontalHeaderItem(1).setText("订单完成数量") + self.task_table.horizontalHeaderItem(2).setText("托盘完成轴数") + self.task_table.horizontalHeaderItem(3).setText("托盘完成数量") + + logging.info(f"已更新包装记录统计数据: 总完成轴数={api_stats['count_all']}, 总完成数量={api_stats['weight_all']:.2f}, 已完成数量={local_stats['count']}, 已完成公斤={local_stats['weight']:.2f}") except Exception as e: logging.error(f"更新包装记录统计数据失败: {str(e)}")