浏览代码

Merge branch 'master' into zzd

# Conflicts:
#	app/Http/Controllers/TestController.php
dream 5 年之前
父节点
当前提交
46e836dcfe
共有 100 个文件被更改,包括 2679 次插入200 次删除
  1. 1 1
      .gitignore
  2. 2 0
      app/Console/Commands/SyncBatchTask.php
  3. 16 8
      app/Console/Commands/SyncWMSOrderTask.php
  4. 1 1
      app/Exceptions/Handler.php
  5. 12 19
      app/Http/Controllers/ControlPanelController.php
  6. 85 0
      app/Http/Controllers/MaterialBoxController.php
  7. 90 0
      app/Http/Controllers/StationController.php
  8. 85 0
      app/Http/Controllers/StationRuleBatchController.php
  9. 85 0
      app/Http/Controllers/StationTaskBatchController.php
  10. 85 0
      app/Http/Controllers/StationTaskBatchTypeController.php
  11. 85 0
      app/Http/Controllers/StationTaskCommodityController.php
  12. 85 0
      app/Http/Controllers/StationTaskController.php
  13. 85 0
      app/Http/Controllers/StationTaskMaterialBoxController.php
  14. 85 0
      app/Http/Controllers/StationTaskTypeController.php
  15. 85 0
      app/Http/Controllers/StationTypeController.php
  16. 11 6
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  17. 27 0
      app/Http/Controllers/api/thirdPart/haiq/LightController.php
  18. 9 4
      app/Http/Controllers/api/thirdPart/haiq/PickStationController.php
  19. 24 8
      app/Http/Controllers/api/thirdPart/haiq/StorageController.php
  20. 10 0
      app/MaterialBox.php
  21. 3 0
      app/OracleDOCOrderHeader.php
  22. 4 1
      app/Order.php
  23. 12 0
      app/Providers/AppServiceProvider.php
  24. 30 5
      app/Services/BatchService.php
  25. 124 0
      app/Services/CommodityService.php
  26. 25 0
      app/Services/ForeignHaiRoboticsService.php
  27. 20 0
      app/Services/LogisticService.php
  28. 8 3
      app/Services/OracleDOCOrderHeaderService.php
  29. 212 0
      app/Services/OrderCommodityService.php
  30. 4 4
      app/Services/OrderCountingRecordService.php
  31. 15 2
      app/Services/OrderIssueService.php
  32. 46 33
      app/Services/OrderPackageCommoditiesService.php
  33. 9 1
      app/Services/OrderPackageService.php
  34. 56 35
      app/Services/OrderService.php
  35. 8 4
      app/Services/OrderTrackingService.php
  36. 16 1
      app/Services/OwnerService.php
  37. 33 0
      app/Services/ShopService.php
  38. 39 0
      app/Services/StationService.php
  39. 61 0
      app/Services/StationTaskBatchService.php
  40. 26 0
      app/Services/StationTaskBatchTypeService.php
  41. 33 5
      app/Services/WarehouseService.php
  42. 17 0
      app/Station.php
  43. 10 0
      app/StationRuleBatch.php
  44. 10 0
      app/StationTask.php
  45. 10 0
      app/StationTaskBatch.php
  46. 10 0
      app/StationTaskBatchType.php
  47. 10 0
      app/StationTaskCommodity.php
  48. 10 0
      app/StationTaskMaterialBox.php
  49. 10 0
      app/StationTaskType.php
  50. 10 0
      app/StationType.php
  51. 9 1
      config/api.php
  52. 7 5
      config/cache.php
  53. 1 0
      config/sync.php
  54. 12 0
      database/factories/MaterialBoxFactory.php
  55. 18 0
      database/factories/OracleActAllocationDetailsFactory.php
  56. 14 0
      database/factories/OracleBasCodeFactory.php
  57. 14 0
      database/factories/OracleBasCustomerFactory.php
  58. 15 0
      database/factories/OracleBasSKUFactory.php
  59. 16 0
      database/factories/OracleDOCOrderDetailFactory.php
  60. 35 0
      database/factories/OrcaleDOCOrderHeaderFactory.php
  61. 1 1
      database/factories/ShopFactory.php
  62. 12 0
      database/factories/StationFactory.php
  63. 12 0
      database/factories/StationMissionBatchFactory.php
  64. 12 0
      database/factories/StationMissionBatchTypeFactory.php
  65. 12 0
      database/factories/StationMissionCommodityFactory.php
  66. 12 0
      database/factories/StationMissionMaterialBoxFactory.php
  67. 12 0
      database/factories/StationRuleBatchFactory.php
  68. 12 0
      database/factories/StationTaskFactory.php
  69. 12 0
      database/factories/StationTaskTypeFactory.php
  70. 12 0
      database/factories/StationTypeFactory.php
  71. 13 0
      database/factories/WarehouseFactory.php
  72. 1 1
      database/migrations/2020_01_02_172739_change_waybill_price_model_field.php
  73. 1 1
      database/migrations/2020_03_09_153510_create_stores_table.php
  74. 2 1
      database/migrations/2020_04_09_111540_change_tutorial_table.php
  75. 0 1
      database/migrations/2020_06_02_130804_change_user_duty_check.php
  76. 4 4
      database/migrations/2020_06_11_112028_change_rejected_bills_table.php
  77. 1 1
      database/migrations/2020_06_16_173559_add_authorrities_waybillmanagement_freigt.php
  78. 0 1
      database/migrations/2020_06_30_133655_change_processes_contents_column_type.php
  79. 0 38
      database/migrations/2020_07_24_072012_create_orders_table.php.bak
  80. 1 1
      database/migrations/2020_07_29_155624_create_orders_table.php
  81. 1 1
      database/migrations/2020_09_10_143926_drop_shop_unique_name_index.php
  82. 1 1
      database/migrations/2020_10_19_113042_create_logistic_timings_table.php
  83. 3 1
      database/migrations/2020_11_19_113955_change_order_issue_type_id_index.php
  84. 35 0
      database/migrations/2020_11_30_140957_create_station_types_table.php
  85. 43 0
      database/migrations/2020_11_30_140958_create_stations_table.php
  86. 35 0
      database/migrations/2020_11_30_142346_create_station_rule_batches_table.php
  87. 35 0
      database/migrations/2020_11_30_142430_create_station_task_batches_table.php
  88. 33 0
      database/migrations/2020_11_30_151800_create_station_task_batch_types_table.php
  89. 32 0
      database/migrations/2020_11_30_155611_create_material_boxes_table.php
  90. 35 0
      database/migrations/2020_11_30_155713_create_station_task_material_boxes_table.php
  91. 38 0
      database/migrations/2020_11_30_174327_create_station_task_commodities_table.php
  92. 32 0
      database/migrations/2020_12_01_134905_add_order_type_to_orders.php
  93. 27 0
      database/migrations/2020_12_01_150439_change_batch_field_status_add_executing.php
  94. 38 0
      database/migrations/2020_12_03_114353_add_auth_of_station.php
  95. 38 0
      database/migrations/2020_12_03_144334_add_monitor_default_station_and_station_hardware_id_column.php
  96. 32 0
      database/migrations/2020_12_04_160314_create_station_task_types_table.php
  97. 35 0
      database/migrations/2020_12_04_175932_create_station_tasks_table.php
  98. 32 0
      database/migrations/2020_12_07_111922_add_column_handled_amount_of_station_task_commodities.php
  99. 16 0
      database/seeds/MaterialBoxSeeder.php
  100. 16 0
      database/seeds/StationMissionBatchSeeder.php

+ 1 - 1
.gitignore

@@ -26,5 +26,5 @@ yarn-error.log
 /.gitignore
 /public/icon/img404-thumbnail.jpg
 /public/phpMyAdmin4.8.5/
-/phpunit.xml
 /public/fonts
+/phpunit.xml

+ 2 - 0
app/Console/Commands/SyncBatchTask.php

@@ -138,6 +138,8 @@ class SyncBatchTask extends Command
                 }
             }
         }
+//        $this->batchService->assignTasks($batches);
+
 
         ValueStore::query()->where("name","wave_last_sync_date")->update(["value"=>Carbon::now()->subSeconds(1)->toDateTimeString()]);
     }

+ 16 - 8
app/Console/Commands/SyncWMSOrderTask.php

@@ -38,6 +38,8 @@ class SyncWMSOrderTask extends Command
      */
     public function handle()
     {
+        $is_enabled= config('sync.order_sync.cache_prefix.enabled');
+        if($is_enabled=='false')return;
         $this->syncCreatedOrder();
         $this->syncUpdatedOrder();
     }
@@ -52,24 +54,27 @@ class SyncWMSOrderTask extends Command
         $newest_list    = config('sync.order_sync.cache_prefix.newest_list');
         $hasKey         = config('sync.order_sync.cache_prefix.newest_has');
         $prefixKey      = config('sync.order_sync.cache_prefix.newest');
-
+        ini_set('memory_limit', '512M');
         $orderService = app('OrderService');
         $oracleDOCOrderHeaderService = app('OracleDocOrderHeaderService');
 
-        $last_date = $orderService->getOrderSyncAt($newest,'newest');                              // 获取时间点
-        $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnStartDate($last_date);           // WMS订单
-        if(!$orderHeaders)return;
+        $last_date = $orderService->getOrderSyncAt($newest,'newest');                             // 获取时间点
+
+        $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnStartDate($last_date);               // WMS订单
+        if($orderHeaders->count()==0)return;
         $last_order = $orderHeaders->first();                                                           // 时间点靠后的
-        $renewal_orders = $orderHeaders->where('addtime',$last_order->addtime);
+        $newest_orders = $orderHeaders->where('addtime',$last_order->addtime);
 
         $orderHeaders = $orderService->filterOrderByCache($orderHeaders,$newest_list);                  // 对比缓存
 
-        if(count($orderHeaders)>0 && count($orderHeaders) >0){
+        if(count($newest_orders)>0 && count($orderHeaders) >0){
+
             $orderService->syncOrder($orderHeaders);                                                //  同步订单
             $orderService->cancelOrderCache($newest_list,$prefixKey);                                   //  清除缓存
-            $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$newest_list);             //  添加缓存
+            $orderService->pushOrderCache($newest_orders,$prefixKey,$hasKey,$newest_list);              //  添加缓存
             $orderService->setOrderSyncAt($newest,$last_order->addtime,count($orderHeaders)>0);   //  更新时间
         }
+
     }
 
     public function syncUpdatedOrder()
@@ -82,20 +87,23 @@ class SyncWMSOrderTask extends Command
         $renewal_list   = config('sync.order_sync.cache_prefix.renewal_list');
         $hasKey         = config('sync.order_sync.cache_prefix.renewal_has');
         $prefixKey      = config('sync.order_sync.cache_prefix.renewal');
+        ini_set('memory_limit', '512M');
 
         $orderService = app('OrderService');
         $oracleDOCOrderHeaderService = app('OracleDocOrderHeaderService');
 
         $last_date = $orderService->getOrderSyncAt($renewal,'renewal');                               // 获取时间点
+
         $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnEditDate($last_date);                   // WMS订单
 
