Browse Source

Merge branch 'master' into zengjun

# Conflicts:
#	app/Http/Controllers/TestController.php
#	app/Services/OwnerService.php
#	config/cache.php
ajun 5 years ago
parent
commit
20cad845ad
100 changed files with 2730 additions and 199 deletions
  1. 1 0
      .gitignore
  2. 0 2
      .gitlab-ci.yml
  3. 5 1
      app/Batch.php
  4. 122 19
      app/Console/Commands/SyncBatchTask.php
  5. 3 1
      app/Console/Kernel.php
  6. 1 1
      app/Exceptions/Handler.php
  7. 12 19
      app/Http/Controllers/ControlPanelController.php
  8. 85 0
      app/Http/Controllers/MaterialBoxController.php
  9. 85 0
      app/Http/Controllers/StationController.php
  10. 85 0
      app/Http/Controllers/StationRuleBatchController.php
  11. 85 0
      app/Http/Controllers/StationTaskBatchController.php
  12. 85 0
      app/Http/Controllers/StationTaskBatchTypeController.php
  13. 85 0
      app/Http/Controllers/StationTaskCommodityController.php
  14. 85 0
      app/Http/Controllers/StationTaskMaterialBoxController.php
  15. 85 0
      app/Http/Controllers/StationTypeController.php
  16. 75 42
      app/Http/Controllers/TestController.php
  17. 11 6
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  18. 27 0
      app/Http/Controllers/api/thirdPart/haiq/LightController.php
  19. 9 4
      app/Http/Controllers/api/thirdPart/haiq/PickStationController.php
  20. 24 7
      app/Http/Controllers/api/thirdPart/haiq/StorageController.php
  21. 44 0
      app/Jobs/OrderCreateInstantBill.php
  22. 10 0
      app/MaterialBox.php
  23. 2 0
      app/OwnerFeeDetail.php
  24. 8 0
      app/Providers/AppServiceProvider.php
  25. 48 0
      app/Services/BatchService.php
  26. 1 0
      app/Services/CacheService.php
  27. 15 0
      app/Services/DocWaveHeaderService.php
  28. 25 0
      app/Services/ForeignHaiRoboticsService.php
  29. 1 1
      app/Services/LogisticService.php
  30. 4 4
      app/Services/OrderCountingRecordService.php
  31. 91 0
      app/Services/OrderService.php
  32. 5 0
      app/Services/OwnerFeeDetailService.php
  33. 16 11
      app/Services/OwnerPriceExpressService.php
  34. 29 10
      app/Services/OwnerPriceOperationService.php
  35. 1 0
      app/Services/OwnerService.php
  36. 9 0
      app/Services/ProvinceService.php
  37. 28 0
      app/Services/StationService.php
  38. 60 0
      app/Services/StationTaskBatchService.php
  39. 26 0
      app/Services/StationTaskBatchTypeService.php
  40. 10 0
      app/Station.php
  41. 10 0
      app/StationRuleBatch.php
  42. 10 0
      app/StationTaskBatch.php
  43. 10 0
      app/StationTaskBatchType.php
  44. 10 0
      app/StationTaskCommodity.php
  45. 10 0
      app/StationTaskMaterialBox.php
  46. 10 0
      app/StationType.php
  47. 9 1
      config/api.php
  48. 5 7
      config/cache.php
  49. 12 0
      database/factories/MaterialBoxFactory.php
  50. 12 0
      database/factories/StationFactory.php
  51. 12 0
      database/factories/StationMissionBatchFactory.php
  52. 12 0
      database/factories/StationMissionBatchTypeFactory.php
  53. 12 0
      database/factories/StationMissionCommodityFactory.php
  54. 12 0
      database/factories/StationMissionMaterialBoxFactory.php
  55. 12 0
      database/factories/StationRuleBatchFactory.php
  56. 12 0
      database/factories/StationTypeFactory.php
  57. 0 38
      database/migrations/2020_07_24_072012_create_orders_table.php.bak
  58. 1 1
      database/migrations/2020_07_29_155624_create_orders_table.php
  59. 36 0
      database/migrations/2020_11_30_133112_save_value_store_data_date.php
  60. 35 0
      database/migrations/2020_11_30_140957_create_station_types_table.php
  61. 43 0
      database/migrations/2020_11_30_140958_create_stations_table.php
  62. 35 0
      database/migrations/2020_11_30_142346_create_station_rule_batches_table.php
  63. 35 0
      database/migrations/2020_11_30_142430_create_station_task_batches_table.php
  64. 33 0
      database/migrations/2020_11_30_151800_create_station_task_batch_types_table.php
  65. 36 0
      database/migrations/2020_11_30_153512_add_column_outer_table_owner_fee_details.php
  66. 7 3
      database/migrations/2020_11_30_155611_create_material_boxes_table.php
  67. 35 0
      database/migrations/2020_11_30_155713_create_station_task_material_boxes_table.php
  68. 38 0
      database/migrations/2020_11_30_174327_create_station_task_commodities_table.php
  69. 27 0
      database/migrations/2020_12_01_150439_change_batch_field_status_add_executing.php
  70. 38 0
      database/migrations/2020_12_03_114353_add_auth_of_station.php
  71. 16 0
      database/seeds/MaterialBoxSeeder.php
  72. 16 0
      database/seeds/StationMissionBatchSeeder.php
  73. 16 0
      database/seeds/StationMissionBatchTypeSeeder.php
  74. 16 0
      database/seeds/StationMissionCommoditySeeder.php
  75. 16 0
      database/seeds/StationMissionMaterialBoxSeeder.php
  76. 16 0
      database/seeds/StationRuleBatchSeeder.php
  77. 16 0
      database/seeds/StationSeeder.php
  78. 16 0
      database/seeds/StationTypeSeeder.php
  79. 2 2
      phpunit.xml
  80. 5 5
      resources/views/control/panel.blade.php
  81. 5 0
      resources/views/layouts/menu.blade.php
  82. 13 0
      resources/views/station/index.blade.php
  83. 11 0
      resources/views/station/menu.blade.php
  84. 520 0
      resources/views/station/monitor/indexl.blade.php
  85. 15 0
      resources/views/station/monitor/menu.blade.php
  86. 3 1
      routes/api/thirdPart/haiq.php
  87. 5 0
      routes/web.php
  88. 36 0
      tests/Services/OrderCountingRecordService/DateTestTest.php
  89. 1 1
      tests/Services/OrderCountingRecordService/OrderCountingRecordServiceGetTest.php
  90. 9 3
      tests/Services/OwnerPriceExpressService/OwnerPriceExpressServiceTest.php
  91. 4 4
      tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php
  92. 0 2
      tests/Unit/EchoTest.php
  93. 0 0
      tests/webApi/CreatesApplication.php
  94. 0 0
      tests/webApi/TestCase.php
  95. 1 3
      tests/webApi/flux.http
  96. 0 0
      tests/webApi/package.http
  97. 0 0
      tests/webApi/packageYifang.http
  98. 0 0
      tests/webApi/route.http
  99. 0 0
      tests/webApi/sortingFluxNewBatch.http
  100. 0 0
      tests/webApi/sortingHaochuangProcess.http

+ 1 - 0
.gitignore

@@ -28,3 +28,4 @@ yarn-error.log
 /public/icon/img404-thumbnail.jpg
 /public/phpMyAdmin4.8.5/
 /public/fonts
+/phpunit.xml

+ 0 - 2
.gitlab-ci.yml

@@ -12,8 +12,6 @@ before_script:
   - sudo bash ci/installEnv.sh
 
 
-
-
 build:
   stage: build
   tags:

+ 5 - 1
app/Batch.php

@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
 class Batch extends Model
 {
     protected $fillable = [
-        'id','code','type', 'wms_type', 'status', 'wms_status', 'wms_created_at',
+        'id','code','type', 'wms_type', 'status', 'wms_status', 'wms_created_at',"remark","owner_id",
     ];
     public function orders(){
         return $this->hasMany('App\Order','batch_id','id');
@@ -33,5 +33,9 @@ class Batch extends Model
         });
         return parent::delete(); // TODO: Change the autogenerated stub
     }
+    public function owner()
+    {
+        return $this->hasOne(Owner::class,"id","owner_id");
+    }
 
 }

+ 122 - 19
app/Console/Commands/SyncBatchTask.php

@@ -2,42 +2,145 @@
 
 namespace App\Console\Commands;
 
+use App\Services\BatchService;
+use App\Services\CacheService;
+use App\Services\common\BatchUpdateService;
 use App\Services\DocWaveHeaderService;
