Просмотр исходного кода

Merge branch 'master' into Haozi

# Conflicts:
#	app/Http/Controllers/TestController.php
#	app/Services/OwnerService.php
haozi 5 лет назад
Родитель
Сommit
d7fffb6fee
63 измененных файлов с 1682 добавлено и 110 удалено
  1. 1 0
      .gitignore
  2. 5 1
      app/Batch.php
  3. 120 19
      app/Console/Commands/SyncBatchTask.php
  4. 3 1
      app/Console/Kernel.php
  5. 1 1
      app/Exceptions/Handler.php
  6. 12 19
      app/Http/Controllers/ControlPanelController.php
  7. 85 0
      app/Http/Controllers/MaterialBoxController.php
  8. 85 0
      app/Http/Controllers/StationController.php
  9. 85 0
      app/Http/Controllers/StationMissionBatchController.php
  10. 85 0
      app/Http/Controllers/StationMissionBatchTypeController.php
  11. 85 0
      app/Http/Controllers/StationMissionCommodityController.php
  12. 85 0
      app/Http/Controllers/StationMissionMaterialBoxController.php
  13. 85 0
      app/Http/Controllers/StationRuleBatchController.php
  14. 85 0
      app/Http/Controllers/StationTypeController.php
  15. 53 0
      app/Http/Controllers/TestController.php
  16. 11 6
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  17. 10 0
      app/MaterialBox.php
  18. 2 0
      app/OwnerFeeDetail.php
  19. 24 0
      app/Services/BatchService.php
  20. 15 0
      app/Services/DocWaveHeaderService.php
  21. 4 4
      app/Services/OrderCountingRecordService.php
  22. 41 0
      app/Services/OrderService.php
  23. 16 11
      app/Services/OwnerPriceExpressService.php
  24. 7 0
      app/Services/OwnerService.php
  25. 9 0
      app/Services/ProvinceService.php
  26. 10 0
      app/Station.php
  27. 10 0
      app/StationMissionBatch.php
  28. 10 0
      app/StationMissionBatchType.php
  29. 10 0
      app/StationMissionCommodity.php
  30. 10 0
      app/StationMissionMaterialBox.php
  31. 10 0
      app/StationRuleBatch.php
  32. 10 0
      app/StationType.php
  33. 12 0
      database/factories/MaterialBoxFactory.php
  34. 12 0
      database/factories/StationFactory.php
  35. 12 0
      database/factories/StationMissionBatchFactory.php
  36. 12 0
      database/factories/StationMissionBatchTypeFactory.php
  37. 12 0
      database/factories/StationMissionCommodityFactory.php
  38. 12 0
      database/factories/StationMissionMaterialBoxFactory.php
  39. 12 0
      database/factories/StationRuleBatchFactory.php
  40. 12 0
      database/factories/StationTypeFactory.php
  41. 0 38
      database/migrations/2020_07_24_072012_create_orders_table.php.bak
  42. 1 1
      database/migrations/2020_07_29_155624_create_orders_table.php
  43. 36 0
      database/migrations/2020_11_30_133112_save_value_store_data_date.php
  44. 35 0
      database/migrations/2020_11_30_140957_create_station_types_table.php
  45. 43 0
      database/migrations/2020_11_30_140958_create_stations_table.php
  46. 35 0
      database/migrations/2020_11_30_142346_create_station_rule_batches_table.php
  47. 35 0
      database/migrations/2020_11_30_142430_create_station_mission_batches_table.php
  48. 6 3
      database/migrations/2020_11_30_151800_create_station_mission_batch_types_table.php
  49. 36 0
      database/migrations/2020_11_30_153512_add_column_outer_table_owner_fee_details.php
  50. 32 0
      database/migrations/2020_11_30_155611_create_material_boxes_table.php
  51. 35 0
      database/migrations/2020_11_30_155713_create_station_mission_material_boxes_table.php
  52. 38 0
      database/migrations/2020_11_30_174327_create_station_mission_commodities_table.php
  53. 16 0
      database/seeds/MaterialBoxSeeder.php
  54. 16 0
      database/seeds/StationMissionBatchSeeder.php
  55. 16 0
      database/seeds/StationMissionBatchTypeSeeder.php
  56. 16 0
      database/seeds/StationMissionCommoditySeeder.php
  57. 16 0
      database/seeds/StationMissionMaterialBoxSeeder.php
  58. 16 0
      database/seeds/StationRuleBatchSeeder.php
  59. 16 0
      database/seeds/StationSeeder.php
  60. 16 0
      database/seeds/StationTypeSeeder.php
  61. 5 5
      resources/views/control/panel.blade.php
  62. 36 0
      tests/Services/OrderCountingRecordService/DateTestTest.php
  63. 1 1
      tests/Services/OrderCountingRecordService/OrderCountingRecordServiceGetTest.php

+ 1 - 0
.gitignore

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

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

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

@@ -2,42 +2,143 @@
 
 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]);
+                }
+            }
+        }
 