-        if(!$orderHeaders)return;
+        if($orderHeaders->count()==0)return;
         $renewal_order = $orderHeaders->first();                                                            // 时间点靠后的
         $renewal_orders =  $orderHeaders->where('edittime',$renewal_order->edittime);
 
         $orderHeaders = $orderService->filterOrderByCache($orderHeaders,$renewal_list);                     // 对比缓存
 
         if(count($renewal_orders)>0 && count($orderHeaders)>0){
+
             $orderService->syncOrder($orderHeaders);                                                    // 同步订单
             $orderService->cancelOrderCache($renewal_list,$prefixKey);                                      // 清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$renewal_list);                // 添加缓存

+ 1 - 1
app/Exceptions/Handler.php

@@ -58,7 +58,7 @@ class Handler extends ExceptionHandler
         try{
             if (method_exists($exception,'getStatusCode')) {
             $code = $exception->getStatusCode();
-            Controller::logS('exception',$code,$exception->getTraceAsString().'|| ||'.json_encode($request));
+            Controller::logS('exception',$code,$exception->getTraceAsString().'|| '.$exception->getMessage().' ||'.json_encode($request));
             switch ($code){
                 case 419:return response()->view('exception.login');
                 case 404:return response()->view('exception.404');

+ 12 - 19
app/Http/Controllers/ControlPanelController.php

@@ -24,12 +24,6 @@ class ControlPanelController extends Controller
 
     public function index()
     {
-        /**
-         * @var CheckActiveMenuService $checkActiveMenuService
-         * @var RealtimePendingOrdersService $realtimePendingOrdersService
-         * @var OrderCountingRecordService $orderCountingRecords
-         * @var LaborReportsCountingRecordService $laborReportsCountingRecordService
-         */
         $checkActiveMenuService = app(CheckActiveMenuService::class);
         $menus = $checkActiveMenuService->activeMenus();
         $realtimePendingOrdersService = app(RealtimePendingOrdersService::class);
@@ -45,24 +39,23 @@ class ControlPanelController extends Controller
         $laborReportsCountingRecordService = app(LaborReportsCountingRecordService::class);
         $laborReportsCountingRecords = $laborReportsCountingRecordService->get($start, $end, '日');
         $laborReportsUserGroupsCount = $laborReportsCountingRecordService->userGroupsCount($start, $end);
-        return view('control.panel', compact('menus', 'warehousesOrders', 'orderCountingRecords', 'logisticsCountingRecords', 'warehouseCountingRecords', 'laborReportsCountingRecords','laborReportsUserGroupsCount'));
+        return view('control.panel', compact('menus', 'warehousesOrders', 'orderCountingRecords', 'logisticsCountingRecords', 'warehouseCountingRecords', 'laborReportsCountingRecords', 'laborReportsUserGroupsCount'));
     }
 
     public function orderCountingRecordsApi(Request $request)
     {
         $orderCountingRecordService = app(OrderCountingRecordService::class);
-        $start = $request->start;
-        $end = $request->end;
-        $unit = $request->unit;
-        $orderCountingRecords = $orderCountingRecordService->orderCountingRecords($start, $end, null, $unit, null);
+        $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
+        $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
+        $orderCountingRecords = $orderCountingRecordService->orderCountingRecords($start, $end, null, $request->unit, null);
         return compact('orderCountingRecords');
     }
 
     public function logisticsCountingRecordsApi(Request $request)
     {
         $orderCountingRecordService = app(OrderCountingRecordService::class);
-        $start = $request->start;
-        $end = $request->end;
+        $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
+        $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
         $logisticsCountingRecords = $orderCountingRecordService->logisticsCountingRecords($start, $end);
         return compact('logisticsCountingRecords');
     }
@@ -70,8 +63,8 @@ class ControlPanelController extends Controller
     public function warehouseCountingRecordsApi(Request $request)
     {
         $orderCountingRecordService = app(OrderCountingRecordService::class);
-        $start = $request->start;
-        $end = $request->end;
+        $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
+        $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
         $warehouseCountingRecords = $orderCountingRecordService->warehouseCountingRecords($start, $end);
         return compact('warehouseCountingRecords');
     }
@@ -79,8 +72,8 @@ class ControlPanelController extends Controller
     public function laborReportsCountingRecordApi(Request $request)
     {
         $laborReportsCountingRecordService = app(LaborReportsCountingRecordService::class);
-        $start = $request->start;
-        $end = $request->end;
+        $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
+        $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
         $unit = $request->unit;
         $laborReportsCountingRecords = $laborReportsCountingRecordService->get($start, $end, $unit);
         return compact('laborReportsCountingRecords');
@@ -89,8 +82,8 @@ class ControlPanelController extends Controller
     public function laborReportsUserGroupsCountApi(Request $request)
     {
         $laborReportsCountingRecordService = app(LaborReportsCountingRecordService::class);
-        $start = $request->start;
-        $end = $request->end;
+        $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
+        $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
         $laborReportsUserGroupsCount = $laborReportsCountingRecordService->userGroupsCount($start, $end);
         return compact('laborReportsUserGroupsCount');
     }

+ 85 - 0
app/Http/Controllers/MaterialBoxController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\MaterialBox;
+use Illuminate\Http\Request;
+
+class MaterialBoxController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function show(MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(MaterialBox $materialBox)
+    {
+        //
+    }
+}

+ 90 - 0
app/Http/Controllers/StationController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Station;
+use Illuminate\Http\Request;
+
+class StationController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return void
+     */
+    public function index()
+    {
+
+    }
+    public function monitorIndex()
+    {
+        $stations = Station::query()->with('type:name','parent:name')->whereHas('type',function($query){
+            $query->where('name','料箱监视器');
+        })->paginate(100);
+        return view('station.monitor.index',compact('stations'));
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    public function show(Station $station)
+    {
+        //
+    }
+    public function monitorShow(Station $station)
+    {
+        return view('station.monitor.show',compact('station'));
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(Station $station)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, Station $station)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Station $station)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationRuleBatchController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationRuleBatch;
+use Illuminate\Http\Request;
+
+class StationRuleBatchController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskBatchController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskBatch;
+use Illuminate\Http\Request;
+
+class StationTaskBatchController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskBatchTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskBatchType;
+use Illuminate\Http\Request;
+
+class StationTaskBatchTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskCommodityController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskCommodity;
+use Illuminate\Http\Request;
+
+class StationTaskCommodityController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTask;
+use Illuminate\Http\Request;
+
+class StationTaskController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTask $stationTask)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskMaterialBoxController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskMaterialBox;
+use Illuminate\Http\Request;
+
+class StationTaskMaterialBoxController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskType;
+use Illuminate\Http\Request;
+
+class StationTaskTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskType $stationTaskType)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationType;
+use Illuminate\Http\Request;
+
+class StationTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationType $stationType)
+    {
+        //
+    }
+}

+ 11 - 6
app/Http/Controllers/api/thirdPart/flux/SortingController.php

@@ -86,12 +86,17 @@ class SortingController extends Controller
                         /** @var CommodityService $commodityService */
                         $commodityService=app('CommodityService');
                         $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
-                        $orderCommodity = new OrderCommodity([
-                            'order_id' => $order['id'],
-                            'commodity_id' => $commodity['id'],
-                            'amount' => $requestBarcode['fmqty_each']??0,
-                            'wms_ptltaskid' => $requestBarcode['ptltaskid'],
-                        ]);
+                        $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
+                        if(!$orderCommodity){
+                            $orderCommodity = new OrderCommodity([
+                                'order_id' => $order['id'],
+                                'commodity_id' => $commodity['id'],
+                                'amount' => $requestBarcode['fmqty_each']??0,
+                                'wms_ptltaskid' => $requestBarcode['ptltaskid'],
+                            ]);
+                        }
+                        if(!$orderCommodity['amount'])$orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
+                        if(!$orderCommodity['wms_ptltaskid'])$orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid'];
                         $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
                         if($allocation)
                             $orderCommodity['location'] = $allocation['location'];

+ 27 - 0
app/Http/Controllers/api/thirdPart/haiq/LightController.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\haiq;
+
+
+
+
+use App\Services\ForeignHaiRoboticsService;
+use Illuminate\Http\Request;
+
+class LightController
+{
+    protected $request;
+
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
+    public function __construct(){
+        $this->service=app('ForeignHaiRoboticsService');
+    }
+
+    public function lightOn(Request $request){
+    }
+    public function lightOff(Request $request){
+    }
+
+}

+ 9 - 4
app/Http/Controllers/api/thirdPart/haiq/PickStationController.php

@@ -6,19 +6,24 @@ namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 
+use App\Services\ForeignHaiRoboticsService;
 use Illuminate\Http\Request;
 
 class PickStationController
 {
-    protected $request;
 
-    public function __construct()
-    {
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
+    public function __construct(){
+        $this->service=app('ForeignHaiRoboticsService');
     }
 
     public function processed(Request $request){
         $success = $request->input('success');
-        $code= $success?200:0;
+        $code = $success?200:0;
+        $this->service->markBinProcessed();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
         return ['code'=>$code,'errMsg'=>'','data'=>$request->all()];
     }
+
 }

+ 24 - 8
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -4,16 +4,19 @@
 namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
-use App\Services\LogService;
+use App\Services\ForeignHaiRoboticsService;
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Request;
 
 class StorageController
 {
     protected $request;
 
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
     public function __construct()
     {
+        $this->service=app('ForeignHaiRoboticsService');
         $stockInfo = [
             "skuCode" => "TEST-BSSKU",//商品编码 sku
             "qty" => 9,//数量
@@ -34,12 +37,12 @@ class StorageController
             "bins" => [$bin],//可执行货箱任务
         ]];*/
         $this->request = [[
-            "taskMode"      => 8,
+            "taskMode"      => 2,
             "bins"=>[[
                 "taskCode"  =>"TEST-BS2011160004",
-                "binCode"   => "TESTBINCODE-0",
-                "fromLocCode" => "BIN-IN1",
-                //"toLocCode" => "BIN-OUT1",
+                "binCode"   => "IDE0000034",
+//                "fromLocCode" => "BIN-IN1",
+                "toLocCode" => "BIN-OUT1",
             ]],
             "groupCode"     => 4,
             "priority"      => 20,
@@ -48,10 +51,10 @@ class StorageController
     }
 
     public function relocate(Request $request){
-        $response = Http::post(config('api.haiq.storage.relocate'),$this->request);return $response;
+        $response = Http::post(config('api.haiq.storage.moveBin'),$this->request);
         if (!$response->ok()){
             app('LogService')->log(__METHOD__,"haiq-请求失败,路径异常","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
-            return ['success'=>false,"data"=>"接口异常"];
+            return ['success'=>false,"data"=>$response->body()];
         }
         if (($response["code"] ?? false) && $response["code"] != 200){
             app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
@@ -64,4 +67,17 @@ class StorageController
         app('LogService')->log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
         return ["success"=>true];
     }
+    public function moveBin(Request $request){
+
+    }
+    public function taskUpdate(Request $request){
+        $this->service->taskUpdate();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
+        return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
+    }
+    public function exception(Request $request){
+        $this->service->taskUpdate();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
+        return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
+    }
 }

+ 10 - 0
app/MaterialBox.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class MaterialBox extends Model
+{
+    protected $fillable=['code'];
+}

+ 3 - 0
app/OracleDOCOrderHeader.php

@@ -50,4 +50,7 @@ class OracleDOCOrderHeader extends Model
     public function hasUn(){
         return $this->hasMany('App\OracleDOCOrderDetail','orderno','orderno');
     }
+    public function orderType(){
+        return $this->hasOne('App\OracleBasCode','code','ordertype')->where('codeid','SO_TYP');
+    }
 }

+ 4 - 1
app/Order.php

@@ -14,7 +14,8 @@ class Order extends Model
         'id', 'batch_id',  'owner_id', 'status',
         'created_at', 'code', 'shop_id',  'client_code',
         'logistic_id', 'consignee_name', 'consignee_phone', 'province',
-        'city', 'district', 'address', 'wms_status','warehouse_id','wms_edittime'];
+        'city', 'district', 'address','warehouse_id',
+        'wms_edittime', 'wms_status','order_type'];
 
     /*
      * wms订单号             code=>DOC_ORDER_HEADER[orderno]
@@ -148,6 +149,7 @@ class Order extends Model
             $this['client_code'] = $order['client_code'] &&
             $this['wms_status'] == $order['wms_status'] &&
             $this['wms_edittime'] == $order['wms_edittime'] &&
+            $this['order_type'] == $order['order_type'] &&
             (string)$this['created_at'] == (string)$order['created_at'];
     }
 
@@ -167,6 +169,7 @@ class Order extends Model
         $this['client_code'] = $order['client_code'] ;
         $this['wms_status'] = $order['wms_status'] ;
         $this['wms_edittime'] = $order['wms_edittime'];
+        $this['order_type'] = $order['order_type'];
         $this['created_at'] =$order['created_at'];
     }
 }

+ 12 - 0
app/Providers/AppServiceProvider.php

@@ -4,6 +4,7 @@ namespace App\Providers;
 
 use App\Http\Controllers\Controller;
 use App\Services\AuthorityService;
+use App\Services\BatchService;
 use App\Services\CacheService;
 use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
@@ -12,6 +13,7 @@ use App\Services\common\DataHandlerService;
 use App\Services\CustomerService;
 use App\Services\DepositoryService;
 use App\Services\FeatureService;
+use App\Services\ForeignHaiRoboticsService;
 use App\Services\InventoryAccountMissionService;
 use App\Services\InventoryCompareService;
 use App\Services\LaborReportsCountingRecordService;
@@ -20,6 +22,7 @@ use App\Services\OracleBasCustomerService;
 use App\Services\OracleBasSkuService;
 use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDOCOrderHeaderService;
+use App\Services\OrderCommodityService;
 use App\Services\OrderCommodityAssignService;
 use App\Services\OrderCountingRecordService;
 use App\Services\OrderIssuePerformanceService;
@@ -56,6 +59,9 @@ use App\Services\RejectedBillItemService;
 use App\Services\RejectedBillService;
 use App\Services\ShopService;
 use App\Services\RejectedService;
+use App\Services\StationTaskBatchService;
+use App\Services\StationTaskBatchTypeService;
+use App\Services\StationService;
 use App\Services\StoreCheckingReceiveItemService;
 use App\Services\StoreCheckingReceiveService;
 use App\Services\StoreItemService;
@@ -120,6 +126,7 @@ class AppServiceProvider extends ServiceProvider
     }
 
     private function loadingService(){
+        app()->singleton('BatchService',BatchService::class);
         app()->singleton('CacheService',CacheService::class);
         app()->singleton('UserService',UserService::class);
         app()->singleton('AuthorityService',AuthorityService::class);
@@ -136,6 +143,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('PackageStatisticsService',PackageStatisticsService::class);
         app()->singleton('OracleActAllocationDetailService',OracleActAllocationDetailService::class);
         app()->singleton('ShopService',ShopService::class);
+        app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
         app()->singleton('OrderPackageService',OrderPackageService::class);
         app()->singleton('OrderIssueService',OrderIssueService::class);
         app()->singleton('OrderService',OrderService::class);
@@ -152,6 +160,9 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
         app()->singleton('ProcessesContentService',ProcessesContentService::class);
         app()->singleton('StoreService',StoreService::class);
+        app()->singleton('StationTaskBatchService',StationTaskBatchService::class);
+        app()->singleton('StationTaskBatchTypeService',StationTaskBatchTypeService::class);
+        app()->singleton('StationService',StationService::class);
         app()->singleton('WarehouseService',WarehouseService::class);
         app()->singleton('StoreItemService',StoreItemService::class);
         app()->singleton('PackageService',PackageService::class);
@@ -185,6 +196,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OracleDocOrderHeaderService',OracleDOCOrderHeaderService::class);
         app()->singleton('OracleActAllocationDetailService',OracleActAllocationDetailService::class);
         app()->singleton('OrderIssueProcessLogService',OrderIssueProcessLogService::class);
+        app()->singleton('OrderCommodityService',OrderCommodityService::class);
     }
 
     private function loadingBasedModuleService(){

+ 30 - 5
app/Services/BatchService.php

@@ -1,11 +1,18 @@
-<?php 
+<?php
 
-namespace App\Services; 
+namespace App\Services;
 
 use App\Batch;
+use Exception;
 
 Class BatchService
-{ 
+{
+    /** @var StationTaskBatchService $stationTaskBatchService */
+    private $stationTaskBatchService;
+    public function __construct(){
+        $this->stationTaskBatchService=null;
+    }
+
     public function get(array $params)
     {
         $query = Batch::query();
@@ -18,7 +25,25 @@ Class BatchService
 
     public function insert(array $insert)
     {
-        return Batch::query()->insert($insert);
+        $result = Batch::query()->insert($insert);
+        if($result)$this->assignTasks($insert);
+        return $result;
+    }
+
+    public function updateWhereIn($key,$values,$updateKeyValues){
+        Batch::query()->whereIn($key,$values)->update($updateKeyValues);
+    }
+
+    /**
+     * 为波次附加任务,已附加的重复任务不影响
+     * @param Batch[] $batches
+     * @throws Exception
+     */
+    public function assignTasks(array $batches)
+    {
+        $this->stationTaskBatchService=app('StationTaskBatchService');
+        $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches);
+
     }
 
-}
+}