+use App\Services\LogService;
+use App\ValueStore;
+use Carbon\Carbon;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
 
 class SyncBatchTask extends Command
 {
-    /**
-     * @var string
-     */
     protected $signature = 'sync:batch';
 
-    /**
-     * @var string
-     */
     protected $description = 'sync wms batch task';
 
-    /**
-     * @return void
-     */
+    /** @var DocWaveHeaderService $service */
+    private $service;
+    /** @var BatchService $batchService */
+    private $batchService;
+
     public function __construct()
     {
         parent::__construct();
+        $this->service = app(DocWaveHeaderService::class);
+        $this->batchService = app(BatchService::class);
     }
 
-    /**
-     * Execute the console command.
-     *
-     * @return void
-     */
     public function handle()
     {
-        /** @var DocWaveHeaderService $service */
-        $service = app(DocWaveHeaderService::class);
-        $date = $service->getSyncDate();
-        $flux = $service->get(["edittime"=>$date],["edittime"=>"gtOrEqual"]);
-        if (!$flux)return;
+        $this->disposeHeader();
+        $this->disposeDetail();
+    }
+
+    private function disposeHeader()
+    {
+        //获取更新时间与WMS数据
+        $date = $this->service->getSyncDate();
+        $waves = $this->service->get(["edittime"=>$date],["edittime"=>"gtOrEqual"]);
+        if (count($waves) < 1)return;
+
+        //获取本地数据对比差异
+        $codes = array_column($waves->toArray(),"waveno");
+        $map = [];
+        $batches = $this->batchService->get(["code"=>$codes]);
+        if ($batches){
+            foreach ($batches as $batch)$map[$batch->code] = $batch->id;
+        }
+        $update = [["id","status","remark","updated_at"]];
+        $insert = [];
+        foreach ($waves as $wave){
+            $status = $wave->wavestatus == '40' ? "未处理" : ($wave->wavestatus == '90' ? '取消' : '已处理');
+            if (isset($map[$wave->waveno])){
+                $update[] = [
+                    "id" => $map[$wave->waveno],
+                    "status" => $status,
+                    "remark"=>$wave->descr,
+                    "updated_at"=>$wave->edittime,
+                ];
+                continue;
+            }
+            $owner = app("OwnerService")->codeGetOwner($wave->customerid);
+            $insert[] = [
+                "code" => $wave->waveno,
+                "status" => $status,
+                "remark"=>$wave->descr,
+                "created_at"=>$wave->addtime,
+                "updated_at"=>$wave->edittime,
+                "owner_id"=>$owner->id,
+            ];
+        }
+
+        //存在则更新
+        if (count($update)>1){
+            $bool = app(BatchUpdateService::class)->batchUpdate("batches",$update);
+            if ($bool)LogService::log(__METHOD__,"SUCCESS-同步更新波次成功",json_encode($update));
+            else{
+                LogService::log(__METHOD__,"ERROR-同步更新波次失败",json_encode($update));
+                return;
+            }
+        }
+
+        //不存在则录入
+        if ($insert){
+            $this->batchService->insert($insert);
+            LogService::log(__METHOD__,"SUCCESS-同步插入波次成功",json_encode($insert));
+        }
+        $lastDate = $waves[0]->edittime;
+        $this->service->setSyncDate($lastDate);
+    }
+
+    public function disposeDetail()
+    {
+        $date = app(CacheService::class)->getOrExecute("wave_detail_last_sync_date",function (){
+            $valueStore = ValueStore::query()->where("name","wave_detail_last_sync_date")->first();
+            return $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
+        });
+        $sql = "SELECT WM_CONCAT(ORDERNO) orderno,WAVENO FROM DOC_WAVE_DETAILS WHERE EDITTIME > TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')  GROUP BY WAVENO";
+        $details = DB::connection("oracle")->select(DB::raw($sql),[$date]);
+        if (count($details) < 1)return;
+        $map = [];
+        $nos = [];
+        foreach ($details as $detail){
+            $map[$detail->waveno] = explode(",",$detail->orderno);
+            $nos[] = $detail->waveno;
+        }
+        $batches = $this->batchService->get(["code"=>$nos]);
+        foreach ($batches as $batch){
+            app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
+            unset($map[$batch->code]);
+        }
+        if ($map){
+            $waveCodes = array_keys($map);
+            $waves = $this->service->get(["waveno"=>$waveCodes],["waveno"=>"in"]);
+            $insert = [];
+            foreach ($waves as $wave){
+                $status = $wave->wavestatus == '40' ? "未处理" : ($wave->wavestatus == '90' ? '取消' : '已处理');
+                $owner = app("OwnerService")->codeGetOwner($wave->customerid);
+                $insert[] = [
+                    "code" => $wave->waveno,
+                    "status" => $status,
+                    "remark"=>$wave->descr,
+                    "created_at"=>$wave->addtime,
+                    "updated_at"=>$wave->edittime,
+                    "owner_id"=>$owner->id,
+                ];
+            }
+            if ($insert){
+                $this->batchService->insert($insert);
+                LogService::log(__METHOD__,"SUCCESS-同步插入波次成功",json_encode($insert));
+                $batches = $this->batchService->get(["code"=>$waveCodes]);
+                foreach ($batches as $batch){
+                    app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
+                }
+            }
+        }
+        $this->batchService->assignTasks($batches);
 
 
+        ValueStore::query()->where("name","wave_last_sync_date")->update(["value"=>Carbon::now()->subSeconds(1)->toDateTimeString()]);
     }
 }

+ 3 - 1
app/Console/Kernel.php

@@ -2,6 +2,7 @@
 
 namespace App\Console;
 
+use App\Console\Commands\SyncBatchTask;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
@@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
         \App\Console\Commands\SyncLogCacheTask::class,
         \App\Console\Commands\SyncUserVisitMenuLogsCacheTask::class,
         \App\Console\Commands\TestTemp::class,
+        SyncBatchTask::class,
     ];
 
     /**
@@ -34,12 +36,12 @@ class Kernel extends ConsoleKernel
         $schedule->command('LogExpireDelete')->dailyAt('00:01');
         $schedule->command('InventoryDailyLoggingOwner')->dailyAt('08:00');
         $schedule->command('FluxOrderFix')->hourlyAt(1);
-//        $schedule->command('FluxOrderFix')->cron('* * * * *');
         $schedule->command('WASSyncWMSOrderInformation')->everyMinute();
         $schedule->command('syncLogCacheTask')->everyMinute();
         $schedule->command('createOwnerReport')->monthlyOn(1);
         $schedule->command('createOwnerBillReport')->monthlyOn(1);
         $schedule->command('createOwnerAreaReport')->monthlyOn(25);
+        $schedule->command('sync:batch')->everyMinute();
     }
 
     /**

+ 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)
+    {
+        //
+    }
+}

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

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Station;
+use Illuminate\Http\Request;
+
+class StationController 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\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function show(Station $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/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/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)
+    {
+        //
+    }
+}

+ 75 - 42
app/Http/Controllers/TestController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 
 use App\Authority;
+use App\Batch;
 use App\Carrier;
 use App\Commodity;
 use App\CommodityBarcode;
@@ -11,6 +12,7 @@ use App\Console\Commands\SyncWMSOrderTask;
 use App\Events\CancelOrder;
 use App\Imports\OrderTrackingImport;
 use App\InventoryAccount;
+use App\Jobs\OrderCreateInstantBill;
 use App\LaborReport;
 use App\Log;
 use App\Logistic;
@@ -45,11 +47,13 @@ use App\Services\OrderService;
 use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
 use App\Services\OwnerService;
+use App\Services\ProvinceService;
 use App\Services\ShopService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
 use App\StoreCheckingReceiveItem;
 use App\User;
+use App\ValueStore;
 use App\Warehouse;
 use App\Waybill;
 use App\WaybillPriceModel;
@@ -140,16 +144,34 @@ class TestController extends Controller
         }
     }
 
-    private function dd()
+    public function test4(){
+        $order = Order::query()->whereHas("packages",function ($query){
+            /** @var Builder $query */
+            $query->whereHas("commodities",function ($query){
+                /** @var Builder $query */
+                $query->whereHas("commodity",function ($query){
+                    /** @var Builder $query */
+                    $query->whereNotNull("name");
+                });
+            });
+        })->first();
+        OrderCreateInstantBill::dispatch($order);
+    }
+    public function t($a)
     {
-        StoreCheckingReceiveItem::query()->insert([[
-            "imported_amount" => 1,
-            "produced_at" => null,
-            "invalid_at" => null,
-            "batch_code" => null,
-            "unique_code" => null,
-            "commodity_id" => 36,
-            "store_checking_receive_id" => 2]]);
+        dd(json_encode(
+            [[
+                "taskMode"      => 8,
+                "bins"=>[[
+                    "taskCode"  =>"TEST-BS2011160004",
+                    "binCode"   => "TESTBINCODE-0",
+                    "fromLocCode" => "BIN-IN1",
+                    //"toLocCode" => "BIN-OUT1",
+                ]],
+                "groupCode"     => 4,
+                "priority"      => 20,
+                "sequenceFlag"  => -1,
+            ]]        ));
     }
 
     public function updateLaborRemark(){
@@ -174,17 +196,6 @@ class TestController extends Controller
         }
     }
     public function test2(){
-        $b = Logistic::query()->first();
-        $a = OrderPackage::query()->with("order")->first();
-        $a->bulk = 521;
-        $a->save();
-        if (!$a->order) $a->order = new Order();
-        dd($a);
-        if (!$a->order->logistic)$a->order->logistic = $b;
-        dd($a->order->logistic);
-        dd($a);
-        $a->save();
-        dd($a);
     }
 
     function packageFromLog(Request $request)
