Index: lib/page/offline/offline_down/offline_down_controller.dart
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>import 'package:isar/isar.dart';\nimport 'package:public_lib/extension/json_parse_utils.dart';\nimport 'package:public_lib/net/model/result_data.dart';\nimport 'package:public_lib/ui/base_getx.dart';\nimport 'package:get/get.dart';\nimport 'package:smps_flutter_pda/page/message/application_details/model/application_details_data_model.dart';\nimport 'package:smps_flutter_pda/page/message/application_details/model/application_details_model.dart';\nimport 'package:smps_flutter_pda/page/message/model/application_list_model.dart';\nimport 'package:smps_flutter_pda/page/message/return_apply_details/model/return_apply_details_data_model.dart';\nimport 'package:smps_flutter_pda/page/message/return_apply_details/model/return_apply_details_model.dart';\nimport 'package:smps_flutter_pda/page/message/return_apply_list/model/return_apply_list_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/dump_task/model/dump_task_list_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/dump_task_details/model/dump_task_details_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inbound_list/model/all_oversea_inbound_task_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inbound_list/model/other_delivery_task_data_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inbound_list/model/other_delivery_task_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inbound_list/model/other_inbound_dateils_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inbound_list/model/oversea_inbound_detalis_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inventory/model/inventory_list_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inventory_details/model/inventory_details_data_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/inventory_details/model/inventory_details_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/other_delivery_details/model/other_delivery_details_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/out_warehouse_details/model/out_warehouse_details_data_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/out_warehouse_details/model/out_warehouse_details_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/out_warehouse_list/model/out_warehouse_list_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/oversea_delivery_details/model/oversea_delivery_note_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/return_warehouse_details/model/return_warehouse_details_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/return_warehouse_list/model/return_warehouse_list_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/stock/model/stock_list_model.dart';\nimport 'package:smps_flutter_pda/res/strings.dart';\nimport 'package:smps_flutter_pda/utils/api_utils.dart';\nimport 'package:smps_flutter_pda/utils/smart_manager.dart';\n\nimport '../../../common/db/database_manager.dart';\nimport '../../../common/http/common_http_manager.dart';\nimport '../../../common/http/http.dart';\nimport 'package:sp_util/sp_util.dart';\n\nimport '../../../common/smps_core_config.dart';\nimport '../../../common/spms_application.dart';\nimport '../../overseas/overseas_delivery/model/other_delivery_model.dart';\nimport '../../overseas/overseas_delivery/model/oversea_model.dart';\nimport '../../overseas/shift/model/all_storage_model.dart';\nimport '../../overseas/shift/model/materials_model.dart';\n\nclass OfflineDownBindings extends BaseBindings {\n  @override\n  void dependencies() {\n    Get.lazyPut<OfflineDownController>(() => OfflineDownController());\n  }\n}\n\nclass OfflineDownController extends BaseController {\n  final _apiService = Get.find<ApiService>();\n\n  ///数据模块列表\n  List<String> downListStr = [\n    Ids.deliveryNote.tr,\n    Ids.receiveTheReturnForm.tr,\n    // '${Ids.receipt.tr}&${Ids.returnForm.tr}',\n    Ids.outboundOrder.tr,\n    Ids.transferOrder.tr,\n    Ids.returnOrder.tr,\n    Ids.inventoryList.tr,\n  ];\n\n  String updateId = 'updateId';\n\n  ///标题\n  RxString title = '${Ids.dataDownload.tr}(0/6)'.obs;\n\n  ///勾选的index\n  List<int> selectList = [];\n\n  ///全选\n  RxBool selectAll = false.obs;\n\n  ///是否可以下载\n  RxBool canDown = false.obs;\n\n  ///点击全选\n  void clickAll() {\n    selectAll.value = !selectAll.value;\n    selectList = selectAll.value ? [0, 1, 2, 3, 4, 5] : [];\n    canDown.value = selectAll.value;\n    title.value = '${Ids.dataDownload.tr}(${selectList.length}/6)';\n    update([updateId]);\n  }\n\n  ///单个勾选\n  void clickSinge(int index) {\n    if (selectList.contains(index)) {\n      selectList.remove(index);\n    } else {\n      selectList.add(index);\n    }\n    canDown.value = selectList.isNotEmpty;\n    selectAll.value = selectList.length == 6;\n    title.value = '${Ids.dataDownload.tr}(${selectList.length}/6)';\n    update([updateId]);\n  }\n\n  ///需要修复因为数据库存储以及获取中间的时间差导致的后续结接口不调用的问题\n  ///交货-海运收货交货单-交货单明细\n  OverseaModel? overseaModel;\n\n  ///交货-其他收货收货单-交货单明细\n  OtherDeliveryModel? otherDeliveryModel;\n\n  ///入库列表-海运收货入库任务-入库明细\n  AllOverseaInboundTaskModel? allOverseaInboundTaskModel;\n\n  ///入库列表-其他收货入库任务-入库明细\n  OtherDeliveryTaskDataModel? otherDeliveryTaskDataModel;\n\n  ///领用申请\n  ApplicationListModel? applicationListModel;\n\n  ///退库申请\n  ReturnApplyListModel? returnApplyListModel;\n\n  ///转储列表\n  DumpTaskListModel? dumpTaskListModel;\n\n  ///出库列表\n  OutWarehouseListModel? outWarehouseListModel;\n\n  ///退库列表\n  ReturnWarehouseListModel? returnWarehouseListModel;\n\n  ///盘点任务\n  InventoryListModel? inventoryListModel;\n\n  ///需要先获取所需的物料号\n  List<String> materialsNos = [];\n\n  ///获取仓库中所有的储位信息\n  Future<void> getAllStorageInfo() async {\n    Map<String, dynamic> map = {}\n      ..put('whsCode', SPMSApplication().curWhsLocationCode())\n      ..put('werks', SPMSApplication().wareList);\n    List<AllStorageModel>? modelList = await DatabaseManager()\n        .isar\n        ?.allStorageModels\n        .filter()\n        .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n        .findAll();\n    ResultData resultData = await _apiService.getAllStorageInfo(map);\n    if (resultData.isSuccess()) {\n      AllStorageModel model = resultData.data;\n      model.werks = SPMSApplication().wareList.first;\n      if (modelList == null || modelList.isEmpty) {\n        await DatabaseManager().saveData(\n            () => DatabaseManager().isar?.allStorageModels.put(model));\n      } else {\n        model.id = modelList.first.id;\n        await DatabaseManager().saveData(\n            () => DatabaseManager().isar?.allStorageModels.put(model));\n      }\n    }\n  }\n\n  ///获取海外运货交货单\n  Future<void> getOverseasDeliveryList() async {\n    Map<String, dynamic> map = {}\n      ..put('cabinetNumber', '')\n      ..put('current', 1)\n      ..put('sapDeliveryNote', '')\n      ..put('sapPackageList', '')\n      ..put('size', 1000)\n      ..put('spmsStatus', '0,1')\n      ..put('werksDelivery', '')\n      // ..put('werksReceive', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksReceiveList', SPMSApplication().wareList)\n    ;\n    ResultData resultData = await _apiService.getOverseasDeliveryList(map);\n    if (resultData.isSuccess()) {\n      OverseaModel overseaModel = resultData.data;\n      overseaModel.werks = SPMSApplication().wareList.first;\n      overseaModel.userId = SPMSApplication().userInfo?.userInfo?.userId;\n      this.overseaModel = overseaModel;\n      List<OverseaModel>? modelList = await DatabaseManager()\n          .isar\n          ?.overseaModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList == null || modelList.isEmpty) {\n        await DatabaseManager().saveData(\n            () => DatabaseManager().isar?.overseaModels.put(overseaModel));\n      } else {\n        overseaModel.id = modelList.first.id;\n        await DatabaseManager().saveData(\n            () => DatabaseManager().isar?.overseaModels.put(overseaModel));\n      }\n    }\n  }\n\n  ///获取海运收货所有交易单的交货明细\n  Future<void> getOverSeaDeliveryDetails() async {\n    List<OverseaDeliveryNoteBoxList> modelList = [];\n    if (overseaModel != null) {\n      OverseaModel overseaModel = this.overseaModel!;\n      final List<Future<void>> futures = List.generate(\n          overseaModel.overseaDeliveryNoteList?.records?.length ?? 0,\n          (index) async {\n        Map<String, dynamic> map = {}..put(\n            'sapDeliveryNote',\n            overseaModel\n                .overseaDeliveryNoteList?.records?[index].sapDeliveryNote);\n        ResultData resultData =\n            await _apiService.getOverseaDeliveryDetails(map);\n        OverseaDeliveryNoteModel model = resultData.data;\n        if (model.overseaDeliveryNoteBoxList != null) {\n          modelList.addAll(model.overseaDeliveryNoteBoxList!.toList());\n        }\n      });\n      await Future.wait(futures);\n      if (modelList.isNotEmpty) {\n        materialsNos.addAll(modelList.map((e) => e.materialNo ?? ''));\n      }\n      List<OverseaDeliveryNoteModel>? allModel = await DatabaseManager()\n          .isar\n          ?.overseaDeliveryNoteModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (allModel == null || allModel.isEmpty) {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.overseaDeliveryNoteModels\n            .put(OverseaDeliveryNoteModel(\n                werks: SPMSApplication().wareList.first,\n                overseaDeliveryNoteBoxList: modelList)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.overseaDeliveryNoteModels\n            .put(OverseaDeliveryNoteModel(\n                werks: SPMSApplication().wareList.first,\n                overseaDeliveryNoteBoxList: modelList,\n                id: allModel.first.id)));\n      }\n    }\n  }\n\n  ///获取其他收货交货单\n  Future<ResultData> getOtherDeliveryList() async {\n    Map<String, dynamic> map = {}\n      ..put('businessType', '')\n      ..put('current', 1)\n      ..put('sapDeliveryNote', '')\n      ..put('size', 1000)\n      ..put('spmsStatus', '1')\n      ..put('werksDelivery', '')\n      // ..put('werksReceive', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksDeliveryList', SPMSApplication().wareList)\n    ;\n    ResultData resultData = await _apiService.getOtherDeliveryList(map);\n    if (resultData.isSuccess()) {\n      OtherDeliveryModel otherDeliveryModel = resultData.data;\n      otherDeliveryModel.werks = SPMSApplication().wareList.first;\n      otherDeliveryModel.userId = SPMSApplication().userInfo?.userInfo?.userId;\n      this.otherDeliveryModel = otherDeliveryModel;\n      List<OtherDeliveryModel>? modelList = await DatabaseManager()\n          .isar\n          ?.otherDeliveryModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList == null || modelList.isEmpty) {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryModels\n            .put(otherDeliveryModel));\n      } else {\n        otherDeliveryModel.id = modelList.first.id;\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryModels\n            .put(otherDeliveryModel));\n      }\n    }\n    return resultData;\n  }\n\n  ///获取所有其他收货的交货明细\n  Future<void> getAllOtherDeliveryDetails() async {\n    if (otherDeliveryModel != null) {\n      List<OverseaDnDtlList> modelList = [];\n      OtherDeliveryModel? otherDeliveryModel = this.otherDeliveryModel;\n      final List<Future<void>> futures =\n          List.generate(otherDeliveryModel?.overseaDnList?.records?.length ?? 0,\n              (index) async {\n        Map<String, dynamic> map = {}..put('sapDeliveryNote',\n            otherDeliveryModel?.overseaDnList?.records?[index].sapDeliveryNote);\n        ResultData resultData = await _apiService.getOtherDeliveryDetails(map);\n        OtherDeliveryDetailsModel model = resultData.data;\n        if (model.overseaDnDtlList != null) {\n          modelList.addAll(model.overseaDnDtlList!);\n        }\n      });\n      await Future.wait(futures);\n      if (modelList.isNotEmpty) {\n        materialsNos.addAll(modelList.map((e) => e.materialNo ?? ''));\n      }\n      List<OtherDeliveryDetailsModel>? allModel = await DatabaseManager()\n          .isar\n          ?.otherDeliveryDetailsModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (allModel == null || allModel.isEmpty) {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryDetailsModels\n            .put(OtherDeliveryDetailsModel(\n                werks: SPMSApplication().wareList.first,\n                overseaDnDtlList: modelList)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryDetailsModels\n            .put(OtherDeliveryDetailsModel(\n                werks: SPMSApplication().wareList.first,\n                overseaDnDtlList: modelList,\n                id: allModel.first.id)));\n      }\n    }\n  }\n\n  ///获取所有入库列表-海运收货的入库任务\n  Future<void> getAllOverseaDeliveryTask() async {\n    Map<String, dynamic> map = {}\n      ..put('current', 1)\n      ..put('size', 1000)\n      ..put('spmsStatus', '1')\n      // ..put('werks', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksList', SPMSApplication().wareList)\n      // ..put('whsLocationCode', SPMSApplication().curWhsLocationCode())\n    ;\n    ResultData resultData = await _apiService.getAllOverseaDeliveryTask(map);\n    if (resultData.isSuccess()) {\n      AllOverseaInboundTaskModel allOverseaInboundTaskModel = resultData.data;\n      this.allOverseaInboundTaskModel = allOverseaInboundTaskModel;\n      //先检查同一个表是否已存在，存在就更新，否则就创建新的\n      List<AllOverseaInboundTaskModel>? data = await DatabaseManager()\n          .isar\n          ?.allOverseaInboundTaskModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (data != null && data.isNotEmpty) {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.allOverseaInboundTaskModels\n            .put(allOverseaInboundTaskModel\n              ..werks = SPMSApplication().wareList.first\n              ..id = data.first.id));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.allOverseaInboundTaskModels\n            .put(allOverseaInboundTaskModel\n              ..werks = SpUtil.getString(SPMSCoreConfig.WARE_HOUSE)));\n      }\n    }\n  }\n\n  ///获取所有入库列表-海运收货的入库任务明细\n  Future<void> getAllOverseaInboundDetails() async {\n    if (allOverseaInboundTaskModel != null) {\n      List<GetOverseaWhsInDtlList> list = [];\n      AllOverseaInboundTaskModel model = allOverseaInboundTaskModel!;\n      final List<Future<void>> futures = List.generate(\n          model.overseaWhsInList?.records?.length ?? 0, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('uuidWhsIn', model.overseaWhsInList?.records?[index].uuidWhsIn);\n        ResultData resultData =\n            await _apiService.getSingleOverseaInboundDetails(map);\n        if (resultData.isSuccess()) {\n          OverseaInboundDetalisModel model = resultData.data;\n          if (model.getOverseaWhsInDtlList != null) {\n            list.addAll(model.getOverseaWhsInDtlList!.toList());\n          }\n        }\n      });\n      await Future.wait(futures);\n      if (list.isNotEmpty) {\n        materialsNos.addAll(list.map((e) => e.materialNo ?? ''));\n      }\n      List<OverseaInboundDetalisModel>? data = await DatabaseManager()\n          .isar\n          ?.overseaInboundDetalisModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (data != null && data.isNotEmpty) {\n        OverseaInboundDetalisModel overseaInboundDetalisModel = data.first;\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.overseaInboundDetalisModels\n            .put(OverseaInboundDetalisModel(\n                werks: SPMSApplication().wareList.first,\n                id: overseaInboundDetalisModel.id,\n                getOverseaWhsInDtlList: list)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.overseaInboundDetalisModels\n            .put(OverseaInboundDetalisModel(\n                werks: SPMSApplication().wareList.first,\n                getOverseaWhsInDtlList: list)));\n      }\n    }\n  }\n\n  ///获取入库列表-本地采购所有的入库单任务\n  Future<void> getAllOtherDeliveryTask() async {\n    if (otherDeliveryModel != null) {\n      OtherDeliveryModel allData = otherDeliveryModel!;\n      allData.overseaDnList?.records\n          ?.where((element) => element.businessType == '02');\n      //这个数组是用来收集所有的交易单号-入库单号\n      List<OtherDeliveryTaskModel> list = [];\n      //根据交易单来查询关联的入库单\n      final List<Future<void>> futures =\n          List.generate(allData.overseaDnList!.records!.length, (index) async {\n        Map<String, dynamic> map = {}..put('sapDeliveryNote',\n            allData.overseaDnList!.records![index].sapDeliveryNote);\n        ResultData result = await _apiService.getSingleOtherDeliveryTask(map);\n        if (result.isSuccess()) {\n          //在这里获取每个交易单号下面的入库单号\n          OtherDeliveryTaskModel model = result.data;\n          model.dataVersion =\n              allData.overseaDnList!.records![index].dataVersion;\n          model.sapDeliveryNote =\n              allData.overseaDnList!.records![index].sapDeliveryNote;\n          //这里需要过滤掉任务状态不为1的，1是已保存\n          List<BatchReceiptionList>? batchList = model.batchReceiptionList\n              ?.where((element) => element.spmsStatus == '1')\n              .toList();\n          if (batchList != null && batchList.isNotEmpty) {\n            list.add(model);\n          }\n        }\n      });\n      await Future.wait(futures);\n      this.otherDeliveryTaskDataModel = OtherDeliveryTaskDataModel(\n          werks: SPMSApplication().wareList.first, allData: list);\n      //先查找是否数据库是否已存在\n      List<OtherDeliveryTaskDataModel>? otherDeliveryTaskDataModel =\n          await DatabaseManager()\n              .isar\n              ?.otherDeliveryTaskDataModels\n              .filter()\n              .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n              .findAll();\n      if (otherDeliveryTaskDataModel != null &&\n          otherDeliveryTaskDataModel.isNotEmpty) {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryTaskDataModels\n            .put(OtherDeliveryTaskDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: list,\n                id: otherDeliveryTaskDataModel.first.id)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.otherDeliveryTaskDataModels\n            .put(OtherDeliveryTaskDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: list)));\n      }\n    }\n  }\n\n  ///获取其他收货-本地采购所有交货单的入库任务明细\n  Future<void> getAllOtherInboundDetails() async {\n    if (otherDeliveryTaskDataModel != null) {\n      OtherDeliveryTaskDataModel model = otherDeliveryTaskDataModel!;\n      //需要把入库任务整合到一个list中\n      List<BatchReceiptionList>? allList = model.allData\n          ?.expand((element) =>\n              element.batchReceiptionList!.cast<BatchReceiptionList>().toList())\n          .toList();\n      if (allList != null && allList.isNotEmpty) {\n        //然后这个allList来获取本地采购的所有交货单的入库明细\n        List<BatchReceiptionDtlList> batchReceiptionDtlList = [];\n        final List<Future<void>> futures =\n            List.generate(allList.length, (index) async {\n          Map<String, dynamic> map = {}..put('spmsId', allList[index].spmsId);\n          ResultData resultData =\n              await _apiService.getSingleOtherInboundDetails(map);\n          if (resultData.isSuccess()) {\n            OtherInboundDateilsModel otherInboundDateilsModel = resultData.data;\n            if (otherInboundDateilsModel.batchReceiptionDtlList != null &&\n                otherInboundDateilsModel.batchReceiptionDtlList!.isNotEmpty) {\n              batchReceiptionDtlList.addAll(\n                  otherInboundDateilsModel.batchReceiptionDtlList!.toList());\n            }\n          }\n        });\n        await Future.wait(futures);\n        if (batchReceiptionDtlList.isNotEmpty) {\n          materialsNos\n              .addAll(batchReceiptionDtlList.map((e) => e.materialNo ?? ''));\n        }\n        //需要先检查是否存在这个数据库\n        List<OtherInboundDateilsModel>? allModel = await DatabaseManager()\n            .isar\n            ?.otherInboundDateilsModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (allModel != null && allModel.isNotEmpty) {\n          await DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.otherInboundDateilsModels\n              .put(OtherInboundDateilsModel(\n                  werks: SPMSApplication().wareList.first,\n                  batchReceiptionDtlList: batchReceiptionDtlList,\n                  id: allModel.first.id)));\n        } else {\n          await DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.otherInboundDateilsModels\n              .put(OtherInboundDateilsModel(\n                werks: SPMSApplication().wareList.first,\n                batchReceiptionDtlList: batchReceiptionDtlList,\n              )));\n        }\n      }\n    }\n  }\n\n  ///获取所有的领用申请\n  Future<void> getAllApplicationList() async {\n    Map<String, dynamic> map = {}\n      ..put('createUser', '')\n      ..put('current', 1)\n      ..put('size', 1000)\n      ..put('spmsId', '')\n      ..put('spmsStatus', \"3\")\n      // ..put('werks', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksList', SPMSApplication().wareList)\n      // ..put('whsLocationCode', SPMSApplication().curWhsLocationCode())\n      ..put('workshopCode', '');\n    ResultData resultData = await _apiService.getApplicationList(map);\n    if (resultData.isSuccess()) {\n      ApplicationListModel data = resultData.data;\n      applicationListModel = data;\n      //判断数据库是否已存在\n      List<ApplicationListModel>? modelList = await DatabaseManager()\n          .isar\n          ?.applicationListModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        ApplicationListModel model = modelList.first;\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.applicationListModels\n            .put(ApplicationListModel(\n                werks: SPMSApplication().wareList.first,\n                id: model.id,\n                overseaRequisitionList: data.overseaRequisitionList)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.applicationListModels\n            .put(ApplicationListModel(\n                werks: SPMSApplication().wareList.first,\n                overseaRequisitionList: data.overseaRequisitionList)));\n      }\n    }\n  }\n\n  ///获取所有领用单详情\n  Future<void> getApplicationDetails() async {\n    List<ApplyModel>? records =\n        applicationListModel?.overseaRequisitionList?.records;\n    if (records != null && records.isNotEmpty) {\n      List<ApplicationDetailsModel> allData = [];\n      final List<Future<void>> futures =\n          List.generate(records.length, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('uuidRequisition', records[index].uuidRequisition);\n        ResultData resultData = await _apiService.getApplicationDetails(map);\n        if (resultData.isSuccess()) {\n          ApplicationDetailsModel model = resultData.data;\n          allData.add(model);\n        }\n      });\n      await Future.wait(futures);\n      if (allData.isNotEmpty) {\n        List<OverseaRequisitionDtlList> list = [];\n\n        allData\n            .map(\n                (e) => list.addAll(e.overseaRequisitionDtlList?.toList() ?? []))\n            .toList();\n\n        materialsNos.addAll(list.map((e) => e.materialNo ?? ''));\n      }\n      //判断数据库是否已存在\n      List<AllApplicationDetailsDataModel>? modelList = await DatabaseManager()\n          .isar\n          ?.allApplicationDetailsDataModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        AllApplicationDetailsDataModel model = modelList.first;\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.allApplicationDetailsDataModels\n            .put(AllApplicationDetailsDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: allData,\n                id: model.id)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.allApplicationDetailsDataModels\n            .put(AllApplicationDetailsDataModel(\n              werks: SPMSApplication().wareList.first,\n              allData: allData,\n            )));\n      }\n    }\n  }\n\n  ///获取所有的退料列表\n  Future<void> getReturnApplyList() async {\n    Map<String, dynamic> map = {}\n      ..put('current', 1)\n      ..put('size', 1000)\n      // ..put('werks', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksList', SPMSApplication().wareList)\n      // ..put('whsLocationCode', SPMSApplication().curWhsLocationCode())\n    ;\n    ResultData resultData = await _apiService.getReturnApplyList(map);\n    if (resultData.isSuccess()) {\n      ReturnApplyListModel returnApplyListModel = resultData.data;\n      this.returnApplyListModel = returnApplyListModel;\n      if (returnApplyListModel.overseaRequisitionList?.records != null &&\n          returnApplyListModel.overseaRequisitionList!.records!.isNotEmpty) {\n        List<ReturnApplyListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.returnApplyListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          ReturnApplyListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.returnApplyListModels\n              .put(ReturnApplyListModel(\n                  werks: SPMSApplication().wareList.first,\n                  overseaRequisitionList:\n                      returnApplyListModel.overseaRequisitionList,\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.returnApplyListModels\n              .put(ReturnApplyListModel(\n                werks: SPMSApplication().wareList.first,\n                overseaRequisitionList:\n                    returnApplyListModel.overseaRequisitionList,\n              )));\n        }\n      }\n    }\n  }\n\n  ///获取所有退料申请详情\n  Future<void> getReturnApplyDetails() async {\n    List<ReturnApplyItemModel>? records =\n        returnApplyListModel?.overseaRequisitionList?.records;\n    if (records != null && records.isNotEmpty) {\n      List<ReturnApplyDetailsModel> allData = [];\n      final List<Future<void>> futures =\n          List.generate(records.length, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('uuidRequisition', records[index].uuidRequisition);\n        ResultData resultData = await _apiService.getReturnApplyDetails(map);\n        if (resultData.isSuccess()) {\n          ReturnApplyDetailsModel model = resultData.data;\n          allData.add(model);\n        }\n      });\n      await Future.wait(futures);\n      if (allData.isNotEmpty) {\n        List<EamReturnSkuDtlList> list = [];\n        allData\n            .map((e) => list.addAll(e.eamReturnSkuDtlList?.toList() ?? []))\n            .toList();\n\n        materialsNos.addAll(list.map((e) => e.materialNo ?? ''));\n      }\n      //判断数据库是否已存在\n      List<ReturnApplyDetailsDataModel>? modelList = await DatabaseManager()\n          .isar\n          ?.returnApplyDetailsDataModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        ReturnApplyDetailsDataModel model = modelList.first;\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.returnApplyDetailsDataModels\n            .put(ReturnApplyDetailsDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: allData,\n                id: model.id)));\n      } else {\n        await DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.returnApplyDetailsDataModels\n            .put(ReturnApplyDetailsDataModel(\n              werks: SPMSApplication().wareList.first,\n              allData: allData,\n            )));\n      }\n    }\n  }\n\n  ///转储列表\n  Future<void> getDumpTaskList() async {\n    Map<String, dynamic> map = {}\n      ..put('current', 1)\n      ..put('sapDeliveryNote', '')\n      ..put('size', 1000)\n      ..put('spmsStatus', '5')\n      // ..put('werksDumpIn', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksReceiveList', SPMSApplication().wareList)\n      ..put('werksDumpOut', '')\n      ..put('whsDumpNo', '')\n      ..put('whsLocationCodeDumpIn', '')\n      ..put('whsLocationCodeDumpOut', '');\n    ResultData resultData = await _apiService.getDumpTaskList(map);\n    if (resultData.isSuccess()) {\n      DumpTaskListModel modelData = resultData.data;\n      dumpTaskListModel = modelData;\n      if (modelData.overseaWhsDumpList?.records != null &&\n          modelData.overseaWhsDumpList!.records!.isNotEmpty) {\n        List<DumpTaskListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.dumpTaskListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          DumpTaskListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.dumpTaskListModels\n              .put(DumpTaskListModel(\n                  werks: SPMSApplication().wareList.first,\n                  overseaWhsDumpList: modelData.overseaWhsDumpList,\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(() =>\n              DatabaseManager().isar?.dumpTaskListModels.put(DumpTaskListModel(\n                    werks: SPMSApplication().wareList.first,\n                    overseaWhsDumpList: modelData.overseaWhsDumpList,\n                  )));\n        }\n      }\n    }\n  }\n\n  ///获取所有转储任务详情\n  Future<void> getDumpTaskDetails() async {\n    List<DumpItemModel>? records =\n        dumpTaskListModel?.overseaWhsDumpList?.records;\n    if (records != null && records.isNotEmpty) {\n      List<OverseaWhsDumpDtls> allData = [];\n      final List<Future<void>> futures =\n          List.generate(records.length, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('whsDumpUuid', records[index].whsDumpUuid);\n        ResultData resultData = await _apiService.getDumpTaskDetails(map);\n        if (resultData.isSuccess()) {\n          DumpTaskDetailsModel data = resultData.data;\n          if (data.overseaWhsDumpDtls != null &&\n              data.overseaWhsDumpDtls!.isNotEmpty) {\n            allData.addAll(data.overseaWhsDumpDtls!);\n          }\n        }\n      });\n      await Future.wait(futures);\n      if (allData.isNotEmpty) {\n        materialsNos.addAll(allData.map((e) => e.materialNo ?? ''));\n      }\n      List<DumpTaskDetailsModel>? modelList = await DatabaseManager()\n          .isar\n          ?.dumpTaskDetailsModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        DumpTaskDetailsModel model = modelList.first;\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.dumpTaskDetailsModels\n            .put(DumpTaskDetailsModel(\n                werks: SPMSApplication().wareList.first,\n                overseaWhsDumpDtls: allData,\n                id: model.id)));\n      } else {\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.dumpTaskDetailsModels\n            .put(DumpTaskDetailsModel(\n              werks: SPMSApplication().wareList.first,\n              overseaWhsDumpDtls: allData,\n            )));\n      }\n    }\n  }\n\n  ///获取所有出库列表数据\n  Future<void> getOutWarehouseList() async {\n    Map<String, dynamic> map = {}\n      ..put('comments', '')\n      ..put('current', 1)\n      ..put('movementType', '')\n      ..put('size', 1000)\n      ..put('spmsId', '')\n      ..put('spmsStatus', '1')\n      ..put('subject', '')\n      // ..put('werks', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksList', SPMSApplication().wareList)\n      // ..put('whsLocationCode', SPMSApplication().curWhsLocationCode())\n      ..put('workshopCode', '');\n    ResultData resultData = await _apiService.getOutWarehouseList(map);\n    if (resultData.isSuccess()) {\n      OutWarehouseListModel data = resultData.data;\n      outWarehouseListModel = data;\n      if (data.whsOutList?.records != null &&\n          data.whsOutList!.records!.isNotEmpty) {\n        List<OutWarehouseListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.outWarehouseListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          OutWarehouseListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.outWarehouseListModels\n              .put(OutWarehouseListModel(\n                  werks: SPMSApplication().wareList.first,\n                  whsOutList: data.whsOutList,\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.outWarehouseListModels\n              .put(OutWarehouseListModel(\n                werks: SPMSApplication().wareList.first,\n                whsOutList: data.whsOutList,\n              )));\n        }\n      }\n    }\n  }\n\n  ///获取所有出库详情\n  Future<void> getOutWarehouseDetails() async {\n    List<WhsOutItem>? records = outWarehouseListModel?.whsOutList?.records;\n    if (records != null && records.isNotEmpty) {\n      List<OutWarehouseDetailsModel> allData = [];\n      final List<Future<void>> futures =\n          List.generate(records.length, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('uuidWhsOut', records[index].uuidWhsOut);\n        ResultData resultData = await _apiService.getOutWarehouseDetails(map);\n        if (resultData.isSuccess()) {\n          OutWarehouseDetailsModel data = resultData.data;\n          allData.add(OutWarehouseDetailsModel(\n              uuidWhsOut: records[index].uuidWhsOut,\n              overseaWhsOut: data.overseaWhsOut,\n              overseaWhsOutDtl: data.overseaWhsOutDtl));\n        }\n      });\n      await Future.wait(futures);\n      if (allData.isNotEmpty) {\n        List<OverseaWhsOutDtl> list = [];\n        allData\n            .map((e) => list.addAll(e.overseaWhsOutDtl?.toList() ?? []))\n            .toList();\n\n        materialsNos.addAll(list.map((e) => e.materialNo ?? ''));\n      }\n      List<OutWarehouseDetailsDataModel>? modelList = await DatabaseManager()\n          .isar\n          ?.outWarehouseDetailsDataModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        OutWarehouseDetailsDataModel model = modelList.first;\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.outWarehouseDetailsDataModels\n            .put(OutWarehouseDetailsDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: allData,\n                id: model.id)));\n      } else {\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.outWarehouseDetailsDataModels\n            .put(OutWarehouseDetailsDataModel(\n              werks: SPMSApplication().wareList.first,\n              allData: allData,\n            )));\n      }\n    }\n  }\n\n  ///获取所有退库列表数据\n  Future<void> getReturnWarehouseList() async {\n    Map<String, dynamic> map = {}\n      ..put('comments', '')\n      ..put('current', 1)\n      ..put('movementType', '')\n      ..put('size', 1000)\n      ..put('spmsId', '')\n      ..put('spmsStatus', '1')\n      ..put('subject', '')\n      // ..put('werks', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ..put('werksList', SPMSApplication().wareList)\n      // ..put('whsLocationCode', SPMSApplication().curWhsLocationCode())\n      ..put('workshopCode', '');\n    ResultData resultData = await _apiService.getReturnWarehouseList(map);\n    if (resultData.isSuccess()) {\n      ReturnWarehouseListModel data = resultData.data;\n      returnWarehouseListModel = data;\n      if (data.otherTaskList?.records != null &&\n          data.otherTaskList!.records!.isNotEmpty) {\n        List<ReturnWarehouseListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.returnWarehouseListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          ReturnWarehouseListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.returnWarehouseListModels\n              .put(ReturnWarehouseListModel(\n                  werks: SPMSApplication().wareList.first,\n                  otherTaskList: data.otherTaskList,\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.returnWarehouseListModels\n              .put(ReturnWarehouseListModel(\n                werks: SPMSApplication().wareList.first,\n                otherTaskList: data.otherTaskList,\n              )));\n        }\n      }\n    }\n  }\n\n  ///获取所有退库详情\n  Future<void> getReturnWarehouseDetails() async {\n    List<OtherTaskItem>? records =\n        returnWarehouseListModel?.otherTaskList?.records;\n    if (records != null && records.isNotEmpty) {\n      List<OtherDtlList> allData = [];\n      final List<Future<void>> futures =\n          List.generate(records.length, (index) async {\n        Map<String, dynamic> map = {}..put('uuid', records[index].uuid);\n        ResultData resultData =\n            await _apiService.getReturnWarehouseDetails(map);\n        if (resultData.isSuccess()) {\n          ReturnWarehouseDetailsModel data = resultData.data;\n          if (data.otherDtlList != null && data.otherDtlList!.isNotEmpty) {\n            allData.addAll(data.otherDtlList!.toList());\n          }\n        }\n      });\n      await Future.wait(futures);\n      if (allData.isNotEmpty) {\n        materialsNos.addAll(allData.map((e) => e.materialNo ?? ''));\n      }\n      List<ReturnWarehouseDetailsModel>? modelList = await DatabaseManager()\n          .isar\n          ?.returnWarehouseDetailsModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        ReturnWarehouseDetailsModel model = modelList.first;\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.returnWarehouseDetailsModels\n            .put(ReturnWarehouseDetailsModel(\n                werks: SPMSApplication().wareList.first,\n                otherDtlList: allData,\n                id: model.id)));\n      } else {\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.returnWarehouseDetailsModels\n            .put(ReturnWarehouseDetailsModel(\n              werks: SPMSApplication().wareList.first,\n              otherDtlList: allData,\n            )));\n      }\n    }\n  }\n\n  ///获取所有的盘点任务\n  Future<void> getInventoryCheck() async {\n    Map<String, dynamic> map = {}\n      ..put('inventoryCheckCategory', '')\n      ..put('inventoryCheckId', '')\n      ..put('inventoryCheckResult', '')\n      ..put('natureOfTheFactory', '')\n      ..put('pageNo', 1)\n      ..put('pageSize', 1000)\n      ..put('spmsStatus', '2,3')\n      ..put('werks', SPMSApplication().wareList)\n      // ..put('werksWhsCodeGroup', {\n      //   'werks': SpUtil.getString(SPMSCoreConfig.WARE_HOUSE),\n      //   'whsLocationCode': SPMSApplication().whsLocationCode\n      // })\n      ..put('whsLocationCode', SPMSApplication().curWhsLocationCode());\n    ResultData resultData = await _apiService.getInventoryCheck(map);\n    if (resultData.isSuccess()) {\n      InventoryListModel inventoryListModel = resultData.data;\n      this.inventoryListModel = resultData.data;\n      if (inventoryListModel.invCheckList != null &&\n          inventoryListModel.invCheckList!.isNotEmpty) {\n        List<InventoryListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.inventoryListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          InventoryListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.inventoryListModels\n              .put(InventoryListModel(\n                  werks: SPMSApplication().wareList.first,\n                  invCheckList: inventoryListModel.invCheckList,\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.inventoryListModels\n              .put(InventoryListModel(\n                werks: SPMSApplication().wareList.first,\n                invCheckList: inventoryListModel.invCheckList,\n              )));\n        }\n      }\n    }\n  }\n\n  ///获取所有盘点任务详情\n  Future<void> getInventoryDetails() async {\n    if (inventoryListModel?.invCheckList != null &&\n        inventoryListModel!.invCheckList!.isNotEmpty) {\n      List<InventoryDetailsModel> list = [];\n      final List<Future<void>> futures = List.generate(\n          inventoryListModel!.invCheckList!.length, (index) async {\n        Map<String, dynamic> map = {}\n          ..put('uuid', inventoryListModel!.invCheckList![index].uuid);\n        ResultData resultData = await _apiService.getInventoryDetails(map);\n        if (resultData.isSuccess()) {\n          InventoryDetailsModel data = resultData.data;\n          if (data.inventoryCheckDtls != null &&\n              data.inventoryCheckDtls!.isNotEmpty) {\n            materialsNos.addAll(data.inventoryCheckDtls\n                    ?.map((e) => e.materialNo ?? '')\n                    .toList() ??\n                []);\n            list.add(data);\n          }\n        }\n      });\n      await Future.wait(futures);\n      List<InventoryDetailsDataModel>? modelList = await DatabaseManager()\n          .isar\n          ?.inventoryDetailsDataModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      if (modelList != null && modelList.isNotEmpty) {\n        InventoryDetailsDataModel model = modelList.first;\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.inventoryDetailsDataModels\n            .put(InventoryDetailsDataModel(\n                werks: SPMSApplication().wareList.first,\n                allData: list,\n                id: model.id)));\n      } else {\n        DatabaseManager().saveData(() => DatabaseManager()\n            .isar\n            ?.inventoryDetailsDataModels\n            .put(InventoryDetailsDataModel(\n              werks: SPMSApplication().wareList.first,\n              allData: list,\n            )));\n      }\n    }\n  }\n\n  ///库存明细\n  Future<void> getWerksStorageInvList() async {\n    Map<String, dynamic> map = {}\n      ..put('current', 1)\n      ..put('isZero', false)\n      ..put('size', 1000)\n      // ..put('werks', SPMSApplication().wareList.first)\n      ..put('werksList', SPMSApplication().wareList)\n    ;\n    ResultData resultData = await _apiService.getWerksStorageInvList(map);\n    if (resultData.isSuccess()) {\n      StockListModel stockListModel = resultData.data;\n      if (stockListModel.whsStorageInvList?.records != null &&\n          stockListModel.whsStorageInvList!.records!.isNotEmpty) {\n        List<StockListItem> list=[];\n        list.addAll(stockListModel.whsStorageInvList?.records??[]);\n        if((stockListModel.whsStorageInvList?.total??0)>1000){\n          int current=stockListModel.whsStorageInvList!.total!-1000;\n          int allPage=current~/1000+1;\n          List<Future<void>> futures = List.generate(allPage, (index)async{\n            Map<String,dynamic> map={}\n              ..put('current', index+2)\n              ..put('isZero', false)\n              ..put('size', 1000)\n              // ..put('werks', SPMSApplication().wareList.first)\n              ..put('werksList', SPMSApplication().wareList)\n            ;\n            ResultData result =\n            await _apiService.getWerksStorageInvList(map);\n            StockListModel model = result.data;\n            list.addAll(model.whsStorageInvList?.records??[]);\n          });\n          await Future.wait(futures);\n          materialsNos.addAll(list\n              .map((e) => e.materialNo ?? '')\n              .toList());\n        }else{\n          materialsNos.addAll(stockListModel.whsStorageInvList!.records!\n              .map((e) => e.materialNo ?? '')\n              .toList());\n        }\n        List<StockListModel>? modelList = await DatabaseManager()\n            .isar\n            ?.stockListModels\n            .filter()\n            .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n            .findAll();\n        if (modelList != null && modelList.isNotEmpty) {\n          StockListModel model = modelList.first;\n          DatabaseManager().saveData(() => DatabaseManager()\n              .isar\n              ?.stockListModels\n              .put(StockListModel(\n                  werks: SPMSApplication().wareList.first,\n                  marmList: stockListModel.marmList,\n                  whsStorageInvList: WhsStorageInvList(records: list),\n                  id: model.id)));\n        } else {\n          DatabaseManager().saveData(\n              () => DatabaseManager().isar?.stockListModels.put(StockListModel(\n                    werks: SPMSApplication().wareList.first,\n                    marmList: stockListModel.marmList,\n                    whsStorageInvList: WhsStorageInvList(records: list),\n                  )));\n        }\n      }\n    }\n  }\n\n  ///批量下载数据\n  Future<void> getAllData() async {\n    if (!canDown.value) {\n      SmartManager().showCenterToast(\n          Ids.pleaseCheckTheCorrespondingModuleForOfflineDownload.tr);\n      return;\n    }\n    List<Future<void>> futures = List.from([\n      ///获取仓库中所有的储位信息-allStorageModels\n      getAllStorageInfo(),\n\n      ///库存明细\n      getWerksStorageInvList(),\n    ]);\n    for (var element in selectList) {\n      switch (element) {\n        case 0:\n          futures.add(\n            ///获取海外运货交货单-overseaModels\n            getOverseasDeliveryList().then((value) =>\n\n                ///获取海运收货所有交易单的交货明细-overseaDeliveryNoteModels\n                getOverSeaDeliveryDetails()),\n          );\n          futures.add(\n            ///获取其他收货交货单-otherDeliveryModels\n            getOtherDeliveryList().then((value) {\n              ///获取所有其他收货的交货明细-otherDeliveryDetailsModels\n              getAllOtherDeliveryDetails();\n\n              ///获取入库列表-本地采购所有的入库单任务-otherDeliveryTaskDataModels\n              getAllOtherDeliveryTask().then(\n                (value) =>\n\n                    ///获取其他收货-本地采购所有交货单的入库任务明细-otherInboundDateilsModels\n                    getAllOtherInboundDetails(),\n              );\n            }),\n          );\n          futures.add(\n            ///获取所有入库列表-海运收货的入库任务-allOverseaInboundTaskModels\n            getAllOverseaDeliveryTask().then(\n              (value) =>\n\n                  ///获取所有入库列表-海运收货的入库任务明细-overseaInboundDetalisModels\n                  getAllOverseaInboundDetails(),\n            ),\n          );\n          break;\n        case 1:\n          futures.add(\n\n              ///获取所有的领用申请-applicationListModels\n              getAllApplicationList().then((value) =>\n\n                  ///获取所有的领用详情-allApplicaitonDetailsDataModels\n                  getApplicationDetails()));\n          futures.add(\n\n              ///获取所有的退料列表-returnApplyListModels\n              getReturnApplyList().then((value) =>\n\n                  ///获取所有退料申请详情-returnApplyDetailsDataModels\n                  getReturnApplyDetails()));\n          break;\n        case 2:\n          futures.add(\n            ///获取所有出库列表数据-outWarehouseListModels\n            getOutWarehouseList().then((value) =>\n\n                ///获取所有入库详情-outWarehouseDetailsDataModels\n                getOutWarehouseDetails()),\n          );\n          break;\n        case 3:\n          futures.add(\n            ///转储列表-dumpTaskListModels\n            getDumpTaskList().then((value) =>\n\n                ///获取所有转储任务详情-dumpTaskDetailsModels\n                getDumpTaskDetails()),\n          );\n          break;\n        case 4:\n          futures.add(\n            ///获取所有退库列表数据-returnWarehouseListModels\n            getReturnWarehouseList().then((value) =>\n\n                ///获取所有退库详情-returnWarehouseDetailsModels\n                getReturnWarehouseDetails()),\n          );\n          break;\n        case 5:\n          futures.add(\n            ///获取所有的盘点任务\n            getInventoryCheck().then((value) =>\n\n                ///获取所有盘点任务详情\n                getInventoryDetails()),\n          );\n          break;\n      }\n    }\n    await Future.wait(futures)\n        .then((value) =>\n\n            ///获取所有物料列表-materialsModels\n            Future.delayed(const Duration(milliseconds: 1000), () {\n              getAllMaterials();\n            }))\n        .then((value) =>\n            SmartManager().showCenterToast(Ids.downloadCompleted.tr));\n  }\n\n  getAllMaterials() {\n    List<String> set = materialsNos.toSet().toList();\n    ApiUtils().getSingleMaterials(set, save: true);\n  }\n}\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/page/offline/offline_down/offline_down_controller.dart b/lib/page/offline/offline_down/offline_down_controller.dart
--- a/lib/page/offline/offline_down/offline_down_controller.dart	(revision 9d2376020ee71dcfd3a73a92ea5383e575314753)
+++ b/lib/page/offline/offline_down/offline_down_controller.dart	(date 1713336233332)
@@ -160,6 +160,15 @@
     }
   }
 