+ 124 - 0
app/Services/CommodityService.php

@@ -8,12 +8,20 @@ use App\CommodityBarcode;
 use App\OracleBasSKU;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
+use App\Shop;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\Cache;
 
 Class CommodityService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
+
     public function firstOrCreate($param,$column = null):Commodity{
         if ($column) return Commodity::query()->firstOrCreate($param,$column);
         return Commodity::query()->firstOrCreate($param);
@@ -332,4 +340,120 @@ Class CommodityService
         if ($query->count() > 0)return true;
         return false;
     }
+
+    public function getCommoditiesByMap($map)
+    {
+        /**
+         * @var OwnerService $ownerService
+         * @var OracleBasSkuService $oracleBasSkuService
+         */
+        $ownerService = app('OwnerService');
+        $oracleBasSkuService = app('OracleBasSkuService');
+
+        $commodities_map = (function()use($map){
+            $commodities_map = [];
+            if(count($map)==0)return $commodities_map;
+            Commodity::query()->with("owner")->whereIn('sku',array_unique(data_get($map,'*.sku')))->whereHas('owner',function($query)use($map){
+                $query->whereIn('code',array_unique(data_get($map,'*.owner_code')));
+            })->get()->each(function($commodity)use(&$commodities_map){
+                $commodities_map[json_encode(['owner_code' => $commodity['owner']['code'], 'sku' => $commodity['sku']])] = $commodity;
+            });
+            return $commodities_map;
+        })();
+
+        $owner_codes = (function()use($map){
+            $owner_codes = [];
+            if(count($map) == 0)return $owner_codes;
+            foreach ($map as $item) {
+                $owner_codes[$item['owner_code']] = $item['owner_code'];
+            }
+            return $owner_codes;
+        })();
+
+        $owner_map = (function()use($ownerService,$owner_codes){
+            $owners = $ownerService->getOwnerByCodes($owner_codes);
+            $map = [];
+            $owners->each(function ($owner)use(&$map){
+                $map[$owner['code']] = $owner['id'];
+            });
+            return $map;
+        })();
+
+        $collect = collect();
+        if(count($map) == 0) return $collect;
+        $unexists = [];$sku = [];$owner_code = [];
+
+        foreach ($map as $item) {
+            $owner = Cache::get("owner_code_{$item['owner_code']}_sku_{$item['sku']}");
+            if($owner){
+                $collect->push($owner);
+                continue;
+            }
+            $key = json_encode( ['owner_code' => $item['owner_code'], 'sku' => $item['sku']]);
+            if(!empty($commodities_map[json_encode($key)])){
+                 $commodities_map[$key];
+                continue;
+            }
+            $unexists[json_encode($key)] = true;
+            $sku[] = $item['sku'];
+            $owner_code[] = $item['owner_code'];
+        }
+
+        if(count($unexists) == 0)return $collect;
+        $BasSKUs = $oracleBasSkuService->get( ['SKU'=>$sku,'CustomerID'=>$owner_code]);
+        $BasSKUs = $BasSKUs->filter(function($bas_sku)use($unexists,$commodities_map){
+            $arr = [
+                'owner_code' => $bas_sku['customerid'],
+                'sku' => $bas_sku['sku']
+            ];
+            $key = json_encode($arr);
+            if(!empty($commodities_map($key)))return false;
+            return $unexists[json_encode($arr)] ?? false;
+        });
+        $inner_params = (function()use($BasSKUs,$owner_map){
+            $map = [];
+            $date = Carbon::now();
+            $BasSKUs->each(function($basSku)use(&$map,$owner_map,$date){
+                $map[] = [
+                    'owner_id' => $owner_map[$basSku['customerid']] ?? '',
+                    'sku' => $basSku->sku,
+                    'name' =>$basSku->descr_c,
+                    'length' =>$basSku->skulength,
+                    'width' => $basSku->skuwidth,
+                    'height' => $basSku->skuhigh,
+                    'volumn' => $basSku->cube,
+                    'created_at' => $date,
+                    'updated_at' => $date,
+                ];
+            });
+            return $map;
+        })();
+        if(count($inner_params)==0)return $collect;
+        foreach (array_chunk($inner_params,4000) as $item) {
+            try {
+                $bool = Commodity::query()->insert($item);
+                if($bool){
+                    app('LogService')->log(__METHOD__,__FUNCTION__,"批量添加 Commodity Success ".count($inner_params).' || '.json_encode($inner_params));
+                    $commodities = Commodity::query()->with('owner')->whereIn('owner_id',data_get($item,'*.owner_id'))->whereIn('sku',data_get($item,'*.sku'))->get();
+                    $this->pushToCache($commodities);
+                    $collect = $collect->concat($commodities);
+                }
+                else app('LogService')->log(__METHOD__,__FUNCTION__,"批量添加 Commodity FAILED ".' || '.json_encode($inner_params));
+            } catch (\Exception $e) {
+                app('LogService')->log(__METHOD__,__FUNCTION__,"批量添加 Commodity ERROR ".' || '.json_encode($inner_params).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            }
+        }
+        return $collect;
+    }
+
+    private function pushToCache($commodities)
+    {
+        if (count($commodities) < 1) return null;
+        foreach ($commodities as $commodity) {
+            $commodity_key = "owner_code_{$commodity['owner']['code']}_sku_{$commodity['sku']}";
+            Cache::remember($commodity_key, config('cache.expirations.forever'), function () use ($commodity) {
+                return $commodity;
+            });
+        }
+    }
 }

+ 25 - 0
app/Services/ForeignHaiRoboticsService.php

@@ -0,0 +1,25 @@
+<?php
+
+
+namespace App\Services;
+
+
+use Illuminate\Http\Request;
+
+class ForeignHaiRoboticsService
+{
+
+    public function moveBin(){
+
+    }
+
+    public function markBinProcessed(){
+
+    }
+    public function taskUpdate(){
+
+    }
+    public function throwException(){
+
+    }
+}

+ 20 - 0
app/Services/LogisticService.php

@@ -4,9 +4,11 @@ namespace App\Services;
 
 use App\Logistic;
 use App\OracleBasCustomer;
+use App\Shop;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Str;
 
 Class LogisticService
@@ -88,5 +90,23 @@ Class LogisticService
         return Logistic::query()->find($id);
     }
 
+    public function getLogisticByCodes($codes)
+    {
+        $collect = collect();
+        if(count($codes) == 0) return $collect;
+        foreach ($codes as $code) {
+            $collect->push(Cache::remember("getLogisticByCodes_{$code}", config('database.cache.expirations.rand'), function()use($code){
+                $logistic = Logistic::query()->where('code',$code)->first();
+                if($logistic)return $logistic;
+                $baseCustomers = OracleBasCustomer::query()
+                    ->selectRaw('Customer_Type,CustomerID,Descr_C')
+                    ->where('Customer_Type','CA')
+                    ->where('CustomerID',$code)->first();
+                if(!$baseCustomers)return null;
+                return Logistic::query()->create(['name' => $baseCustomers['descr_c'], 'code' => $baseCustomers['customerid']]);
+            }));
+        }
+        return $collect;
+    }
 
 }

+ 8 - 3
app/Services/OracleDOCOrderHeaderService.php

@@ -20,7 +20,7 @@ Class OracleDOCOrderHeaderService
         'DOC_Order_Header.CarrierName', 'DOC_Order_Header.LastShipmentTime','DOC_Order_Header.EDISendFlag',
         'DOC_Order_Header.SOReference5', 'DOC_Order_Header.C_Tel2','DOC_Order_Header.Transportation',
         'DOC_Order_Header.WareHouseId','DOC_Order_Header.SOStatus','DOC_Order_Header.C_Tel1','DOC_Order_Header.C_District',
-        'DOC_Order_Header.IssuePartyName'
+        'DOC_Order_Header.IssuePartyName','DOC_Order_Header.OrderType'
     ];
 
     function first(array $params){
@@ -71,13 +71,16 @@ Class OracleDOCOrderHeaderService
             ->with(['oracleBASCustomer'=>function($query){
                 $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
             },'oracleDOCOrderDetails'=>function($query){
-                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
+                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered,doc_order_details.Location');
             }, 'actAllocationDetails'=>function($query){
                 $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
             },'oracleBASCode'=>function($query){
                 $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
+            },'orderType'=>function($query){
+                $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
             }])
             ->where('DOC_Order_Header.addTime','>=',$startDate)
+            ->whereColumn('DOC_Order_Header.editTime','=','DOC_Order_Header.addTime')
             ->orderByDesc('DOC_Order_Header.addTime')
             ->get();
     }
@@ -87,11 +90,13 @@ Class OracleDOCOrderHeaderService
             ->with(['oracleBASCustomer'=>function($query){
                 $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
             },'oracleDOCOrderDetails'=>function($query){
-                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
+                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered,doc_order_details.Location');
             }, 'actAllocationDetails'=>function($query){
                 $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
             },'oracleBASCode'=>function($query){
                 $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
+            },'orderType'=>function($query){
+                $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
             }])
             ->where('DOC_Order_Header.editTime','>=',$startDate)
             ->whereColumn('DOC_Order_Header.editTime','!=','DOC_Order_Header.addTime')

+ 212 - 0
app/Services/OrderCommodityService.php