@@ -335,28 +346,6 @@ class TestController extends Controller
         }
     }
 
-    public function delme()
-    {
-        $fields = [
-            'doc_order_header.userdefine1',
-            'doc_order_header.userdefine2',
-            'doc_order_header.SOReference5',
-            'doc_order_header.waveno',
-            'doc_order_header.orderno',
-            'doc_order_header.customerid',
-            'doc_order_header.Consigneename'
-        ];
-        if ('') {
-            $resultOracleObj = OracleDOCOrderHeader::select($fields)->where('orderno', 'SO200603004708');
-        } else {
-            $resultOracleObj = OracleActAllocationDetails::select($fields);
-            $resultOracleObj->where('picktotraceid', '546152742096');
-            $resultOracleObj->leftJoin('DOC_Order_Header', 'act_allocation_details.orderno', 'doc_order_header.orderno');
-        }
-        $_temOracleInfo = $resultOracleObj->first();
-
-        dd($_temOracleInfo);
-    }
 
     public function mergerPackageData()
     {
@@ -1212,4 +1201,48 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         dump(Carbon::now());
     }
 
+    public function reNewBatches3()
+    {
+        $batches=Batch::query()->where('id','>',324)->get('code');
+//        $batchCodes = $batches->map(function($batch){
+//            return $batch['code'];
+//        })->toArray();
+        $batchCodes = ['W201201000037',
+            'W201201000038',
+            'W201201000039',
+            'W201201000040',
+            'W201201000041',
+            'W201201000052',
+            'W201201000053',
+            'W201201000054',
+            'W201201000055',
+            'W201201000056',
+            'W201201000057',
+            'W201201000071',
+            'W201201000074',
+            'W201201000075',
+            'W201201000076',];
+        $requests=[];
+//        $logs=Log::query()->select('description')->where('CREATED_AT','>','2020-11-11')
+//            ->where('type',"issued_newBatch")
+//            ->get();
+//        dd($logs);
+        foreach($batchCodes as $code){
+//            $request=Cache::get('temp'.$code)['description'];
+            $request=Log::query()->select('description')->where('CREATED_AT','>','2020-12-01')
+                ->where('type',"issued_newBatch")
+                ->where('description','like',"%{$code}%")
+                ->first();
+            if($request){
+                $response=Zttp::post('https://wcs.baoshi56.com/api/thirdPart/flux/sorting/newBatch',
+                    json_decode($request['description'])
+                );
+                app('LogService')->log(__METHOD__,__FUNCTION__,$response->body());
+                $requests[]=$response->body();
+            }
+//            Cache::put('temp'.$code,$request);
+//            $requests[]=$request;
+        }
+        dd($requests);
+    }
 }

+ 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 - 7
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -4,16 +4,20 @@
 namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
+use App\Services\ForeignHaiRoboticsService;
 use App\Services\LogService;
+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 +38,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 +52,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 +68,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()];
+    }
 }

+ 44 - 0
app/Jobs/OrderCreateInstantBill.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Order;
+use App\Services\LogService;
+use App\Services\OrderService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class OrderCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+
+    protected $order;
+    /**
+     * Create a new job instance.
+     *
+     * @param Order $order
+     * @return void
+     */
+    public function __construct(Order $order)
+    {
+        $this->order = $order;
+    }
+
+    /**
+     *
+     * @param OrderService $service
+     * @return void
+     */
+    public function handle(OrderService $service)
+    {
+        try{
+            $service->createInstantBill($this->order);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-订单生成即时账单",$this->order->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 10 - 0
app/MaterialBox.php

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

+ 2 - 0
app/OwnerFeeDetail.php

@@ -24,6 +24,8 @@ class OwnerFeeDetail extends Model
         "work_fee",         //作业费
         "logistic_fee",     //物流费
         "created_at",       //创建时间
+        "outer_id",         //关联表ID
+        "outer_table_name", //关联表名
     ];
     public $timestamps = false;
 

+ 8 - 0
app/Providers/AppServiceProvider.php

@@ -13,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;
@@ -58,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;
@@ -138,6 +142,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);
@@ -154,6 +159,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);

+ 48 - 0
app/Services/BatchService.php

@@ -0,0 +1,48 @@
+<?php
+
+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();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->get();
+    }
+
+    public function insert(array $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);
+    }
+
+}

+ 1 - 0
app/Services/CacheService.php

@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Cache;
 class CacheService
 {
     function getOrExecute(String $key, $func, $expiration=null){
+        if(!$expiration) $expiration=config('cache.expirations.default');
         return Cache::remember($key, $expiration, $func);
 //        $results = Cache::get($key);
 //        if(!$results){

+ 15 - 0
app/Services/DocWaveHeaderService.php

@@ -26,6 +26,15 @@ Class DocWaveHeaderService
             case "gtOrEqual":
                 $query->where($column,">=",$value);
                 break;
+            case "gt":
+                $query->where($column,">",$value);
+                break;
+            case "raw":
+                $query->whereRaw($value);
+                break;
+            case "in":
+                $query->whereIn($column,$value);
+                break;
         }
         return $query;
     }
@@ -36,4 +45,10 @@ Class DocWaveHeaderService
         $valueStore = ValueStore::query()->where("name","wave_last_sync_date")->first();
         return $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
     }
+
+    public function setSyncDate(string $value)
+    {
+        $valueStore = ValueStore::query()->where("name","wave_last_sync_date");
+        return $valueStore->update(["value"=>$value]);
+    }
 }

+ 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(){
+
+    }
+}

+ 1 - 1
app/Services/LogisticService.php

@@ -26,7 +26,7 @@ Class LogisticService
                 $query->where("type",$type)->orWhere("type","全部");
             });
             return $query->get();
-        },config('cache.expirations.persistent'));
+        },config('cache.expirations.rarelyChange'));
     }
 
     public function firstOrCreate(array $params, array $values = null){

+ 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);
             });

+ 91 - 0
app/Services/OrderService.php

@@ -9,6 +9,8 @@ use App\OracleDOCOrderHeader;
 use App\Order;
 use App\OrderIssue;
 use App\Owner;
+use App\OwnerPriceExpress;
+use App\OwnerPriceLogistic;
 use App\RejectedBill;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
@@ -16,6 +18,7 @@ use App\Shop;
 use App\ValueStore;
 use App\Warehouse;
 use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\Cache;
@@ -1130,4 +1133,92 @@ class OrderService
             $orderService->setOrderSyncAt($renewal,$renewal_order->addTime,count($orderHeaders)>0);   // 更新时间
         }
     }
+
+    public function update(array $params, array $values)
+    {
+        $query = Order::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->update($values);
+    }
+
+    public function createInstantBill(Order $order):bool
+    {
+        //检查订单对象
+        if (!$order || $order->wms_status != "订单完成")return false;
+        if (!$order->packages || !$order->packages[0]->commodities || !$order->packages[0]->commodities[0]->commodity)$order->load(["packages"=>function($query){
+            /** @var Builder $query */
+            $query->with(["commodities"=>function($query){
+                /** @var Builder $query */
+                $query->with("commodity");
+            }]);
+        }]);
+
+        /** @var OwnerPriceExpressService $service */
+        $service = app("OwnerPriceExpressService");
+        $logistic_fee = 0;
+        $commodities = [];
+        $amount = 0;
+        $volume = 0;
+        $weight = 0;
+        $logistic_bill = "";
+        foreach ($order->packages as &$package){
+            $logistic_bill .= $package->logistic_number.",";
+            $volume += $package->bulk;
+            $weight += $package->weight;
+
+            // 四维转二维
+            foreach($package->commodities as &$commodity){
+                $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
+                $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
+                $amount += $commodity->amount;
+            }
+            $commodities = array_merge($commodities,$package->commodities->toArray());
+
+            if ($logistic_fee!==null){
+                $provinceName = $order->province;
+                $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                    return app("ProvinceService")->first(["name"=>$provinceName]);
+                },60);
+                if (!$province)$logistic_fee = null;
+
+                $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+                if ($fee<0)$logistic_fee = null;
+
+                $logistic_fee += $fee;
+            }
+        }
+        if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
+
+        $object = ["commodities"=>$commodities,"logistic_name"=>($order->logistic ? $order->logistic->name : ''),"shop_name"=>($order->shop ? $order->shop->name : '')];
+        $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name","承运商"=>"logistic_name","店铺类型"=>"shop_name"];
+
+        /** @var OwnerPriceOperationService $service */
+        $service = app("OwnerPriceOperationService");
+        $work_fee = $service->matchRule($object,$mapping,$order->owner_id,"出库");
+        if ($work_fee < 0)$work_fee = null;
+
+       if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $order->owner_id,
+            "worked_at"         => $order->wms_edittime,
+            "type"              => "发货",
+            "shop_id"           => $order->shop_id,
+            "operation_bill"    => $order->client_code,
+            "consignee_name"    => $order->consignee_name,
+            "consignee_phone"   => $order->consignee_phone,
+            "commodity_amount"  => $amount,
+            "logistic_bill"     => rtrim($logistic_bill,","),
+            "volume"            => $volume,
+            "weight"            => $weight,
+            "logistic_id"       => $order->logistic_id,
+            "work_fee"          => $work_fee,
+            "logistic_fee"      => $logistic_fee,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $order->id,
+            "outer_table_name"  => "orders",
+        ]))return true;
+       return false;
+    }
 }

