From 72460817d338a3f9c0c02f28c44db4e6d3fe5e14 Mon Sep 17 00:00:00 2001 From: icewint Date: Sat, 7 Dec 2024 15:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0EBS=E7=A0=81=E7=9B=98?= =?UTF-8?q?=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/apiclient/WmsApiClient.dart | 35 ++++- lib/page/stockIn/StackInWheelEBS.dart | 187 ++++++++++++++++++++------ lib/page/stockIn/StackInWheelMes.dart | 2 - 3 files changed, 178 insertions(+), 46 deletions(-) diff --git a/lib/apiclient/WmsApiClient.dart b/lib/apiclient/WmsApiClient.dart index 5b470b4..682dec9 100644 --- a/lib/apiclient/WmsApiClient.dart +++ b/lib/apiclient/WmsApiClient.dart @@ -9,7 +9,7 @@ class WmsApiClient { static Dio instance() { if(!initializeComplete) { final options = BaseOptions( - baseUrl: 'http://192.168.3.109:19990', + baseUrl: 'http://10.168.1.100:19990', connectTimeout: const Duration(seconds: 5), receiveTimeout: const Duration(seconds: 3), ); @@ -51,7 +51,7 @@ class WmsApiClient { return { "code" : response.statusCode, "data": response.data }; } - /// 绑定入库 + /// MES绑定入库 static Future bindingVehicleIn(dynamic bindingVehicleData, {int timeOut = 5000}) async { instance(); final response = await dio.post( @@ -65,4 +65,35 @@ class WmsApiClient { ); return { "code" : response.statusCode, "data": response.data }; } + + /// 获取EBS入库单信息 + static Future getCuxData({int timeOut = 5000}) async { + instance(); + final response = await dio.get( + "/api/mobile/stockIn/getCuxData", + options: Options( + responseType: ResponseType.json, + sendTimeout: Duration(milliseconds: timeOut), + receiveTimeout: Duration(milliseconds: timeOut), + ) + ); + return { "code" : response.statusCode, "data": response.data }; + } + + + /// EBS绑定入库 + static Future bindingVehicleInEbs(dynamic bindingVehicleData, {int timeOut = 5000}) async { + instance(); + final response = await dio.post( + "/api/mobile/stockIn/bindingVehicleInEbs", + data: jsonEncode(bindingVehicleData), + options: Options( + responseType: ResponseType.json, + sendTimeout: Duration(milliseconds: timeOut), + receiveTimeout: Duration(milliseconds: timeOut), + ) + ); + return { "code" : response.statusCode, "data": response.data }; + } + } \ No newline at end of file diff --git a/lib/page/stockIn/StackInWheelEBS.dart b/lib/page/stockIn/StackInWheelEBS.dart index 9496f2b..1d43f54 100644 --- a/lib/page/stockIn/StackInWheelEBS.dart +++ b/lib/page/stockIn/StackInWheelEBS.dart @@ -20,15 +20,11 @@ class _StockInWheelEBSPageState extends State { List tableData = []; // 表格数据类型 int tableIndex = 0; // 序号 int selectCount = 0; // 已选择的数量 + String inArea = "立体库"; // 入库位置 @override void initState() { super.initState(); - tableData.add({ - "action":"", - "id":"1", - "vehicleNo":"测试" - }); } @override @@ -68,10 +64,10 @@ class _StockInWheelEBSPageState extends State { ), BrnRadioInputFormItem( title: "选择目的地:", - options: const ["立体库", "装箱线"], - value: "立体库", + options: [inArea, "装箱线"], + value: inArea, onChanged: (oldValue, newValue) { - BrnToast.show("点击触发回调${oldValue}_${newValue}_onChanged", context); + inArea = newValue ?? "立体库"; }, ), Padding(padding: const EdgeInsets.only( @@ -99,25 +95,24 @@ class _StockInWheelEBSPageState extends State { ), child: TDTable( bordered: true, - height: 300, width: MediaQuery.of(context).size.width, backgroundColor: Colors.transparent, columns: [ TDTableCol(title: '*', colKey: 'action', width: 45, align: TDTableColAlign.center), TDTableCol(title: '序号', colKey: 'id', align: TDTableColAlign.center, width: 80), - TDTableCol(title: '载具号', colKey: 'vehicleNo', align: TDTableColAlign.center, ellipsis: true, width: 80), - TDTableCol(title: '箱号', colKey: 'boxNo', align: TDTableColAlign.center, ellipsis: true, width: 80), - TDTableCol(title: '包装数量', colKey: 'goodsNum', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '产品编码', colKey: 'goodsId', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '每包数量', colKey: 'numPerBox', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '包数量', colKey: 'picketNum', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '零包数量', colKey: 'otherNum', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '销售订单', colKey: 'saleOrderNo', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '包装层级', colKey: 'packetLevel', align: TDTableColAlign.center, ellipsis: true, width: 100), - TDTableCol(title: '周期', colKey: 'cycle', align: TDTableColAlign.center, ellipsis: true, width: 80), - TDTableCol(title: '客户销售订单', colKey: 'customSaleOrderNo', align: TDTableColAlign.center, ellipsis: true, width: 110), - TDTableCol(title: '子库', colKey: 'minorWarehouseId', align: TDTableColAlign.center, ellipsis: true, width: 80), - TDTableCol(title: '产品描述', colKey: 'goodsDesc', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '物料ID', colKey: 'itemId', align: TDTableColAlign.center, ellipsis: true, width: 80), + TDTableCol(title: '物料编码', colKey: 'itemCode', align: TDTableColAlign.center, ellipsis: true, width: 80), + TDTableCol(title: '数量', colKey: 'quantity', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '已接收数量', colKey: 'quantityReceives', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '物料描述', colKey: 'itemDesc', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '订单头主键', colKey: 'poHeaderId', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '订单行主键', colKey: 'poLineId', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '发运行主键', colKey: 'lineLocationId', align: TDTableColAlign.center, ellipsis: true, width: 100), + TDTableCol(title: '收货组织代码', colKey: 'shipToOrganization', align: TDTableColAlign.center, ellipsis: true, width: 110), + TDTableCol(title: '采购单位', colKey: 'purUomCode', align: TDTableColAlign.center, ellipsis: true, width: 80), + TDTableCol(title: '库存单位', colKey: 'invUomCode', align: TDTableColAlign.center, ellipsis: true, width: 110), + TDTableCol(title: '发运行号', colKey: 'shipmentNum', align: TDTableColAlign.center, ellipsis: true, width: 80), + TDTableCol(title: '分配ID', colKey: 'poDistributionId', align: TDTableColAlign.center, ellipsis: true, width: 100), ], data: tableData, onCellTap: (index, dynamic, cell) { @@ -140,28 +135,83 @@ class _StockInWheelEBSPageState extends State { /// 获取入库单数据 void getTableData() { - + BrnLoadingDialog.show(context, content: "正在拉取数据", barrierDismissible: false); + setState(() { + tableData = []; + tableIndex = 0; + }); + WmsApiClient.getCuxData().then((response){ + if(response["code"] != 200) { + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败", btnLabel: "我知道了"); + } + return; + } + final data = Map.from(jsonDecode(response["data"])); + if(data["code"] == 200) { + // 服务器返回成功 + final cuxData = data["data"] as List; + setState(() { + for (var item in cuxData) { + tableIndex ++; + tableData.add({ + 'id': (tableIndex).toString(), + 'itemId': item["itemId"].toString(), + 'itemCode': item["itemCode"], + 'quantity': item["quantity"].toString(), + 'quantityReceives': item["quantityReceives"].toString(), + 'itemDesc': item["itemDesc"], + 'poHeaderId': item["poHeaderId"].toString(), + 'poLineId': item["poLineId"].toString(), + 'lineLocationId': item["lineLocationId"].toString(), + 'shipToOrganization': item["shipToOrganization"], + 'purUomCode': item["purUomCode"], + 'invUomCode': item["invUomCode"], + 'shipmentNum': item["shipmentNum"].toString(), + 'poDistributionId': item["poDistributionId"].toString(), + }); + } + }); + return; + } + // 服务器返回失败 + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showWarningMessage(thisContext, "警告", "服务器返回失败:${data["message"]}", btnLabel: "我知道了"); + } + return; + }).catchError((err){ + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showErrorMessage(thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()}", btnLabel: "我知道了"); + } + return; + }).whenComplete((){ + var thisContext = context; + if(thisContext.mounted) { + BrnLoadingDialog.dismiss(thisContext); + } + }); } - - /// 显示详细信息 void showDetails(index, dynamic) { String goodsDetails = ""; goodsDetails += "序号:${dynamic["id"]??""}\r\n"; - goodsDetails += "载具号:${dynamic["vehicleNo"]??""}\r\n"; - goodsDetails += "箱号:${dynamic["boxNo"]??""}\r\n"; - goodsDetails += "包装数量:${dynamic["goodsNum"]??""}\r\n"; - goodsDetails += "产品编码:${dynamic["goodsId"]??""}\r\n"; - goodsDetails += "每包数量:${dynamic["numPerBox"]??""}\r\n"; - goodsDetails += "包数量:${dynamic["picketNum"]??""}\r\n"; - goodsDetails += "零包数量:${dynamic["otherNum"]??""}\r\n"; - goodsDetails += "销售订单:${dynamic["saleOrderNo"]??""}\r\n"; - goodsDetails += "包装层级:${dynamic["packetLevel"]??""}\r\n"; - goodsDetails += "周期:${dynamic["cycle"]??""}\r\n"; - goodsDetails += "客户销售订单:${dynamic["customSaleOrderNo"]??""}\r\n"; - goodsDetails += "子库:${dynamic["minorWarehouseId"]??""}\r\n"; - goodsDetails += "产品描述:${dynamic["goodsDesc"]??""}"; + goodsDetails += "物料ID:${dynamic["itemId"]??""}\r\n"; + goodsDetails += "物料编码:${dynamic["itemCode"]??""}\r\n"; + goodsDetails += "数量:${dynamic["quantity"]??""}\r\n"; + goodsDetails += "已接收数量:${dynamic["quantityReceives"]??""}\r\n"; + goodsDetails += "物料描述:${dynamic["itemDesc"]??""}\r\n"; + goodsDetails += "订单头主键:${dynamic["poHeaderId"]??""}\r\n"; + goodsDetails += "订单行主键:${dynamic["poLineId"]??""}\r\n"; + goodsDetails += "发运行主键:${dynamic["lineLocationId"]??""}\r\n"; + goodsDetails += "收货组织代码:${dynamic["shipToOrganization"]??""}\r\n"; + goodsDetails += "采购单位:${dynamic["purUomCode"]??""}\r\n"; + goodsDetails += "库存单位:${dynamic["invUomCode"]??""}\r\n"; + goodsDetails += "发运行号:${dynamic["shipmentNum"]??""}\r\n"; + goodsDetails += "分配ID:${dynamic["poDistributionId"]??""}"; DialogUtils.showMessage(context, "详情", goodsDetails, btnLabel: "我知道了"); } @@ -171,7 +221,8 @@ class _StockInWheelEBSPageState extends State { DialogUtils.showWarningMessage(context, "警告", "您当前没有待入库的入库单", btnLabel: "确定"); return; } - if(_vehicleTextController.text == "") { + String vehicleNo = _vehicleTextController.text; + if(vehicleNo == "") { DialogUtils.showWarningMessage(context, "警告", "请先扫描载具号", btnLabel: "返回填写"); return; } @@ -180,9 +231,61 @@ class _StockInWheelEBSPageState extends State { DialogUtils.showWarningMessage(context, "警告", "您还没有选择入库单", btnLabel: "返回选择"); return; } - DialogUtils.showConfirmMessage(context, "完成确认?", "当前选择了 $selectCount 条入库单,是否继续?", confirmBtn: "继续", confirm: (){ - - + DialogUtils.showConfirmMessage(context, "完成确认?", "当前选择了 $selectCount 条入库单,是否继续?", confirmBtn: "继续", confirm: () { + int taskType = inArea == "立体库" ? 1 : 2; // 1 表示进库,2 表示进站台 + List bindingGoods = []; + dynamic requestData = {"vehicleNo" : vehicleNo, "taskType" : taskType, "bindingGoods" : bindingGoods }; + for (var item in selectData) { + bindingGoods.add({ + "boxNo": item["itemId"], + "numPerBox": item["quantityReceives"], + "goodsNum": item["quantity"], + "picketNum": item["quantity"], + "otherNum": item["quantity"], + "goodsId": item["itemCode"], + "saleOrderNo": item["lineLocationId"], + "packetLevel": "", + "cycle": "", + "customSaleOrderNo": item["shipToOrganization"], + "minorWarehouseId": item["poDistributionId"], + "goodsDesc": item["itemDesc"], + "poHeaderId":item["poHeaderId"], + "poLineId":item["poLineId"], + "lineLocationId":item["lineLocationId"], + }); + } + BrnLoadingDialog.show(context, content: "正在请求入库"); + WmsApiClient.bindingVehicleInEbs(requestData).then((response){ + final data = Map.from(jsonDecode(response["data"])); + if(data["code"] == 200) { + // 请求成功 + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showSuccessMessage(thisContext, "成功", "", btnLabel: "我知道了"); + getTableData(); // 刷新信息 + setState(() { + _vehicleTextController.text = ""; + }); + } + return; + } + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showWarningMessage(thisContext, "警告", "服务器返回失败:${data["message"]}", btnLabel: "我知道了"); + } + return; + }).catchError((err){ + var thisContext = context; + if(thisContext.mounted) { + DialogUtils.showErrorMessage(thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()} \r\n ${jsonEncode(requestData)}", btnLabel: "我知道了"); + } + return; + }).whenComplete((){ + var thisContext = context; + if(thisContext.mounted) { + BrnLoadingDialog.dismiss(thisContext); + } + }); }); } diff --git a/lib/page/stockIn/StackInWheelMes.dart b/lib/page/stockIn/StackInWheelMes.dart index c123a49..e52364f 100644 --- a/lib/page/stockIn/StackInWheelMes.dart +++ b/lib/page/stockIn/StackInWheelMes.dart @@ -104,7 +104,6 @@ class _StockInWheelMesPageState extends State { ), child: TDTable( bordered: true, - height: 300, width: MediaQuery.of(context).size.width, backgroundColor: Colors.transparent, columns: [ @@ -310,7 +309,6 @@ class _StockInWheelMesPageState extends State { BrnLoadingDialog.dismiss(thisContext); } }); - }); }