@@ -0,0 +1,212 @@
+<?php
+
+namespace App\Services;
+
+use App\Order;
+use App\OrderCommodity;
+use Carbon\Carbon;
+
+Class OrderCommodityService
+{
+    public function syncOrderCommodities(&$orderHeaders)
+    {
+        /**
+         * @var CommodityService $commodityService
+         * @var OwnerService $ownerService
+         */
+        $commodityService = app('CommodityService');
+        $ownerService = app('OwnerService');
+        if(count($orderHeaders) == 0)return ;
+        $order_nos = array_unique(data_get($orderHeaders,'*.orderno'));
+        $commodities_map = [];$owners_id_maps = [];
+        $owner_code_maps = (function()use(&$ownerService,&$orderHeaders,&$owners_id_maps){
+            $customer_ids= array_unique(data_get($orderHeaders,'*.customerid'));
+            $owners = $ownerService->getOwnerByCodes($customer_ids);
+            $owner_code_maps = [];
+            if(count($owners) == 0)return $owner_code_maps;
+            foreach ($owners as $owner) {
+                $owner_code_maps[$owner['code']]= $owner['id'];
+                $owners_id_maps[$owner['id']] =  $owner['code'];
+            }
+            return $owner_code_maps;
+        })();
+        // 重组OrderDetails
+        $orderDetails_map = (function()use(&$orderHeaders,&$owner_code_maps,&$commodities_map){
+            $map = [];
+            if(count($orderHeaders)==0)return $map;
+            foreach ($orderHeaders as $orderHeader) {
+                $Order_Details = $orderHeader->oracleDOCOrderDetails;
+                $Order_Details->each(function($item)use(&$map,&$owner_code_maps,&$commodities_map){
+                    if(!empty($item['customerid']) && !empty($item['sku'])){
+                        $key = "owner_code_{$item['customerid']}_sku_{$item['sku']}";
+                        $commodities_map[$key] =  ['owner_code'=>$item['customerid'],'sku'=>$item['sku']];
+                    }
+                    $key = "orderno_{$item['orderno']}_sku{$item['sku']}_each_{$item['qtyordered']}_location_{$item['location']}";
+                    if(empty($map[$key]))$map[$key]=[];
+                    $map[$key][] = [
+                        'code' => $item['orderno'],
+                        'sku' => $item['sku'],
+                        'owner_id'=>$owner_code_maps[$item['customerid']],
+                        'amount' => $item['qtyordered'],
+                        'location' => $item['location']
+                    ];
+                });
+            }
+            return $map;
+        })();
+        $commodities = $commodityService->getCommoditiesByMap($commodities_map);
+        $commodities_maps = (function()use($commodities,$owners_id_maps){
+            $map = [];
+            if(count($commodities) == 0)return $map;
+            foreach ($commodities as $commodity) {
+                $owner_code = $owners_id_maps[$commodity['owner_id']];
+                $key ="owner_code_{$owner_code}_sku_{$commodity['sku']}";
+                $map[$key] = $commodity;
+            }
+            return $map;
+        })();
+        $order_id_map = [];
+        $orders_map = (function()use($order_nos,&$order_id_map){
+            $map = [];
+            if(count($order_nos)==0)return $map;
+            $orders = Order::query()->whereIn('code',$order_nos)->get();
+            $orders->each(function($item)use(&$map,&$order_id_map){
+                $map[$item['code']] = ['id'=>  $item['id'], 'owner_id' =>  $item['owner_id']];
+                $order_id_map[$item['id']] = ['code'=>  $item['code'], 'owner_id' =>  $item['owner_id']];
+            });
+            return $map;
+        })();
+        $orderCommodities = OrderCommodity::query()->with('commodity','order')->whereHas('order',function($query)use($order_nos){
+            $query->whereIn('code',$order_nos);
+        })->get();
+
+        $orderCommodities_map = $this->regroupOrderCommodities($orderCommodities);              // 重组orderCommodities
+        $inner_params = $this->filterInnerParams($orderDetails_map,$orderCommodities_map);
+        $del_ids = $this->filterDeleteParams($orderDetails_map,$orderCommodities_map);
+        if(count($inner_params)>0){
+            $inner_arr = array_chunk($inner_params,4000);
+            foreach ($inner_arr as $item) {
+                $created_params = $this->createByInnerParams($item,$orders_map,$commodities_maps,$owners_id_maps);
+                $this->insert($created_params);
+            }
+        }
+        if(count($del_ids)>0){
+            $orderCommodities = OrderCommodity::query()->whereIn('id',$del_ids)->get();
+            $this->batchDelete($orderCommodities);
+        }
+    }
+
+    private function regroupOrderCommodities(&$orderCommodities)
+    {
+        $map = [];
+        if(count($orderCommodities)==0)return $map;
+        foreach ($orderCommodities as $orderCommodity) {
+            $key = "orderno_{$orderCommodity['order']['code']}_sku{$orderCommodity['commodity']['sku']}_each_{$orderCommodity['amount']}_location_{$orderCommodity['location']}";
+            if(empty($map[$key]))$map[$key] =[];
+            $map[$key][] = [
+                'id' =>$orderCommodity['id'],
+                'code' => $orderCommodity['order']['orderno'],
+                'sku' => $orderCommodity['commodity']['sku'],
+                'owner_id' => $orderCommodity['order']['owner_id'],
+                'amount' => $orderCommodity['amount'],
+                'location' => $orderCommodity['location']
+            ];
+        }
+        return $map;
+    }
+
+    private function filterInnerParams(&$orderDetails_map,&$orderCommodities_map)
+    {
+        $inner_params = [];
+        if(count($orderDetails_map) == 0)return $inner_params;
+        foreach ($orderDetails_map as $key=>&$map) {
+            if(empty($orderCommodities_map[$key])){
+                foreach ($map as &$item) {
+                    $inner_params[] = $item;
+                }
+            }elseif(count($map)>count($orderCommodities_map[$key])){
+                foreach ($map as &$obj) {
+                    if($orderCommodities_map[$key]>0)array_shift($orderCommodities_map[$key]);
+                    elseif($orderCommodities_map[$key]==0)$inner_params[] = $obj;
+                }
+            } elseif(count($map)==count($orderCommodities_map[$key]))continue;
+            unset($orderDetails_map[$key]);
+            $map = null;
+        }
+        return $inner_params;
+    }
+    private function filterDeleteParams(&$orderDetails_map,&$orderCommodities_map)
+    {
+        $del_ids = [];
+        if(count($orderDetails_map) == 0)return $del_ids;
+        foreach ($orderCommodities_map as $key=>$map) {
+            if(empty($orderDetails_map[$key])){
+                foreach ($map as &$item) {
+                    $del_ids[] = $item['id'];
+                }
+            }elseif(count($map)>count($orderDetails_map[$key])){
+                foreach ($map as $key1=>&$obj) {
+                    if(count($orderDetails_map[$key]) == 0){
+                        $del_ids [] = $obj['id'];
+                        unset($map[$key1]);
+                    } else{
+                        array_shift($orderDetails_map[$key]);
+                    }
+                }
+            }
+        }
+        return $del_ids;
+    }
+
+    private function createByInnerParams(&$inner_params,&$orders_map,&$commodities_maps,&$owner_id_maps)
+    {
+        $created_params = [];
+        if(count($inner_params) == 0)return $created_params;
+        $data = Carbon::now();
+        foreach ($inner_params as &$item) {
+            $order = $orders_map[$item['code']] ?? false;
+            if(!$order)continue;
+            $owner_code = $owner_id_maps[$item['owner_id']];
+            $key = "owner_code_{$owner_code}_sku_{$item['sku']}";
+            $commodity = $commodities_maps[$key];
+            $created_params[] = [
+                'order_id' =>$order['id'],
+                'commodity_id' =>$commodity['id'],
+                'amount' =>$item['amount'],
+                'location' =>$item['location'],
+                'created_at' =>$data,
+                'updated_at' => $data
+            ];
+        }
+        return $created_params;
+    }
+
+    public function batchDelete($orderCommodities)
+    {
+        if(count($orderCommodities) == 0)return true;
+        try {
+            $bool =  OrderCommodity::destroy(data_get($orderCommodities, '*.id'));
+            if($bool)app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities));
+            else app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities FAULT'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities).' || ');
+            return $bool;
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities ERROR'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            return false;
+        }
+    }
+
+    public function insert($innerParams){
+        if(!$innerParams)return false;
+        if(count($innerParams)==0)return false;
+        try {
+            $bool = OrderCommodity::query()->insert($innerParams);
+            if ($bool) app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities SUCCESS' . ' || ' . count($innerParams) . ' || ' . json_encode($innerParams));
+            else app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities FAULT' . ' || ' . count($innerParams) . ' || ' . json_encode($innerParams));
+            return $bool;
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities ERROR'. ' || ' . count($innerParams) . ' || ' . json_encode($innerParams).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            return false;
+        }
+    }
+}
+

+ 4 - 4
app/Services/OrderCountingRecordService.php