+ 5 - 0
app/Services/OwnerFeeDetailService.php

@@ -55,4 +55,9 @@ Class OwnerFeeDetailService
         return $query->sql();
     }
 
+    public function create(array $params)
+    {
+        return OwnerFeeDetail::query()->create($params);
+    }
+
 }

+ 16 - 11
app/Services/OwnerPriceExpressService.php

@@ -101,7 +101,7 @@ Class OwnerPriceExpressService
     }
 
     /**
-     * CODE: -1:未找到计费模型
+     * CODE: -1:未找到计费模型 -2:重量无效
      *
      * @param double $weight
      * @param integer $owner_id
@@ -111,16 +111,21 @@ Class OwnerPriceExpressService
      */
     public function matching($weight, $owner_id, $logistic_id, $province_id)
     {
-        $model = OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
-            /** @var Builder $query */
-            $query->where("province_id",$province_id);
-        }])->whereHas("owners",function ($query)use($owner_id){
-            /** @var Builder $query */
-           $query->where("id",$owner_id);
-        })->whereHas("logistics",function ($query)use($logistic_id){
-            /** @var Builder $query */
-            $query->where("id",$logistic_id);
-        })->first();
+        if (!$weight)return -2;
+
+        $key = "price_express_".$province_id."_".$logistic_id."_".$owner_id;
+        $model = app(CacheService::class)->getOrExecute($key,function ()use($owner_id, $logistic_id, $province_id){
+            return OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
+                /** @var Builder $query */
+                $query->where("province_id",$province_id);
+            }])->whereHas("owners",function ($query)use($owner_id){
+                /** @var Builder $query */
+                $query->where("id",$owner_id);
+            })->whereHas("logistics",function ($query)use($logistic_id){
+                /** @var Builder $query */
+                $query->where("id",$logistic_id);
+            })->first();
+        });
         if (!$model || !$model->details)return -1;
         if ($weight < $model->initial_weight)$weight = $model->initial_weight;
         $initialMoney = $model->initial_weight*$model->details[0]->initial_weight_price;

+ 29 - 10
app/Services/OwnerPriceOperationService.php

@@ -104,11 +104,10 @@ Class OwnerPriceOperationService
      * @param array $columnMapping       key-val
      * @param string $owner_id
      * @param string $type
-     * @param string $sku
      * @return double
      * 错误代码: -1:无匹配对象 -2:无计费模型 -3:未知单位 -4:sku为空 -5:货主未找到 -6:无箱规 -7:未匹配到计费模型
      */
-    public function matchRule($matchObject, $columnMapping, $owner_id, $sku = null, $type = '出库')
+    public function matchRule($matchObject, $columnMapping, $owner_id, $type = '出库')
     {
         $unitModels = Unit::query()->whereIn("name",["件","箱","单"])->get();
         $units = [];
@@ -144,7 +143,12 @@ Class OwnerPriceOperationService
                     if ($bool === true){
                         if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                         if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $sum = $this->changeUnit($sum,$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
+                            }
+                            $sum = $sumTemp;
                             if ($sum<0)return $sum;
                         }
                         if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
@@ -153,7 +157,12 @@ Class OwnerPriceOperationService
                 }else{
                     if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                     if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $sum = $this->changeUnit($sum,$owner_id,$sku);
+                        $sumTemp = 0;
+                        $packageColumn = $columnMapping["packages"] ?? "packages";
+                        foreach ($matchObject[$packageColumn] as $commodity){
+                            $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
+                        }
+                        $sum = $sumTemp;
                         if ($sum<0)return $sum;
                     }
                     if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
@@ -168,11 +177,11 @@ Class OwnerPriceOperationService
             if ($rule->strategy == '特征'){
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);//匹配特征
                 if ($bool === true){
-                    $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                    $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id);
                     if ($money>0)return $money;
                 };
             }else{
-                $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id);
                 if ($money>0)return $money;
             };
         }
@@ -186,7 +195,7 @@ Class OwnerPriceOperationService
         return ceil($amount/$pack);
     }
 
-    private function matchOutStorage($rules, $columnMapping, $matchObject, $units, $owner_id, $sku)
+    private function matchOutStorage($rules, $columnMapping, $matchObject, $units, $owner_id)
     {
         $amountColumn = $columnMapping["amount"] ?? "amount";
         $packageColumn = $columnMapping["packages"] ?? "packages";
@@ -200,7 +209,7 @@ Class OwnerPriceOperationService
                 case "特征":
                     foreach ($packages as &$package){
                         if ($package["price"] ?? false)continue;
-                        if (!app("FeatureService")->matchFeature($rule->feature,["商品名称"=>"commodity"],["commodity"=>$package[$commodityColumn] ?? ''])) continue;
+                        if (!app("FeatureService")->matchFeature($rule->feature,["商品名称"=>$commodityColumn],["commodity"=>$package[$commodityColumn] ?? ''])) continue;
 
                         if (!$unitName)$unitName = $units[$rule->unit_id];
                         else {
@@ -210,7 +219,12 @@ Class OwnerPriceOperationService
                         $package["price"] = $rule->unit_price;
                         if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($package[$amountColumn],$owner_id,$commodity["sku"]);
+                            }
+                            $amount = $sumTemp;
                             if ($amount<0)return $amount;
                             $package[$amountColumn] = $amount;
                         }
@@ -228,7 +242,12 @@ Class OwnerPriceOperationService
                         $package["price"] = $rule->unit_price;
                         if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($package[$amountColumn],$owner_id,$commodity["sku"]);
+                            }
+                            $amount = $sumTemp;
                             if ($amount<0)return $amount;
                             $package[$amountColumn] = $amount;
                         }

+ 1 - 0
app/Services/OwnerService.php

@@ -57,6 +57,7 @@ Class OwnerService
                     'name' => $basCustomer['descr_c'],
                     'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
                 ]);
+                continue;
             }
             if ($owner['name']!=$basCustomer['descr_c']){
                 $owner->update([

+ 9 - 0
app/Services/ProvinceService.php

@@ -29,4 +29,13 @@ Class ProvinceService
         }
         return null;
     }
+
+    public function first(array $params)
+    {
+        $query = Province::query();
+        foreach ($params as $column=>$param){
+            $query->where($column,$param);
+        }
+        return $query->first();
+    }
 }

+ 28 - 0
app/Services/StationService.php

@@ -0,0 +1,28 @@
+<?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
+     */
+    public 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;
+    }
+}

+ 60 - 0
app/Services/StationTaskBatchService.php

@@ -0,0 +1,60 @@
+<?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型线分捡');
+
+        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'=>'待处理'
+                ]);
+                $batch = '已处理';
+            }
+        }
+        $this->batchService->updateWhereIn('id',data_get($batches,'*.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;
+        });
+    }
+}

+ 10 - 0
app/Station.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Station extends Model
+{
+    protected $fillable=['name', 'code', 'station_type_id','sequence','parent_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/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/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' => "",  //灭灯
         ],
     ],
 

+ 5 - 7
config/cache.php

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

+ 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 [
+        //
+    ];
+});

+ 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/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 [
+        //
+    ];
+});

+ 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('未处理');

+ 36 - 0
database/migrations/2020_11_30_133112_save_value_store_data_date.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class SaveValueStoreDataDate extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        \App\ValueStore::query()->firstOrCreate(["name"=>"wave_last_sync_date"]);
+        Schema::table("batches",function (Blueprint $table){
+            $table->string("remark")->nullable()->comment("中文描述");
+            $table->string("owner_id")->index()->nullable()->comment("外键货主");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        \App\ValueStore::query()->where("name","wave_last_sync_date")->delete();
+        Schema::table("batches",function (Blueprint $table){
+            $table->dropColumn("remark");
+            $table->dropColumn("owner_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')->index()->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['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');
+    }
+}

+ 36 - 0
database/migrations/2020_11_30_153512_add_column_outer_table_owner_fee_details.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnOuterTableOwnerFeeDetails extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        \App\ValueStore::query()->firstOrCreate(["name"=>"wave_detail_last_sync_date"]);
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->bigInteger("outer_id")->nullable()->index()->comment("关联表ID");
+            $table->string("outer_table_name")->nullable()->comment("关联表名称");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        \App\ValueStore::query()->where("name","wave_detail_last_sync_date")->delete();
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->dropColumn("outer_id");
+            $table->dropColumn("outer_table_name");
+        });
+    }
+}

