import 'dart:convert'; import 'package:dio/dio.dart'; import 'baseDio.dart'; import 'package:logger/logger.dart'; import 'package:wms_app/model/bo/stock_in_data_xugong.dart'; import 'package:uuid/uuid.dart'; import 'package:logger/logger.dart'; class StockInApi { static var logger = Logger( printer: PrettyPrinter(), ); static var uuidGen = Uuid(); /// 空载具入库 static Future emptyVehicleIn(String vehicleNo, {int timeOut = 5000}) async { final response = await BaseDio.instance() .post("/system/storage/addEmpty?vehicleNo=$vehicleNo", options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } /// 码盘完成 static Future stockInComplete( List stockInDataXuGong, String vehicleNo, {int timeOut = 5000}) async { logger.e("yuqili $stockInDataXuGong"); final stockInDataJson = stockInDataXuGong.map((item) => item.toJson()).toList(); final request = { "data": stockInDataJson, "vehicleNo": vehicleNo }; final response = await BaseDio.instance().post("/system/storage/addOtherList", data: jsonEncode(request), options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } /// 码盘完成 static Future createInTask( List stockInDataXuGong, String vehicleNo, {int timeOut = 5000}) async { logger.e("yuqili $stockInDataXuGong"); final stockInDataJson = stockInDataXuGong.map((item) => item.toJson()).toList(); final request = { "data": stockInDataJson, "vehicleNo": vehicleNo }; final response = await BaseDio.instance().post("/app/task/createInRequest", data: jsonEncode(request), options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } /// 扫描之后从数据库获取EBS数据 static Future getGoodsCanUse(String orderId, String goodsId, {int timeOut = 5000}) async { final response = await BaseDio.instance() .post("/api/mobile/stockIn/getCanUseGoods", data: jsonEncode({"orderId": orderId, "goodsId": goodsId}), options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } static Future getAppOrderGoodsList({int timeOut = 5000}) async { final response = await BaseDio.instance().get("/app/pmsOrderIn/list/inc/first", options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } static Future addStockIn(StockInDataXuGong item, {int timeOut = 5000}) async { final response = await BaseDio.instance().post("/app/pmsOrderIn", data: jsonEncode({ "listId": uuidGen.v4(), "orderType": 0, "customerId": uuidGen.v4(), "orderId": "test", "goodsId": item.goodsId, "goodsNum": 0, "goodsCode": uuidGen.v4(), "goodsDesc": "test", "unit": "test", "spare1": item.spare1, "spare2": item.spare2, "orderStatus": 1, }), options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); logger.e("yuqili ${response.data}"); return {"code": response.statusCode, "data": response.data}; } static Future addCompleted(String listId, {int timeOut = 5000}) async { final response = await BaseDio.instance().post("/app/pmsOrderIn/add/completed", data: jsonEncode({ "listId": listId, }), options: Options( responseType: ResponseType.json, sendTimeout: Duration(milliseconds: timeOut), receiveTimeout: Duration(milliseconds: timeOut), )); return {"code": response.statusCode, "data": response.data}; } }