@@ -50,7 +50,7 @@ class OrderCountingRecordService
     public function orderCountingRecords($start, $end, $ownerIds = null, $unit = '日', $user = null)
     {
         $key = 'orderCountingRecords_' . $start . '_' . $end . '_' . $unit . '_' . Auth::user()->id;
-        return Cache::remember($key, 1, function () use ($start, $end, $unit, $ownerIds, $user) {
+        return Cache::remember($key, 60, function () use ($start, $end, $unit, $ownerIds, $user) {
             $orders = $this->get($start, $end, null, $unit, null);
             $dataList = collect();
             $orders->groupBy('date_target')->each(function ($items) use (&$dataList, $unit) {
@@ -160,8 +160,8 @@ class OrderCountingRecordService
         $countingOwnerIds = $this->getCountingOwnerIds($ownerIds, $user);
         $resultOrders = collect();
         $unExistingOrders = [];
-        $carbonInterfaces = $this->periodDateToArray($start, $end, $unit);
-        foreach ($carbonInterfaces as $dateStr) {
+        $dateArray = $this->periodDateToArray($start, $end, $unit);
+        foreach ($dateArray as $dateStr) {
             foreach ($countingOwnerIds as $ownerId) {
                 $key = "order_counting_records_{$dateStr}_{$ownerId}_{$unit}";
                 $orders = Cache::get($key);
@@ -191,7 +191,7 @@ class OrderCountingRecordService
                 $key = "order_counting_records_{$dateStr}_{$owner_id}_{$unit}";
                 $ttl = 3600 * 24;
                 if ($dateStr == Carbon::now()->toDateString()) {
-                    $ttl = 1;
+                    $ttl = 70;
                 }
                 Cache::put($key, $item, $ttl);
             });

+ 15 - 2
app/Services/OrderIssueService.php

@@ -219,6 +219,18 @@ class OrderIssueService
                 }
             });
         }
+        if(isset($condition['sendOrderClientCode'])){
+            $query->whereHas('secondOrder',function($query)use($condition){
+                $this->searchWay($query,$condition['sendOrderClientCode'],'client_code');
+            });
+            $query->orWhere('second_client_no',$condition['sendOrderClientCode']);
+        }
+        if(isset($condition['sendOrderLogisticNumber'])){
+            $query->whereHas('secondOrder.packages',function($query)use($condition){
+                $this->searchWay($query,$condition['sendOrderLogisticNumber'],'logistic_number');
+            });
+            $query->orWhere('second_logistic_number',$condition['sendOrderLogisticNumber']);
+        }
         return $query;
     }
 
@@ -333,7 +345,8 @@ class OrderIssueService
                 'imported_status' => $imported_status,
                 'custom_code' => $custom_code,
                 'hidden_tag' => $hiddenTag,
-                'updated_at' => $data
+                'updated_at' => $data,
+                'created_at' => $data
             ];
         }
         try {
@@ -517,7 +530,7 @@ class OrderIssueService
 
     public function createOrderIssue($logisticNumber, $type, $result_explain, $importedStatus = '正常', $custom_code = null,$hiddenTag = null)
     {
-        $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
+        $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode','orderType'])
             ->whereHas('actAllocationDetails', function ($query) use ($logisticNumber) {
                 $query->where('picktotraceid', $logisticNumber);
             })->get();

+ 46 - 33
app/Services/OrderPackageCommoditiesService.php

@@ -606,28 +606,48 @@ class OrderPackageCommoditiesService
          * @var DataHandlerService $dataHandService
          * @var CommodityService $commodityService
          * @var OrderPackageService $orderPackageService
+         * @var OwnerService $ownerService
          */
         $dataHandService = app('DataHandlerService');
         $commodityService = app('CommodityService');
         $orderPackageService  = app( 'OrderPackageService');
+        $ownerService  = app( 'OwnerService');
         if(!$orderHeaders)return ;
 
-        $commodityService->getByWmsOrders($orderHeaders);   // 预先处理     3s
+        $map = [];
+        foreach ($orderHeaders as $orderHeader) {
+            $Order_Details = $orderHeader->oracleDOCOrderDetails;
+            $Order_Details->each(function($item)use(&$map){
+                if(!empty($item['customerid']) && !empty($item['sku'])){
+                    $key = "owner_code_{$item['customerid']}_sku_{$item['sku']}";
+                    $map[$key] =  ['owner_code'=>$item['customerid'],'sku'=>$item['sku']];  // 货主编码 sku编码
+                }
+            });
+        }
+        $commodities = $commodityService->getCommoditiesByMap($map);   // 预先处理     3s
         $orderPackages = $orderPackageService->getByWmsOrders($orderHeaders);
         $orderCommodities = $this->getByWmsOrder($orderHeaders);
+        $owner_code_map = [];
+        $owner_id_map = (function()use(&$orderHeaders,&$ownerService,&$owner_code_map){
+            $owner_id_map = [];
+            $owners = $ownerService->getOwnerByCodes(array_unique(data_get($orderHeaders,'*.customerid')));
+            if(count($owners) == 0) return $owner_id_map;
+            foreach ($owners as $owner) {
+                $owner_id_map[$owner['id']] = $owner;
+                $owner_code_map[$owner['code']]  = $owner;
+            }
+            return $owner_id_map;
+        })();
 
         $package_map = $dataHandService->dataHeader(['logistic_number'],$orderPackages);
         $orderCommodities = $this->regroupOrderCommodities($orderCommodities);
-
         $orderAllocationDetails = $this->regroupWmsOrderAllocationDetails($orderHeaders);
         $del_orderCommodities  =[];
-
         $update_params =$this->filterUpdateParams($orderAllocationDetails,$orderCommodities,$del_orderCommodities);                  // 修改
-        $inner_params = $this->filterInnerParams($orderAllocationDetails,$orderCommodities);                              // 创建
+        $inner_params = $this->filterInnerParams($orderAllocationDetails,$orderCommodities);                                            // 创建
         $delete_params = $this->filterDeleteParams($orderAllocationDetails,$orderCommodities);                                           // 删除
-
         if(count($inner_params)>0)
-            $this->createOrderCommodities($inner_params,$package_map);  // 创建 3s
+            $this->createOrderCommodities($inner_params,$package_map,$commodities,$owner_id_map);  // 创建 3s
 
         if(count($update_params)>0)
             $this->updateOrderCommodities($update_params);              // 更新
@@ -750,26 +770,19 @@ class OrderPackageCommoditiesService
         return $del_params;
     }
     // TODO  根据数据创建
-    public function createOrderCommodities($inner_params,$package_map)
+    public function createOrderCommodities(&$inner_params,&$package_map,&$commodities,&$owner_id_map)
     {
         /** @var DataHandlerService $dataHandlerService */
         $dataHandlerService  = app('DataHandlerService');
-        $sku = [];$owners = [];
-        foreach ($inner_params as $inner_param) {
-            $sku_code = $inner_param['sku'];$owner_code = $inner_param['owner_code'];
-            if(!isset($sku[$sku_code]))
-                $sku[$sku_code] = $sku_code;
-            if(!isset($owner_code[$owner_code]))
-                $owners[$owner_code] = $owner_code;
-        }
-        $commodities = Commodity::query()->with('owner')->whereHas('owner',function ($query)use($owners){
-            $query->whereIn('code',$owners);
-        })->whereIn('sku',$sku)->get();
-        $commodity_map = [];
-        foreach ($commodities as $commodity) {
-            $key = ' owner='.$commodity->owner->code.' sku='.$commodity->sku;
-            $commodity_map[$key] = $commodity;
-        }
+        $commodity_map = (function()use(&$commodities,&$owner_id_map){
+            $map = [];
+            foreach ($commodities as $commodity) {
+                $owner = $owner_id_map[$commodity['owner_id']] ;
+                $key = ' owner='.$owner->code.' sku='.$commodity->sku;
+                $map[$key] = $commodity;
+            }
+            return $map;
+        })();
         $create_params =[];
         $date = Carbon::now();
         foreach ($inner_params as $inner_param) {
@@ -786,19 +799,19 @@ class OrderPackageCommoditiesService
             ];
         }
         if(count($create_params)>0){
-            try {
-                $inner_array = array_chunk($create_params,1000);
-                foreach ($inner_array as $item) {
+            $inner_array = array_chunk($create_params,5000);
+            foreach ($inner_array as $item) {
+                try {
                     $bool = $this->insert($item);
-                    LogService::log(__METHOD__,__FUNCTION__,'批量添加 orderCommodity --'. $bool ." || ".count($create_params).' || '.json_encode($create_params));
+                    LogService::log(__METHOD__, __FUNCTION__, '批量添加 orderCommodity ' . ($bool > 0 ? 'SUCCESS' : 'FAULT') . " || " . count($item) . ' || ' . json_encode($create_params));
+                } catch (\Exception $e) {
+                    LogService::log(__METHOD__,__FUNCTION__.'error','批量添加 orderCommodity ERROR'." || ".count($item).' || '.json_encode($item). ' || '.json_encode($e->getMessage()). ' || '.json_encode($e->getTraceAsString()));
                 }
-            } catch (\Exception $e) {
-                LogService::log(__METHOD__,__FUNCTION__.'error','批量添加 orderCommodity error'." || ".count($create_params).' || '.json_encode($create_params));
             }
         }
     }
     // TODO
-    public function updateOrderCommodities($orderCommodities)
+    public function updateOrderCommodities(&$orderCommodities)
     {
         if(!$orderCommodities)return ;
         $updated_at = Carbon::now();
@@ -816,17 +829,17 @@ class OrderPackageCommoditiesService
             $this->batchUpdate($update_params);
     }
     // TODO 删除
-    public function deleteOrderCommodities($orderCommodities){
+    public function deleteOrderCommodities(&$orderCommodities){
         if(!$orderCommodities)return;
         if(count($orderCommodities)==0)return;
         try {
             $ids = data_get($orderCommodities, '*.id');
             if(count($ids) >0){
                 $bool = OrderPackageCommodities::query()->whereIn('id', data_get($orderCommodities, '*.id'))->delete();
-                LogService::log(__METHOD__, __FUNCTION__, '批量删除 OrderCommodity -- ' . $bool . '||' .count($orderCommodities)  . ' || ' . json_encode($orderCommodities));
+                LogService::log(__METHOD__, __FUNCTION__, '批量删除 OrderCommodity '  . ($bool > 0 ? 'SUCCESS' : 'FAULT') .'||' .count($orderCommodities)  . ' || ' . json_encode($orderCommodities));
             }
         } catch (\Exception $e) {
-            LogService::log(__METHOD__, __FUNCTION__.' error', '批量删除 OrderCommodity Error-- ' . $e->getMessage() . '||' . $e->getTraceAsString() );
+            LogService::log(__METHOD__, __FUNCTION__.' error', '批量删除 OrderCommodity Error' . ' || ' . json_encode($e->getMessage()) . ' || ' . json_encode($e->getTraceAsString()));
         }
 
     }

+ 9 - 1
app/Services/OrderPackageService.php

@@ -392,7 +392,9 @@ class OrderPackageService
          * @var OrderPackageCommoditiesService $OrderPackageCommoditiesService
          */
         $OrderPackageCommoditiesService = app('OrderPackageCommoditiesService');
+
         $this->syncPackageByOrderHeaders($orderHeaders);
+
         $OrderPackageCommoditiesService->syncOrderPackageCommodities($orderHeaders);
     }
     // TODO
@@ -407,16 +409,22 @@ class OrderPackageService
         $orderPackageCommodityService= app('OrderPackageCommoditiesService');
         $orderTrackingService = app('OrderTrackingService');
         if(!$orderHeaders)return;
+
         $orders = $orderService->getByWmsOrders($orderHeaders);
+
         $packages = $this->getByOrderNos(data_get($orderHeaders,'*.orderno'));          // 已有
+
         $this->createOrderPackage($orderHeaders,$orders,$packages);                     // 创建package
 
         $del_ids = $this->deleteUnnecessaryPackage($orderHeaders,$packages);     // 删除package
+
         $orderPackageCommodityService->deleteUnnecessaryOrderCommodities($del_ids);     // 删除 orderCommodity
 
         $orderTracking = OrderTracking::query()->whereHas('commodities.package',function($query)use($del_ids){
             $query->whereIn('id',$del_ids);
         })->get();
+        if($orderTracking->count()==0)return;
+
         $orderTrackingService->deleteOrderTracings($orderTracking);                     // 删除追踪件
     }
     // TODO
@@ -439,7 +447,7 @@ class OrderPackageService
         }
         if(count($inner_params)>0){
             try {
-                $inner_array = array_chunk($inner_params,1000);
+                $inner_array = array_chunk($inner_params,5000);
                 foreach ($inner_array as $params) {
                     $bool = $this->insert($params);
                     $bool ? LogService::log(__METHOD__, __FUNCTION__, '批量添加 OrderPackage ' . count($inner_params) . ' || ' . json_encode($inner_params)) : null;

+ 56 - 35
app/Services/OrderService.php

@@ -681,7 +681,7 @@ class OrderService
     public function getByWmsOrders($orderHeaders){
         if(!$orderHeaders){return null;}
         $order_nos = data_get($orderHeaders,'*.orderno');
-        return Order::query()->whereIn('code',$order_nos)->get();
+        return Order::query()->with('packages.commodities')->whereIn('code',$order_nos)->get();
     }
 
     public function 返回有问题件的订单号($orders)
@@ -774,20 +774,25 @@ class OrderService
         return  $orders ? $orders->first() : null ;
     }
 
-    // TODO
     public function syncOrder(&$orderHeaders)
     {
         /**
          * @var OrderPackageService $packageService
+         * @var OrderCommodityService $orderCommodityService
          */
         $packageService = app("OrderPackageService");
+        $orderCommodityService = app("OrderCommodityService");
+
         $this->syncOrderByWMSOrderHeaders($orderHeaders);
+
+        $orderCommodityService->syncOrderCommodities($orderHeaders);
+
         $packageService->syncOrderPackage($orderHeaders);
     }
-    // TODO
+
     public function syncOrderByWMSOrderHeaders(&$orderHeaders)
     {
-        if($orderHeaders->isEmpty())return [];
+        if($orderHeaders->isEmpty())return;
         /**
          * @var OwnerService $ownerService
          * @var LogisticService $logisticService
@@ -798,33 +803,51 @@ class OrderService
         $logisticService = app("LogisticService");
         $shopService = app('ShopService');
         $warehouseService = app('WarehouseService');
+        $owner_codes = [];$logistic_codes = [];$warehouse_codes = [];$shop_names = [];
+        foreach ($orderHeaders as $orderHeader) {
+            if(!empty($orderHeader['customerid']))
+                $owner_codes[$orderHeader['customerid']] = $orderHeader['customerid'];
+            if(!empty($orderHeader['warehouseid']))
+                $warehouse_codes[$orderHeader['warehouseid']] = $orderHeader['warehouseid'];
+            if(!empty($orderHeader['userdefine1']))
+                $logistic_codes[$orderHeader['userdefine1']] = $orderHeader['userdefine1'];
+            if(!empty($orderHeader['issuepartyname']) && !empty($orderHeader['customerid'])){
+                $value = ['owner_code'=>$orderHeader['customerid'],'issuepartyname'=>$orderHeader['issuepartyname']];
+                $key = "owner_code_{$orderHeader['customerid']}_issuepartyname_{$orderHeader['issuepartyname']}";
+                $shop_names[$key] = $value;
+            }
+        }
+        $owners = $ownerService->getOwnerByCodes($owner_codes);
+        $logistics = $logisticService->getLogisticByCodes($logistic_codes);
+        $shops = $shopService->getShopByCodeMap($shop_names);
+        $warehouses = $warehouseService->getWareHouseByCode($warehouse_codes);
 
-        $owners = $ownerService->getByWmsOrders($orderHeaders);
-        $logistics = $logisticService->getByWmsOrders($orderHeaders);
-        $shops = $shopService->getByWmsOrders($orderHeaders);
-        $warehouses = $warehouseService->getByWmsOrders($orderHeaders);
         $orders = $this->getByWmsOrders($orderHeaders);
+
         $created_params = $this->getCreateOrderModelsByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops); //3s
 
         $update_order = $this->getUpdateOrderModelByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops);
+
+
         // 转换插入 3s
         if(count($created_params) > 0){
-            collect($created_params)->chunk(4000)->each(function($inner_params){
+            collect($created_params)->chunk(3500)->each(function($inner_params){
                 $this->insert($inner_params->toArray());
             });
         }
         $update_params = [
-            ['id','code','warehouse_id','owner_id','shop_id','logistic_id','consignee_name','consignee_phone','province','city','district','address','client_code','wms_status','created_at','updated_at','wms_edittime']
+            ['id','code','warehouse_id','owner_id','shop_id','logistic_id','consignee_name','consignee_phone','province','city','district','address','client_code','wms_status','created_at','updated_at','wms_edittime','order_type']
         ];
-        $update_order->map(function ($item){
-            return $item->toArray();
-        })->each(function($item)use(&$update_params){
-            $update_params[] =$item;
+
+        $update_order->each(function($item)use(&$update_params){
+            $update_params[] = $item->toArray();
         });
+        if(count($update_order)==0)return;
+
         $this->batchUpdate($update_params);
     }
-    // TODO
-    public function getCreateOrderModelsByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops)
+
+    public function getCreateOrderModelsByWMSOrderHeaders(&$orderHeaders,&$orders,&$warehouses,&$owners,&$logistics,&$shops)
     {
         /** @var DataHandlerService $dataHandlerService */
         $dataHandlerService = app('DataHandlerService');
@@ -835,7 +858,6 @@ class OrderService
         $shop_map = $dataHandlerService->dataHeader(['name','owner_id'],$shops);
         $order_map = $dataHandlerService->dataHeader(['code'],$orders);
 
-//        $collect = collect();
         $inner_params  = [];
         $date = (string)Carbon::now();
         foreach ($orderHeaders as $orderHeader) {
@@ -844,12 +866,11 @@ class OrderService
             if(isset($order))continue;
             $order_model = $this->getCreateOrderModels($orderHeader,$warehouse_map,$owner_map,$logistic_map,$shop_map,$date);
             $inner_params[] = $order_model;
-//            $collect->push($order_model);
         }
         return $inner_params;
     }
-    // TODO
-    public function getUpdateOrderModelByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops)
+
+    public function getUpdateOrderModelByWMSOrderHeaders(&$orderHeaders,&$orders,&$warehouses,&$owners,&$logistics,&$shops)
     {
         /**
          * @var DataHandlerService $dataHandlerService
@@ -874,7 +895,7 @@ class OrderService
         }
         return $collect;
     }
-    // TODO
+
     public function getCreateOrderModels(&$orderHeader,&$warehouse_map,&$owner_map,&$logistic_map,&$shop_map,$date)
     {
         /** @var DataHandlerService $dataHandlerService */
@@ -901,6 +922,7 @@ class OrderService
             'client_code' => $orderHeader['soreference1'],
             'wms_edittime' => $orderHeader['edittime'],
             'wms_status' => $orderHeader->oracleBASCode->codename_c??'',
+            'order_type' => $orderHeader->orderType->codename_c??'',
             'updated_at' => $date,
             'created_at' => $orderHeader['addtime']
         ];
@@ -917,7 +939,7 @@ class OrderService
      * @param $updateParams
      * @return mixed
      */
-    public function UpdateOrderParamBy($shop, $logistic, $owner, $warehouse, $order, $orderHeader, string $updated_at, &$updateParams)
+    public function UpdateOrderParamBy(&$shop, &$logistic, &$owner, &$warehouse, &$order, &$orderHeader, string &$updated_at, &$updateParams)
     {
         $shop_id = $shop->id ?? null;
         $logistic_id = $logistic->id ?? null;
@@ -952,11 +974,11 @@ class OrderService
                 'updated_at' => $updated_at,
                 'created_at' => $orderHeader->addtime,
                 'wms_edittime' => $orderHeader->edittime,
+                'order_type' => $orderHeader->orderType->codename_c??'',
                 'warehouse_id' => $warehouse_id];
         }
     }
 