+ 7 - 3
database/migrations/2020_11_27_133112_save_value_store_data.php → database/migrations/2020_11_30_155611_create_material_boxes_table.php

@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
-class SaveValueStoreData extends Migration
+class CreateMaterialBoxesTable extends Migration
 {
     /**
      * Run the migrations.
@@ -13,7 +13,11 @@ class SaveValueStoreData extends Migration
      */
     public function up()
     {
-        \App\ValueStore::query()->firstOrCreate(["name"=>"wave_last_sync_date"]);
+        Schema::create('material_boxes', function (Blueprint $table) {
+            $table->id();
+            $table->string('code')->unique();
+            $table->timestamps();
+        });
     }
 
     /**
@@ -23,6 +27,6 @@ class SaveValueStoreData extends Migration
      */
     public function down()
     {
-        \App\ValueStore::query()->where("name","wave_last_sync_date")->delete();
+        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');
+    }
+}

+ 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();
+        }
+    }
+}

+ 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()
+    {
+        //
+    }
+}

+ 16 - 0
database/seeds/StationMissionBatchTypeSeeder.php

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

+ 16 - 0
database/seeds/StationMissionCommoditySeeder.php

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

+ 16 - 0
database/seeds/StationMissionMaterialBoxSeeder.php

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

+ 16 - 0
database/seeds/StationRuleBatchSeeder.php

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

+ 16 - 0
database/seeds/StationSeeder.php

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

+ 16 - 0
database/seeds/StationTypeSeeder.php

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

+ 2 - 2
phpunit.xml

@@ -34,8 +34,8 @@
         <server name="APP_ENV" value="testing"/>
         <server name="BCRYPT_ROUNDS" value="4"/>
         <server name="CACHE_DRIVER" value="redis"/>
-        <server name="DB_CONNECTION" value="sqlite"/>
-        <server name="DB_DATABASE" value=":memory:"/>
+        <!--<server name="DB_CONNECTION" value="sqlite"/>
+        <server name="DB_DATABASE" value=":memory:"/>-->
         <server name="MAIL_DRIVER" value="array"/>
         <server name="QUEUE_CONNECTION" value="sync"/>
         <server name="SESSION_DRIVER" value="array"/>

+ 5 - 5
resources/views/control/panel.blade.php

@@ -273,15 +273,15 @@
                         }
                     }]
                 },
-                orderCountingRecordsDate: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
+                orderCountingRecordsDate: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
-                logisticsCountingRecordsData: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
+                logisticsCountingRecordsData: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
-                warehouseCountingRecordsData: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
+                warehouseCountingRecordsData: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
-                laborReportsCountingRecordsDate: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
+                laborReportsCountingRecordsDate: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
-                laborReportsUserGroupsCountDate: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
+                laborReportsUserGroupsCountDate: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
                 orderCountingRecordsUnit: '日',
                 laborReportsCountingRecordUnit: '日',

+ 5 - 0
resources/views/layouts/menu.blade.php

@@ -47,6 +47,11 @@
                                     :class="{active:isActive('personnel',1)}">
                     <span class="fa fa-header" style="color: #72441b"></span>
                     人事管理</a></li> @endcan
+        @can('站管理')
+            <li class="nav-item"><a href="{{url("station/index")}}" class="nav-link"
+                                    :class="{active:isActive('station',1)}">
+                    <span class="fa fa-share-alt-square" style="color: #72441b"></span>
+                    站管理</a></li> @endcan
         @can('基础设置')
             <li class="nav-item"><a href="{{url("maintenance")}}" class="nav-link"
                                     :class="{active:isActive('maintenance',1)}">

+ 13 - 0
resources/views/station/index.blade.php

@@ -0,0 +1,13 @@
+@extends('layouts.app')
+@section('title')站管理@endsection
+
+@section('content')
+    @component('station.menu')@endcomponent
+    <div class="container-fluid">
+
+    </div>
+@endsection
+
+@section('lastScript')
+
+@endsection

+ 11 - 0
resources/views/station/menu.blade.php

@@ -0,0 +1,11 @@
+
+<div class="container-fluid nav2" id="nav2">
+    <div class="card">
+        <ul class="nav nav-pills">
+            @can('站管理-监视器')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('station/monitor/index')}}" :class="{active:isActive('monitor',2)}">监视器</a>
+                </li> @endcan
+        </ul>
+    </div>
+</div>

+ 520 - 0
resources/views/station/monitor/indexl.blade.php