+  ///多工厂本地数据库查询
+  Future<List<OverseaModel>> _multiWareQuery()async{
+    List<OverseaModel> overseaModelList=[];
+    IsarCollection<OverseaModel>? collection=  DatabaseManager().isar?.overseaModels;
+    for (var ware in SPMSApplication().wareList) {
+      overseaModelList.addAll(await collection?.filter().werksEqualTo(ware).findAll()??[]);
+    }
+    return overseaModelList;
+  }
   ///获取海外运货交货单
   Future<void> getOverseasDeliveryList() async {
     Map<String, dynamic> map = {}
@@ -175,16 +184,13 @@
     ;
     ResultData resultData = await _apiService.getOverseasDeliveryList(map);
     if (resultData.isSuccess()) {
+      //todo 改了多工厂之后，OverseaModel这个结构来存本地数据就不合理了，因为后台返回的结果是包含多个仓库的列表，而OverseaModel这个结构定死了只有一个仓库。不兼容
       OverseaModel overseaModel = resultData.data;
-      overseaModel.werks = SPMSApplication().wareList.first;
+      // 按理说，这个请求返回的结果需要按工厂分拣好列表，每一个工厂里有多个交货单，按工厂分别存储。或者直接按返回数据存储，然后读取的时候，只读取对应工厂的内容
+      overseaModel.werks = SPMSApplication().wareList.first;//目前这种存储方式会有上述问题，但是如果终端客户只选择一个工厂，问题也不大
       overseaModel.userId = SPMSApplication().userInfo?.userInfo?.userId;
       this.overseaModel = overseaModel;
-      List<OverseaModel>? modelList = await DatabaseManager()
-          .isar
-          ?.overseaModels
-          .filter()
-          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))
-          .findAll();
+      List<OverseaModel>? modelList = await _multiWareQuery();
       if (modelList == null || modelList.isEmpty) {
         await DatabaseManager().saveData(
             () => DatabaseManager().isar?.overseaModels.put(overseaModel));
Index: lib/page/overseas/overseas_delivery/overseas_delivery_controller.dart
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>import 'package:flutter/cupertino.dart';\nimport 'package:flutter/material.dart';\nimport 'package:isar/isar.dart';\nimport 'package:public_lib/net/model/result_data.dart';\nimport 'package:public_lib/ui/base_getx.dart';\nimport 'package:get/get.dart';\nimport 'package:public_lib/ui/base_viewmodel.dart';\nimport 'package:smps_flutter_pda/common/android_channel/android_channel_mixin.dart';\nimport 'package:smps_flutter_pda/common/db/database_manager.dart';\nimport 'package:smps_flutter_pda/common/page_state.dart';\nimport 'package:smps_flutter_pda/common/smps_core_config.dart';\nimport 'package:smps_flutter_pda/common/spms_application.dart';\nimport 'package:smps_flutter_pda/page/hi_getcontroller.dart';\nimport 'package:smps_flutter_pda/page/overseas/overseas_delivery/model/oversea_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/overseas_delivery/model/sap_package_model.dart';\nimport 'package:smps_flutter_pda/page/overseas/overseas_delivery/oversea_delivrey_main_controller.dart';\nimport 'package:smps_flutter_pda/res/strings.dart';\nimport 'package:smps_flutter_pda/utils/smart_manager.dart';\nimport 'package:sp_util/sp_util.dart';\nimport '../../../common/http/http.dart';\nimport 'package:collection/collection.dart';\n\nclass OverseasDeliveryBindings extends BaseBindings {\n  @override\n  void dependencies() {\n    Get.lazyPut<OverseasDeliveryController>(() => OverseasDeliveryController());\n  }\n}\n\nclass OverseasDeliveryController extends HiGetController with AndroidChannelMixin  {\n\n\n  ///请求的数据\n  Rx<PageWrapListState<OverseaModel, Records>> overseaModel =\n      PageWrapListState<OverseaModel, Records>(\n          (p0) => p0.overseaDeliveryNoteList?.records,pageName: 'current').obs;\n\n  ///按照箱子号分组的数据\n  List<SapPackageModel> sapPackageModelList = [];\n\n  ///按照柜号和交货单号区分的数据\n  List<Records> sapDeliveryList = [];\n\n  ///选择的筛选方式0，按箱子号，1，按柜号，2按交货单号\n  RxInt findType = 0.obs;\n\n  ///筛选方式\n  List<String> findTypeList = ['P/L', 'C/R', 'DN'];\n\n  ///搜索的内容\n  late TextEditingController textEditingController;\n\n  ///搜索框焦点\n  FocusNode focusNode = FocusNode();\n\n  @override\n  void onInit() {\n    textEditingController= TextEditingController();\n    listener.addListener(_scanListener);\n    getOverseasDeliveryList();\n    super.onInit();\n  }\n\n  void _scanListener() {\n    if (focusNode.hasFocus) {\n      textEditingController.text = listener.eventParameter;\n      getOverseasDeliveryList();\n    }\n  }\n  @override\n  onClose(){\n    textEditingController.dispose();\n    listener.removeListener(_scanListener);\n  }\n  ///获取海外运货交货单\n  Future<void> getOverseasDeliveryList({int? page = 1}) async {\n    bool connectivity = await SPMSApplication().checkConnectivity();\n    if (connectivity) {\n      String cabinetNumber = '';\n      String sapDeliveryNote = '';\n      String sapPackageList = '';\n      switch (findType.value) {\n        case 0:\n          sapPackageList = textEditingController.text;\n          break;\n        case 1:\n          cabinetNumber = textEditingController.text;\n          break;\n        case 2:\n          sapDeliveryNote = textEditingController.text;\n          break;\n      }\n      overseaModel\n        ..put('cabinetNumber', cabinetNumber)\n        ..put('current', page)\n        ..put('sapDeliveryNote', sapDeliveryNote)\n        ..put('sapPackageList', sapPackageList)\n        ..put('size', 1000)\n        ..put('spmsStatus', '0,1')\n        ..put('werksDelivery', '')\n        ..put('werksReceiveList', SPMSApplication().wareList)\n        // ..put('werksReceive', SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n      ;\n      ResultData resultData =\n          await overseaModel.request(apiService.getOverseasDeliveryList);\n      if (resultData.isSuccess()) {\n        OverseaModel overseaModel = resultData.data;\n        overseaData(overseaModel);\n      }\n    } else {\n      List<OverseaModel>? overseaModelList = await DatabaseManager()\n          .isar\n          ?.overseaModels\n          .filter()\n          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))\n          .findAll();\n      OverseaModel overseaModel;\n      if (overseaModelList == null) {\n        SmartManager().showCenterToast(\n            Ids.noNetworkAndNoOfflineDataRequiredForThisFunction.tr);\n      } else {\n        overseaModel = overseaModelList.first;\n        if (textEditingController.text.isNotEmpty) {\n          switch (findType.value) {\n            case 0:\n              overseaModel.overseaDeliveryNoteList?.records = overseaModel\n                  .overseaDeliveryNoteList?.records\n                  ?.where((element) =>\n                      element.sapPackageList == textEditingController.text)\n                  .toList();\n              break;\n            case 1:\n              overseaModel.overseaDeliveryNoteList?.records = overseaModel\n                  .overseaDeliveryNoteList?.records\n                  ?.where((element) =>\n                      element.cabinetNumber == textEditingController.text)\n                  .toList();\n              break;\n            case 2:\n              overseaModel.overseaDeliveryNoteList?.records = overseaModel\n                  .overseaDeliveryNoteList?.records\n                  ?.where((element) =>\n                      element.sapDeliveryNote == textEditingController.text)\n                  .toList();\n          }\n        }\n        overseaData(overseaModel);\n      }\n    }\n  }\n\n  void overseaData(OverseaModel overseaModel) {\n    OverseaDeliveryMainController deliveryMainController=Get.find();\n    deliveryMainController.title.value =\n        '${Ids.deliveryList.tr}(${overseaModel.overseaDeliveryNoteList?.records?.length ?? 0})';\n    List<Records>? records = overseaModel.overseaDeliveryNoteList?.records;\n    if (records != null) {\n      switch (findType.value) {\n        case 0:\n          Map<String?, List<Records>> grouped = groupBy<Records, String?>(\n              records, (record) => record.sapPackageList);\n          Map<String?, List<SapDeliveryList>> map = grouped.map((key, value) =>\n              MapEntry(\n                  key,\n                  value\n                      .map((e) => SapDeliveryList(\n                          sapDeliveryNote: e.sapDeliveryNote,\n                          werksDelivery: e.werksDelivery,\n                          cabinetNumber: e.cabinetNumber,\n                          uuidDeliveryNote: e.uuidDeliveryNote,\n                          werksReceive: e.werksReceive,\n                          spmsStatus: e.spmsStatus))\n                      .toList()));\n          sapPackageModelList = map.entries\n              .map((e) => SapPackageModel(\n                    sapPackage: SapPackage(\n                        sapPackageNo: e.key, sapDeliveryList: e.value),\n                  ))\n              .toList();\n          break;\n        case 1:\n        case 2:\n          sapDeliveryList = records;\n          break;\n      }\n      this.overseaModel.setState(ViewState.Idle);\n      this.overseaModel.refresh();\n    }\n  }\n}\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/page/overseas/overseas_delivery/overseas_delivery_controller.dart b/lib/page/overseas/overseas_delivery/overseas_delivery_controller.dart
--- a/lib/page/overseas/overseas_delivery/overseas_delivery_controller.dart	(revision 9d2376020ee71dcfd3a73a92ea5383e575314753)
+++ b/lib/page/overseas/overseas_delivery/overseas_delivery_controller.dart	(date 1713322014587)
@@ -72,6 +72,15 @@
     textEditingController.dispose();
     listener.removeListener(_scanListener);
   }
+  ///多工厂本地数据库查询
+  Future<List<OverseaModel>> _multiWareQuery()async{
+    List<OverseaModel> overseaModelList=[];
+    IsarCollection<OverseaModel>? collection=  DatabaseManager().isar?.overseaModels;
+    for (var ware in SPMSApplication().wareList) {
+      overseaModelList.addAll(await collection?.filter().werksEqualTo(ware).findAll()??[]);
+    }
+    return overseaModelList;
+  }
   ///获取海外运货交货单
   Future<void> getOverseasDeliveryList({int? page = 1}) async {
     bool connectivity = await SPMSApplication().checkConnectivity();
@@ -108,14 +117,9 @@
         overseaData(overseaModel);
       }
     } else {
-      List<OverseaModel>? overseaModelList = await DatabaseManager()
-          .isar
-          ?.overseaModels
-          .filter()
-          .werksEqualTo(SpUtil.getString(SPMSCoreConfig.WARE_HOUSE))
-          .findAll();
+      List<OverseaModel>? overseaModelList = await _multiWareQuery();
       OverseaModel overseaModel;
-      if (overseaModelList == null) {
+      if (overseaModelList.isEmpty) {
         SmartManager().showCenterToast(
             Ids.noNetworkAndNoOfflineDataRequiredForThisFunction.tr);
       } else {