-    // TODO
     public function createOrFindOrder($orderHeader)
     {
         $order = Order::query()->where('code',$orderHeader->orderno)->first();
@@ -971,7 +993,7 @@ class OrderService
             return null;
         }
     }
-    // TODO
+
     public function createOrFindOrderInfo($orderHeader)
     {
         /**
@@ -984,7 +1006,7 @@ class OrderService
         $orderHeaders->push($orderHeader);
         try {
             $this->syncOrderByWMSOrderHeaders($orderHeaders);
-            $orderPackageService->syncOrderPackage($orderHeaders);
+            $orderPackageService->syncPackageByOrderHeaders($orderHeaders);
             $orderPackageCommoditiesService->syncOrderPackageCommodities($orderHeaders);
             return  Order::query()->with('packages.commodities')->where('code',$orderHeader->orderno)->first();
         } catch (\Exception $e) {
@@ -993,8 +1015,6 @@ class OrderService
         }
     }
 
-
-    // TODO
     public function setOrderSyncAt($key,$date,$bool=true){
         if($bool){
             ValueStore::query()->where('name',$key)->update(['value'=>Carbon::parse($date)->subSeconds(1)]);
@@ -1002,7 +1022,7 @@ class OrderService
             ValueStore::query()->where('name',$key)->update(['value'=>$date]);
         }
     }
-    // TODO
+
     public function getOrderSyncAt($key,$type='newest'){
         $keyValue = ValueStore::query()->where('name',$key)->first();
         if($keyValue->value)return $keyValue->value;
@@ -1011,7 +1031,7 @@ class OrderService
         if($order)return $order->created_at;
         return Carbon::now()->subSeconds(65);
     }
-    // TODO
+
     public function pushOrderCache($orderHeaders,$prefixKey,$hasKey,$list_key){
         $list = [];
         try {
@@ -1028,7 +1048,7 @@ class OrderService
 
         }
     }
-    // TODO
+
     public function filterOrderByCache($orderHeaders,$key)
     {
         /**
@@ -1046,10 +1066,11 @@ class OrderService
             return $orderHeaders;
         }
     }
-    // TODO
+
     public function cancelOrderCache($key,string $prefix)
     {
         try {
+            Redis::LLEN($key);
             $list = Cache::get($key);
             collect($list)->each(function ($item)use($prefix) {
                 Cache::forget($prefix.$item);
@@ -1058,7 +1079,7 @@ class OrderService
         } catch (\Exception $e) {
         }
     }
-    // TODO
+
     public function syncCreatedOrder(){
         /**
          * @var OracleDOCOrderHeaderService $oracleDOCOrderHeaderService
@@ -1080,12 +1101,12 @@ class OrderService
 
         if(count($orderHeaders)>0 && count($orderHeaders) >0){
             $orderService->syncOrder($orderHeaders);                                                //  同步订单
-            $orderService->cancelOrderCache($newest_list);                                              //  清除缓存
+            $orderService->cancelOrderCache($newest_list,$prefixKey);                                   //  清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$newest_list);             //  添加缓存
             $orderService->setOrderSyncAt($newest,$last_order->addTime,count($orderHeaders)>0);   //  更新时间
         }
     }
-    // TODO
+
     public function syncUpdatedOrder(){
         /**
          * @var OracleDOCOrderHeaderService $oracleDOCOrderHeaderService
@@ -1107,7 +1128,7 @@ class OrderService
 
         if(count($renewal_orders)>0 && count($orderHeaders)>0){
             $orderService->syncOrder($orderHeaders);                                                    // 同步订单
-            $orderService->cancelOrderCache($renewal_list);                                                 // 清除缓存
+            $orderService->cancelOrderCache($renewal_list,$prefixKey);                                      // 清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$renewal_list);                // 添加缓存
             $orderService->setOrderSyncAt($renewal,$renewal_order->addTime,count($orderHeaders)>0);   // 更新时间
         }

+ 8 - 4
app/Services/OrderTrackingService.php

@@ -77,6 +77,9 @@ class OrderTrackingService
         if ($params['client'] ?? false)  // 客户
             $query->where('client', 'like', $params['client']);
 
+        if(!empty($params['web_order_number']))
+            $query->where('web_order_number', 'like', $params['web_order_number'].'%');
+
         if ($params['sku'] ?? false) {
             $query->whereHas('commodities.commodity', function ($query) use ($params) {
                 $query->where('sku', $params['sku']);
@@ -210,7 +213,7 @@ class OrderTrackingService
             })->update($update);
             return['success'=> $bool > 0];
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__,__FUNCTION__,'修改追踪件'.json_encode($orderId,$param,$value).$e->getMessage().$e->getTraceAsString());
+            app('LogService')->log(__METHOD__,__FUNCTION__,'修改追踪件'.json_encode($orderId,$param,$value).json_encode($e->getMessage()).json_encode($e->getTraceAsString()));
             return['success'=> false,'fail_info'=>$e->getMessage()];
         }
     }
@@ -260,9 +263,10 @@ class OrderTrackingService
             if ($order_header['notes'] ?? false) {
                 $notes = $order_header->notes;
                 if (strpos($notes, '[')) {
-                    $arr= str_split($notes,strpos($notes,'['));
-                    $client = $arr[0] ?? '';
-                    $order_remark = str_replace(['[',']'],'', $arr[1] ?? '');
+                    $strings = [];
+                    preg_match_all('/^(.*?)(\\[)(.*?)(\\])(.*?)$/u',$notes,$strings);
+                    $client = $strings[1][0];
+                    $order_remark = $strings[3][0];
                 }
             }
             $web_order_number = null;

+ 16 - 1
app/Services/OwnerService.php

@@ -9,6 +9,7 @@ use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
 
 Class OwnerService
 {
@@ -223,5 +224,19 @@ Class OwnerService
             return Owner::query()->firstOrCreate(["code"=>$code],["code"=>$code,"name"=>$code]);
         });
     }
-
+    public function getOwnerByCodes($codes)
+    {
+        $collect = collect();
+        if(count($codes) == 0)return $collect;
+        foreach ($codes as $code) {
+            $collect->push(Cache::remember("getOwnerByCodes_{$code}", config('database.cache.expirations.rand'), function ()use($code){
+                $owner = Owner::query()->where('code',$code)->first();
+                if($owner) return $owner;
+                $basCustomer = OracleBasCustomer::query()->where('Customer_Type','OW')->where('CustomerID', $code)->first();
+                if(!$basCustomer)return null;
+                return Owner::query()->create(['name'=>$basCustomer['descr_c'],'code'=>$basCustomer['customerid']]);
+            }));
+        }
+        return $collect;
+    }
 }

+ 33 - 0
app/Services/ShopService.php

@@ -2,13 +2,21 @@
 
 namespace App\Services;
 
+use App\OracleBasCustomer;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
 use App\Shop;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 class ShopService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
+
     public function getSelection(array $column = ['id', 'name'])
     {
         return Shop::query()->select($column)->get();
@@ -86,5 +94,30 @@ class ShopService
         }
     }
 
+    public function getShopByCodeMap($map)
+    {
+        /** @var OwnerService $ownerService */
+        $ownerService = app('OwnerService');
+        $owner_codes = [];
+        foreach ($map as $item) {
+            $owner_codes[$item['owner_code']]= $item['owner_code'];
+        }
+        $owners = $ownerService->getOwnerByCodes($owner_codes);
+        $owner_map  = [];
+        $owners->each(function($owner)use(&$owner_map){
+            $owner_map[$owner['code']] = $owner;
+        });
+        $collect = collect();
+        if(count($map)==0)return $collect;
+        foreach ($map as $item) {
+            $collect->push(Cache::remember("getShopByCodeMap_{$item['owner_code']}_{$item['issuepartyname']}", null, function()use($item,$owner_map){
+                $owner = $owner_map[$item['owner_code']] ;
+                $shop = Shop::query()->where('owner_id',$owner['id'])->where('name',$item['issuepartyname'])->first();
+                if($shop)return $shop;
+                return Shop::query()->create(['owner_id'=>$owner['id'],'name'=>$item['issuepartyname']]);
+            }));
+        }
+        return $collect;
+    }
 
 }

+ 39 - 0
app/Services/StationService.php

@@ -0,0 +1,39 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Station;
+use App\StationType;
+use Exception;
+use Illuminate\Support\Facades\Cache;
+
+class StationService
+{
+    /**
+     * @param string $typeName
+     * @return Station
+     * @throws Exception
+     */
+    function getDefaultStation(string $typeName):Station{
+        $station= Cache::remember('StationType_default_name_'.$typeName,config('rarelyChange'), function ()use($typeName) {
+            $stationType= StationType::query()->where('name',$typeName)->orderBy('id')->get('id')->first();
+            if(!$stationType) throw new Exception('指定站类型获取不到');
+            return Station::query()->where('station_type_id',$stationType['id'])->first();
+        });
+        if(!$station)throw new Exception('默认站获取不到');
+        return $station;
+    }
+
+    function broadcast($station_id, $json_data){
+        //...
+        //event(new BroadcastToStation($station_id,$json_data))
+    }
+
+    function broadcastBinMonitor($station_id, ){
+        //...
+        //$this->broadcast($station_id, $json_data)
+    }
+
+}

+ 61 - 0
app/Services/StationTaskBatchService.php