@@ -0,0 +1,520 @@
+@extends('layouts.app')
+@section('title')监视器列表 - 站管理@endsection
+
+@section('content')
+    <div id="nav2">
+        @component('station.menu')@endcomponent
+        @component('station.monitor.menu')@endcomponent
+    </div>
+    <div class="container-fluid">
+        <div>
+            <div class="d-none" id="list">
+                @if(Session::has('successTip'))
+                    <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
+                @endif                <div id="form_div"></div>
+                <span class="dropdown">
+                    <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget":class="[rejectedBills_checkBoxes.length>0?'btn-dark text-light':'']"
+                            data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
+                        导出Excel
+                    </button>
+                    <div class="dropdown-menu">
+                        <a class="dropdown-item" @click="exportExcel(false)" href="javascript:">导出勾选内容</a>
+                        <a class="dropdown-item" @click="exportExcel(true)" href="javascript:">导出所有页</a>
+                    </div>
+                </span>
+                @can('退货管理-编辑')
+                    {{--                                        <select name="" class="tooltipTarget form-control-sm" style="vertical-align: middle"--}}
+                    {{--                                                title="将勾选记录的入库状态设定为是或否,仅对未完结状态的记录有效" @change="setIsLoaded_batch"--}}
+                    {{--                                                :class="[rejectedBills_checkBoxes.length>0?'btn-dark':'btn-outline-dark']">--}}
+                    {{--                                            <option value="">修改入库</option>--}}
+                    {{--                                            <option value="1">设定为是</option>--}}
+                    {{--                                            <option value="0">设定为否</option>--}}
+                    {{--                                            <option value="null">无需入库</option>--}}
+                    {{--                                            <option value="2">待推单</option>--}}
+                    {{--                                        </select>--}}
+                @endcan
+                @can('退货管理-审核')
+                    <span class="btn btn-sm" @click="checkAll" style="cursor: pointer"
+                          :class="[rejectedBills_checkBoxes.length>0?'btn-dark':'btn-outline-dark']">审核</span>
+                @endcan
+                @can('退货管理-编辑')
+                    <span class="btn btn-sm" @click="finishAll" style="cursor: pointer"
+                          :class="[rejectedBills_checkBoxes.length>0?'btn-dark':'btn-outline-dark']">完结</span>
+                @endcan
+                <span class="dropdown">
+                    <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget":class="[rejectedBills_checkBoxes.length>0?'btn-dark text-light':'']"
+                            data-toggle="dropdown" title="将勾选记录的入库状态设定为是或否,仅对未完结状态的记录有效">
+                        修改入库
+                    </button>
+                    <div class="dropdown-menu">
+                        <a class="dropdown-item" @click="setIsLoaded_batch(1)" href="javascript:">设定为是</a>
+                        <a class="dropdown-item" @click="setIsLoaded_batch(0)" href="javascript:">设定为否</a>
+                        <a class="dropdown-item" @click="setIsLoaded_batch('null')" href="javascript:">无需入库</a>
+                        <a class="dropdown-item" @click="setIsLoaded_batch(2)" href="javascript:">待推单</a>
+                        <a class="dropdown-item" @click="setIsLoaded_batch(4)" href="javascript:">待确认</a>
+                    </div>
+                </span>
+
+                @can('退货管理-编辑')
+                    <a class="btn btn-sm btn-outline-dark" href="{{url('rejected/importRejectedNumber')}}" style="cursor: pointer">导入修改</a>
+                @endcan
+                <span for="checkSelectingAll" class="d-none" id="cloneCheckAll">
+                    <input type="checkbox" class="form-control-sm tooltipTarget" title="全选"
+                           id="checkSelectingAll" @click="checkBoxAllToggle($event)">
+                </span>
+
+
+                <table class="table table-striped table-sm table-bordered table-hover text-nowrap d-none" id="headerRoll" ></table>
+                <table class="table table-striped table-sm table-bordered table-hover text-nowrap" style="background: #fff;" id="headerParent">
+                    <tr id="header"></tr>
+                    <tr v-for="(rejectedBill,i) in rejectedBills" :data-id="rejectedBill.id">
+                        <td>
+                            <input type="checkbox" v-model="rejectedBills_checkBoxes" :value="rejectedBill.id"/>
+                        </td>
+                        <td class="text-nowrap">
+{{--                            <span class="text-muted" style="opacity:0.7">@{{ i+1 }}</span> <span v-if="issueIds.includes(rejectedBill.id)" class="badge badge-pill badge-danger">问题件</span>--}}
+                            <span class="text-muted" style="opacity:0.7">@{{ i+1 }}</span> <span v-if="rejectedBill.order_issue" class="badge badge-pill badge-danger">问题件</span>
+                        </td>
+                        <td class="text-muted">
+                            <span v-if="rejectedBill.is_checked==1" class="text-success">
+                                <span class="fa fa-check-square"></span> @{{ rejectedBill.checked_numbers }}
+                            </span>
+                            <span v-else>
+                                未审核
+                            </span>
+                        </td>
+                        <td class="" :class="[rejectedBill.is_finished==1?'text-success':'text-muted']">@{{rejectedBill.is_finished | yesNo}}</td>
+                        <td class="" :class="[rejectedBill.is_loaded==1?'text-success':'text-muted']">
+                            <span v-if="rejectedBill.is_loaded==4">
+                                <button class="btn btn-sm btn-info" @click="confirmBeStored($event,rejectedBill.id)">确定入库</button>
+                            </span>
+                            <span v-else>@{{rejectedBill.is_loaded | yesNoIsLoaded}}</span>
+                        </td>
+                        <td class="text-muted">@{{rejectedBill.created_at}}</td>
+                        <td><span v-if="rejectedBill.owner">@{{rejectedBill.owner.name}}</span></td>
+                        <td>@{{rejectedBill.logistic_number_return}}</td>
+                        <td class="text-muted"><span v-if="rejectedBill.logistic">@{{rejectedBill.logistic.name}}</span></td>
+                        <td>@{{rejectedBill.order_number}}</td>
+                        <td class="text-muted">@{{rejectedBill.sender}}</td>
+                        <td class="text-muted">@{{rejectedBill.mobile_sender}}</td>
+                        <td>@{{rejectedBill.logistic_number}}</td>
+                        @cannot('退货管理-到付费用')<td class="text-muted">@{{rejectedBill.fee_collected}}</td>@endcannot
+                        @can('退货管理-查询-客户定义-爱奇艺')<td class="text-muted">@{{rejectedBill.common_01}}</td>@endcan
+                        <td class="text-muted">@{{rejectedBill.common_02}}</td>
+                        <td class="text-muted">@{{rejectedBill.goods_amount}}</td>
+                        <td colspan="8">
+                            <div class="text-center" v-if="rejectedBill.detailFolding && rejectedBill.items.length>1">
+                                <a href="javascript:;" @click="rejectedBill.detailFolding=false">@{{rejectedBill.goods_amount}}件商品,点击展开明细</a></div>
+                            <table class="table table-sm" v-else>
+                                <tr v-for="item in rejectedBill.items">
+                                    <td style="width: 140px">@{{item.barcode_goods}}</td>
+                                    <td style="width: 140px">@{{item.name_goods}}</td>
+                                    <td style="width: 30px">@{{item.amount}}</td>
+                                    <td class="text-muted">@{{item.quality_label}}</td>
+                                    <td class="text-muted">@{{item.batch_number}}</td>
+                                    <td class="text-muted">@{{item.made_at}}</td>
+                                    <td class="text-muted">@{{item.validity_at}}</td>
+                                    <td class="text-muted">@{{item.remark}}</td>
+                                </tr>
+                                <tr v-if="!rejectedBill.detailFolding && rejectedBill.items.length>1">
+                                    <td colspan="8" class="text-center">
+                                        <a href="javascript:;" @click="rejectedBill.detailFolding=true">点击收起明细</a>
+                                    </td>
+                                </tr>
+                            </table>
+                        </td>
+                        {{--                        <td class="text-muted" style="max-width: 190px">@{{rejectedBill.remark}}</td>--}}
+                        <td style="min-width:150px;">
+                            @can('退货管理-编辑备注')
+                                <textarea class="form-control form-control-sm"   :rows="rejectedBill.remark?Math.ceil(rejectedBill.remark.length/8):2"  cols=8
+                                          @change="updateRejectedBillRemark($event)" :value="rejectedBill.remark" :data_id="rejectedBill.id">@{{ rejectedBill.remark }}</textarea>
+                            @else
+                                <span>@{{rejectedBill.remark}}</span>
+                            @endcan
+                        </td>
+                        <td class="text-muted">@{{rejectedBill.operator_name}}</td>
+                        @can('退货管理-编辑')
+                            <td>
+                                <span v-if="rejectedBill.is_finished!=1">
+                                @can('退货管理-编辑')
+                                        <button class="btn btn-outline-info btn-sm tooltipTarget" @click="edit(rejectedBill.id)">改</button>
+                                    @endcan
+                                    @can('退货管理-删除')
+                                        <button
+                                            class="btn btn-outline-danger btn-sm tooltipTarget" @click="destroy(rejectedBill)">删</button>
+                                    @endcan
+                                </span>
+                                <span v-else class="text-muted">已完结</span>
+                            </td>
+                        @endcan
+                    </tr>
+                </table>
+                <div class="text-info h5 btn btn">{{$rejectedBills->count()}}/{{$rejectedBills->total()}}</div>
+                {{$rejectedBills->appends($paginateParams)->links()}}
+            </div>
+        </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        let rejectedBills={!! $rejectedBills->toJson()!!}.data;
+        rejectedBills.forEach(function(rejectedBill){
+            rejectedBill.detailFolding=true;
+        })
+        let owners=[
+                @foreach($owners as $owner)
+            {id:'{{$owner->id}}',name:'{{$owner->name}}'},
+            @endforeach
+        ];
+        let logistics=[
+            @foreach($logistics as $logistic)
+            {!! $logistic !!},
+            @endforeach
+        ];
+        let qualityLabels=[
+                @foreach($qualityLabels as $qualityLabel)
+            {id:'{{$qualityLabel->id}}',name:'{{$qualityLabel->name}}'},
+            @endforeach
+        ];
+            @if(isset($paginateParams))
+        let paginateParams={!! json_encode($paginateParams) !!};
+            @endif
+        let total='{{$rejectedBills->total()}}';
+        let editUrl = "{{url('rejectedBill')}}/";
+        let destroyUrl = "{{url('rejectedBill')}}/";
+        let ajaxConfirmBeStoredUrl = '{{url("apiLocal/rejectedBill/apiConfirmBeStored")}}';
+        let ajaxCheckUrl = '{{url("apiLocal/rejectedBill/apiSetIsLoadedAll")}}';
+        let ajaxCheckAllURL = '{{url("rejected/ajaxCheckAll")}}';
+        let ajaxFinishAllUrl='{{url("rejected/ajaxFinishAll")}}';
+        let csrfInput='@csrf';
+    </script>
+    <script src="{{mix('js/queryForm/export.js')}}"></script>
+    <script src="{{mix('js/queryForm/queryForm.js')}}"></script>
+    <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
+    <script>
+        let vue = new Vue({
+            el:"#list",
+            data:{
+                rejectedBills:rejectedBills,
+                rejectedBills_checkBoxes:[],
+                owners:[
+                        @foreach($owners as $owner)
+                    {name:'{{$owner->id}}',value:'{{$owner->name}}'},
+                    @endforeach
+                ],
+                {{--issueIds:{!! $issueIds !!},--}}
+                logistics:[
+                        @foreach($logistics as $logistic)
+                    {name:'{{$logistic->id}}',value:'{{$logistic->name}}'},
+                    @endforeach
+                ],
+                qualityLabels:[
+                        @foreach($qualityLabels as $qualityLabel)
+                    {name:'{{$qualityLabel->id}}',value:'{{$qualityLabel->name}}'},
+                    @endforeach
+                ],
+            },
+            mounted:function(){
+                $(".tooltipTarget").tooltip({'trigger':'hover'});
+                $('#list').removeClass('d-none');
+                let data=[        ];
+                this.form=new query({
+                    el:"#form_div",
+                    condition:data
+                });
+                this.form.init();
+                let _this = this;
+                let column = [
+                    {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
+                        dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
+                    {name:'index',value: '序号', neglect: true},
+                    {name:'checked_numbers',value: '是否审核', neglect: true},
+                    {name: 'is_finished', value: '是否完结',neglect: true},
+                    {name: 'is_loaded', value: '是否入库', neglect: true},
+                    {name:'created_at',value: '创建时间'},
+                    {name: 'owner_name', value: '客户名称', neglect: true},
+                    {name: 'logistic_number_return', value: '退回单号'},
+                    {name: 'logistic_name', value: '退回公司', neglect: true},
+                    {name:'order_number',value: '订单号'},
+                    {name: 'sender', value: '姓名'},
+                    {name: 'mobile_sender', value: '电话'},
+                    {name: 'logistic_number', value: '原单单号'},
+                        @cannot('退货管理-到付费用'){name:'fee_collected',value: '到付费用',neglect: true},@endcannot
+                        @can('退货管理-查询-客户定义-爱奇艺'){name:'common_01',value: '寄件方省'},@endcan
+                    {name:'common_02',value: '重量'},
+                    {name:'goods_amount',value: '商品总数'},
+                    {name:'item_barcode_goods',value: '商品条码', neglect: true},
+                    {name: 'item_name_goods', value: '商品名称', neglect: true},
+                    {name: 'item_amount', value: '数量', neglect: true},
+                    {name:'item_quality_label',value: '是否正品', neglect: true},
+                    {name:'item_batch_number',value: '批次号', neglect: true},
+                    {name:'item_made_at',value: '生产日期', neglect: true},
+                    {name:'item_validity_at',value: '效期', neglect: true},
+                    {name:'item_remark',value: '备注', neglect: true},
+                    {name:'remark',value: '退单备注'},
+                    {name:'operator_name',value: '录入人'},
+                        @can('退货管理-编辑','退货管理-删除'){name:'remove',value: '操作', neglect: true},@endcan
+                ];
+                setTimeout(function () {
+                    let header = new Header({
+                        el: "#header",
+                        column: column,
+                        data: _this.rejectedBills,
+                        restorationColumn: 'id',
+                        fixedTop:($('#form_div').height())+2,
+                        offset:0.5,
+                        vue:vue,
+                        checkbox : 'rejectedBills_checkBoxes',
+                    });
+                    header.init();
+                },0);
+            },
+            watch:{
+                rejectedBills_checkBoxes:{
+                    handler(){
+                        if (this.rejectedBills_checkBoxes.length === this.rejectedBills.length){
+                            document.querySelector('#checkSelectingAll').checked = true;
+                            document.querySelector('#checkSelectingAll_temp').checked = true;
+                        }else {
+                            document.querySelector('#checkSelectingAll').checked = false;
+                            document.querySelector('#checkSelectingAll_temp').checked = false;
+                        }
+                    },
+                    deep:true
+                }
+            },
+            methods:{
+                updateRejectedBillRemark:function (e) {
+                    let target = $(e.target);
+                    let _this = this;
+                    let id = target.attr('data_id');
+                    let remark = target.val();
+                    let ajaxUrl= '{{url("rejected/changeRejectedBillRemark")}}';
+                    axios.post(ajaxUrl,{'id':id,'remark':remark}).then(function (response) {
+                        if(response.data.success){
+                            _this.updateRejectedBills(id,remark);
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess('备注修改成功');
+                        }else{
+                            tempTip.setDuration(3000);
+                            tempTip.show('备注修改失败!'+response.data.fail_info);
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('备注修改失败!网络异常:'+err);
+                    });
+
+                },
+                // 更新表格数据
+                updateRejectedBills(id,remark){
+                    this.rejectedBills.some(function(rejectedBill){
+                        if(parseInt(rejectedBill.id) === parseInt(id)){
+                            rejectedBill.remark = remark;
+                            return true;
+                        }
+                    })
+                },
+                edit(id){
+                    window.location.href=editUrl+id+"/edit";
+                    // window.open(editUrl+id+"/edit",'_blank') ;
+                },
+                destroy:function(rejectedBill){
+                    if(!confirm('确定要删除退货信息“' + rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+ '”吗?')){return;}
+                    let data=this;
+                    let url = destroyUrl+rejectedBill.id;
+                    axios.delete(url,{id:rejectedBill.id})
+                        .then(function (response) {
+                            if(response.data.success){
+                                for (let i = 0; i < data.rejectedBills.length; i++) {
+                                    if (data.rejectedBills[i].id===rejectedBill.id){
+                                        data.rejectedBills.splice(i,1);
+                                        break;
+                                    }
+                                }
+                                tempTip.setDuration(1000);
+                                tempTip.showSuccess('删除退货信息"'+rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+'"成功!')
+                            }else{
+                                tempTip.setDuration(1000);
+                                tempTip.show('删除退货信息"'+rejectedBill.owner.name+':'+rejectedBill.logistic_number_return+'"失败!')
+                            }
+                        })
+                        .catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show('删除退货信息失败!'+'网络错误:' + err);
+                        });
+                },
+                cancelCheckConfirmAll:function(){
+                    $('#checkConfirmingAll').tooltip('hide');
+                    setTimeout(function () {
+                        $(".tooltipTarget").tooltip({'trigger':'hover'})
+                    }, 10);
+                    this.rejectedBills.forEach(function(rejectedBill){
+                        if(rejectedBill.is_checked===-1)
+                            rejectedBill.is_checked='0';
+                    })
+                },
+                setIsLoaded_batch:function(val){
+                    let _this=this;
+                    if(_this.rejectedBills_checkBoxes.length===0){
+                        tempTip.show('没有勾选记录');
+                        $(e.target).val("");
+                        return;
+                    }
+                    let is_loaded=0;
+                    let is_loadedLabel='否';
+                    if(parseInt(val)===1){
+                        is_loaded=1;
+                        is_loadedLabel='是';
+                    }else if(parseInt(val)===2){
+                        is_loaded=2;
+                        is_loadedLabel='待推单';
+                    }else if(parseInt(val)===4){
+                        is_loaded=4;
+                        is_loadedLabel='待确认';
+                    }else if(val==="null"){
+                        is_loaded='null';
+                        is_loadedLabel='无需入库';
+                    }
+                    if(!confirm("确定要标记所有勾选入库情况为'"+is_loadedLabel+"'吗")){return;}
+                    axios.post(ajaxCheckUrl,{ids:_this.rejectedBills_checkBoxes,is_loaded:is_loaded}).then(function(response){
+                        if(response.data.success){
+                            _this.rejectedBills_checkBoxes.forEach(function(id){
+                                _this.rejectedBills.forEach(function(bill){
+                                    if(bill.id===id){
+                                        bill.is_loaded=is_loaded;
+                                    }
+                                });
+                            });
+                            tempTip.setDuration(1000);
+                            tempTip.showSuccess('修改勾选记录的入库状态成功');
+                        }else{
+                            tempTip.setDuration(2500);
+                            tempTip.show('修改勾选记录的入库状态失败,错误:'+response.data.fail_info);
+                        }
+                    }).catch(function (e) {
+                        alert('网络连接错误:'+e);
+                        tempTip.setDuration(2500);
+                        tempTip.show('审核勾选内容失败,网络连接错误:'+e);
+
+                    });
+                    $(e.target).val("")
+                },
+                checkBoxAllToggle:function(e){
+                    if (e.target.checked) {
+                        this.rejectedBills.forEach((el) => {
+                            if (!el.id) this.rejectedBills_checkBoxes.push(el.id);
+                            if (el.id && this.rejectedBills_checkBoxes.indexOf(el.id) == '-1') {
+                                this.rejectedBills_checkBoxes.push(el.id);
+                            }
+                        });
+                    } else {
+                        this.rejectedBills_checkBoxes = [];
+                    }
+                },
+                checkAll:function(){
+                    let _this=this;
+                    if(_this.rejectedBills_checkBoxes.length===0){
+                        tempTip.show('没有勾选记录');
+                        return
+                    }
+                    if(!confirm("确定要标记所有勾选内容为'已审核'吗")){return;}
+                    axios.post(ajaxCheckAllURL,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
+                        if(response.data.success){
+                            response.data.rejecteds.forEach(function (rejected) {
+                                _this.rejectedBills.forEach(function(rejectedBill){
+                                    if(parseInt(rejectedBill.id)===parseInt(rejected.id)){
+                                        rejectedBill.is_checked=1;
+                                        rejectedBill.checked_numbers=rejected.checked_numbers;
+                                    }
+                                });
+                            });
+                            tempTip.setDuration(1000);
+                            tempTip.showSuccess('审核勾选内容成功');
+                        }else{
+                            tempTip.setDuration(2500);
+                            tempTip.show('审核勾选内容失败,错误:'+response.data.fail_info);
+                        }
+                    }).catch(function (e) {
+                        alert('网络连接错误:'+e);
+                        tempTip.setDuration(2500);
+                        tempTip.show('审核勾选内容失败,网络连接错误:'+e);
+                    })
+                },
+                confirmBeStored:function($e,id){
+                    let _this=this;
+                    axios.post(ajaxConfirmBeStoredUrl,{id:id}).then(function(response){
+                        if(response.data.success){
+                            _this.rejectedBills.forEach(function(rejectedBill){
+                                if(rejectedBill.id===id){
+                                    rejectedBill.is_loaded=1;
+                                }
+                            });
+                            tempTip.setDuration(1000);
+                            tempTip.showSuccess('确认入库成功');
+                        }else{
+                            tempTip.setDuration(2500);
+                            tempTip.okWindow('数据异常无法确认!请在WMS确定入库状态后,勾选该条目手动修改相应入库状态!','知道了')
+                        }
+                    }).catch(function (e) {
+                        alert('确认失败,网络连接错误:'+e);
+                        tempTip.setDuration(2500);
+                        tempTip.show('确认失败,网络连接错误:'+e);
+
+                    })
+                },
+                finishAll:function(){
+                    let _this=this;
+                    if(_this.rejectedBills_checkBoxes.length===0){
+                        tempTip.show('没有勾选记录');
+                        return
+                    }
+                    if(!confirm("确定要标记所有勾选内容为'已完结'吗")){return;}
+                    axios.post(ajaxFinishAllUrl,{ids:_this.rejectedBills_checkBoxes}).then(function(response){
+                        if(response.data.success){
+                            _this.rejectedBills.forEach(function(rejectedBill){
+                                _this.rejectedBills_checkBoxes.forEach(function (checkedId) {
+                                    if(rejectedBill.id===checkedId){
+                                        rejectedBill.is_finished=1;
+                                    }
+                                });
+                            });
+                            tempTip.setDuration(1000);
+                            tempTip.showSuccess('标记勾选内容为完结成功');
+                        }else{
+                            tempTip.setDuration(2500);
+                            tempTip.show('标记勾选内容为完结失败,错误:'+response.data.fail_info);
+                        }
+                    }).catch(function (e) {
+                        alert('网络连接错误:'+e);
+                        tempTip.setDuration(2500);
+                        tempTip.show('标记勾选内容完结失败,网络连接错误:'+e);
+                    })
+                },
+                exportExcel:function(checkAllSign){
+                    let url = '{{url('rejected/export')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(checkAllSign,this.rejectedBills_checkBoxes,url,total,token);
+                },
+
+            },
+            filters:{
+                yesNo:function (val) {
+                    if(!val||val===0||val==='0'){return '否'}
+                    return '是'
+                },
+                yesNoIsLoaded:function (val) {
+                    switch(val){
+                        case 0:case '0':return '否';
+                        case 1:case '1':return '是';
+                        case 2:case '2':return '待推单';
+                        case 3:case '3':return '交互异常';
+                        case 4:case '4':return '待确认';
+                        case null:case 'null':return '无需入库';
+                    }
+                    return '';
+                }
+            }
+        });
+    </script>
+@endsection