+        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/StationMissionBatchController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationMissionBatch;
+use Illuminate\Http\Request;
+
+class StationMissionBatchController 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\StationMissionBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationMissionBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationMissionBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationMissionBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationMissionBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationMissionBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationMissionBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationMissionBatch $stationMissionBatch)
+    {
+        //
+    }
+}

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

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationMissionBatchType;
+use Illuminate\Http\Request;
+
+class StationMissionBatchTypeController 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\StationMissionBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationMissionBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationMissionBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationMissionBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationMissionBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationMissionBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationMissionBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationMissionBatchType $stationMissionBatchType)
+    {
+        //
+    }
+}

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

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationMissionCommodity;
+use Illuminate\Http\Request;
+
+class StationMissionCommodityController 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\StationMissionCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationMissionCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationMissionCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationMissionCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationMissionCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationMissionCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationMissionCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationMissionCommodity $stationMissionCommodity)
+    {
+        //
+    }
+}

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

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationMissionMaterialBox;
+use Illuminate\Http\Request;
+
+class StationMissionMaterialBoxController 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\StationMissionMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationMissionMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationMissionMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationMissionMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationMissionMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationMissionMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationMissionMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationMissionMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+}

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

+ 53 - 0
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;
@@ -46,10 +47,12 @@ use App\Services\OrderService;
 use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
 use App\Services\OwnerService;
+use App\Services\ProvinceService;
 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;
@@ -1006,6 +1009,11 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         app(StoreService::class)->insertStore($param);
         var_dump('end',Carbon::now());
     }
+    public  function  testSyncAsn(){
+        $startDate=Carbon::parse('2020-11-12 17:48:00')->subSeconds(65)->format('Y-m-d H:i:s');
+        app(StoreService::class)->syncWmsAsnData($startDate);
+    }
+
     public function changeOrder()
     {
         /**
@@ -1220,4 +1228,49 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         $commodityService=app(CommodityService::class);
         $commodityService->pushCommodityToCache();
     }
+
+    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'];

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

+ 24 - 0
app/Services/BatchService.php

@@ -0,0 +1,24 @@
+<?php 
+
+namespace App\Services; 
+
+use App\Batch;
+
+Class BatchService
+{ 
+    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)
+    {
+        return Batch::query()->insert($insert);
+    }
+
+}

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

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

+ 41 - 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;
@@ -1146,4 +1148,43 @@ 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->status != "订单完成")return false;
+        if (!$order->packages)$order->load("packages");
+
+        /** @var OwnerPriceExpressService $service */
+        $service = app("OwnerPriceExpressService");
+        $logistic_fee = 0;
+        foreach ($order->packages as $package){
+            $provinceName = $order->province;
+            $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                return app("ProvinceService")->first(["name"=>$provinceName]);
+            },86400);
+            if (!$province){$logistic_fee = null;break;}
+
+            $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+            if ($fee<0){$logistic_fee = null;break;}
+
+            $logistic_fee += $fee;
+        }
+
+        $work_fee = 0;
+        /** @var OwnerPriceOperationService $service */
+        $service = app("OwnerPriceOperationService");
+        $service->matchRule($order,[]);
+
+    }
 }

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

+ 7 - 0
app/Services/OwnerService.php

@@ -233,4 +233,11 @@ Class OwnerService
         return $collect;
     }
 
+    public function codeGetOwner($code)
+    {
+        return app(CacheService::class)->getOrExecute("owner_".$code,function ()use($code){
+            return Owner::query()->firstOrCreate(["code"=>$code],["code"=>$code,"name"=>$code]);
+        });
+    }
+
 }

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

+ 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/StationMissionBatch.php

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

+ 10 - 0
app/StationMissionBatchType.php

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

+ 10 - 0
app/StationMissionCommodity.php

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

+ 10 - 0
app/StationMissionMaterialBox.php

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

+ 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/StationType.php

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

+ 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\StationMissionBatch;
+use Faker\Generator as Faker;
+
+$factory->define(StationMissionBatch::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionBatchTypeFactory.php

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

+ 12 - 0
database/factories/StationMissionCommodityFactory.php

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

+ 12 - 0
database/factories/StationMissionMaterialBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationMissionMaterialBox;
+use Faker\Generator as Faker;
+
+$factory->define(StationMissionMaterialBox::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_mission_batches_table.php

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

+ 6 - 3
database/migrations/2020_11_27_133112_save_value_store_data.php → database/migrations/2020_11_30_151800_create_station_mission_batch_types_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 CreateStationMissionBatchTypesTable extends Migration
 {
     /**
      * Run the migrations.
@@ -13,7 +13,10 @@ class SaveValueStoreData extends Migration
      */
     public function up()
     {
-        \App\ValueStore::query()->firstOrCreate(["name"=>"wave_last_sync_date"]);
+        Schema::create('station_mission_batch_types', function (Blueprint $table) {
+            $table->id();
+            $table->timestamps();
+        });
     }
 
     /**
@@ -23,6 +26,6 @@ class SaveValueStoreData extends Migration
      */
     public function down()
     {
-        \App\ValueStore::query()->where("name","wave_last_sync_date")->delete();
+        Schema::dropIfExists('station_mission_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");
+        });
+    }
+}

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

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

+ 35 - 0
database/migrations/2020_11_30_155713_create_station_mission_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 CreateStationMissionMaterialBoxesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_mission_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_mission_material_boxes');
+    }
+}

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

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStationMissionCommoditiesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('station_mission_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_mission_commodities_s_m_s_index');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('station_mission_commodities');
+    }
+}

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

+ 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: '日',

+ 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([