@@ -0,0 +1,61 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Batch;
+use App\StationTaskBatch;
+use App\StationTaskBatchType;
+use Exception;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Cache;
+
+class StationTaskBatchService
+{
+    /** @var StationService $stationService */
+    private $stationService;
+    /** @var StationTaskBatchTypeService $stationTaskBatchTypeService */
+    private $stationTaskBatchTypeService;
+    /** @var BatchService $batchService */
+    private $batchService;
+    public function __construct(){
+        $this->stationService=null;
+        $this->stationTaskBatchTypeService=null;
+        $this->batchService=null;
+    }
+
+    /**
+     * @param $batches Batch[]
+     * @throws Exception
+     */
+    public function createByBatches(array $batches){
+        $this->stationService=app('StationService');
+        $this->stationTaskBatchTypeService=app('StationTaskBatchTypeService');
+        $this->batchService=app('BatchService');
+
+        $stationMissionBatches_toCreate=new Collection();
+        $station=$this->stationService->getDefaultStation('料箱出货口');
+        $id_stationMissionBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
+
+        $batches_handled=[];
+        foreach ($batches as $batch){
+            if ($batch['status']=='未处理'){
+                $stationMissionBatches_toCreate->push([
+                    'batch_id'=>$batch['id'],
+                    'station_id'=>$station['id'],
+                    'station_mission_batch_type_id'=> $id_stationMissionBatchType,
+                    'status'=>'待处理'
+                ]);
+                $batches_handled[]=$batch;
+            }
+        }
+        $this->batchService->updateWhereIn('id',data_get($batches_handled,'*.id'),['status'=>'处理中']);
+        $this->insert($stationMissionBatches_toCreate->toArray());
+        return $stationMissionBatches_toCreate;
+    }
+
+    public function insert(array $stationMissionBatches_inArray){
+        return StationTaskBatch::query()->insert($stationMissionBatches_inArray);
+    }
+}

+ 26 - 0
app/Services/StationTaskBatchTypeService.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Station;
+use App\StationTaskBatchType;
+use App\StationType;
+use Illuminate\Support\Facades\Cache;
+
+class StationTaskBatchTypeService
+{
+    /**
+     * @param string $key
+     * @param string $value
+     * @return Station
+     */
+    public function firstByWhere(string $key,string $value):Station{
+        return Cache::remember('station_mission_batch_type_id_by_'.$key.$value, config('rarelyChange'), function ()use($key,$value) {
+            $stationMissionBatchType =StationTaskBatchType::query()->where($key, $value)->first();
+            if(!$stationMissionBatchType)throw new \Exception("找不到 StationMissionBatchType,where $key = $value");
+            return $stationMissionBatchType;
+        });
+    }
+}

+ 33 - 5
app/Services/WarehouseService.php

@@ -7,9 +7,15 @@ use App\Owner;
 use App\Warehouse;
 use Illuminate\Support\Collection;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 Class WarehouseService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
 
     public function firstOrCreate(array $params, array $values = null)
     {
@@ -45,11 +51,17 @@ Class WarehouseService
             return $warehouses->where('code',$oracleBasCustomer->warehouseid)->count()==0;
         });
         foreach ($oracleBasCustomers as $oracleBasCustomer){
-            $wereHouse=Warehouse::query()->create([
-                'code'=>$oracleBasCustomer->customerid,
-                'name'=>$oracleBasCustomer->descr_c
-            ]);
-            $collet->push($wereHouse);
+            $params =[
+                'code' => $oracleBasCustomer->customerid,
+                'name' => $oracleBasCustomer->descr_c
+            ];
+            try {
+                $wereHouse = Warehouse::query()->create($params);
+                $collet->push($wereHouse);
+                app('LogService')->log(__METHOD__,__FUNCTION__,'创建 warehouse success'.json_encode($wereHouse));
+            } catch (\Exception $e) {
+                app('LogService')->log(__METHOD__,__FUNCTION__,'创建 warehouse error'.json_encode($params).json_encode($e->getMessage()));
+            }
         }
         return  $collet;
     }
@@ -93,4 +105,20 @@ Class WarehouseService
         return Warehouse::query()->insert($fillables);
     }
 
+    public function getWareHouseByCode($codes)
+    {
+        $collect = collect();
+        if(count($codes)==0)return $collect;
+        foreach ($codes as $code) {
+            $collect->push(Cache::remember("WareHouse_{$code}",config('database.cache.expirations.rand'),function()use($code){
+                $wareHouse =  Warehouse::query()->where('code',$code)->first();
+                if($wareHouse)return $wareHouse;
+                $bas_customer = OracleBasCustomer::query()->selectRaw('Customer_Type,CustomerId,Descr_C')->where('CustomerId',$code)->where('Customer_Type','WH')->first();
+                if(!$bas_customer) return null;
+                return Warehouse::query()->create(['name'=>$bas_customer['descr_c'],'code'=>$bas_customer['customerid']]);
+            }));
+        }
+        return $collect;
+    }
 }
+

+ 17 - 0
app/Station.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Station extends Model
+{
+    protected $fillable=['name', 'code', 'station_type_id','sequence','parent_id'];
+
+    public function type(){
+        return $this->belongsTo(StationType::class,'station_type_id');
+    }
+    public function parent(){
+        return $this->belongsTo(Station::class,'parent_id','id');
+    }
+}

+ 10 - 0
app/StationRuleBatch.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationRuleBatch extends Model
+{
+    protected $fillable=['name','station_type_id','batch_type','owner_id'];
+}

+ 10 - 0
app/StationTask.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTask extends Model
+{
+    protected $fillable = ['station_id', 'station_type_id'];
+}

+ 10 - 0
app/StationTaskBatch.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskBatch extends Model
+{
+    protected $fillable=['batch_id','station_id','station_mission_batch_type_id','status'];
+}

+ 10 - 0
app/StationTaskBatchType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskBatchType extends Model
+{
+    protected $fillable=['name'];
+}

+ 10 - 0
app/StationTaskCommodity.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskCommodity extends Model
+{
+    protected $fillable= ['station_id','material_box_id','commodity_id','amount','order_id','status','station_id'];
+}

+ 10 - 0
app/StationTaskMaterialBox.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskMaterialBox extends Model
+{
+    protected $fillable=['station_id','material_box_id','status'];
+}

+ 10 - 0
app/StationTaskType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskType extends Model
+{
+    //
+}

+ 10 - 0
app/StationType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationType extends Model
+{
+    protected $fillable=['name'];
+}

+ 9 - 1
config/api.php

@@ -37,9 +37,17 @@ return [
         ],
     ],
 
+    /** 海柔
+     *  https://was.baoshi56.com/api/thirdPart/haiq/pickStation/processed  //标记料箱已处理
+     *  https://was.baoshi56.com/api/thirdPart/haiq/storage/taskUpdate  //任务状态更新
+     *  https://was.baoshi56.com/api/thirdPart/haiq/storage/exception  //异常通知
+     */
     'haiq'=>[
         'storage'=>[
-            'relocate' => "http://59.37.126.227:65448/api/haiqEss/gr/relocate",
+//            'relocate' => "http://59.37.126.227:65448/api/haiqEss/gr/relocate",
+            'moveBin' => "http://192.168.1.201:2011/api/haiqEss/gr/relocate",  //移动料箱
+            'lightOn' => "http://192.168.1.201:2011/api/ptl/curlPTL",  //亮灯
+            'lightOff' => "",  //灭灯
         ],
     ],
 

+ 7 - 5
config/cache.php