+ 15 - 0
resources/views/station/monitor/menu.blade.php

@@ -0,0 +1,15 @@
+<div id="nav2">
+    @component('station.menu')
+    @endcomponent
+    <div class="container-fluid nav3">
+        <div class="card menu-third" >
+            <ul class="nav nav-pills">
+                @can('站管理-监视器')
+                    <li class="nav-item">
+                        <a class="nav-link" href="{{url('inventory/statement/changeInventory?range=1')}}" :class="{active:isActive('changeInventory',3)}">监视器</a>
+                    </li> @endcan
+            </ul>
+        </div>
+    </div>
+</div>
+

+ 3 - 1
routes/api/thirdPart/haiq.php

@@ -8,7 +8,9 @@ use Illuminate\Support\Facades\Route;
 
 
 Route::group(['prefix'=>'storage'],function(){
-    Route::post('relocate', "StorageController@relocate");//移库
+    Route::post('moveBin', "StorageController@moveBin");//移库
+    Route::post('taskUpdate', "StorageController@taskUpdate");//移库
+    Route::post('exception', "StorageController@exception");//移库
 });
 Route::group(['prefix'=>'pickStation'],function(){
     Route::post('processed', "PickStationController@processed");//移库

+ 5 - 0
routes/web.php

@@ -589,6 +589,11 @@ Route::group(['prefix'=>'customer'],function(){
     });
     Route::get('relating',function (){return view('customer.relating');});
 });