@@ -5,11 +5,13 @@ use Illuminate\Support\Str;
 return [
 
     'expirations'=>[
-        'default'=>10,
-        'oftenChange'=>5,
-        'rarelyChange'=>60,
-        'commonFrequent'=>20,
-        'owners'=>20,
+        'default'=>10,          //默认
+        'oftenChange'=>5,       //经常改
+        'rarelyChange'=>60,     //几乎不变
+        'commonFrequent'=>20,  //一般频率
+        'forever' =>null,       //永久
+
+        'owners'=>20,           //模型Owner
     ],
     /*
     |--------------------------------------------------------------------------

+ 1 - 0
config/sync.php

@@ -9,6 +9,7 @@ return [
         'start_at'=> '',    // 开始同步WMS的时间  时间格式: yyyy-MM-dd HH:mm:ss 如 2020-09-05 13:15:16
     ],
     'order_sync' => [
+        'enabled' => true,
         'interval' => 1,   // 时间以分为单位
         'start_at'=> '',    // 开始同步WMS的时间  时间格式: yyyy-MM-dd HH:mm:ss 如 2020-09-05 13:15:16
         'cache_prefix' => [

+ 12 - 0
database/factories/MaterialBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\MaterialBox;
+use Faker\Generator as Faker;
+
+$factory->define(MaterialBox::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 18 - 0
database/factories/OracleActAllocationDetailsFactory.php

@@ -0,0 +1,18 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleActAllocationDetails;
+use Faker\Generator as Faker;
+
+$factory->define(OracleActAllocationDetails::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => $faker->name,
+        'sku'=>$faker->name,
+        'qtyordered' => $faker->numberBetween(1,50),
+        'qty_each' => $faker->numberBetween(1,50),
+        'location' => $faker->md5,
+        'picktotraceid'  => $faker->uuid
+    ];
+});

+ 14 - 0
database/factories/OracleBasCodeFactory.php

@@ -0,0 +1,14 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasCode;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasCode::class, function (Faker $faker) {
+    return [
+        'codeid' => $faker->uuid,
+        'code' => $faker->uuid,
+        'codename_c' => $faker->name,
+    ];
+});

+ 14 - 0
database/factories/OracleBasCustomerFactory.php

@@ -0,0 +1,14 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasCustomer;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasCustomer::class, function (Faker $faker) {
+    return [
+        'customer_type'=> $faker->uuid,
+        'customerid'=> $faker->uuid,
+        'descr_c'=> $faker->name
+    ];
+});

+ 15 - 0
database/factories/OracleBasSKUFactory.php

@@ -0,0 +1,15 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasSKU;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasSKU::class, function (Faker $faker) {
+    return [
+        'customerid'=>$faker->name,
+        'sku' =>$faker->name,
+        'descr_c' =>$faker->title(20),
+        'packid'=>$faker->name,
+    ];
+});

+ 16 - 0
database/factories/OracleDOCOrderDetailFactory.php

@@ -0,0 +1,16 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleDOCOrderDetail;
+use Faker\Generator as Faker;
+
+$factory->define(OracleDOCOrderDetail::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => $faker->name,
+        'sku'=>$faker->name,
+        'qtyordered' => $faker->numberBetween(1,50),
+        'location' => $faker->md5
+    ];
+});

+ 35 - 0
database/factories/OrcaleDOCOrderHeaderFactory.php

@@ -0,0 +1,35 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleDOCOrderHeader;
+use Faker\Generator as Faker;
+
+$factory->define(OracleDOCOrderHeader::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => '',
+        'ordertime' =>$faker->time(),
+        'soreference1' => $faker->uuid,
+        'consigneeid' => '',
+        'c_contact' =>$faker->title(10),
+        'consigneename' => $faker->title(11),
+        'c_address1' => $faker->address,
+        'c_city' =>$faker->city,
+        'c_province' =>$faker->city,
+        'addtime' => $faker->date(),
+        'edittime' => $faker->date(),
+        'notes' => $faker->text(15),
+        'carriername'  =>'',
+        'lastshipmenttime' => $faker->date(),
+        'edisendflag' => "Y",
+        'soreference5' => $faker->uuid,
+        'c_tel2' => $faker->phoneNumber,
+        'transportation' => $faker->phoneNumber,
+        'warehouseid' => '',
+        'sostatus' => '99',
+        'c_tel1' => $faker->phoneNumber,
+        'c_district' => $faker->city,
+        'issuepartyname'=> $faker->date(),
+    ];
+});

+ 1 - 1
database/factories/ShopFactory.php

@@ -8,6 +8,6 @@ use Faker\Generator as Faker;
 $factory->define(Shop::class, function (Faker $faker) {
     return [
         'name' => $faker->name,
-        'owner_id' => factory(\App\Owner::class),
+        'owner_id' => 1,
     ];
 });

+ 12 - 0
database/factories/StationFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Station;
+use Faker\Generator as Faker;
+
+$factory->define(Station::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionBatchFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskBatch;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskBatch::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionBatchTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskBatchType;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskBatchType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionCommodityFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskCommodity;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskCommodity::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionMaterialBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskMaterialBox;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskMaterialBox::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationRuleBatchFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationRuleBatch;
+use Faker\Generator as Faker;
+
+$factory->define(StationRuleBatch::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTaskFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTask;
+use Faker\Generator as Faker;
+
+$factory->define(StationTask::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTaskTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskType;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationType;
+use Faker\Generator as Faker;
+
+$factory->define(StationType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 13 - 0
database/factories/WarehouseFactory.php

@@ -0,0 +1,13 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Warehouse;
+use Faker\Generator as Faker;
+
+$factory->define(Warehouse::class, function (Faker $faker) {
+    return [
+        'name' => $faker->name,
+        'code' => $faker->uuid
+    ];
+});

+ 1 - 1
database/migrations/2020_01_02_172739_change_waybill_price_model_field.php

@@ -26,7 +26,7 @@ class ChangeWaybillPriceModelField extends Migration
     public function down()
     {
         Schema::table('waybill_price_models', function (Blueprint $table) {
-            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
+//            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
         });
     }
 }

+ 1 - 1
database/migrations/2020_03_09_153510_create_stores_table.php

@@ -19,7 +19,7 @@ class CreateStoresTable extends Migration
             $table->integer('warehouse_id')->nullable()->comment('仓库ID');
             $table->integer('owner_id')->index()->nullable()->comment('货主ID');
             $table->enum('stored_method',['正常','快速入库','采购入库','笕尚退货入库单','笕尚进仓入库单','笕尚移仓入库单','B2B入库','笕尚调整入库单','换货入库','初始化库存','虚拟入库','其他入库','退货入库','调拨入库'])->default('正常');
-            $table->enum('status',['待盘点','盘点中','复盘中','已完成','已审核'])->default(null)->nullable();
+            $table->enum('status',['无需入库','已入库','未入库','待推单','完全收货','部分收货','已码盘','订单创建','ASN关闭','等待释放','收货取消'])->default(null)->nullable();
             $table->string('remark')->nullable();
             $table->timestamp('deleted_at')->nullable()->index();
             $table->timestamp('updated_at')->nullable();

+ 2 - 1
database/migrations/2020_04_09_111540_change_tutorial_table.php

@@ -32,7 +32,8 @@ class ChangeTutorialTable extends Migration
             $table->longText('content')->after('name')->nullable()->comment('富文本内容');
         });
         Schema::table('users', function (Blueprint $table) {
-            $table->string('email')->unique()->change();
+//            $table->unique('email','users_email_unique');
+//            $table->string('email')->unique()->change();
         });
     }
 }

+ 0 - 1
database/migrations/2020_06_02_130804_change_user_duty_check.php

@@ -26,7 +26,6 @@ class ChangeUserDutyCheck extends Migration
     public function down()
     {
         Schema::table('user_duty_checks', function (Blueprint $table) {
-            $table->dropColumn('workgroup_id');
         });
     }
 }

+ 4 - 4
database/migrations/2020_06_11_112028_change_rejected_bills_table.php

@@ -14,8 +14,8 @@ class ChangeRejectedBillsTable extends Migration
     public function up()
     {
         Schema::table('rejected_bills',function (Blueprint $table){
-            $table->index('is_loaded');
-            $table->index('is_checked');
+            $table->index('is_loaded','rejected_bills_is_loaded_index');
+            $table->index('is_checked','rejected_bills_is_checked_index');
         });
     }
 
@@ -28,8 +28,8 @@ class ChangeRejectedBillsTable extends Migration
     {
         //
         Schema::table('rejected_bills',function (Blueprint $table){
-            $table->dropIndex('is_loaded');
-            $table->dropIndex('is_checked');
+            $table->dropIndex('rejected_bills_is_loaded_index');
+            $table->dropIndex('rejected_bills_is_checked_index');
         });
     }
 }

+ 1 - 1
database/migrations/2020_06_16_173559_add_authorrities_waybillmanagement_freigt.php

@@ -31,7 +31,7 @@ class AddAuthorritiesWaybillmanagementFreigt extends Migration
     public function down()
     {
         foreach ($this->authNames as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->destroy();
+            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
         }
     }
 }

+ 0 - 1
database/migrations/2020_06_30_133655_change_processes_contents_column_type.php

@@ -26,7 +26,6 @@ class ChangeProcessesContentsColumnType extends Migration
     public function down()
     {
         Schema::table('processes_contents',function (Blueprint $table){
-            $table->dropColumn('type');
             $table->string('is_full',2)->default('N')->comment('是否成品');
         });
     }

+ 0 - 38
database/migrations/2020_07_24_072012_create_orders_table.php.bak

@@ -1,38 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateOrdersTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('orders', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->string("batch_id")->index()->nullable();
-            $table->string("code")->index();
-            $table->integer("owner_id")->nullable();
-            $table->enum("status",['处理中','未处理','已处理','取消','异常'])->default('未处理');
-            $table->string("wms_status");
-
-
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('orders');
-    }
-}

+ 1 - 1
database/migrations/2020_07_29_155624_create_orders_table.php

@@ -15,7 +15,7 @@ class CreateOrdersTable extends Migration
     {
         Schema::create('orders', function (Blueprint $table) {
             $table->bigIncrements('id');
-            $table->string("batch_id")->index()->nullable();
+            $table->integer("batch_id")->index()->nullable();
             $table->string("code")->index()->nullable();
             $table->integer("owner_id")->nullable();
             $table->enum("status",['处理中','未处理','已处理','取消','异常'])->default('未处理');

+ 1 - 1
database/migrations/2020_09_10_143926_drop_shop_unique_name_index.php

@@ -27,7 +27,7 @@ class DropShopUniqueNameIndex extends Migration
     public function down()
     {
         Schema::table('shops', function (Blueprint $table) {
-            $table->string('name')->unique('shops_name_unique');
+            $table->string('name')->unique('shops_name_unique')->change();
         });
     }
 }

+ 1 - 1
database/migrations/2020_10_19_113042_create_logistic_timings_table.php

@@ -42,7 +42,7 @@ class CreateLogisticTimingsTable extends Migration
     {
         $create_array = [];
         $map = $this->getMap();
-        $logistic=Logistic::firstOrCreate(['name'=>'顺丰特惠']);
+        $logistic=Logistic::firstOrCreate(['name'=>'顺丰特惠','code'=>'SFTH']);
 //        $logistic = Logistic::query()->where('name','顺丰特惠')->first();
         $time = \Carbon\Carbon::now()->format('Y-m-d H:i:s');
         foreach ($map as $item) {

+ 3 - 1
database/migrations/2020_11_19_113955_change_order_issue_type_id_index.php

@@ -25,6 +25,8 @@ class ChangeOrderIssueTypeIdIndex extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('order_issues');
+        Schema::table('order_issues', function (Blueprint $table) {
+            $table->dropColumn('order_issue_type_id');
+        });
     }
 }

+ 35 - 0
database/migrations/2020_11_30_140957_create_station_types_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTypesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_types', function (Blueprint $table) {
+            $table->id();
+            $table->string('name')->index();
+            $table->timestamps();
+        });
+        \App\StationType::query()->firstOrCreate(['name'=>'料箱出货口']);
+        \App\StationType::query()->firstOrCreate(['name'=>'料箱入货口']);
+        \App\StationType::query()->firstOrCreate(['name'=>'料箱监视器']);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_types');
+    }
+}

+ 43 - 0
database/migrations/2020_11_30_140958_create_stations_table.php

@@ -0,0 +1,43 @@
+<?php
+
+use App\Station;
+use App\StationType;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('stations', function (Blueprint $table) {
+            $table->id();
+            $table->integer('parent_id')->index()->nullable();
+            $table->string('name')->index()->nullable();
+            $table->string('code')->unique()->nullable()->comment('机器编码');
+            $table->integer('station_type_id')->index();
+            $table->integer('sequence')->index()->nullable();
+            $table->timestamps();
+        });
+        $stationType= StationType::query()->firstOrCreate(['name'=>'料箱出货口']);
+        $station= Station::query()->firstOrCreate(['code'=>'BIN-OUT01','station_type_id'=>$stationType['id']]);
+        $station['sequence']=1;
+        $station['station_type_id']=$stationType['id'];
+        $station->save();
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('stations');
+    }
+}

+ 35 - 0
database/migrations/2020_11_30_142346_create_station_rule_batches_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationRuleBatchesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_rule_batches', function (Blueprint $table) {
+            $table->id();
+            $table->string('name')->index()->nullable();
+            $table->integer('station_type_id')->index()->nullable();
+            $table->string('batch_type')->index()->nullable();
+            $table->integer('owner_id')->index()->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_rule_batches');
+    }
+}

+ 35 - 0
database/migrations/2020_11_30_142430_create_station_task_batches_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTaskBatchesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_task_batches', function (Blueprint $table) {
+            $table->id();
+            $table->integer('batch_id')->index();
+            $table->integer('station_id')->index();
+            $table->integer('station_task_batch_type_id')->index();
+            $table->enum('status',['待处理','挂起','处理中','完成','异常','取消'])->index();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_task_batches');
+    }
+}

+ 33 - 0
database/migrations/2020_11_30_151800_create_station_task_batch_types_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTaskBatchTypesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_task_batch_types', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->timestamps();
+        });
+        \App\StationTaskBatchType::query()->firstOrCreate(['name'=>'U型线分捡']);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_task_batch_types');
+    }
+}

+ 32 - 0
database/migrations/2020_11_30_155611_create_material_boxes_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateMaterialBoxesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('material_boxes', function (Blueprint $table) {
+            $table->id();
+            $table->string('code')->unique();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('material_boxes');
+    }
+}

+ 35 - 0
database/migrations/2020_11_30_155713_create_station_task_material_boxes_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTaskMaterialBoxesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_task_material_boxes', function (Blueprint $table) {
+            $table->id();
+            $table->integer('station_id')->index();
+            $table->integer('material_box_id');  //联合索引
+            $table->enum('status',['待处理','挂起','处理中','完成','异常','取消'])->index();  //联合索引
+            $table->index(['material_box_id','status']);
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_task_material_boxes');
+    }
+}

+ 38 - 0
database/migrations/2020_11_30_174327_create_station_task_commodities_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTaskCommoditiesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_task_commodities', function (Blueprint $table) {
+            $table->id();
+            $table->integer('station_id');  //联合索引
+            $table->integer('material_box_id');  //联合索引
+            $table->integer('commodity_id')->index();
+            $table->integer('amount')->default(0);
+            $table->integer('order_id')->index();
+            $table->enum('status',['待处理','挂起','处理中','完成','异常','取消'])->index();  //有联合索引
+            $table->index(['station_id','material_box_id','status'],'station_task_commodities_s_m_s_index');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_task_commodities');
+    }
+}

+ 32 - 0
database/migrations/2020_12_01_134905_add_order_type_to_orders.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddOrderTypeToOrders extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->string('order_type')->index()->nullable()->comment('订单类型')->after('wms_status');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->dropColumn('order_type');
+        });
+    }
+}

+ 27 - 0
database/migrations/2020_12_01_150439_change_batch_field_status_add_executing.php

@@ -0,0 +1,27 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\DB;
+
+class ChangeBatchFieldStatusAddExecuting extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE batches MODIFY COLUMN status ENUM('未处理','已处理','取消','处理中','挂起','异常')");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        DB::statement("ALTER TABLE batches MODIFY COLUMN status ENUM('未处理','已处理','取消')");
+    }
+}

+ 38 - 0
database/migrations/2020_12_03_114353_add_auth_of_station.php

@@ -0,0 +1,38 @@
+<?php
+
+use App\Authority;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddAuthOfStation extends Migration
+{
+
+    protected $authNames=[
+        "站管理",
+        "站管理-监视器",
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->authNames as $name){
+            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->authNames as $name){
+            Authority::where('name',$name)->delete();
+        }
+    }
+}

+ 38 - 0
database/migrations/2020_12_03_144334_add_monitor_default_station_and_station_hardware_id_column.php

@@ -0,0 +1,38 @@
+<?php
+
+use App\Station;
+use App\StationType;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddMonitorDefaultStationAndStationHardwareIdColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('stations', function (Blueprint $table) {
+            $table->string('remark')->nullable();
+        });
+        $stationType= StationType::query()->firstOrCreate(['name'=>'料箱监视器']);
+        $station= Station::query()->firstOrCreate(['name'=>'料箱监视器01']);
+        $station['sequence']=1;
+        $station['station_type_id']=$stationType['id'];
+        $station->save();
+    }
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('stations', function (Blueprint $table) {
+            $table->dropColumn('remark');
+        });
+    }
+}

+ 32 - 0
database/migrations/2020_12_04_160314_create_station_task_types_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTaskTypesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_task_types', function (Blueprint $table) {
+            $table->id();
+            $table->string('name')->index();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_task_types');
+    }
+}

+ 35 - 0
database/migrations/2020_12_04_175932_create_station_tasks_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationTasksTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_tasks', function (Blueprint $table) {
+            $table->id();
+            $table->integer('station_id');
+            $table->integer('station_type_id')->nullable()->index();
+            $table->enum('status',['待处理','挂起','处理中','完成','异常','取消'])->index();
+            $table->index('station_id','station_type_id','status');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_tasks');
+    }
+}

+ 32 - 0
database/migrations/2020_12_07_111922_add_column_handled_amount_of_station_task_commodities.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnHandledAmountOfStationTaskCommodities extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('station_task_commodities', function (Blueprint $table) {
+            $table->integer('handled_amount')->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('station_task_commodities', function (Blueprint $table) {
+            $table->dropColumn('handled_amount');
+        });
+    }
+}

+ 16 - 0
database/seeds/MaterialBoxSeeder.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class MaterialBoxSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+    }
+}

+ 16 - 0
database/seeds/StationMissionBatchSeeder.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class StationMissionBatchSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+    }
+}

部分文件因为文件数量过多而无法显示