+
+/** 站管理 */
+Route::group(['prefix'=>'station'],function(){
+    Route::get('index',function (){return view('station.index');});
+});
 /** 控制台 */
 Route::group(['prefix'=>'control'],function () {
    Route::get('panel/menu','ControlPanelController@index') ;

+ 36 - 0
tests/Services/OrderCountingRecordService/DateTestTest.php

@@ -3,6 +3,8 @@
 namespace OrderCountingRecordService;
 
 
+use App\Services\CacheService;
+use App\Services\OrderCountingRecordService;
 use Carbon\Carbon;
 use DateInterval;
 use DatePeriod;
@@ -11,6 +13,15 @@ use Tests\TestCase;
 
 class DateTestTest extends TestCase
 {
+    /** @var OrderCountingRecordService $orderCountingRecordService */
+    public $orderCountingRecordService;
+
+    public function setUp(): void
+    {
+        parent::setUp();
+        $this->orderCountingRecordService = app(OrderCountingRecordService::class);
+    }
+
     /**
      * @test
      */
@@ -20,4 +31,29 @@ class DateTestTest extends TestCase
         $this->assertTrue('2020-48' == Carbon::now()->year . '-' . Carbon::now()->week);
         $this->assertTrue('2020-11' == Carbon::now()->year . '-' . Carbon::now()->month);
     }
+
+    /**
+     * @test
+     */
+    public function compare_date()
+    {
+        $dateStr = '2020-12-30';
+
+        $end = Carbon::parse($dateStr)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $dateStr;
+
+        dd($end);
+    }
+
+    /**
+     * @test
+     */
+    public function for_date()
+    {
+        $start =  Carbon::now()->subMonth()->toDateString();
+        $end =  Carbon::now()->toDateString();
+        $unit = '月';
+        dump($start, $end, $unit);
+        $dateArray =$this->orderCountingRecordService->periodDateToArray($start, $end, $unit);
+        dd($dateArray);
+    }
 }

+ 1 - 1
tests/Services/OrderCountingRecordService/OrderCountingRecordServiceGetTest.php

@@ -35,7 +35,7 @@ class OrderCountingRecordServiceGetTest extends TestCase
         $start = Carbon::now()->subDays(2)->format('Y-m-d');
         $end = (new Carbon())->toDateString();
 
-        $this->actingAs(factory(User::class)->create(['name' => 'yang']));
+        $this->actingAs($user = factory(User::class)->create(['name' => 'yang']));
 
         $owner = factory(Owner::class)->create();
         $orders = factory(Order::class)->times(20)->create([

+ 9 - 3
tests/Services/OwnerPriceExpressService/OwnerPriceExpressServiceTest.php

@@ -185,13 +185,19 @@ class OwnerPriceExpressServiceTest extends  TestCase
             "initial_weight_price" => 2,     //初始单价 4.8
             "additional_weight_price"=>2.2,  //续重单价
         ]);
-        $model->owners()->sync([1]);
-        $model->logistics()->sync([1]);
-        $result = $this->service->matching(18.6,1,1,1);
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1
+        ]);
+        $logistic = factory(Logistic::class)->create();
+        $model->owners()->sync([$owner->id]);
+        $model->logistics()->sync([$logistic->id]);
+        $result = $this->service->matching(18.6,$owner->id,$logistic->id,1);
         $this->assertEquals(18,$result);
         $model->owners()->sync([]);
         $model->logistics()->sync([]);
         OwnerPriceExpressProvince::destroy($detail->id);
+        Owner::destroy($owner->id);
+        Logistic::destroy($logistic->id);
     }
 
 

+ 4 - 4
tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php

@@ -137,9 +137,9 @@ class OwnerPriceOperationServiceTest extends  TestCase
             /** @var Mock $mock */
             $mock->shouldReceive("matchFeature")->andReturn(true);
         });
-        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>55]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>55,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"入库");
         $this->assertEquals(12.88,$result);
-        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>57]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>57,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"出库");
         $this->assertEquals(99.5,$result);
     }
     /**
@@ -147,9 +147,9 @@ class OwnerPriceOperationServiceTest extends  TestCase
      */
     public function testMatchRule1()
     {
-        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>56]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>56,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"入库");
         $this->assertEquals(26.64,$result);
-        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>58]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>58,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"出库");
         $this->assertEquals(58.4,$result);
     }
 

+ 0 - 2
tests/Unit/EchoTest.php

@@ -2,8 +2,6 @@
 
 namespace Tests\Unit;
 
-use App\Services\CacheService;
-use Illuminate\Support\Facades\Cache;
 use Tests\TestCase;
 
 class EchoTest extends TestCase

+ 0 - 0
tests/CreatesApplication.php → tests/webApi/CreatesApplication.php


+ 0 - 0
tests/TestCase.php → tests/webApi/TestCase.php


+ 1 - 3
tests/webApi/flux.http

@@ -8,9 +8,7 @@
 POST https://testwas.baoshi56.com/api/thirdPart/flux/package/new
 Content-Type: application/json
 
-{"request":{"TASKID":"3509760355826","Orderno":"SO200302002282","palletid":"3509760355826","SOReference5":"3509760355826",
-  "Customer":"BILI","Consigneename":"吴凡","CarrierID":"YUNDA","USERDEFINE1":"W200302000204","USERDEFINE2":"09.[BILI]截单波次","USERDEFINE3":null}}
-
+"[{"taskMode":8,"bins":[{"taskCode":"TEST-BS2011160004","binCode":"TESTBINCODE-0","fromLocCode":"BIN-IN1"}],"groupCode":4,"priority":20,"sequenceFlag":-1}]
 ###
 
 

+ 0 - 0
tests/package.http → tests/webApi/package.http


+ 0 - 0
tests/packageYifang.http → tests/webApi/packageYifang.http


+ 0 - 0
tests/route.http → tests/webApi/route.http


+ 0 - 0
tests/sortingFluxNewBatch.http → tests/webApi/sortingFluxNewBatch.http


+ 0 - 0
tests/sortingHaochuangProcess.http → tests/webApi/sortingHaochuangProcess.http


Some files were not shown because too many files changed in this diff