Переглянути джерело

Merge branch 'master' into Haozi

hu hao 5 роки тому
батько
коміт
435722f4fc
84 змінених файлів з 1774 додано та 636 видалено
  1. 67 0
      app/Console/Commands/CheckCacheRackStorage.php
  2. 2 0
      app/Console/Commands/SyncBatchTask.php
  3. 8 3
      app/Console/Commands/SyncOrderPackageLogisticRouteTask.php
  4. 1 0
      app/Console/Kernel.php
  5. 3 1
      app/Events/DeliveryAppointmentEvent.php
  6. 6 1
      app/Feature.php
  7. 9 1
      app/Filters/OrderPackageFilters.php
  8. 11 2
      app/Http/Controllers/CacheShelfController.php
  9. 3 5
      app/Http/Controllers/CarTypesController.php
  10. 15 0
      app/Http/Controllers/DeliveryAppointmentController.php
  11. 57 9
      app/Http/Controllers/StationRuleBatchController.php
  12. 87 0
      app/Http/Controllers/StorageController.php
  13. 49 4
      app/Http/Controllers/TestController.php
  14. 12 0
      app/Http/Controllers/WaveController.php
  15. 76 76
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  16. 1 1
      app/Http/Controllers/api/thirdPart/haiq/LightController.php
  17. 6 2
      app/Http/Controllers/api/thirdPart/haiq/StorageController.php
  18. 2 0
      app/Http/Kernel.php
  19. 1 0
      app/Http/Middleware/Authenticate.php
  20. 21 0
      app/Http/Middleware/CheckCsrfToken.php
  21. 1 0
      app/Http/Middleware/VerifyCsrfToken.php
  22. 70 0
      app/Http/Requests/Station/StationRuleBatchRequest.php
  23. 50 0
      app/Jobs/LogisticSFSync.php
  24. 3 1
      app/Jobs/LogisticYDSync.php
  25. 3 1
      app/Jobs/LogisticYTOSync.php
  26. 3 2
      app/Jobs/LogisticZopSync.php
  27. 1 1
      app/Logistic.php
  28. 30 1
      app/MaterialBox.php
  29. 2 2
      app/OracleDOCWaveDetails.php
  30. 1 3
      app/Package.php
  31. 2 0
      app/Providers/AppServiceProvider.php
  32. 0 3
      app/Providers/AuthServiceProvider.php
  33. 97 40
      app/Services/CacheShelfService.php
  34. 27 10
      app/Services/ForeignHaiRoboticsService.php
  35. 0 121
      app/Services/LogisticSFService.php
  36. 7 3
      app/Services/LogisticYDService.php
  37. 5 1
      app/Services/LogisticYTOService.php
  38. 34 0
      app/Services/MaterialBoxService.php
  39. 10 10
      app/Services/OracleDocWaveDetailService.php
  40. 53 41
      app/Services/OrderPackageReceivedSyncService.php
  41. 10 2
      app/Services/OwnerPriceOperationService.php
  42. 2 2
      app/Services/PackageStatisticsService.php
  43. 13 2
      app/Services/StationTaskMaterialBoxService.php
  44. 2 2
      app/Services/common/BatchUpdateService.php
  45. 5 0
      app/StationRuleBatch.php
  46. 1 1
      app/StationTaskMaterialBox.php
  47. 27 0
      app/Storage.php
  48. 1 1
      app/library/baidu-api-speech/lib/2a7552bdd1b678c303ad53645baeafce
  49. 0 44
      database/migrations/2021_05_11_101611_exception_message_able_null_order_packages_table.php
  50. 32 0
      database/migrations/2021_05_19_154807_change_logistics_table_add_english_name_column.php
  51. 38 0
      database/migrations/2021_05_19_171047_add_station_rule_batch_author.php
  52. 34 0
      database/migrations/2021_05_19_172118_create_storages_table.php
  53. 32 0
      database/migrations/2021_05_19_173442_add_materialBoxes_field_status.php
  54. 34 0
      database/migrations/2021_05_20_142418_change_car_types_add_length_column.php
  55. 1 0
      database/seeds/StationRuleBatchSeeder.php
  56. 25 4
      public/t.php
  57. 2 0
      resources/js/queryForm/header.js
  58. 10 3
      resources/views/customer/project/create.blade.php
  59. 2 1
      resources/views/customer/project/part/_operation.blade.php
  60. 7 0
      resources/views/maintenance/logistic/create.blade.php
  61. 9 2
      resources/views/maintenance/logistic/edit.blade.php
  62. 2 0
      resources/views/maintenance/logistic/index.blade.php
  63. 1 1
      resources/views/maintenance/tutorial/create.blade.php
  64. 11 6
      resources/views/package/logistic/index.blade.php
  65. 23 24
      resources/views/package/measureMonitor/index.blade.php
  66. 4 1
      resources/views/station/cachingShelf/list/_fillBox.blade.php
  67. 41 15
      resources/views/station/cachingShelf/list/index.blade.php
  68. 5 0
      resources/views/station/menu.blade.php
  69. 51 0
      resources/views/station/rule/_edit.blade.php
  70. 47 0
      resources/views/station/rule/_table.blade.php
  71. 140 0
      resources/views/station/rule/index.blade.php
  72. 9 0
      resources/views/station/rule/menu.blade.php
  73. 57 16
      resources/views/store/deliveryAppointment/exhibition.blade.php
  74. 2 1
      resources/views/store/inStorage/cacheRackStorage.blade.php
  75. 29 55
      resources/views/transport/waybill/edit.blade.php
  76. 12 10
      resources/views/transport/waybill/index.blade.php
  77. 10 1
      routes/apiLocal.php
  78. 12 6
      routes/web.php
  79. 1 1
      tests/Feature/LogisticZopSyncTest.php
  80. 114 0
      tests/Services/CacheShelfService/ClearTaskTest.php
  81. 4 3
      tests/Services/LogisticQiaoSFService/LogisticQiaoSFServiceTest.php
  82. 36 0
      tests/Services/LogisticSFSync/HandleTest.php
  83. 40 0
      tests/Services/OrderPackageReceivedSyncService/SyncLogisticRouteTest.php
  84. 0 87
      tests/Services/OrderPackageReceivedSyncService/TestGetLogisticNumbers.php

+ 67 - 0
app/Console/Commands/CheckCacheRackStorage.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Station;
+use App\StationTask;
+use App\StationTaskMaterialBox;
+use Illuminate\Console\Command;
+use Illuminate\Database\Eloquent\Collection;
+
+class CheckCacheRackStorage extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'check:cacheRack';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'check cache rack storage info';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     */
+    public function handle()
+    {
+        $stations = Station::query()->select("id","code")->where("station_type_id",5)
+            ->whereNotNull("parent_id")
+            ->whereNotIn("id",StationTask::query()->select("station_id")
+                ->where("status","!=","完成")->whereIn("station_id",Station::query()->select("id")->where("station_type_id",5)
+                    ->whereNotNull("parent_id"))->groupBy("station_id"))
+            ->get();
+        foreach ($stations as $station){
+            $box = app("MaterialBoxService")->getAnEmptyBox();
+            if (!$box)continue;
+            $task = StationTask::query()->create([
+                'status' => "待处理",
+                'station_id' => $station->id,
+            ]);
+            $collection = new Collection();
+            $collection->append(StationTaskMaterialBox::query()->create([
+                'station_id' => $station->id,
+                'material_box_id'=>$box->id,
+                'status'=>"待处理",
+                'type' => '取',
+                'station_task_id' => $task->id,
+            ]));
+            app("ForeignHaiRoboticsService")->fetchGroup($station->code,$collection,'','立架出至缓存架');
+        }
+    }
+}

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

@@ -251,6 +251,7 @@ sql;
             LogService::log(__METHOD__,"波次同步-修改订单波次号",json_encode($updateOrder));
             app("BatchService")->checkBatchOrderInfo($updatingBatches);
             LogService::log(__METHOD__,"修改过的波次_",json_encode($updatingBatches));
+            LogService::log(__METHOD__,"波次注册一入口",json_encode($updatingBatches));
             BatchTaskJob::dispatch($updatingBatches);    //在这里为波次注册队列任务!
         }
 
@@ -278,6 +279,7 @@ sql;
                     app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
                 }
                 app("BatchService")->checkBatchOrderInfo($batches);
+                LogService::log(__METHOD__,"波次注册二入口",json_encode($batches));
                 BatchTaskJob::dispatch($batches);    //在这里为波次注册队列任务!
             }
         }

+ 8 - 3
app/Console/Commands/SyncOrderPackageLogisticRouteTask.php

@@ -8,6 +8,10 @@ use Illuminate\Console\Command;
 
 class SyncOrderPackageLogisticRouteTask extends Command
 {
+    /**
+     * @var OrderPackageReceivedSyncService $service
+     */
+    public $service;
     /**
      * The name and signature of the console command.
      *
@@ -39,8 +43,9 @@ class SyncOrderPackageLogisticRouteTask extends Command
      */
     public function handle()
     {
-        LogService::log(__CLASS__,"同步快递信息",'');
-        ini_set('memory_limit','2226M');
-        (new OrderPackageReceivedSyncService)->syncLogisticRoute();
+        LogService::log(SyncOrderPackageLogisticRouteTask::class, "同步快递信息定时任务启动", '');
+        ini_set('memory_limit', '2226M');
+        $this->service = app('OrderPackageReceivedSyncService');
+        $this->service->syncLogisticRoute();
     }
 }

+ 1 - 0
app/Console/Kernel.php

@@ -80,6 +80,7 @@ class  Kernel extends ConsoleKernel
         $schedule->command('create:weightStatistic')->dailyAt("00:30");
         $schedule->command('sync:carrier')->hourlyAt(1);
         $schedule->command('createProcurementTotalBill')->monthlyOn(1);
+        $schedule->command('check:cacheRack')->everyMinute();
     }
 
     /**

+ 3 - 1
app/Events/DeliveryAppointmentEvent.php

@@ -29,7 +29,7 @@ class DeliveryAppointmentEvent implements ShouldBroadcastNow
             $query->withCount("cars");
         }]);
 
-        $owner = $car->deliveryAppointment->owner->name ?? "";
+        $owner = $delivery->deliveryAppointment->owner->name ?? "";
         $len = mb_strlen($owner);
         $ownerName = "";
         for($i=0;$i<$len-1;$i++)$ownerName .= "*";
@@ -45,6 +45,8 @@ class DeliveryAppointmentEvent implements ShouldBroadcastNow
         $delivery->type = DeliveryAppointment::TYPE[$delivery->deliveryAppointment->type_mark] ?? '';
         $delivery->period = isset($delivery->deliveryAppointment->date_period) ? ($delivery->deliveryAppointment->date_period==0 ? '上午' : '下午') : '';
         $delivery->delivery_time = $delivery->delivery_time ? substr($delivery->delivery_time,11,5) : '';
+
+        $delivery->morrow = $delivery->deliveryAppointment->appointment_date == date('Y-m-d',strtotime("+1 day"));
         $this->delivery = $delivery->withoutRelations();
     }
 

+ 6 - 1
app/Feature.php

@@ -19,7 +19,7 @@ class Feature extends Model
     const TYPE = [
         0 => "商品名称",  //二级
         1 => "订单类型",
-        2 => "承运商",
+        2 => "承运商名称",
         3 => "店铺类型",
         4 => "波次类型",
         5 => "商品备注",  //二级
@@ -27,6 +27,8 @@ class Feature extends Model
         7 => "订单备注",
         10=> "订单商品数",//二级
         11=> "属性仓",
+        12=> "订单商品数",
+        13=> "承运商英文名",
     ];
     //额外定义 8:商品数量 9:商品
     const TYPE_NODE = [0,5,6,8,9,10]; //标注二级类型
@@ -41,6 +43,7 @@ class Feature extends Model
             9 => "store_items.commodity",
             10=> "store_items.total",
             11=> "warehouse.name",
+            12=> "total",
         ],
         "order" => [
             0 => "packages.commodities.commodity.name",
@@ -54,6 +57,8 @@ class Feature extends Model
             8 => 'packages.commodities.amount',
             9 => 'packages.commodities.commodity',
             10=> 'packages.commodities.total',
+            12=> "total",
+            13=> "logistic.english_name",
         ]
     ];
 }

+ 9 - 1
app/Filters/OrderPackageFilters.php

@@ -15,7 +15,7 @@ class OrderPackageFilters
     protected $request;
     protected $queryBuilder;
     protected $filters = ['logistic_number', 'status', 'received_at_start',
-        'received_at_end', 'is_weighed', 'logistic_id', 'owner_id', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date'];
+        'received_at_end', 'is_weighed', 'logistic_id', 'owner_id', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date','has_transfer_status'];
 
     public function __construct(Request $request)
     {
@@ -49,6 +49,14 @@ class OrderPackageFilters
     {
         $this->queryBuilder->where('exception_type', $exception_type);
     }
+    private function has_transfer_status($has_transfer_status)
+    {
+        if ($has_transfer_status=='是') {
+            $this->queryBuilder->whereNotNull('transfer_status');
+        } elseif ($has_transfer_status=='否') {
+            $this->queryBuilder->whereNull('transfer_status');
+        }
+    }
 
     private function status($status)
     {

+ 11 - 2
app/Http/Controllers/CacheShelfController.php

@@ -51,9 +51,18 @@ class CacheShelfController extends Controller
     public function lightOnApi(Request $request,CacheShelfService $service)
     {
         if($request['stationCode'] && $request['materialBoxCode'])
-        return $service->createStationTask($request['stationCode'],$request['materialBoxCode']);
-
+           return $service->createStationTask($request['stationCode'],$request['materialBoxCode']);
         return ['success' => false,'message' => '参数错误'];
     }
 
+    /**
+     * @param Request $request
+     * @return array|bool[]
+     */
+    public function clearTaskApi(Request $request): array
+    {
+        $code = $request['station'];
+        return app(CacheShelfService::class)->clearTask($code);
+    }
+
 }

+ 3 - 5
app/Http/Controllers/CarTypesController.php

@@ -77,15 +77,13 @@ class CarTypesController extends Controller
         if ($id){$name=$id;}
         $validator=Validator::make($request->input(),[
             'CarType.name'=>['required','max:50',isset($name)?"unique:car_types,name,$name":'unique:car_types,name'],
-            'CarType.model'=>'nullable|alpha_dash|max:50',
-            'CarType.length'=>'nullable|numeric|min:0',
-            'CarType.load'=>'nullable|numeric|min:0',
+            'CarType.model'=>'nullable|max:50',
+            'CarType.length'=>'nullable|min:0',
+            'CarType.load'=>'nullable|min:0',
         ],[
             'required'=>':attribute 为必填项',
-            'alpha_dash'=>':attribute 应为字母,数字,下划线',
             'max'=>':attribute 字符过多或数值过大',
             'min'=>':attribute 不得为负',
-            'numeric'=>':attribute 应为数字',
             'unique'=>':attribute 已存在',
         ],[
             'CarType.name'=>'车辆名称',

+ 15 - 0
app/Http/Controllers/DeliveryAppointmentController.php

@@ -188,6 +188,11 @@ class DeliveryAppointmentController extends Controller
             DeliveryAppointmentCar::query()->insert($insert);
         });
         dispatch(new DeliveryAppointmentCheck($appointment->id))->delay(Carbon::parse($appointment->appointment_date." ".(explode("-",DeliveryAppointment::PERIOD[$appointment->date_period])[1]).":00:01"));
+        //当日或次日预约单广播
+        if (strtotime(date('Y-m-d',strtotime("+2 day")))>strtotime($appointment->appointment_date." 00:00:00")){
+            $appointment->load("cars");
+            event(new DeliveryAppointmentEvent($appointment->cars[0]));
+        }
         //md5加密在密文第五位后插入
         $md5 = substr_replace(md5(date("m-d")),$appointment->id,5,0);
         $this->success(["key"=>$md5]);
@@ -234,6 +239,16 @@ class DeliveryAppointmentController extends Controller
             ]);
         });
         dispatch(new DeliveryAppointmentCheck($appointment->id))->delay(Carbon::parse($selectDate["date"]." ".(explode("-",DeliveryAppointment::PERIOD[$selectDate["time"]])[1]).":00:01"));
+        //当日或次日预约单广播
+        $old = $appointment->appointment_date == date('Y-m-d') ? 0 : ($appointment->appointment_date == date('Y-m-d',strtotime('+1 day') ? 1 : 2));
+        $new = $selectDate["date"] == date('Y-m-d') ? 0 : ($selectDate["date"] == date('Y-m-d',strtotime('+1 day') ? 1 : 2));
+        if ($old==2 && $new==2)$this->success(); //超过广播区间不推送
+        if (($old-$new)!=0 || $appointment->date_period!=$selectDate["time"]){
+            $appointment->cars[0]->change = true;
+            $appointment->cars[0]->old = $old;
+            $appointment->cars[0]->new = $new;
+            event(new DeliveryAppointmentEvent($appointment->cars[0]));
+        }
         $this->success();
     }
 

+ 57 - 9
app/Http/Controllers/StationRuleBatchController.php

@@ -2,25 +2,73 @@
 
 namespace App\Http\Controllers;
 
+use App\Components\AsyncResponse;
+use App\Http\Requests\Station\StationRuleBatchRequest;
+use App\Services\OwnerService;
 use App\StationRuleBatch;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Contracts\View\Factory;
 use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+use Illuminate\Support\Facades\Gate;
+use Illuminate\View\View;
+
 
 class StationRuleBatchController extends Controller
 {
+    use AsyncResponse;
+
     /**
      * Display a listing of the resource.
      *
-     * @return \Illuminate\Http\Response
+     * @param Request $request
+     * @param OwnerService $ownerService
+     * @return Application|Factory|View
      */
-    public function index()
+    public function index(Request $request,OwnerService $ownerService)
     {
-        //
+        if(!Gate::allows('站管理-站规则')){ return redirect(url('/'));  }
+        $stationRuleBatches = StationRuleBatch::query()->with('stationType','owner')->orderByDesc('id')->paginate($request['paginate'] ?? 50);
+        $owners = $ownerService->getAuthorizedOwners();
+        return view('station.rule.index',compact('stationRuleBatches','owners'));
+    }
+
+    /**
+     * store API
+     * @param StationRuleBatchRequest $request
+     */
+    public function storeApi(StationRuleBatchRequest $request)
+    {
+        $this->gate('站管理-站规则-编辑');
+        $stationRuleBatch = StationRuleBatch::query()->create($request->only(['name','owner_id']));
+        $stationRuleBatch->load('stationType','owner');
+        $this->success($stationRuleBatch);
+    }
+
+    /**
+     * update API
+     * @param StationRuleBatchRequest $request
+     */
+    public function updateApi(StationRuleBatchRequest $request)
+    {
+        $this->gate('站管理-站规则-编辑');
+        $stationRuleBatch = StationRuleBatch::query()->whereKey($request['id'])->first();
+        $stationRuleBatch->update($request->all());
+        $stationRuleBatch->load('stationType','owner');
+        $this->success($stationRuleBatch);
+    }
+
+    public function destroyApi(Request $request)
+    {
+        $this->gate('站管理-站规则-删除');
+        StationRuleBatch::query()->whereKey($request['id'])->delete();
+        $this->success();
     }
 
     /**
      * Show the form for creating a new resource.
      *
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function create()
     {
@@ -31,7 +79,7 @@ class StationRuleBatchController extends Controller
      * Store a newly created resource in storage.
      *
      * @param  \Illuminate\Http\Request  $request
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function store(Request $request)
     {
@@ -42,7 +90,7 @@ class StationRuleBatchController extends Controller
      * Display the specified resource.
      *
      * @param  \App\StationRuleBatch  $stationRuleBatch
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function show(StationRuleBatch $stationRuleBatch)
     {
@@ -53,7 +101,7 @@ class StationRuleBatchController extends Controller
      * Show the form for editing the specified resource.
      *
      * @param  \App\StationRuleBatch  $stationRuleBatch
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function edit(StationRuleBatch $stationRuleBatch)
     {
@@ -65,7 +113,7 @@ class StationRuleBatchController extends Controller
      *
      * @param  \Illuminate\Http\Request  $request
      * @param  \App\StationRuleBatch  $stationRuleBatch
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function update(Request $request, StationRuleBatch $stationRuleBatch)
     {
@@ -76,7 +124,7 @@ class StationRuleBatchController extends Controller
      * Remove the specified resource from storage.
      *
      * @param  \App\StationRuleBatch  $stationRuleBatch
-     * @return \Illuminate\Http\Response
+     * @return Response
      */
     public function destroy(StationRuleBatch $stationRuleBatch)
     {

+ 87 - 0
app/Http/Controllers/StorageController.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Components\AsyncResponse;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
+
+class StorageController extends Controller
+{
+    use AsyncResponse;
+
+    public function putShelf()
+    {
+        $asn = \request("asn");
+        $ide = \request("ide");
+        $barCode = \request("barCode");
+        $amount = \request("amount");
+        if (!$asn || !$ide || !$barCode || !$amount)$this->error("信息不完整");
+        $sql = <<<sql
+SELECT * FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
+WHERE asnno = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ?)
+sql;
+        $asn = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn,$barCode,$barCode]);
+        if (!$asn || $asn->receivedqty_each<$amount)$this->error("ASN不存在或数量异常");
+        $sql = <<<sql
+SELECT fmlotnum,fmlocation,toid FROM ACT_TRANSACTION_LOG WHERE transactiontype = 'IN' AND fmcustomerid = ? AND fmsku = ? AND docno = ? AND doclineno = ? AND doctype = 'ASN' AND pa_flag = 'Y'
+sql;
+        $act = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn->customerid,$asn->sku,$asn->asnno,$asn->asnlineno]);
+        if (!$act)$this->error("没有入库记录");
+        $sql = <<<sql
+SELECT * FROM inv_lot_loc_id  WHERE lotnum = ? AND traceid = ? AND customerid= ?  and sku = ?
+sql;
+        $inv = DB::connection("oracle")->select(DB::raw($sql),[$act->fmlotnum,$act->toid,$asn->customerid,$asn->sku]);
+        if (!$inv)$this->error("余量与入库不符");
+        DB::transaction(function ()use($inv,$amount,$ide,$asn,$act){
+            $db = DB::connection("oracle");
+            $qty = $amount;
+            foreach ($inv as $in){
+                if ($qty==0)break;
+                if ($in->qty > $qty){
+                    $db->update(DB::raw("update inv_lot_loc_id set qty = qty-?,qtymvout = qty-? where lotnum = ? and locationid = ? and traceid = ?"),[
+                        $qty,$qty,$in->lotnum,$in->locationid,$in->traceid
+                    ]);//TODO 遗留问题:对应生成分配库位上架数量未被变更
+                    $in->qty = $in->qty-$qty;
+                    $qty = 0;
+                }else{
+                    $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? and locationid = ? and traceid = ?"),[
+                        $in->lotnum,$in->locationid,$in->traceid
+                    ]);
+                    $qty = $qty-$in->qty;
+                }
+            }
+            if ($qty!=0){
+                $db->rollBack();
+                $this->error("上架数量与入库数量不符");
+            }
+            $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? AND traceid = ? AND traceid != '*'"),[
+                $inv[0]->lotnum,$inv[0]->traceid
+            ]);
+            $inv = $db->selectOne(DB::raw("SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND locationid = ? AND customerid = ? AND sku = ? AND traceid = '*' FOR UPDATE"),[
+                $inv[0]->lotnum,$ide,$inv[0]->customerid,$inv[0]->sku
+            ]);
+            $who = 'WAS'.(Auth::user() ? '-'.Auth::user()["name"] : '');
+            if ($inv)$db->update(DB::raw("UPDATE inv_lot_loc_id SET qty = qty+? WHERE lotnum = ? AND locationid = ? AND traceid = '*'"),[
+                (int)$amount,$inv[0]->lotnum,$ide
+            ]);
+            else $db->insert(DB::raw("INSERT INTO inv_lot_loc_id VALUES(?,?,'*',?,?,?,0,0,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,0,'*',0,null)"),[
+                $inv[0]->lotnum,$ide,$inv[0]->customerid,$inv[0]->sku,$amount,date("Y-m-d H:i:s"),$who,
+                date("Y-m-d H:i:s"),$who
+            ]);
+            $sql = <<<sql
+INSERT INTO ACT_TRANSACTION_LOG VALUES(?,'PA',?,?,?,?,'ASN',?,?,?,?,?,?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')),?,
+TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')),?,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,?,null,null,null,'*',?,?,?,?,?,?,?,
+?,?,?,?,?,'N',null,?,?,?,?,?,?,?,null,null)
+sql;
+            $db->insert(DB::raw($sql),[
+                'WA'.date('ymdHis').substr(\request("asn"),-2).rand(0,9),$asn->customerid,$asn->sku,
+                $asn->asnno,$asn->asnlineno,$inv[0]->lotnum,$act->fmlocation,$act->toid,$asn->packid,$asn->uom,$amount,$amount,$act->status,date("Y-m-d H:i:s"),$who,
+                date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),$asn->customerid,$asn->sku,$ide,$who,$asn->packid,$asn->uom,$amount,$amount,$inv[0]->lotnum,
+                'QC_TASKID',$act->qc_sequence,$act->qc_flag,'*',$act->pa_sequence,$act->warehouseid,$act->userdefine1,$act->userdefine2,
+                $act->userdefine3,$act->userdefine4,$act->userdefine5,$act->edisendflag
+            ]);
+        });
+        //成功后应去修改ASN状态及数量
+    }
+}

+ 49 - 4
app/Http/Controllers/TestController.php

@@ -44,6 +44,7 @@ use App\LaborReport;
 use App\LaborReportStatus;
 use App\Log;
 use App\Logistic;
+use App\MaterialBox;
 use App\MeasuringMachine;
 use App\Menu;
 use App\Notifications\SendEmailNotification;
@@ -179,8 +180,48 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
+    public function createCacheRack()
+    {
+        $stations = [
+            "HAIB1-01-02","HAIB1-01-03",
+            "HAIB1-02-01","HAIB1-02-03",
+            "HAIB1-03-01","HAIB1-03-02","HAIB1-03-03"
+        ];
+        foreach ($stations as $station){
+            Station::query()->create([
+                "parent_id" => 6,
+                "name" => $station,
+                "code" => $station,
+                "station_type_id" => 5,
+            ]);
+        }
+        dd("OK");
+    }
     public function test()
     {
+        $stations = Station::query()->select("id","code")->where("station_type_id",5)
+            ->whereNotNull("parent_id")
+            ->whereNotIn("id",StationTask::query()->select("station_id")
+                ->where("status","!=","完成")->whereIn("station_id",Station::query()->select("id")->where("station_type_id",5)
+                    ->whereNotNull("parent_id"))->groupBy("station_id"))
+            ->get();
+        foreach ($stations as $station){
+            $box = app("MaterialBoxService")->getAnEmptyBox();
+            if (!$box)continue;
+            $task = StationTask::query()->create([
+                'status' => "待处理",
+                'station_id' => $station->id,
+            ]);
+            $collection = new \Illuminate\Database\Eloquent\Collection();
+            $collection->append(StationTaskMaterialBox::query()->create([
+                'station_id' => $station->id,
+                'material_box_id'=>$box->id,
+                'status'=>"待处理",
+                'type' => '取',
+                'station_task_id' => $task->id,
+            ]));
+        }
+        dd(1);
         $asnno = "ASN2105141388";
         $query = DB::raw("SELECT b.ALTERNATE_SKU1,h.WAREHOUSEID,h.asnno,d.ASNLINENO,d.SKUDESCRC,h.CUSTOMERID,d.SKU,d.PACKID,d.RECEIVEDQTY_EACH,d.EXPECTEDQTY_EACH,d.LOTATT01,d.LOTATT02,d.lotatt04,".
             "d.lotatt05,d.lotatt08,d.USERDEFINE1,d.USERDEFINE2,d.USERDEFINE3,d.USERDEFINE4,d.USERDEFINE5,d.RECEIVINGLOCATION FROM DOC_ASN_DETAILS d ".
@@ -961,7 +1002,6 @@ class TestController extends Controller
 
     public function logistic_route_sync()
     {
-        ini_set('max_execution_time', 60*10);
         $orderPackageReceivedSyncService = new OrderPackageReceivedSyncService();
         $orderPackageReceivedSyncService->syncLogisticRoute();
     }
@@ -980,9 +1020,14 @@ class TestController extends Controller
 
     public function ld2()
     {
-        /** @var LogisticService $logisticService */
-        $logisticService=app('LogisticService');
-        var_dump($logisticService->get(['name'=>'顺丰'])->first());
+        $m=MaterialBox::query()->first();
+        dump($m);
+        $m['status'] = '在缓存架';
+        dump($m['status']);
+        $m->update();
+        $m=MaterialBox::query()->first();
+        dump($m['status']);
+
     }
     public function y111()
     {

+ 12 - 0
app/Http/Controllers/WaveController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Batch;
 use App\Components\AsyncResponse;
 use App\Order;
+use App\OrderBin;
 use App\Services\WaveService;
 use Exception;
 use Illuminate\Http\Request;
@@ -112,6 +113,17 @@ class WaveController extends Controller
             Order::query()->whereIn("code",$ordernos)->update([
                 "batch_id"=>$wave->id
             ]);
+            Order::query()->with(["batch","bin"])->whereIn("code",$ordernos)->get()->each(function ($order){
+                if (!$order->bin){
+                    $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"),[$order->batch->code,$order->code]);
+                    if ($bin){
+                        OrderBin::query()->create([
+                            'order_id' => $order->id,
+                            'number' => $bin->seqno,
+                        ]);
+                    }
+                }
+            });
         }
         $this->success($error);
     }

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

@@ -30,83 +30,83 @@ class SortingController extends Controller
      */
     public function newBatch(Request $request)
     {
-       $requestArr=$request->all();
+//       $requestArr=$request->all();
         app('LogService')->log(__METHOD__, 'issued_' . __FUNCTION__, json_encode($request->all()));
-        !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
-        $errors=$this->newBatchValidator($requestArr)->errors();
-        if(count($errors)>0){
-            app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
-            return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
-                'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
-        }
-        $requestBatches = $requestArr['request']?? '';
-
-        foreach ($requestBatches as $requestBatch){
-            $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
-            $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
-
-            if(!$batch)$batch=new Batch();
-            $batch->fill([
-                    'code' => $requestBatch['waveno'],
-                    'wms_type' => $requestBatch['batch_type']??'',
-                    'wms_status' => $requestBatch['docstatus']??'',
-                    'status' => '未处理',
-                    'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
-            ]);
-            $batch->save();
-            $oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
-            foreach($requestBatch['order_list'] as $requestOrder){
-                $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
-                $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
-                if(!$order){
-                    $order=app("OrderService")->createOrder([
-                        'batch_id' => $batch['id'],
-                        'code' => $requestOrder['docno'],
-                        'owner_id' => $owner['id'],
-                        'wms_status' => $requestOrder['docstatus']??'波次下发',
-                        'status' => '未处理',
-                    ]);
-                    app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
-                }else{
-                    $order['batch_id']= $batch['id'] ;
-                    $order['owner_id']=$order['owner_id']??$owner['owner_id'];
-                    $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
-                    $order['status']=$order['status']??'未处理';
-                }
-                $order->save();
-                OrderBin::query()->firstOrCreate([
-                    'order_id' => $order['id'],
-                    'number' => $requestOrder['reservedfield01'],
-                ]);
-                foreach($requestOrder['barcode_list'] as $requestBarcode){
-                    $orderCommodity=OrderCommodity::query()
-                        ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
-                    if(!$orderCommodity){
-                        /** @var CommodityService $commodityService */
-                        $commodityService=app('CommodityService');
-                        $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
-                        $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'],
-                            ]);
-                        }else{
-                            $orderCommodity['order_id']=$order['id'];
-                            $orderCommodity['commodity_id']=$commodity['id'];
-                            $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
-                            $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
-                        }
-                        $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
-                        if($allocation)
-                            $orderCommodity['location'] = $allocation['location'];
-                        $orderCommodity->save();
-                    }
-                }
-            }
-        }
+//        !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
+//        $errors=$this->newBatchValidator($requestArr)->errors();
+//        if(count($errors)>0){
+//            app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
+//            return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
+//                'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+//        }
+//        $requestBatches = $requestArr['request']?? '';
+//
+//        foreach ($requestBatches as $requestBatch){
+//            $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
+//            $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
+//
+//            if(!$batch)$batch=new Batch();
+//            $batch->fill([
+//                    'code' => $requestBatch['waveno'],
+//                    'wms_type' => $requestBatch['batch_type']??'',
+//                    'wms_status' => $requestBatch['docstatus']??'',
+//                    'status' => '未处理',
+//                    'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
+//            ]);
+//            $batch->save();
+//            $oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
+//            foreach($requestBatch['order_list'] as $requestOrder){
+//                $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
+//                $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
+//                if(!$order){
+//                    $order=app("OrderService")->createOrder([
+//                        'batch_id' => $batch['id'],
+//                        'code' => $requestOrder['docno'],
+//                        'owner_id' => $owner['id'],
+//                        'wms_status' => $requestOrder['docstatus']??'波次下发',
+//                        'status' => '未处理',
+//                    ]);
+//                    app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
+//                }else{
+//                    $order['batch_id']= $batch['id'] ;
+//                    $order['owner_id']=$order['owner_id']??$owner['owner_id'];
+//                    $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
+//                    $order['status']=$order['status']??'未处理';
+//                }
+//                $order->save();
+//                OrderBin::query()->firstOrCreate([
+//                    'order_id' => $order['id'],
+//                    'number' => $requestOrder['reservedfield01'],
+//                ]);
+//                foreach($requestOrder['barcode_list'] as $requestBarcode){
+//                    $orderCommodity=OrderCommodity::query()
+//                        ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
+//                    if(!$orderCommodity){
+//                        /** @var CommodityService $commodityService */
+//                        $commodityService=app('CommodityService');
+//                        $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
+//                        $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'],
+//                            ]);
+//                        }else{
+//                            $orderCommodity['order_id']=$order['id'];
+//                            $orderCommodity['commodity_id']=$commodity['id'];
+//                            $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
+//                            $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
+//                        }
+//                        $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
+//                        if($allocation)
+//                            $orderCommodity['location'] = $allocation['location'];
+//                        $orderCommodity->save();
+//                    }
+//                }
+//            }
+//        }
         return response()->json(['Response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000',
             'returnDesc'=>'消息处理成功:Success','resultInfo'=>'']]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
     }

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

@@ -33,7 +33,7 @@ class LightController
      */
     public function update(Request $request){// 拍灯以后的消息发至此处
         $station = Station::query()->with('stationType')->where('code',$request['locCode'])->first();
-        if( $station->stationType && $station->stationType->name == '缓存架' ){  // 拍灯 推送任务
+        if( ($station ?? false) && ($station->stationType->name ?? false) && $station->stationType->name == '缓存架' ){  // 拍灯 推送任务
             if($request['PTLAction'] !== 0) return ['location' => 200,'errMsg' => 'is cacheShelf','data' => $request->all()];
             /** @var CacheShelfService $cacheShelfService */
             $cacheShelfService = app(CacheShelfService::class);

+ 6 - 2
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 use App\Http\Requests\ForeignHaiRobotic_taskUpdateRequest;
+use App\MaterialBox;
 use App\Services\ForeignHaiRoboticsService;
 use App\Services\LogService;
 use Illuminate\Http\Request;
@@ -199,8 +200,8 @@ class StorageController
             "areaCode"=> "1004",
             "PTLAction"=> 1, //1是开,0是关
             "PTLSettings"=> [
-                "color"=> 1,
-                "frequency"=> 1
+                "color"=> 2, //灯颜色,0红,1绿,2绿,3黄
+                "frequency"=> 0 //频率 0是不动,最大是3
             ],
             "displayInfo"=> [
                 "detail01"=> "detail01",
@@ -323,6 +324,9 @@ class StorageController
         $responseBody = $response->body();
         LogService::log(__CLASS__,__METHOD__,$responseBody);
         $responseBody = strstr($responseBody,'200')?'请求出库料箱"'.implode(',',$codes).'"成功':$responseBody;
+        if(strstr($responseBody,'成功')){
+            MaterialBox::query()->whereIn('code',$codes)->update(['status'=>'在出库中']);
+        }
         return ['result'=> $responseBody];
     }
 }

+ 2 - 0
app/Http/Kernel.php

@@ -2,6 +2,7 @@
 
 namespace App\Http;
 
+use App\Http\Middleware\CheckCsrfToken;
 use App\Http\Middleware\LogPostRequest;
 use Illuminate\Foundation\Http\Kernel as HttpKernel;
 
@@ -75,6 +76,7 @@ class Kernel extends HttpKernel
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
         'auth.api' => \App\Http\Middleware\ApiAuth::class,
         'procurement.auth.api' => \App\Http\Middleware\ProcurementApiAuth::class,
+        'check.token' => CheckCsrfToken::class,
     ];
 
     /**

+ 1 - 0
app/Http/Middleware/Authenticate.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Middleware;
 
+use Closure;
 use Illuminate\Auth\Middleware\Authenticate as Middleware;
 
 class Authenticate extends Middleware

+ 21 - 0
app/Http/Middleware/CheckCsrfToken.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class CheckCsrfToken
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        if (!$request->cookie("XSRF-TOKEN"))return redirect("login");
+        return $next($request);
+    }
+}

+ 1 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -20,5 +20,6 @@ class VerifyCsrfToken extends Middleware
      */
     protected $except = [
         'store/deliveryAppointment/delivery',
+        'package/weigh/measureMonitor/speech',
     ];
 }

+ 70 - 0
app/Http/Requests/Station/StationRuleBatchRequest.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace App\Http\Requests\Station;
+
+use App\Traits\RequestApiFormValidation;
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Support\Facades\Route;
+
+class StationRuleBatchRequest extends FormRequest
+{
+    use RequestApiFormValidation;
+
+    protected $storeApiRules = [
+        'name' => 'required',
+        'owner_id' => 'required'
+    ];
+    protected $updateApiRules = [
+        'name' => 'required',
+        'owner_id' => 'required'
+    ];
+    protected $storeApiMessage = [
+        'name.required' => '规则名称为必填项',
+        'owner_id.required' => '货主为必填项',
+    ];
+    protected $updateApiMessage = [
+        'name.required' => '规则名称为必填项',
+        'owner_id.required' => '货主为必填项',
+    ];
+
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules(): array
+    {
+        $routeName = Route::currentRouteName();
+        switch ($routeName) {
+            case 'station.rule.storeApi':
+                return $this->storeApiRules;
+            case 'station.rule.updateApi':
+                return $this->updateApiRules;
+            default:
+                return [];
+        }
+    }
+
+    public function messages(): array
+    {
+        $routeName = Route::currentRouteName();
+        switch ($routeName) {
+            case 'station.rule.storeApi':
+                return $this->storeApiMessage;
+            case 'station.rule.updateApi':
+                return $this->updateApiMessage;
+            default:
+                return [];
+        }
+    }
+}

+ 50 - 0
app/Jobs/LogisticSFSync.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\LogisticSFService;
+use App\Services\LogService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class LogisticSFSync implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    public $logistic_number;
+
+    /**
+     * @var LogisticSFService $logisticSFService
+     */
+    public $logisticSFService;
+    public $orderPackageReceivedSyncService;
+
+    /**
+     * LogisticSFSync constructor.
+     * @param $logistic_number
+     */
+    public function __construct($logistic_number)
+    {
+        $this->logistic_number = $logistic_number;
+    }
+
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     * @throws \Exception
+     */
+    public function handle()
+    {
+        ini_set('max_execution_time', 60);
+        LogService::log(LogisticSFSync::class, "{$this->logistic_number}-JOB-SF", '');
+        $this->logisticSFService = app('LogisticSFService');
+        $formedData = $this->logisticSFService->get([$this->logistic_number]);
+        $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
+        $this->orderPackageReceivedSyncService->update($formedData);
+    }
+}

+ 3 - 1
app/Jobs/LogisticYDSync.php

@@ -3,6 +3,7 @@
 namespace App\Jobs;
 
 use App\Services\LogisticYDService;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -42,7 +43,8 @@ class LogisticYDSync implements ShouldQueue
      */
     public function handle()
     {
-        ini_set('max_execution_time', 10);
+        ini_set('max_execution_time', 60);
+        LogService::log(LogisticYDSync::class, "{$this->logistic_number}-JOB-YD", '');
         $this->logisticYDService = app('LogisticYDService');
         //先订阅订单
         $this->logisticYDService->registerApi([$this->logistic_number]);

+ 3 - 1
app/Jobs/LogisticYTOSync.php

@@ -4,6 +4,7 @@ namespace App\Jobs;
 
 use App\Services\LogisticYDService;
 use App\Services\LogisticYTOService;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -42,7 +43,8 @@ class LogisticYTOSync implements ShouldQueue
      */
     public function handle()
     {
-        ini_set('max_execution_time', 10);
+        ini_set('max_execution_time', 60);
+        LogService::log(LogisticYTOSync::class, "{$this->logistic_number}-JOB-YTO", '');
         $this->logisticYTOService = app('LogisticYTOService');
         $nativeResponse = $this->logisticYTOService->query($this->logistic_number);
         $formattedData = $this->logisticYTOService->format($nativeResponse);

+ 3 - 2
app/Jobs/LogisticZopSync.php

@@ -6,6 +6,7 @@ use App\library\zop\ZopClient;
 use App\library\zop\ZopProperties;
 use App\library\zop\ZopRequest;
 use App\OrderPackage;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -37,8 +38,8 @@ class LogisticZopSync implements ShouldQueue
      */
     public function handle()
     {
-        //
-        ini_set('max_execution_time', 10);
+        ini_set('max_execution_time', 60);
+        LogService::log(LogisticZopSync::class, "{$this->logistic_number}-JOB-ZOP", '');
         $zopResult = [];
         $response = $this->sentRequestToZT();
         if(is_null($response)) return;

+ 1 - 1
app/Logistic.php

@@ -17,7 +17,7 @@ class Logistic extends Model
     use ModelLogChanging;
     use SoftDeletes;
     use ModelTimeFormat;
-    protected $fillable = ['name','code',"type","mobile","remark","delivery_fee","is_bunched"];
+    protected $fillable = ['name','code',"type","mobile","remark","delivery_fee","is_bunched","english_name"];
 
 
     static function nameById($id){

+ 30 - 1
app/MaterialBox.php

@@ -10,5 +10,34 @@ class MaterialBox extends Model
 {
     use ModelLogChanging;
 
-    protected $fillable=['code'];
+    protected $fillable=['code','status'];
+
+    static public $enums=[
+        'status'=>[
+            '在库外'=>1,
+            '在U型线'=>2,
+            '在缓存架'=>3,
+            '在立库'=>4,
+            '在出库中'=>5,
+            '在入库中'=>6,
+            '未知'=>7,
+            '异常'=>8,
+        ],
+    ];
+    function __construct(array $attributes = [])
+    {
+        foreach (self::$enums as &$enum) {
+            $enum=$enum+array_flip($enum);
+        }
+        parent::__construct($attributes);
+    }
+
+    public function getStatusAttribute($value)
+    {
+        return self::$enums['status'][$value];
+    }
+    public function setStatusAttribute($value)
+    {
+        $this->attributes['status']=self::$enums['status'][$value];
+    }
 }

+ 2 - 2
app/OracleDOCWaveDetails.php

@@ -13,14 +13,14 @@ class OracleDOCWaveDetails extends Model
     protected $connection='oracle';
     protected $table='DOC_WAVE_DETAILS';
     public $timestamps=false;
-    protected $primaryKey = 'OrdderNo';
+    protected $primaryKey = 'OrderNo';
     function getIncrementing()
     {
         return false;
     }
 
     static public function unpackedOrders($batchNumber){
-        return OracleDOCWaveDetails::where('doc_wave_details.waveno', $batchNumber)->leftJoin('doc_order_header','doc_order_header.orderno','doc_wave_details.orderno')->where(function ($query){
+        return OracleDOCWaveDetails::query()->where('doc_wave_details.waveno', $batchNumber)->leftJoin('doc_order_header','doc_order_header.orderno','doc_wave_details.orderno')->where(function ($query){
             $query->where('doc_order_header.SOSTATUS','<>','99')->where('doc_order_header.SOSTATUS','<>','63');
         })->get();
     }

+ 1 - 3
app/Package.php

@@ -103,9 +103,7 @@ class Package extends Model
                 "created_at"=>$now,
             ]);
         }
-        DB::transaction(function ()use($packages){
-            Package::query()->insert($packages);
-        });
+        Package::query()->insert($packages);
     }
     public function unifyThisMeasureUnderSameBatch(){
         $this->fetchPaperBox();

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -24,6 +24,7 @@ use App\Services\ForeignHaiRoboticsService;
 use App\Services\InventoryAccountMissionService;
 use App\Services\InventoryCompareService;
 use App\Services\LaborReportsCountingRecordService;
+use App\Services\LogisticSFService;
 use App\Services\LogisticYTOService;
 use App\Services\LogService;
 use App\Services\MaterialBoxService;
@@ -188,6 +189,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('InventoryDailyLogService',InventoryDailyLogService::class);
         app()->singleton('LaborReportsCountingRecordService',LaborReportsCountingRecordService::class);
         app()->singleton('LogService',LogService::class);
+        app()->singleton('LogisticSFService',LogisticSFService::class);
         app()->singleton('LogisticService',LogisticService::class);
         app()->singleton('LogisticYDService',LogisticYDService::class);
         app()->singleton('LogisticYTOService',LogisticYTOService::class);

+ 0 - 3
app/Providers/AuthServiceProvider.php

@@ -7,11 +7,8 @@ use App\CustomerLog;
 use App\CustomerLogStatus;
 use App\Policies\CustomerLogPolice;
 use App\Policies\CustomerLogStatusesPolice;
-use App\Services\AuthorityService;
 use App\Services\CacheService;
 use App\Services\UserService;
-use App\User;
-use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

+ 97 - 40
app/Services/CacheShelfService.php

@@ -7,9 +7,11 @@ use App\Exceptions\ErrorException;
 use App\MaterialBox;
 use App\Station;
 use App\StationTask;
+use App\StationTaskChildren;
 use App\StationTaskMaterialBox;
 use App\StationType;
 use App\Traits\ServiceAppAop;
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
@@ -50,7 +52,7 @@ class   CacheShelfService
      */
     public function lightOffTask($locCode, $PTLAction): array
     {
-        $station = Station::query()->where('code', $locCode)->first();
+        $station = Station::query()->with('pendingStationTask.stationTaskMaterialBoxes.materialBox')->where('code', $locCode)->first();
         try {
             $bool = $this->putBinToStore($station);                         // 推送任务
             if($bool){
@@ -81,36 +83,47 @@ class   CacheShelfService
 
         /** @var StationTaskMaterialBox $takeStationTaskMaterialBox */
         $takeStationTaskMaterialBox = $station['pendingStationTask']['stationTaskMaterialBoxes']->first();
-
         $formStation = $this->stationService->getStation_byType('立库');
 
-        // 创建入立库任务
-        $stationTask = $this->stationTaskService->create(1);               // 生成站任务
-        $this->stationTaskService->registerStations($stationTask,[$formStation['id']]);   // 注册站任务站
-        /** @var StationTaskMaterialBox $putStationTaskMaterialBox */
-        $putStationTaskMaterialBox = $this->stationTaskMaterialBoxService->create([
+        // 查询是否有待处理的入库任务
+        $putStationTaskMaterialBox = StationTaskMaterialBox::query()->where([
             'station_id' => $formStation['id'],
             'material_box_id' => $takeStationTaskMaterialBox['material_box_id'],
             'status' => '待处理',
-        ]);
-        $putStationTaskMaterialBox['station_task_id'] = $stationTask->first()['id'];
-        $putStationTaskMaterialBox['type'] = '放';
-        $putStationTaskMaterialBox->update();
+        ])->first();
 
-        $params = [[
-            'station_task_id'=>$stationTask->first()['id'],
-            'station_taskable_type'=>StationTaskMaterialBox::class,
-            'station_taskable_id'=>$putStationTaskMaterialBox['id']
-        ]];
-
-        $this->stationTaskChildService->insert($params);    // 任务任务注册
-        // 标记站任务为处理中
-        $this->stationTaskMaterialBoxService->set($takeStationTaskMaterialBox,[
-            'status' => '处理中'
-        ]);
+        // 创建入立库任务
+        if(!$putStationTaskMaterialBox){
+            $stationTask = $this->stationTaskService->create(1);               // 生成站任务
+            $this->stationTaskService->registerStations($stationTask,[$formStation['id']]);   // 注册站任务站
+            /** @var StationTaskMaterialBox $putStationTaskMaterialBox */
+            $putStationTaskMaterialBox = $this->stationTaskMaterialBoxService->create([
+                'station_id' => $formStation['id'],
+                'material_box_id' => $takeStationTaskMaterialBox['material_box_id'],
+                'status' => '待处理',
+            ]);
+            $putStationTaskMaterialBox['station_task_id'] = $stationTask->first()['id'];
+            $putStationTaskMaterialBox['type'] = '放';
+            $putStationTaskMaterialBox->update();
+
+            $params = [[
+                'station_task_id'=>$stationTask->first()['id'],
+                'station_taskable_type'=>StationTaskMaterialBox::class,
+                'station_taskable_id'=>$putStationTaskMaterialBox['id']
+            ]];
+
+            $this->stationTaskChildService->insert($params);    // 任务任务注册
+        }
 
         // 推立库任务
-        return $this->foreignHaiRoboticsService->putBinToStore_fromCacheShelf($putStationTaskMaterialBox,$station['code']);
+        $isSuccess =  $this->foreignHaiRoboticsService->putBinToStore_fromCacheShelf($putStationTaskMaterialBox,$station['code']);
+        if($isSuccess) $this->stationTaskMaterialBoxService->set($takeStationTaskMaterialBox,['status' => '处理中']);  // 任务推送成功 标记站任务为处理中
+        else {
+            $materialBoxCode = $station['pendingStationTask']['stationTaskMaterialBoxes']->first()->code ?? '';
+            $this->_stationCacheBroadCast($station->code,0,'error');
+            $this->_stationCacheLightOn($station->code,$materialBoxCode,'拍灯重试任务');
+        }
+        return $isSuccess;
     }
 
     /**
@@ -137,12 +150,19 @@ class   CacheShelfService
 
         $materialBox = MaterialBox::query()->firstOrCreate(['code' => $materialBoxCode]);
 
-        if($station['pendingStationTask'] ?? false){
-            return ['success' => false,'message' => '当前已有未完成的站任务'];
+        $station->load('pendingStationTask.stationTaskMaterialBoxes.materialBox');
+        if($station->pendingStationTask){
+            if($station['pendingStationTask']['stationTaskMaterialBoxes']->first()->materialBox->code == $materialBoxCode){
+                $response = $this->_stationCacheLightOn($stationCode,$materialBoxCode,'任务重试');
+                if($response->code) return ['success'=>true,'message' =>  '任务重试'];
+                return ['success'=>true,'message' =>  '任务重试失败'];
+            }
+            return ['success' => false,'message' => '当前已有进行重的任务'];
         }
-        $stationTask = $this->stationTaskService->create(1);                                                    // 生成站任务
+
+        $stationTask = $this->stationTaskService->create(1);                                                       // 生成站任务
         $stationTaskMaterialBox = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($station,$materialBox);     // 创建料箱任务
-        $this->stationTaskService->registerStations($stationTask,[$station['id']]);                                            // 注册站任务站
+        $this->stationTaskService->registerStations($stationTask,[$station['id']]);                                               // 注册站任务站
         $stationTaskMaterialBox['station_task_id'] = $stationTask->first()['id'];
         $stationTaskMaterialBox->update();
         $params = [[
@@ -153,7 +173,6 @@ class   CacheShelfService
         $this->stationTaskChildService->insert($params);                                                                        // 任务任务注册
 
         $body = $this->_stationCacheLightOn($stationCode,$materialBoxCode);
-
         if($body->code == 200)return ['success'=>true];
         return ['success' => false,'message' => '机器人亮灯异常'];
     }
@@ -161,20 +180,18 @@ class   CacheShelfService
     /**
      * 控制格口亮灯
      * @param $locCode
-     * @param string $title
      * @param null $materialCode
+     * @param string $title
+     * @param string $color
      * @return mixed
      */
-    public function _stationCacheLightOn($locCode,$materialCode = null,$title = 'title')
+    public function _stationCacheLightOn($locCode,$materialCode = null,$title = 'title' ,string $color = '1')
     {
         $params = [
             "areaCode" => "1004",
             'locCode' => $locCode,
             'PTLAction' => 1,
-            'PTLSettings' => [
-                'color'=> 1,
-                'frequency'  =>1
-                ],
+            'PTLSettings' => ['color'=> $color, 'frequency'  =>1],
             "displayInfo" => [
                 "detail01" => $materialCode,
                 "detail02" => "detail02",
@@ -188,8 +205,9 @@ class   CacheShelfService
                 "uomDesc02" => "uo"
             ],
         ];
-        $response = Http::post(config('api.haiq.storage.light'), $params);
-        return json_decode($response->body());
+        return new MaterialBox(['code' => 200]);
+//        $response = Http::post(config('api.haiq.storage.light'), $params);
+//        return json_decode($response->body());
     }
 
     /**
@@ -209,11 +227,12 @@ class   CacheShelfService
     }
 
     /**
-     * 广播 通知货物被取走
+     * 广播 type success成功 error 异常
      * @param $locCode
      * @param $PTLAction
+     * @param string $type
      */
-    public function _stationCacheBroadCast($locCode,$PTLAction)
+    public function _stationCacheBroadCast($locCode, $PTLAction,string $type = 'success')
     {
         if($PTLAction == 0){
             $station = Station::query()->with('parent')->where('code',$locCode)->first();
@@ -223,6 +242,7 @@ class   CacheShelfService
                 'code'  => $station['parent']['code'],
                 'gird_id' => $station['id'],
                 'grid_code' => $station['code'],
+                'type' => $type
             ]);
             broadcast(new BroadcastToStation($station['parent_id'],$json));
         }
@@ -252,7 +272,44 @@ class   CacheShelfService
         // 入立架任务
         if($putStationTaskMaterial->stationTask)$putStationTaskMaterial->stationTask->update(['status' => '完成']);
 
-        $this->_stationCacheLightOff($takeStationTaskMaterialBox->station->code ?? null);
-        $this->_stationCacheBroadCast($takeStationTaskMaterialBox->station->code,0);
+        $this->_stationCacheLightOff($takeStationTaskMaterialBox->station->code ?? null);  //海柔格口灭灯
+        $this->_stationCacheBroadCast($takeStationTaskMaterialBox->station->code, 0);    //通知缓存架任务完成
+    }
+
+    /**
+     * 取消任务
+     * @param $stationCode
+     * @return array
+     */
+    public function clearTask($stationCode): array
+    {
+        $station = Station::query()->with(['currentStationTask.stationTaskMaterialBoxes.materialBox',
+            'pendingStationTask.stationTaskMaterialBoxes.materialBox'])
+            ->where('code',$stationCode)->first();
+
+        if($station->currentStationTask)return ['success' => false,'message' => '当前任务正在执行','data'=>$stationCode];
+        if($station->pendingStationTask->stationTaskMaterialBoxes->count() == 0){
+            $station->pendingStationTask->delete();
+            return ['success' => true];
+        }
+
+        $taskStationTaskMaterialBox = $station->pendingStationTask->stationTaskMaterialBoxes->first() ?? null;
+        $stationTaskMaterialBoxes = StationTaskMaterialBox::query()->with('stationTask')
+            ->where('material_box_id',$taskStationTaskMaterialBox['material_box_id'])
+            ->where('station_id','!=',$station->pendingStationTask['id'])
+            ->get();
+
+        foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
+            if($stationTaskMaterialBox->stationTask){
+                StationTaskChildren::query()->where([
+                    'station_task_id' => $stationTaskMaterialBox->stationTask['id'],
+                    'station_taskable_type'=>StationTaskMaterialBox::class,
+                    'station_taskable_id'=>$stationTaskMaterialBox['id']])->delete();
+
+                $stationTaskMaterialBox->stationTask->delete();
+            }
+            $stationTaskMaterialBox->delete();
+        }
+        return ['success' => true];
     }
 }

+ 27 - 10
app/Services/ForeignHaiRoboticsService.php

@@ -88,19 +88,19 @@ class ForeignHaiRoboticsService
         ]];
     }
 
-    public function fetchGroup($toLocation, Collection $taskMaterialBoxes, $groupIdPrefix=''): bool
+    public function fetchGroup($toLocation, Collection $taskMaterialBoxes, $groupIdPrefix='',$mode='立架出至输送线'): bool
     {
         LogService::log(__METHOD__,'runMany','波次任务分配6.r5f0:');
         LogService::log(__METHOD__,'runMany','波次任务分配6.r5f1:'.json_encode($toLocation).json_encode($taskMaterialBoxes).json_encode($groupIdPrefix));
         $dataToPost=$this->makeJson_move(
             $taskMaterialBoxes,
-            '立架出至输送线',
+            $mode,
             '',
             $toLocation??'',
             $groupIdPrefix
         );
         LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2:'.json_encode($dataToPost));
-        return $this->controlHaiRobot($dataToPost);
+        return $this->controlHaiRobot($dataToPost,$taskMaterialBoxes,'立架出至输送线');
     }
 
     public function moveBin(){
@@ -214,11 +214,11 @@ class ForeignHaiRoboticsService
                 '输送线入立架',
                 'BIN-IN1',//TODO:这里应该是动态取得,参考出立架getULineExit()方法,不然不能从站获得对应的出口,而且要改Station的child为children
                 '',
-                $stationTaskMaterialBox['stationTaskBatch']['id']
+                $stationTaskMaterialBox_toStore['stationTaskBatch']['id']
             );
-            $this->controlHaiRobot($dataToPost);
+            $this->controlHaiRobot($dataToPost,collect([$stationTaskMaterialBox_toStore]),'输送线入立架');
 
-            $stationTaskMaterialBox = $stationTaskMaterialBox??$materialBox??null;
+            $stationTaskMaterialBox = $stationTaskMaterialBox_toStore??$materialBox??null;
             if($stationTaskMaterialBox && get_class($stationTaskMaterialBox)==MaterialBox::class){
                 $stationTaskMaterialBox = StationTaskMaterialBox::query()
                     ->where('material_box_id',$stationTaskMaterialBox['id'])
@@ -257,7 +257,7 @@ class ForeignHaiRoboticsService
         );
         LogService::log('海柔请求','putBinToStore3',
             json_encode($dataToPost));
-        $controlSuccess = $this->controlHaiRobot($dataToPost);
+        $controlSuccess = $this->controlHaiRobot($dataToPost,collect([$stationTaskMaterialBox_toStore]),'输送线入立架');
 
         return $controlSuccess;
     }
@@ -282,7 +282,7 @@ class ForeignHaiRoboticsService
         );
         LogService::log('海柔请求','putBinToStore_fromCacheShelf3', json_encode($dataToPost));
 
-        $controlSuccess = $this->controlHaiRobot($dataToPost);
+        $controlSuccess = $this->controlHaiRobot($dataToPost,collect([$stationTaskMaterialBox]),'缓存架入立架');
         LogService::log('海柔请求','putBinToStore_fromCacheShelf4', 'controlHaiRobot '. json_encode($controlSuccess));
 
         if($controlSuccess){
@@ -380,7 +380,7 @@ class ForeignHaiRoboticsService
      * @param array $dataToPost
      * @return bool
      */
-    public function controlHaiRobot(array $dataToPost): bool
+    public function controlHaiRobot(array $dataToPost,Collection $taskMaterialBoxes,$modeName): bool
     {
         LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1:'.json_encode($dataToPost));
         try{
@@ -424,7 +424,24 @@ class ForeignHaiRoboticsService
             . '请求:' . json_encode($dataToPost)
             . '调用堆栈c:' . json_encode(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), 0, 3))
         );
-        return $isSuccess = !$errMsg;
+        $isSuccess = !$errMsg;
+        $标记料箱状态=(function() use ($taskMaterialBoxes,$modeName){
+            foreach ($taskMaterialBoxes as $taskMaterialBox){
+                switch ($modeName){
+                    case '缓存架入立架':
+                    case '输送线入立架':
+                    case '移动立架内位置':
+                    $taskMaterialBox->materialBox['status']='在入库中';break;
+                    case '立架出至输送线':
+                    case '立架出至缓存架':
+                    $taskMaterialBox->materialBox['status']='在出库中';break;
+                    default:
+                        $taskMaterialBox->materialBox['status']='未知';break;
+                }
+                $taskMaterialBox->materialBox->update();
+            }
+        })();
+        return $isSuccess;
     }
 
 }

+ 0 - 121
app/Services/LogisticSFService.php

@@ -234,125 +234,4 @@ xml;
         }
         return $result;
     }
-
-
-//    /**
-//     * @param array $data
-//     * @param $lastRouteDate
-//     * @return array
-//     */
-//    private function setExceptionType(array $data, $lastRouteDate): array
-//    {
-//        $logistic_number = $data['logistic_number'];
-//        /** @var OrderPackage $orderPackage */
-//        $orderPackage = OrderPackage::query()->with('order')->where('logistic_number', $logistic_number)->first();
-//        $delivered_duration = now()->diffInHours(Carbon::parse($orderPackage['sent_at']));
-//        $last_routed_duration = now()->diffInHours(Carbon::parse($lastRouteDate));
-//        $VALID_HOURS = 4;
-//        $SHORT_RESPONSE_HOURS = 24;
-//        $LONG_RESPONSE_HOURS = (function ($province) {
-//            switch ($province) {
-//                case '浙江省':
-//                case '江苏省':
-//                case '上海':
-//                case '安徽省':
-//                    return 72;
-//                case '北京':
-//                case '天津':
-//                case '江西省':
-//                case '湖北省':
-//                case '湖南省':
-//                case '广东省':
-//                case '福建省':
-//                case '山东省':
-//                case '河北省':
-//                case '河南省':
-//                case '山西省':
-//                case '四川省':
-//                case '陕西省':
-//                case '重庆':
-//                case '广西壮族自治区':
-//                case '贵州省':
-//                case '云南省':
-//                case '海南省':
-//                case '吉林省':
-//                case '黑龙江省':
-//                case '辽宁省':
-//                    return 120;
-//                case '青海省':
-//                case '宁夏回族自治区':
-//                case '甘肃省':
-//                case '内蒙古自治区':
-//                case '新疆维吾尔自治区':
-//                case '西藏自治区':
-//                    return 168;
-//                default:
-//                    break;
-//            }
-//        })($orderPackage->order->province);
-//        $SENDING_RESPONSE_HOURS = 48;
-//        $IS_ROUTED = 1;               //0000 0001 有路由信息
-//        $IS_IN_VALID_TIME = 2;        //0000 0010 大于4小时
-//        $IS_WEIGHED = 4;              //0000 0100 称重过
-//        $IS_RECEIVED = 8;          //0000 1000 已经收货
-//        $IS_SENDING = 16;             //0001 0000 正在派送
-//        $IS_SHORT_NO_RESPONSE = 32;     //0010 0000 中转异常
-//        $IS_LONG_NO_RESPONSE = 64;     //0010 0000 疑似丢件
-//        $IS_SENDING_NO_RESPONSE = 128;     //0010 0000 派送异常
-//        $conclusion = (function () use (
-//            $data, $delivered_duration, $last_routed_duration,
-//            $VALID_HOURS, $IS_ROUTED, $IS_IN_VALID_TIME, $IS_WEIGHED, $IS_RECEIVED, $IS_SENDING, $IS_SHORT_NO_RESPONSE, $IS_LONG_NO_RESPONSE, $IS_SENDING_NO_RESPONSE,
-//            $SHORT_RESPONSE_HOURS, $LONG_RESPONSE_HOURS, $SENDING_RESPONSE_HOURS,
-//            $orderPackage
-//        ) {
-//            $conclusion = 0;
-//            $conclusion |= !empty($data['transfer_status']) ? $IS_ROUTED : 0;
-//            $conclusion |= ($delivered_duration > $VALID_HOURS) ? $IS_IN_VALID_TIME : 0;
-//            $conclusion |= ($orderPackage->weighed_at) ? $IS_WEIGHED : 0;
-//            $conclusion |= ($data['status'] == '已收件') ? $IS_RECEIVED : 0;
-//            $conclusion |= ($data['status'] == '派送中') ? $IS_SENDING : 0;//
-//            $conclusion |= ($last_routed_duration > $SHORT_RESPONSE_HOURS && $last_routed_duration < $LONG_RESPONSE_HOURS) ? $IS_SHORT_NO_RESPONSE : 0;
-//            $conclusion |= ($last_routed_duration > $LONG_RESPONSE_HOURS) ? $IS_LONG_NO_RESPONSE : 0;
-//            $conclusion |= ($last_routed_duration > $SENDING_RESPONSE_HOURS && $data['status'] == '派送中') ? $IS_SENDING_NO_RESPONSE : 0;
-//            return $conclusion;
-//        })();
-//        switch ($conclusion) {
-//            case $IS_IN_VALID_TIME:
-//                $data['exception_type'] = '疑似库内丢件';
-//                break;
-//            case $IS_IN_VALID_TIME | $IS_WEIGHED:
-//                $data['exception_type'] = '揽件异常';
-//                break;
-//            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE:
-//            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE | $IS_WEIGHED:
-//                $data['exception_type'] = '中转异常';
-//                break;
-//            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE:
-//            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE | $IS_WEIGHED:
-//                $data['exception_type'] = '疑似丢件';
-//                break;
-//            default:
-//                break;
-//        }
-//
-//        if($conclusion
-//            ==($conclusion | $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE)){
-//            $data['exception_type'] = '派件异常';
-//        }
-//
-//        switch ($conclusion) {
-//            case $IS_IN_VALID_TIME:
-//            case $IS_IN_VALID_TIME | $IS_WEIGHED:
-//            case $IS_ROUTED | $IS_SHORT_NO_RESPONSE:
-//            case $IS_LONG_NO_RESPONSE:
-//                $data['exception'] = '是';
-//                break;
-//            default:
-//                break;
-//        }
-//        return [
-//            'exception_type' => array_key_exists('exception_type', $data) ? $data['exception_type'] : null,
-//            'exception' => array_key_exists('exception', $data) ? $data['exception'] : null,
-//        ];
-//    }
 }

+ 7 - 3
app/Services/LogisticYDService.php

@@ -89,12 +89,16 @@ class LogisticYDService
 
     public function format($nativeResponse)
     {
-        $result = [];
-        if ($nativeResponse->code != '0000') {
+        if ($nativeResponse->code != '0000' || $nativeResponse->data->result=="false") {
             return [];
         } else {
             $nativeData = $nativeResponse->data;
-            $result['logistic_number'] = $nativeData->mailno;
+            try {
+                $result['logistic_number'] = $nativeData->mailno;
+            } catch (\Exception $e) {
+                LogService::log(LogisticYDService::class, "YD快递信息异常", $nativeResponse);
+                return [];
+            }
             $nativeRoutes = $nativeData->steps;
             if (!empty($nativeRoutes)) {
                 $lastNativeRoute = $nativeRoutes[count($nativeRoutes) - 1];

+ 5 - 1
app/Services/LogisticYTOService.php

@@ -47,7 +47,11 @@ class LogisticYTOService
         $result = [];
         if (is_object($response) && $response->code=='1001') {return [];}
         else {
-            $result['logistic_number'] = $response[0]->waybill_No;
+            try {
+                $result['logistic_number'] = $response[0]->waybill_No;
+            } catch (\Exception $e) {
+                LogService::log(LogisticYTOService::class, "YTO快递信息异常", $response);
+            }
             if (!empty($response)) {
                 $lastNativeRoute = $response[count($response) - 1];
                 $result['status'] = $this->getStatus($lastNativeRoute);

+ 34 - 0
app/Services/MaterialBoxService.php

@@ -8,6 +8,7 @@ use App\MaterialBox;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Cache;
 use App\Traits\ServiceAppAop;
+use Illuminate\Support\Facades\DB;
 
 
 class MaterialBoxService
@@ -16,4 +17,37 @@ class MaterialBoxService
     protected $modelClass=MaterialBox::class;
 
 
+    /**
+     * 获取一个空料箱
+     *
+     * @return MaterialBox|null
+     */
+    public function getAnEmptyBox()
+    {
+        $id = 0;
+        while (true){
+            $boxes = MaterialBox::query()->select('id',"code")->where("id",">",$id)->where("code","like","IDE%")
+                ->where("status",4)->limit(10)->orderBy("id")->get();
+            if ($boxes->count()==0)break;
+            $ides = [];
+            $str = "(";
+            for ($i=0;$i<count($boxes)-1;$i++){
+                $str .= "'".$boxes[$i]->code."',";
+                $ides[$boxes[$i]->code] = $boxes[$i];
+            }
+            $box = $boxes[count($boxes)-1];
+            $ides[$box->code] = $box;
+            $str .= "'".$box->code."')";
+            $id = $box->id;
+            $sql = <<<sql
+SELECT LOCATIONID,SUM(QTY+QTYPA) qty FROM INV_LOT_LOC_ID WHERE LOCATIONID IN {$str} GROUP BY LOCATIONID
+sql;
+            foreach (DB::connection("oracle")->select(DB::raw($sql)) as $item){
+                if ((int)$item->qty==0)return $ides[$item->locationid];
+                unset($ides[$item->locationid]);
+            }
+            if ($ides)return current($ides);
+        }
+        return null;
+    }
 }

+ 10 - 10
app/Services/OracleDocWaveDetailService.php

@@ -25,9 +25,9 @@ class OracleDocWaveDetailService
             $waveNos = array_values(array_diff(data_get($items, '*.waveno'),['*']));
             try {
                 OracleDOCWaveDetails::query()->whereIn('OrderNo', $clearOrderNos)->whereIn('WaveNo', $waveNos)->delete();
-                app('LogService')->log(__CLASS__, __METHOD__, 'Delete OracleDOCWaveDetails' . '  ' . json_encode($clearOrderNos).json_encode($waveNos));
+                app('LogService')->log(__CLASS__, __FUNCTION__, 'Delete OracleDOCWaveDetails' . '  ' . json_encode($clearOrderNos).json_encode($waveNos));
             } catch (Exception $e) {
-                app('LogService')->log(__CLASS__, __METHOD__,'Error clearCancelledOrder'.json_encode($clearOrderNos).json_encode($waveNos));
+                app('LogService')->log(__CLASS__, __FUNCTION__,'Error clearCancelledOrder'.json_encode($clearOrderNos).json_encode($waveNos));
             }
         });
     }
@@ -99,11 +99,11 @@ class OracleDocWaveDetailService
             return;
 
         $orderHeaders = OracleDOCOrderHeader::query()
-            ->selectRaw('orderno,waveno,editTime')
-            ->where('EDITTIME', '>', Carbon::parse($sync_at))
-            ->where('ERPCANCELFLAG', 'Y')
-            ->orderByDesc('editTime')->get();
-
+            ->selectRaw('orderno,waveno,edittime,erpcancelflag')
+            ->where('EditTime', '>', Carbon::parse($sync_at))
+            ->where('WaveNo','!=','*')
+            ->where('ERPCancelFLAG', 'Y')
+            ->orderByDesc('EditTime')->get();
         $orderHeaderList = $orderHeaders->chunk(50);
         $update_at = Carbon::now();
         if(count($orderHeaders)>0){
@@ -111,19 +111,19 @@ class OracleDocWaveDetailService
                 $this->clearCancelledOrder($items);
                 if ($items->count() > 0) {
                     OracleDOCOrderHeader::query()
-                        ->whereIn('orderNo', data_get($items, '*.orderno'))
+                        ->whereIn('orderno', data_get($items, '*.orderno'))
                         ->whereIn('waveno', data_get($items, '*.waveno'))
                         ->update(['waveno' => '*','editTime' =>$update_at]);
                     $json = json_encode($items->map(function ($orderHeader) {
                         return ['orderno' => $orderHeader->orderno, 'waveno' => $orderHeader->waveno];
                     }));
-                    app('LogService')->log(__CLASS__, __METHOD__, 'update OrderHeader' . '  ' . $json);
+                    app('LogService')->log(__CLASS__, __FUNCTION__, 'update OrderHeader' . '  ' . $json);
                     $this->disposeOrderBatchId(data_get($items, '*.orderno'));
                 }
             }
         }
         $end_time = (string)Carbon::now();
-        $sync_at = $orderHeaders->first()->editTime ?? $sync_at;
+        $sync_at = $orderHeaders->first()->edittime ?? $sync_at;
         $this->setSyncAt($sync_at);
         $this->setSyncStartAt((string)$start_time);
         $this->setSyncEndAt($end_time);

+ 53 - 41
app/Services/OrderPackageReceivedSyncService.php

@@ -4,6 +4,7 @@
 namespace App\Services;
 
 
+use App\Jobs\LogisticSFSync;
 use App\Jobs\LogisticYDSync;
 use App\Jobs\LogisticYTOSync;
 use App\Jobs\LogisticZopSync;
@@ -25,23 +26,58 @@ class OrderPackageReceivedSyncService
      */
     public function syncLogisticRoute()
     {
-        $logisticNumbers = $this->getLogisticNumbers();
-        $this->update($this->getLogisticRoutes($logisticNumbers));
-        //更新中通
-        $ZTOLogisticNumbers = $logisticNumbers['ZTO'];
-        foreach ($ZTOLogisticNumbers as $logisticNumber) {
-            LogisticZopSync::dispatch($logisticNumber);
-        }
-        //更新韵达
-        $YDLogisticNumbers = $logisticNumbers['YUNDA'];
-        foreach ($YDLogisticNumbers as $logistic_number) {
-            LogisticYDSync::dispatch($logistic_number);
-        }
-        //更新圆通
-        $YTOLogisticNumbers = $logisticNumbers['YTO'];
-        foreach ($YTOLogisticNumbers as $logistic_number) {
-            LogisticYTOSync::dispatch($logistic_number);
+        LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法", '');
+        ini_set('max_execution_time', 60 * 60);
+        //初始化时间 2020-12-31 23:59:59
+        $initDate = Carbon::parse(config('api_logistic.init_date'));
+        $query = OrderPackage::query()
+            ->select(['logistic_number', 'order_id'])
+            ->with(['order' => function ($query) {
+                return $query->with('logistic');
+            }]);
+        if (Carbon::now()->lte($initDate)) {//当前时间小于等于初始化时间
+            //初始化查询一个月的数据,exception为否
+            $query = $query->where('sent_at', '>=', $initDate->subDays((int)config('api_logistic.days'))->toDateTimeString())
+                ->whereNull('received_at');
+        } else {//查询20天以内的数据
+            $query = $query->where('sent_at', '>=', now()->subDays(20))
+                ->whereNull('received_at');
         }
+        $query->chunk(2000, function ($orderPackages) {
+            $logisticNumbers = $this->buildData($orderPackages);
+            //sf
+            if (array_key_exists('SF', $logisticNumbers)) {
+                $SFLogisticNumbers = $logisticNumbers['SF'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-SF", '');
+                foreach ($SFLogisticNumbers as $logisticNumber) {
+                    LogisticSFSync::dispatch($logisticNumber);
+                }
+            }
+            //更新中通
+            if (array_key_exists('ZTO', $logisticNumbers)) {
+                $ZTOLogisticNumbers = $logisticNumbers['ZTO'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-ZTO", '');
+                foreach ($ZTOLogisticNumbers as $logisticNumber) {
+                    LogisticZopSync::dispatch($logisticNumber);
+                }
+            }
+            //更新韵达
+            if (array_key_exists('YUNDA', $logisticNumbers)) {
+                $YDLogisticNumbers = $logisticNumbers['YUNDA'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YUNDA", '');
+                foreach ($YDLogisticNumbers as $logistic_number) {
+                    LogisticYDSync::dispatch($logistic_number);
+                }
+            }
+            //更新圆通
+            if (array_key_exists('YTO', $logisticNumbers)) {
+                $YTOLogisticNumbers = $logisticNumbers['YTO'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", '');
+                foreach ($YTOLogisticNumbers as $logistic_number) {
+                    LogisticYTOSync::dispatch($logistic_number);
+                }
+            }
+        });
     }
 
     /**
@@ -97,6 +133,7 @@ class OrderPackageReceivedSyncService
     public function update(array $orderPackages)
     {
         foreach ($orderPackages as $data) {
+            if (empty($data)) continue;
             $orderPackage = OrderPackage::query()->where('logistic_number', $data['logistic_number'])->first();
             if (isset($data['status'])) $orderPackage->status = $data['status'];
             if (isset($data['received_at'])) $orderPackage->received_at = $data['received_at'];
@@ -107,31 +144,6 @@ class OrderPackageReceivedSyncService
         }
     }
 
-    /**
-     * 查询当前日期前的快递单号并按照承运商分类
-     */
-    public function getLogisticNumbers(): array
-    {
-        //初始化时间 2020-12-31 23:59:59
-        $initDate = Carbon::parse(config('api_logistic.init_date'));
-        $query = OrderPackage::query()
-            ->with(['order' => function ($query) {
-                return $query->with('logistic');
-            }]);
-        if (Carbon::now()->lte($initDate)) {//当前时间小于等于初始化时间
-            //初始化查询一个月的数据,exception为否
-            $query = $query->where('sent_at', '>=', $initDate->subDays((int)config('api_logistic.days'))->toDateTimeString())
-                ->whereNull('received_at');
-        } else {//查询20天以内的数据
-            $query = $query->where('sent_at', '>=', now()->subDays(20)->toDateTimeString())
-                ->whereNull('received_at');
-        }
-        $result = [];
-        $query->chunk(200, function ($orderPackages) use (&$result) {
-            return $result = array_merge($result, $this->buildData($orderPackages));
-        });
-        return $result;
-    }
 
     /**
      * 将orderPackage集合分类并摘取指定数据

+ 10 - 2
app/Services/OwnerPriceOperationService.php

@@ -328,10 +328,18 @@ class OwnerPriceOperationService
         $money = null;
         $taxFee = null;
 
-        if ($type == '出库')$total = app("OrderService")->getOrderQuantity($ownerId)+1;//获取该货主本月C端单量
-        else {
+        if ($type == '出库'){
+            $total = app("OrderService")->getOrderQuantity($ownerId)+1;//获取该货主本月C端单量
+            $matchObject->packages->each(function ($package)use(&$orderTotal){
+                $package->commodities->each(function ($commodity)use(&$orderTotal){
+                    $orderTotal += (int)$commodity->amount;
+                });
+            });
+            $matchObject[$columnMapping[12]] = $orderTotal;
+        }else {
             $total = 0;
             if ($matchObject->storeItems)foreach ($matchObject->storeItems as $item)$total += $item->amount;
+            $matchObject[$columnMapping[12]] = $total;
             $total += app("StoreService")->getStoreAmount($ownerId);//获取该货主本月入库件数
         }
         foreach ($rules as $rule){

+ 2 - 2
app/Services/PackageStatisticsService.php

@@ -26,8 +26,8 @@ class PackageStatisticsService
                 ->selectRaw('orders.owner_id,logistic_id');
 
         $columnQueryRules=[
-            'created_at_start' => ['alias' => 'order_packages.created_at','startDate' => ":00"],
-            'created_at_end' => ['alias' => 'order_packages.created_at','endDate' => ":59"],
+            'created_at_start' => ['alias' => 'weighed_at','startDate' => ":00"],
+            'created_at_end' => ['alias' => 'weighed_at','endDate' => ":59"],
             'logistic_id' => ['multi' => ','],
             'owner_id' => ['multi' => ','],
         ];

+ 13 - 2
app/Services/StationTaskMaterialBoxService.php

@@ -165,16 +165,22 @@ class StationTaskMaterialBoxService
                     /** @var StationTask $stationTask */
                     $stationTask = $this->stationTaskService->getProcessing();
                     $this->stationService->broadcastBinMonitor($stationTaskMaterialBox['station_id'], $stationTask);
+                    $stationTaskMaterialBox->materialBox['status']='在U型线';
+                    $stationTaskMaterialBox->materialBox->update();
                     break;
                 case '入立库':
                     $this->set($stationTaskMaterialBox,[
                         'id' => $stationTaskMaterialBox['station_id'],
                         'status' => '完成',
                     ]);
-
                     $this->cacheShelfService->putStationTaskMaterialBoxProcess($stationTaskMaterialBox);
+                    $stationTaskMaterialBox->materialBox['status']='在立库';
+                    $stationTaskMaterialBox->materialBox->update();
+                    break;
+                case '入缓存架':
+                    $stationTaskMaterialBox->materialBox['status']='在缓存架';
+                    $stationTaskMaterialBox->materialBox->update();
                     break;
-                case '入缓存架':break;
                 default:;
             }
         }catch (\Exception $e){
@@ -317,6 +323,11 @@ class StationTaskMaterialBoxService
         ){
             return '入立库';
         }
+        if($isCacheShelf=(
+            $stationTaskMaterialBox['station']['stationType']['name'] == '缓存架')
+        ){
+            return '入缓存架';
+        }
 //        if($isStoring=false){
 //            return '入库';
 //        }

+ 2 - 2
app/Services/common/BatchUpdateService.php

@@ -64,10 +64,10 @@ class BatchUpdateService
         try {
             // DB::update
             $bool = DB::connection($connection)->update($updateSql, $bindings);
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新' . count($multipleData) . $tableName . $updateSql . json_encode($bindings));
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新:' . $tableName . ' | '.json_encode($multipleData));
             return $bool;
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败' . count($multipleData) . $tableName . $updateSql . json_encode($bindings) . $e->getMessage() . $e->getTraceAsString());
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败' . $tableName . ' | '.json_encode($multipleData) . $e->getMessage() . $e->getTraceAsString());
             return false;
         }
     }

+ 5 - 0
app/StationRuleBatch.php

@@ -18,4 +18,9 @@ class StationRuleBatch extends Model
     {
         return $this->belongsTo(StationType::class);
     }
+
+    public function owner() :BelongsTo
+    {
+        return $this->belongsTo(Owner::class);
+    }
 }

+ 1 - 1
app/StationTaskMaterialBox.php

@@ -13,7 +13,7 @@ class StationTaskMaterialBox extends Model
 {
     use ModelLogChanging;
 
-    protected $fillable=['station_id','material_box_id','status'];
+    protected $fillable=['station_id','material_box_id','status','type','station_task_batch_id','station_task_id'];
 
     function materialBox(): HasOne
     {

+ 27 - 0
app/Storage.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+
+class Storage extends Model
+{
+    use ModelLogChanging;
+
+    protected $fillable = [
+        "material_box_id",
+        "commodity_id",
+        "amount"
+    ];
+
+    public function materialBox()
+    {   //料箱
+        $this->belongsTo(MaterialBox::class);
+    }
+    public function commodity()
+    {   //商品
+        $this->belongsTo(Commodity::class);
+    }
+}

+ 1 - 1
app/library/baidu-api-speech/lib/2a7552bdd1b678c303ad53645baeafce

@@ -1 +1 @@
-{"refresh_token":"25.4d53cf00633b3d4a1aac4042f9eece5b.315360000.1899260149.282335-18688250","expires_in":2592000,"session_key":"9mzdCKZyPT8dnHgqKTa2IKAbjeiTI6dKyllds7VEsgOWDGIjY2BEgLmOazFfJmWYYTC0\/RVFMWlS0krsTPpuSdMxopSCHw==","access_token":"24.3bc112d85964e45cab8f8b33c75ac42d.2592000.1586492149.282335-18688250","scope":"audio_voice_assistant_get brain_enhanced_asr audio_tts_post public brain_all_scope picchain_test_picchain_api_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi qatest_scope1 fake_face_detect_\u5f00\u653eScope vis-ocr_\u865a\u62df\u4eba\u7269\u52a9\u7406 idl-video_\u865a\u62df\u4eba\u7269\u52a9\u7406","session_secret":"7ed83fac7de4c020d1f1627700b9ab71","time":1583900148,"is_cloud_user":false}
+{"refresh_token":"25.7e4748217e997c84c2402b9b24adb134.315360000.1936752238.282335-18688250","expires_in":2592000,"session_key":"9mzdCPblW0XXeNGCMqTv\/JHlyb1R+CCFsPtDR+I+pkvO3Wt6R95mYM6B\/czx+j6XbwA+xuH79EnEt1k9LyvlecbmLoyo3A==","access_token":"24.32855024de5bed138fec0c12a1dd166d.2592000.1623984238.282335-18688250","scope":"brain_asr_async brain_speech_realtime audio_voice_assistant_get brain_enhanced_asr audio_tts_post public brain_all_scope picchain_test_picchain_api_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\u5f00\u653eScope vis-ocr_\u865a\u62df\u4eba\u7269\u52a9\u7406 idl-video_\u865a\u62df\u4eba\u7269\u52a9\u7406 smartapp_component smartapp_search_plugin avatar_video_test","session_secret":"a8e2a31ba3a17b7c3f30efa29600b809","time":1621392238,"is_cloud_user":false}

+ 0 - 44
database/migrations/2021_05_11_101611_exception_message_able_null_order_packages_table.php

@@ -1,44 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class ExceptionMessageAbleNullOrderPackagesTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->dropIndex('order_packages_logistic_number_unique');
-        });
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->string('exception_message')->nullable()->change();
-        });
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->unique('logistic_number','order_packages_logistic_number_unique');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->dropIndex('order_packages_logistic_number_unique');
-        });
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->string('exception_message')->nullable(false)->change();
-        });
-        Schema::table('order_packages', function (Blueprint $table) {
-            $table->unique('logistic_number','order_packages_logistic_number_unique');
-        });
-    }
-}

+ 32 - 0
database/migrations/2021_05_19_154807_change_logistics_table_add_english_name_column.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeLogisticsTableAddEnglishNameColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->string("english_name")->nullable()->comment("英文名称");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->dropColumn("english_name");
+        });
+    }
+}

+ 38 - 0
database/migrations/2021_05_19_171047_add_station_rule_batch_author.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddStationRuleBatchAuthor extends Migration
+{
+    public $names = [
+        '站管理-站规则',
+        '站管理-站规则-编辑',
+        '站管理-站规则-创建',
+        '站管理-站规则-删除',
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->names as $item) {
+            \App\Authority::query()->firstOrCreate(['name' => $item],['alias_name' => $item]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->names as $item) {
+            \App\Authority::query()->where('name' , $item)->delete();
+        }
+    }
+}

+ 34 - 0
database/migrations/2021_05_19_172118_create_storages_table.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateStoragesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('storages', function (Blueprint $table) {
+            $table->id();
+            $table->bigInteger("material_box_id")->index()->comment("外键料箱");
+            $table->bigInteger("commodity_id")->nullable()->index()->comment("外键商品");
+            $table->integer("amount")->default(0)->comment("数量");
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('storages');
+    }
+}

+ 32 - 0
database/migrations/2021_05_19_173442_add_materialBoxes_field_status.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddMaterialBoxesFieldStatus extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('material_boxes', function (Blueprint $table) {
+            $table->tinyInteger('status')->nullable()->index('material_boxes_i_status');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('material_boxes', function (Blueprint $table) {
+            $table->dropColumn('status');
+        });
+    }
+}

+ 34 - 0
database/migrations/2021_05_20_142418_change_car_types_add_length_column.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeCarTypesAddLengthColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('car_types', function (Blueprint $table) {
+            $table->string('length')->comment('车长(米)')->change();
+            $table->string('load')->nullable()->comment('载重(吨)')->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('car_types', function (Blueprint $table) {
+            $table->decimal('length')->comment('车长(米)')->change();
+            $table->decimal('load')->nullable()->comment('载重(吨)')->change();
+        });
+    }
+}

+ 1 - 0
database/seeds/StationRuleBatchSeeder.php

@@ -12,5 +12,6 @@ class StationRuleBatchSeeder extends Seeder
     public function run()
     {
         //
+        factory(\App\StationRuleBatch::class)->times(3)->create();
     }
 }

+ 25 - 4
public/t.php

@@ -1,5 +1,26 @@
 <?php
-$codes=['sdf',33,'4'];
-$responseBody = 'sadfsdlfkj200,34324';
-$responseBody = strstr($responseBody,'200')?'取料箱'.implode(',',$codes).'成功':$responseBody;
-var_dump($responseBody);
+
+
+class Aa
+{
+    static public $enums=[
+        'status'=>[
+            '在库外'=>6,
+            '在U型线'=>1,
+            '在出库中'=>2,
+            '在入库中'=>3,
+            '在立库'=>4,
+            '异常'=>5,
+        ],
+    ];
+    function __construct(array $attributes = [])
+    {
+        foreach (self::$enums as &$enum) {
+            $enum=$enum+array_flip($enum);
+        }
+    }
+
+}
+
+$aa = new Aa();
+var_dump(Aa::$enums['status'][1]);

+ 2 - 0
resources/js/queryForm/header.js

@@ -270,6 +270,7 @@ window.Header = function getHeader(object) {
                         trs[j].children[moveTd.index].firstElementChild.style.width = newWidth;
                         trs[j].children[moveTd.index].style.minWidth = newWidth;
                     }
+                    _targetDom.style.width = _targetDom.offsetWidth+diff+"px";
                     moveTd.oldX = event.clientX;
                 }
             }
@@ -612,5 +613,6 @@ window.Header = function getHeader(object) {
         createSetting();
         _exeHid([]);
         bindGlobalEvent();
+        _targetDom.style.width = _targetDom.offsetWidth+"px";
     };
 };

+ 10 - 3
resources/views/customer/project/create.blade.php

@@ -551,12 +551,14 @@
                 //重载作业费
                 _overrideOperation(operation){
                     if (operation.discount_count){
-                        if (operation.discount_count) operation.discount_count = operation.discount_count.split(",");
-                        if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
                         operation.isDiscount = true;
-                    }
+                        operation.discount_count = operation.discount_count.split(",");
+                    } else operation.discount_count = [];
+                    if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
+                    else operation.total_discount_price = [];
                     operation.items.forEach((item,j)=>{
                         if (item.discount_price) operation.items[j].discount_price = item.discount_price.split(",");
+                        else operation.items[j].discount_price = [];
                     });
                     if (operation.total_price)operation.isSingle = true;
                     if (operation.type_mark===0 || operation.type_mark==='0')operation.isRejected = true;
@@ -1910,6 +1912,11 @@
                     this.model.operation.total_discount_price.push("");
                     arr.push('');
                 },
+                //开启满减
+                onDiscount(type){
+                  if (!type)return;
+                  if (this.model.operation.discount_count.length===0) this.model.operation.discount_count = [""];
+                },
                 //删除阶梯满减阈值
                 delDiscount(index){
                     this.model.operation.items.forEach((item,i)=>{

+ 2 - 1
resources/views/customer/project/part/_operation.blade.php

@@ -40,7 +40,7 @@
 <div class="row mt-3">
     <label class="col-2" for="isDiscount">是否满减</label>
     <div class="col-2">
-        <input type="checkbox" id="isDiscount" class="rounded mt-1" v-model="model.operation.isDiscount">
+        <input type="checkbox" id="isDiscount" class="rounded mt-1" v-model="model.operation.isDiscount" @change="onDiscount(model.operation.isDiscount)">
     </div>
     <div class="col-8 row" v-if="model.operation.isDiscount">
         <div class="col-1 cursor-pointer"><span class="fa fa-plus" @click="addDiscount(model.operation.discount_count)"></span></div>
@@ -175,6 +175,7 @@
     <input id="surcharge" type="number" step="0.01" min="0" class="form-control col-3" :class="errors.surcharge ? 'is-invalid' : ''" v-model="model.operation.surcharge">
     <label for="surcharge_unit_id" class="col-2 text-right">单位</label>
     <select id="surcharge_unit_id" v-model="model.operation.surcharge_unit_id" class="form-control col-2" :class="errors.surcharge_unit_id ? 'is-invalid' : ''">
+        <option> </option>
         <option v-for="unit in pool.units" :value="unit.id" v-if="unit.name=='件' || unit.name=='单'">@{{ unit.name }}</option>
     </select>
 </div>

+ 7 - 0
resources/views/maintenance/logistic/create.blade.php

@@ -41,6 +41,13 @@
                             @enderror
                         </div>
                     </div>
+                    <div class="form-group row">
+                        <label for="english_name" class="col-2 col-form-label text-right">承运商英文名称</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control" id="english_name"
+                                   name="english_name" autocomplete="off" value="{{ old('name') }}">
+                        </div>
+                    </div>
                     <div class="form-group row">
                         <label for="code" class="col-2 col-form-label text-right">承运商代码 <b class="text-danger">*</b></label>
                         <div class="col-8">

+ 9 - 2
resources/views/maintenance/logistic/edit.blade.php

@@ -36,7 +36,7 @@
                         </div>
                     </div>
                     <div class="form-group row">
-                        <label for="name" class="col-2 col-form-label text-right">物流公司名称 <b class="text-danger">*</b></label>
+                        <label for="name" class="col-2 col-form-label text-right">承运商名称 <b class="text-danger">*</b></label>
                         <div class="col-8">
                             <input type="text" class="form-control @error('name') is-invalid @enderror"
                                    name="name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$logistic->name}}@endif" required>
@@ -48,7 +48,14 @@
                         </div>
                     </div>
                     <div class="form-group row">
-                        <label for="code" class="col-2 col-form-label text-right">物流公司代码 <b class="text-danger">*</b></label>
+                        <label for="english_name" class="col-2 col-form-label text-right">承运商英文名称</label>
+                        <div class="col-8">
+                            <input id="english_name" type="text" class="form-control"
+                                   name="english_name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$logistic->name}}@endif" >
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="code" class="col-2 col-form-label text-right">承运商代码 <b class="text-danger">*</b></label>
                         <div class="col-8">
                             <input type="text" class="form-control @error('code') is-invalid @enderror"
                                    name="code" autocomplete="off" value="@if(old('code')){{old('code')}}@else{{$logistic->code}}@endif" required>

+ 2 - 0
resources/views/maintenance/logistic/index.blade.php

@@ -16,6 +16,7 @@
                     <tr>
                         <th>ID</th>
                         <th>承运商名称</th>
+                        <th>承运商英文名称</th>
                         <th>承运商代码</th>
                         <th>承运商联系方式</th>
                         <th>承运商类型</th>
@@ -27,6 +28,7 @@
                     <tr v-for="(logistic,i) in logistics" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
                         <td class="text-muted">@{{logistic.id}}</td>
                         <td>@{{logistic.name}}&nbsp;<span class="badge badge-success" v-if="logistic.is_bunched=='Y'">子母单</span></td>
+                        <td>@{{logistic.english_name}}</td>
                         <td>@{{logistic.code}}</td>
                         <td>@{{logistic.mobile}}</td>
                         <td>@{{logistic.type}}</td>

+ 1 - 1
resources/views/maintenance/tutorial/create.blade.php

@@ -1,7 +1,7 @@
 @extends('layouts.app')
 @section('title')录入-教程@endsection
 @section('head')
-    <link rel="stylesheet" type="text/css" href="{{mix('css/trix.css')}}">
+    <link rel="stylesheet" type="text/css" href="{{asset('css/trix.css')}}">
     <script type="text/javascript" src="{{mix('js/trix.js')}}"></script>
     <script>
 

+ 11 - 6
resources/views/package/logistic/index.blade.php

@@ -215,10 +215,6 @@
 
 
                         {name: 'sent_at_start', type: 'dateTime', tip: '选择显示发出时间的起始时间'},
-                        {name: 'sent_at_end', type: 'dateTime', tip: '选择显示发出时间的截止时间'},
-
-
-
                         {
                             name: 'is_weighed',
                             type: 'select',
@@ -226,6 +222,14 @@
                             placeholder: '是否称重',
                             data: [{name: false, value: '无'}, {name: true, value: '已称重'}]
                         },
+                        {name: 'received_at_start', type: 'dateTime', tip: '选择显示收货时间的起始时间'},
+                        {
+                            name: 'has_transfer_status',
+                            type: 'select',
+                            tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的状态'],
+                            placeholder: '是否有物流信息',
+                            data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
+                        },
                         {name: 'default_date', type: 'checkbox', tip: '默认15天', data: [{name: 'ture', value: '默认15天'}]},
 
                     ], [
@@ -243,8 +247,7 @@
                             placeholder: ['货主', '定位或多选货主'],
                             data: _this.owners
                         },
-                        {name: 'received_at_start', type: 'dateTime', tip: '选择显示收货时间的起始时间'},
-                        {name: 'received_at_end', type: 'dateTime', tip: '选择显示收货时间的截止时间'},
+                        {name: 'sent_at_end', type: 'dateTime', tip: '选择显示发出时间的截止时间'},
                         {
                             name: 'is_exception',
                             type: 'select',
@@ -252,6 +255,8 @@
                             placeholder: '是否有异常',
                             data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
                         },
+                        {name: 'received_at_end', type: 'dateTime', tip: '选择显示收货时间的截止时间'},
+
                         {
                             name: 'exception_type',
                             type: 'select',

+ 23 - 24
resources/views/package/measureMonitor/index.blade.php

@@ -18,7 +18,6 @@
                                         <ul class="nav nav-pills">
                                             <b style="padding: 10px">请选择设备:</b>
                                             <li v-for="measuringMachine in measuringMachines" @click="clickMeasuringMachine(measuringMachine.id)" :class="[measuringMachine.name==package.measuringMachine ?  selectedMachine : otherMachine] " style="padding: 10px">
-                                                {{--<span v-if="package.measuringMachine==measuringMachine.name" :class="[package.measuringMachine_status=='离线' ?  off : on] " style="font-size:12px;"></span>--}}
                                                 <span :class="[measuringMachine.status=='离线' ?  off : on] " style="font-size:12px;"></span>
                                                 <a style="text-decoration:none;cursor:pointer" class="text-dark"  >@{{measuringMachine.name}}</a>
                                             </li>
@@ -32,31 +31,31 @@
                                             <tr>
                                                 <th class="tag" scope="row">货主</th>
                                                 <td style="border-right:thick double #aaaaaa;">@{{package.owner}}</td>
-                                                <th class="tag" scope="row" scope="row">重量(KG)</th>
+                                                <th class="tag" scope="row">重量(KG)</th>
                                                 <td>@{{package.weight}}</td>
                                             </tr>
                                             <tr>
-                                                <th class="tag" scope="row" scope="row">订单编号</th>
+                                                <th class="tag" scope="row">订单编号</th>
                                                 <td style="border-right:thick double #aaaaaa;">@{{package.orderno}}</td>
-                                                <th class="tag" scope="row" scope="row">收件人</th>
+                                                <th class="tag" scope="row">收件人</th>
                                                 <td>@{{package.recipient}}</td>
                                             </tr>
                                             <tr>
-                                                <th class="tag" scope="row" scope="row">承运商</th>
+                                                <th class="tag" scope="row">承运商</th>
                                                 <td style="border-right:thick double #aaaaaa;">@{{package.logistic_name}}</td>
-                                                <th class="tag" scope="row" scope="row">快递单号</th>
+                                                <th class="tag" scope="row">快递单号</th>
                                                 <td>@{{package.logistic_number}}</td>
                                             </tr>
                                             <tr>
-                                                <th class="tag" scope="row" scope="row">纸箱名称</th>
+                                                <th class="tag" scope="row">纸箱名称</th>
                                                 <td style="border-right:thick double #aaaaaa;">@{{package.paperBox}}</td>
-                                                <th class="tag" scope="row" scope="row">体积(CM³)</th>
+                                                <th class="tag" scope="row">体积(CM³)</th>
                                                 <td>@{{package.bulk}}</td>
                                             </tr>
                                             <tr>
-                                                <th  class="tag" scope="row" scope="row">状态</th>
+                                                <th  class="tag" scope="row">状态</th>
                                                 <td style="border-right:thick double #aaaaaa;">@{{package.status}}</td>
-                                                <th  class="tag" scope="row" scope="row">操作时间</th>
+                                                <th  class="tag" scope="row">操作时间</th>
                                                 <td>@{{package.weighed_at}}</td>
                                             </tr>
                                         </table>
@@ -134,33 +133,33 @@
                         let logistic_name = package.order ? (package.order.logistic ? package.order.logistic.name : '') : '';
                         if (_this.logisticAudioURL[logistic_name]){
                             audio.src=_this.logisticAudioURL[logistic_name];
-                            audio.play();
+                            setTimeout(()=>{
+                                audio.play();
+                            },10);
                         }else {
-                            axios.post('/package/measureMonitor/speech',{logistic:logistic_name})
+                            window.tempTip.setDuration(3000);
+                            window.axios.post('package/weigh/measureMonitor/speech',{logistic:logistic_name})
                                 .then(function (response) {
                                     if (response.data){
                                         _this.logisticAudioURL[logistic_name]=response.data;
                                         audio.src=response.data;
-                                        audio.play();
-                                    }else {
-                                        tempTip.setDuration(4000);
-                                        tempTip.show('没有对应快递名称!');
-                                    }
-                                })
-                                .catch(function (err) {
-                                    tempTip.setDuration(4000);
-                                    tempTip.show('语音合成发生错误:'+err);
+                                        setTimeout(()=>{
+                                            audio.play();
+                                        },10);
+                                    }else window.tempTip.show('没有对应快递名称!');
+                                }).catch(function (err) {
+                                    window.tempTip.show('语音合成发生错误:'+err);
                                 });
                         }
-                        tempTip.setDuration(1000);
-                        tempTip.showSuccess('刷新成功!');
+                        window.tempTip.setDuration(1000);
+                        window.tempTip.showSuccess('刷新成功!');
                     }
                 });
             },
             methods:{
                 clickMeasuringMachine(e){
                     let _this=this;
-                    axios.post('{{url('package/measureMonitor/data')}}',{id:e})
+                    window.axios.post('{{url('package/weigh/measureMonitor/data')}}',{id:e})
                         .then(function (response) {
                             if (response.data.id){
                                 let orderPackage=response.data;

+ 4 - 1
resources/views/station/cachingShelf/list/_fillBox.blade.php

@@ -14,6 +14,9 @@
                         <input type="text" id="material-box" class="form-control col" @keydown.enter="pushMaterialBox()" v-model="materialBoxCode">
                     </div>
                 </div>
+                <div class="container" id="alert-box">
+                    <div class="alert-info" >加载中......</div>
+                </div>
                 <hr>
                 <div class="container">
                     <div class="row">
@@ -26,7 +29,7 @@
                 </div>
                 <div class="modal-footer">
                     <button class="btn btn-primary" data-dismiss="modal">关闭</button>
-                    <button class="btn btn-primary" @click="clearCurrentStation">清空</button>
+{{--                    <button class="btn btn-primary" @click="clearCurrentStation">清空</button>--}}
                 </div>
             </div>
         </div>

+ 41 - 15
resources/views/station/cachingShelf/list/index.blade.php

@@ -57,7 +57,8 @@
                             stationCode:stationCode,
                             materialBoxCode:null,
                             row:row,
-                            col:col
+                            col:col,
+                            type:null
                         }
                     }
                 },
@@ -91,19 +92,20 @@
                     $('#box').modal('show');
                 },
                 /** 清空格口号 */
-                clearCurrentStation() {
-                    this.currentStation.data.forEach(function (item, index, items) {
-                        items[index].forEach(function (item, index, self) {
-                            self[index]['code'] = null;
-                        })
-                    });
-                    this.$forceUpdate();
-                },
+                // clearCurrentStation() {
+                //     this.currentStation.data.forEach(function (item, index, items) {
+                //         items[index].forEach(function (item, index, self) {
+                //             self[index]['code'] = null;
+                //         })
+                //     });
+                //     this.$forceUpdate();
+                // },
                 /** 初始化格口 */
                 initCacheGrid() {
                     let url = '{{url('apiLocal/station/cacheShelf/getTasks')}}'+'/'+this.currentStation.id;
                     window.tempTip.setIndex(1099);
                     window.tempTip.setDuration(3000);
+                    $('#alert-box').show();
                     window.axios.get(url).then(res => {
                         if (res.data.data) {
                             for (let index = 0; index < res.data.data.length; index++) {
@@ -115,21 +117,26 @@
                                 let materialBoxCode = res.data.data[index]['pending_station_task']['station_task_material_boxes'][0]['material_box']['code'] ?? null;
                                 this.$set(this.currentStation.grids[stationCode],'materialBoxCode',materialBoxCode);
                             }
+                            $('#alert-box').hide();
                             this.$forceUpdate();
                             return;
                         }
                         window.tempTip.show('获取缓存货架信息失败');
+                        $('#alert-box').hide();
                     }).catch(err => {
                         window.tempTip.show('获取缓存货架信息异常:' + err);
+                        $('#alert-box').hide();
                     });
                 },
                 /** 扫码 1、料箱扫码 */
                 pushMaterialBox(grid = null,$e = null) {
                     // 从格口输入
-                    if(grid) {
+                    if($e) {
                         let materialBoxCode = $($e.target).val();
                         let stationCode = grid['stationCode'];
-                        this.lightOn(stationCode,materialBoxCode);
+
+                        if(materialBoxCode.trim()!=='')this.lightOn(stationCode,materialBoxCode);
+                        else this.clearTask(stationCode);
                         return;
                     }
                     for (const key in this.currentStation.grids) {
@@ -148,7 +155,7 @@
                     window.tempTip.setDuration(2000);
                     window.tempTip.setIndex(1999);
 
-                    if(this.checkMaterialBoxCodeExist(materialBoxCode)){
+                    if(this.checkMaterialBoxCodeExist(materialBoxCode,stationCode)){
                         window.tempTip.show('料箱已被占用');
                         return ;
                     }
@@ -166,10 +173,28 @@
                         window.tempTip.show(err);
                     });
                 },
+                clearTask(stationCode){
+                    let url = '{{url('apiLocal/station/cacheShelf/clearTask')}}';
+                    let data = {station:stationCode};
+                    window.tempTip.setDuration(2000);
+                    window.tempTip.setIndex(1999);
+                    window.axios.post(url,data).then(res=>{
+                        if(res.data.success){
+                            window.tempTip.showSuccess(res.data.message ? res.data.message : '取消任务成功');
+                            this.$set(this.currentStation.grids[stationCode],'materialBoxCode',null);
+                            this.$forceUpdate();
+                            $('#material-box').focus();
+                            return ;
+                        }
+                        window.tempTip.show('取消任务异常:'+res.data.message);
+                    }).catch(err=>{
+                        window.tempTip.show(err);
+                    });
+                },
                 /** 校验是否存在 */
-                checkMaterialBoxCodeExist(materialBoxCode) {
+                checkMaterialBoxCodeExist(materialBoxCode,stationCode) {
                     for (const key in this.currentStation.grids) {
-                        if(this.currentStation.grids[key]['materialBoxCode'] === materialBoxCode)return true;
+                        if(this.currentStation.grids[key]['materialBoxCode'] === materialBoxCode && key !== stationCode )return true;
                     }
                     return false;
                 },
@@ -181,7 +206,8 @@
                         if (!json || json.length === 0) return;
                         if(json['code'] !== this.currentStation.code)return ;
                         if(json['grid_code']){
-                            this.$set(this.currentStation.grids[json['grid_code']],'materialBoxCode',null);
+                            if(json['type'] === 'success') this.$set(this.currentStation.grids[json['grid_code']],'materialBoxCode',null);
+                            if(json['type'] === 'error') this.$set(this.currentStation.grids[json['grid_code']],'type','error');
                             this.$forceUpdate();
                         }
                     });

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

@@ -10,6 +10,11 @@
                 <li class="nav-item">
                     <a target="station/cachingShelf/index" class="nav-link" href="{{url('station/cachingShelf/index')}}" :class="{active:isActive('cachingShelf',2)}">缓存架</a>
                 </li> @endcan
+            @can('站管理-站规则')
+                <li class="nav-item">
+                    <a target="station/rule/index" class="nav-link" href="{{url('station/rule/index')}}" :class="{active:isActive('rule','2')}">站规则</a>
+                </li>
+            @endcan
         </ul>
     </div>
 </div>

+ 51 - 0
resources/views/station/rule/_edit.blade.php

@@ -0,0 +1,51 @@
+<div class="modal face" id="box">
+    <div class="modal-dialog modal-lg boxClass" >
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="modal-title">
+                    <span v-show="tag==='update'">修改规则</span>
+                    <span v-show="tag==='create'">创建规则</span>
+                </div>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <form>
+                    <div class="form-group row">
+                        <label for="owner-id" class="col-sm-3 col-form-label text-right">货主</label>
+                        <div class="col-sm-9 form-inline">
+                            <select id="owner-id" class="form-control col-sm-6"
+                                    :class="errors.owner_id?'is-invalid':''"
+                                    v-model="stationRuleBatch.owner_id" @input="setStationRuleBatchName($event)"
+                                    @change="errors.owner_id = null">
+                                <option value=""></option>
+                                <option :value="owner.id" v-for="owner in ownerFilters">@{{ owner.name }}</option>
+                            </select>
+                            <input type="text" name="material-code" id="owner-id" class="form-control col-sm-3" placeholder="货主" @input="filterOwner($event)" v-model="filterName">
+                            <div class="invalid-feedback" v-if="errors.owner_id">
+                                @{{ errors.owner_id ? errors.owner_id[0] : ''  }}
+                            </div>
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="rule-name" class="col-sm-3 col-form-label text-right">名称</label>
+                        <div class="col-sm-9 form-inline">
+                            <input type="text" name="phone" id="rule-name" class="form-control col-9"
+                                   :class="errors.name &&  !stationRuleBatch.name ?'is-invalid':''"
+                                   v-model="stationRuleBatch.name" @change="errors.name = null">
+                            <div class="invalid-feedback" v-if="errors.name">
+                                @{{ errors.name ? errors.name[0] : ''  }}
+                            </div>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button class="btn btn-primary" @click="_edit" v-show="tag==='update'">修改</button>
+                <button class="btn btn-primary" @click="_create" v-show="tag==='create'">创建</button>
+            </div>
+        </div>
+    </div>
+</div>
+

+ 47 - 0
resources/views/station/rule/_table.blade.php

@@ -0,0 +1,47 @@
+<table class="table table-striped table-md table-hover" id="table">
+    <thead>
+    <tr>
+        <th>
+            序号
+        </th>
+        <th>
+            货主
+        </th>
+        <th>
+            规则名称
+        </th>
+        <th>
+            设备类型
+        </th>
+        <th>
+            波次类型
+        </th>
+        <th>
+            操作
+        </th>
+    </tr>
+    <template v-if="stationRuleBatches.length > 0">
+        <tr v-for="(stationRuleBatch,i) in stationRuleBatches" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
+            <td>
+                @{{ i+1 }}
+            </td>
+            <td>
+                @{{ stationRuleBatch.owner ? stationRuleBatch.owner.name : '' }}
+            </td>
+            <td>
+                @{{ stationRuleBatch.name }}
+            </td>
+            <td>
+                @{{ stationRuleBatch.station_type ? stationRuleBatch.station_type.name  : ''}}
+            </td>
+            <td>
+                @{{ stationRuleBatch.batch_type ? stationRuleBatch.batch_type :'无'}}
+            </td>
+            <td>
+                @can('站管理-站规则-编辑')<button class="btn btn-sm btn-outline-primary" @click="editStationRuleBatch(stationRuleBatch,i)">编辑</button>@endcan
+                @can('站管理-站规则-删除')<button class="btn btn-sm btn-outline-danger" @click="deleteStationRuleBatch(stationRuleBatch,i)">删除</button>@endcan
+            </td>
+        </tr>
+    </template>
+    </thead>
+</table>

+ 140 - 0
resources/views/station/rule/index.blade.php

@@ -0,0 +1,140 @@
+@extends('layouts.app')
+
+@section('title','站规则')
+
+@section('content')
+    <span id="nav2">
+        @component('station.menu')@endcomponent
+        @component('station.rule.menu')@endcomponent
+    </span>
+    <div class="container-fluid d-none" id="list">
+        @can('站管理-站规则-创建')
+            <button class="btn btn-md btn-outline-primary ml-1" @click="createStationRuleBatch">创建</button>
+        @endcan
+        @include('station.rule._table')
+        @include('station.rule._edit')
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        let vue = new Vue({
+            el: '#list',
+            data: {
+                selectTr: null,
+                stationRuleBatches: {!! $stationRuleBatches->toJson() !!}['data'],
+                owners:{!! $owners !!},
+                ownerFilters: [],
+                filterName: null,
+                tag: null,
+                tagIndex: null,
+                stationRuleBatch: {},
+                errors: {}
+            },
+            mounted() {
+                $('#list').removeClass('d-none');
+                this.filterOwner();
+            },
+            methods: {
+                createStationRuleBatch() {
+                    this.tag = 'create';
+                    this.filterOwner();
+                    this.stationRuleBatch = {};
+                    this.errors = {};
+                    $('#box').modal('show');
+                },
+                editStationRuleBatch(item, index) {
+                    this.stationRuleBatch = JSON.parse(JSON.stringify(item));
+                    this.tag = 'update';
+                    this.tagIndex = index;
+                    this.filterOwner();
+                    this.errors = {};
+                    $('#box').modal('show');
+                },
+                deleteStationRuleBatch(item, index) {
+                    if (!confirm("确定要删除对应的栈规则")) {
+                        return;
+                    }
+                    let url = '{{url('apiLocal/station/rule/destroy')}}' + '/?id=' + item['id'];
+                    window.axios.delete(url).then(res => {
+                        if (res.data.success) {
+                            window.tempTip.showSuccess('删除成功');
+                            this.$delete(this.stationRuleBatches, index);
+                            return;
+                        }
+                        window.tempTip.show('删除异常,刷新页面重试');
+                    }).catch(err => {
+                        window.tempTip.show('网络异常,' + err);
+                    });
+                },
+                _create() {
+                    let url = '{{url('apiLocal/station/rule/store')}}';
+                    console.log(this.stationRuleBatch);
+                    window.axios.post(url, this.stationRuleBatch).then(res => {
+                        if (res.data.success) {
+                            this.stationRuleBatches.unshift(res.data.data);
+                            window.tempTip.showSuccess('创建成功');
+                            $('#box').modal('hide');
+                            this.$forceUpdate();
+                            this.tag = null;
+                            this.tagIndex = null;
+                            this.stationRuleBatch = {};
+                            return;
+                        }else if(res.data.errors){
+                            this.errors = res.data.errors;
+                            this.$forceUpdate();
+                            return;
+                        }
+                        window.tempTip.show('创建异常');
+                    }).catch(err => {
+                        window.tempTip.show('网络异常,' + err);
+                    });
+                },
+                _edit() {
+                    let url = '{{url('apiLocal/station/rule/update')}}';
+                    window.axios.put(url, this.stationRuleBatch).then(res => {
+                        if (res.data.success) {
+                            this.$set(this.stationRuleBatches, this.tagIndex, res.data.data);
+                            window.tempTip.showSuccess('修改成功!');
+                            $('#box').modal('hide');
+                            this.tag = null;
+                            this.tagIndex = null;
+                            this.stationRuleBatch = {};
+                            this.$forceUpdate();
+                            return;
+                        }else if(res.data.errors){
+                            this.errors =res.data.errors;
+                            this.$forceUpdate();
+                            return;
+                        }
+                        window.tempTip.show('编辑异常,刷新页面重试');
+                    }).catch(err => {
+                        window.tempTip.show('网络异常,' + err);
+                    });
+                },
+                setStationRuleBatchName($e){
+                    let selectValue = $($e.target).find('option:selected').text();
+                    if(selectValue && !this.stationRuleBatch.name )
+                        this.$set(this.stationRuleBatch,'name',selectValue)
+                },
+                filterOwner($e = null) {
+                    let copyOwner = JSON.parse(JSON.stringify(this.owners));
+                    this.ownerFilters = copyOwner;
+                    if ($e !== null) {
+                        let value = $($e.target).val();
+                        this.ownerFilters = copyOwner.filter(function (owner) {
+                            return owner.name.indexOf(value) !== -1;
+                        });
+                        if (this.ownerFilters.length !== this.owners.length && this.ownerFilters.length > 0) {
+                            this.$set(this.stationRuleBatch,'owner_id',this.ownerFilters[0]['id']);
+                            this.$set(this.stationRuleBatch,'name',this.ownerFilters[0]['name']);
+                        } else {
+                            this.$set(this.stationRuleBatch,'owner_id',null);
+                        }
+                    }
+                    this.$forceUpdate();
+                }
+            }
+        })
+    </script>
+@endsection

+ 9 - 0
resources/views/station/rule/menu.blade.php

@@ -0,0 +1,9 @@
+<div class="container-fluid nav3">
+    <div class="card">
+        <ul class="nav nav-pills">
+            <li class="nav-item">
+                <a target="station/rule/index" class="nav-link" href="{{url('station/rule/index')}}" :class="{active:isActive('rule','2')}">查询</a>
+            </li>
+        </ul>
+    </div>
+</div>

+ 57 - 16
resources/views/store/deliveryAppointment/exhibition.blade.php

@@ -309,13 +309,67 @@
                         break;
                 }
             },
+            _formatObj(res){
+                return {
+                    "id"                    : res.id,
+                    "license_plate_number"  : res.license_plate_number,
+                    "driver_name"           : res.driver_name,
+                    "driver_phone"          : res.driver_phone,
+                    "cubic_meter"           : res.cubic_meter,
+                    "tonne"                 : res.tonne,
+                    "owner_name"            : res.owner_name,
+                    "type"                  : res.type,
+                    "period"                : res.period,
+                    "delivery_time"         : res.delivery_time,
+                    "status"                : res.status,
+                };
+            },
             _sortData(res){
                 if (res.warehouse!=warehouse)return;
+                if (res.change){
+                    let continueMark = true;
+                    switch (Number(res.old)) {
+                        case 0:
+                            switch (Number(res.new)) {
+                                case 0:
+                                    continueMark = false;
+                                    break;
+                                default:
+                                    this.list.some((data,i)=>{
+                                        if (data.id==res.id){
+                                            this.$delete(this.list,i);
+                                            return true;
+                                        }
+                                    });
+                                    if (Number(res.old)===1) continueMark = false;
+                                    break;
+                            }
+                            break;
+                        case 1:
+                            this.nextList.some((data,i)=>{
+                                if (data.id==res.id){
+                                    if (res.new!=1)this.$delete(this.nextList,i);
+                                    else this.$set(this.nextList,i,this._formatObj(res));
+                                    return true;
+                                }
+                            });
+                            if (res.new==0) continueMark = false;
+                            break;
+                        case 2:
+                            continueMark = false;
+                            break;
+                    }
+                    if (continueMark) return;
+                }
+                if (res.morrow){
+                    if (this.nextList.length>=10) this.nextList = this.nextList.splice(0,9);
+                    this.nextList.push(this._formatObj(res));
+                    return;
+                }
                 if (this.list.every((data,i)=>{
                     if (data.id === res.id){
                         this._countChange(data.status,res.status);
-                        //this.$set(this.list[i],"is_delivery",true);
-                        data.status = res.status;
+                        data = this._formatObj(res);
                         this.list.splice(i,1);
                         if (data.status=='1'){
                             if (this.list.every((car,j)=>{
@@ -332,20 +386,7 @@
                 })){
                     this._countChange(null,res.status);
                     if (this.list.length>=10) this.list = this.list.splice(0,9);
-                    let obj = {
-                        "id"                    : res.id,
-                        "license_plate_number"  : res.license_plate_number,
-                        "driver_name"           : res.driver_name,
-                        "driver_phone"          : res.driver_phone,
-                        "cubic_meter"           : res.cubic_meter,
-                        "tonne"                 : res.tonne,
-                        "owner_name"            : res.owner_name,
-                        "type"                  : res.type,
-                        "period"                : res.period,
-                        "delivery_time"         : res.delivery_time,
-                        "status"                : res.status,
-                        /*"is_delivery"           : true,*/
-                    };
+                    let obj = this._formatObj(res);
                     if (res.status=='1'){
                         if (this.list.every((car,j)=>{
                             if (car.status!=res.status){

+ 2 - 1
resources/views/store/inStorage/cacheRackStorage.blade.php

@@ -32,7 +32,7 @@
                         <input type="text" class="form-control rounded col-sm-5 col-8 ml-sm-1 ml-2" :class="errors.barCode ? 'is-invalid' : ''" id="barCode" @blur="codeBlur()" @keydown.enter="checkInfo()" v-model="info.barCode">
                         <div class="input-group-append mt-sm-0 mt-4">
                             <span class="input-group-text d-none d-sm-block">@数量</span>
-                            <label class="d-sm-none col-4 text-right">数量:</label>
+                            <label for="amount" class="d-sm-none col-4 text-right">数量:</label>
                             <span class="input-group-text p-0 border-0">
                                 <input class="form-control" type="number" :class="errors.amount ? 'is-invalid' : ''" step="1" min="1" id="amount" v-model="info.amount">
                             </span>
@@ -105,6 +105,7 @@
                     this._exeTask();
                 },
                 _exeTask(){
+                    window.tempTip.postBasicRequest("{{url('')}}");
                     console.log("ok");
                     //入库成功
                     this.info = {};

+ 29 - 55
resources/views/transport/waybill/edit.blade.php

@@ -106,69 +106,50 @@
                     </div>
                     {{--编辑区--}}
                     <div class="form-group row">
-                        <label  class="col-2 col-form-label text-right text-secondary">运输收费(元)</label>
+                        <label for="other_charge_remark" class="col-2 col-form-label text-right text-muted">其他收费备注</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('charge') is-invalid @enderror"
+                            <input type="text" class="form-control" id="other_charge_remark"
+                                   name="other_charge_remark" autocomplete="off" value="@if(old('other_charge_remark')){{ old('other_charge_remark') }}@else{{$waybill->other_charge_remark}}@endif"  >
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="charge" class="col-2 col-form-label text-right text-secondary">运输收费(元)</label>
+                        <div class="col-3">
+                            <input type="number" step="0.01" min="0" class="form-control @error('charge') is-invalid @enderror"
                                    id="charge" name="charge" v-model="waybill.charge" >
                         </div>
+                        <label for="other_charge" class="col-2 col-form-label text-right text-muted">其他收费(元)</label>
+                        <div class="col-3">
+                            <input id="other_charge" type="number" step="0.01" class="form-control @error('other_charge') is-invalid @enderror"
+                                   name="other_charge" autocomplete="off" value="@if(old('other_charge')){{ old('other_charge') }}@else{{$waybill->other_charge}}@endif"  >
+                        </div>
                         @error('charge')
                         <span class="invalid-feedback" role="alert">
                             <strong>{{ $message }}</strong>
                         </span>
                         @enderror
-                    </div>
-
-                    <div class="form-group row">
-                        <label for="other_charge" class="col-2 col-form-label text-right text-muted">其他收费(元)</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
-                                   name="other_charge" autocomplete="off" value="@if(old('other_charge')){{ old('other_charge') }}@else{{$waybill->other_charge}}@endif"  >
-                            @error('other_charge')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>
-                            @enderror
-                        </div>
-                    </div>
-                    <div class="form-group row">
-                        <label for="other_charge_remark" class="col-2 col-form-label text-right text-muted">其他收费备注</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('other_charge') is-invalid @enderror"
-                                   name="other_charge_remark" autocomplete="off" value="@if(old('other_charge_remark')){{ old('other_charge_remark') }}@else{{$waybill->other_charge_remark}}@endif"  >
-                            @error('other_charge_remark')
-                            <span class="invalid-feedback" role="alert">
-                                        <strong>{{ $message }}</strong>
-                                    </span>·
-                            @enderror
-                        </div>
+                        @error('other_charge')
+                        <span class="invalid-feedback" role="alert">
+                            <strong>{{ $message }}</strong>
+                        </span>
+                        @enderror
                     </div>
 
                     <div class="form-group row" style="margin-bottom: 20px">
                         <label for="logistic_id" class="col-2 col-form-label text-right text-primary">承运商 *</label>
-                        <div class="col-8" style="position: relative">
+                        <div class="col-3" style="position: relative">
                             <select class="form-control @error('logistic_id') is-invalid @enderror" id="logistic_id" style="width: 30%; " name="logistic_id"
                                     :class="errors['logistic_id'] ? 'is-invalid' :''"  v-model="waybill.logistic_id">
                                 <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
                             </select>
-                            <div v-if="errors['logistic_id'] && errors['logistic_id'].length>0" class="invalid-feedback" role="alert" style="position: relative">
-                            <strong class="">@{{ errors['logistic_id'][0] }}</strong>
-                            </div>
-                            <span class="col-sm-5" style="position: absolute;height: 15px;padding: 0">
-                                <p class="form-control-static text-danger small font-weight-bold" style="">{{ $errors->first('logistic_id') }}</p>
-                            </span>
                         </div>
-
-                    </div>
-                    <div class="form-group row">
-                        <label class="col-2 col-form-label text-right">承运商单号</label>
-                        <div class="col-8">
+                        <label for="carrier_bill" class="col-2 col-form-label text-right">承运商单号</label>
+                        <div class="col-3">
                             <input type="text" class="form-control @error('carrier_bill') is-invalid @enderror"
                                    name="carrier_bill" autocomplete="off" v-model="waybill.carrier_bill"  id="carrier_bill">
-                            @error('carrier_bill')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                            @enderror
+                        </div>
+                        <div v-if="errors['logistic_id'] && errors['logistic_id'].length>0" class="invalid-feedback" role="alert" style="position: relative">
+                            <strong class="">@{{ errors['logistic_id'][0] }}</strong>
                         </div>
                     </div>
                     <div v-if="waybill.type=='专线'">
@@ -305,28 +286,21 @@
                     </div>
                     <div class="form-group row">
                         <label for="mileage" class="col-2 col-form-label text-right text-dark">里程数</label>
-                        <div class="col-8">
-                            <input type="number" class="form-control @error('mileage') is-invalid @enderror"
+                        <div class="col-3">
+                            <input type="number" step="0.01" class="form-control @error('mileage') is-invalid @enderror"
                                    name="mileage" autocomplete="off" v-model="waybill.mileage" id="mileage" >
-                            @error('mileage')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                            @enderror
                         </div>
                     </div>
                     <div v-if="waybill.type=='直发车'">
                         <div class="form-group row">
                             <label for="carType_id" class="col-2 col-form-label text-right">车型</label>
-                            <div class="col-8">
+                            <div class="col-3">
                                 <select class="form-control" name="carType_id" style="width: 30%;" v-model="waybill.carType_id" id="carType_id">
                                     <option v-for="carType in carTypes" :value="carType.id">@{{ carType.name }}</option>
                                 </select>
                             </div>
-                        </div>
-                        <div class="form-group row">
                             <label for="car_owner_info" class="col-2 col-form-label text-right">车辆信息</label>
-                            <div class="col-8">
+                            <div class="col-3">
                                 <input type="text" class="form-control"
                                        name="car_owner_info" autocomplete="off" v-model="waybill.car_owner_info" id="car_owner_info" >
                             </div>

+ 12 - 10
resources/views/transport/waybill/index.blade.php

@@ -398,30 +398,31 @@
                         {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
                             placeholder:['货主','定位或多选货主'],data:this.owners},
                         {name:'created_at_start',type:'time',tip:['选择显示创建日期的起始时间','选择显示创建日期的起始时间']},
-                        {name:'updated_at_start',type:'time',tip:['选择显示完结日期的起始时间','选择显示完结日期的起始时间']},
-                        {name:'deliver_at_start',type:'time',tip:['选择显示发货日期的起始时间','选择显示发货日期的起始时间']},
                         {name:'origination',type:'input',tip:'始发地:可在左侧增加百分号(%)进行模糊搜索',placeholder: '始发地'},
+                        {name:'updated_at_start',type:'time',tip:['选择显示完结日期的起始时间','选择显示完结日期的起始时间']},
                         {name:'carrier_bill',type:'input',tip:'可支持多承运商单号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '承运商单号'},
+                        {name:'deliver_at_start',type:'time',tip:['选择显示发货日期的起始时间','选择显示发货日期的起始时间']},
                         {name:'status',type:'select',placeholder: '运单状态',data:this.status},
-                        {name:'source_bill',type:'input',tip: '可支持多上游单号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '上游单号'},
-                        {name:'recipient',type:'input',tip: '可支持多收货人姓名:可在左侧增加百分号(%)进行模糊搜索',placeholder: '收货人姓名'},
-                        {name:'car_owner_info',type:'input',tip: '车辆信息:可在左侧增加百分号(%)进行模糊搜索',placeholder: '车辆信息'},
-                        {name:'mileage',type:'input',tip: '里程:可在左侧增加百分号(%)进行模糊搜索',placeholder: '里程'},
                     ],
                     [
                         {name:'wms_bill_number',type:'input',tip:'可支持多WMS单号:可在两侧增加百分号(%)进行模糊搜索',placeholder: 'WMS单号'},
                         {name:'created_at_end',type:'time',tip:['选择显示创建日期的结束时间','选择显示创建日期的结束时间']},
-                        {name:'updated_at_end',type:'time',tip:['选择显示完结日期的结束时间','选择显示完结日期的结束时间']},
-                        {name:'deliver_at_end',type:'time',tip:['选择显示发货日期的结束时间','选择显示发货日期的结束时间']},
                         {name:'destination',type:'input',tip:'目的地:可在两侧增加百分号(%)进行模糊搜索',placeholder: '目的地'},
+                        {name:'updated_at_end',type:'time',tip:['选择显示完结日期的结束时间','选择显示完结日期的结束时间']},
                         {name:'waybill_number',type:'input',tip:'运单号:可在两侧增加百分号(%)进行模糊搜索',placeholder: '运单号'},
-                        // {name:'logistic_id',type:'select',placeholder: '承运商',data:this.logistics},
+                        {name:'deliver_at_end',type:'time',tip:['选择显示发货日期的结束时间','选择显示发货日期的结束时间']},
                         {name:'logistic_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的承运商'],
                             placeholder:['承运商','定位或多选承运商'],data:this.logistics},
+                    ],
+                    [
+                        {name:'source_bill',type:'input',tip: '可支持多上游单号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '上游单号'},
+                        {name:'recipient',type:'input',tip: '可支持多收货人姓名:可在左侧增加百分号(%)进行模糊搜索',placeholder: '收货人姓名'},
                         {name:'recipient_mobile',type:'input',tip: '可支持多收货人电话:可在左侧增加百分号(%)进行模糊搜索',placeholder: '收货人电话'},
+                        {name:'car_owner_info',type:'input',tip: '车辆信息:可在左侧增加百分号(%)进行模糊搜索',placeholder: '车辆信息'},
+                        {name:'mileage',type:'input',tip: '里程:可在左侧增加百分号(%)进行模糊搜索',placeholder: '里程'},
                         {name:'carrier_weight_other',type:'input',tip: '仓库计重:可在左侧增加百分号(%)进行模糊搜索',placeholder: '仓库计重'},
                         {name:'carType_id',type:'select',placeholder: '车型',data:this.carTypes},
-                    ],
+                    ]
                 ];
                 let param=[];
                 this.$set(param,"uriType",'{{$uriType}}');
@@ -994,6 +995,7 @@
                     let target = $(e.target);
                     let top = target.parent().find('.top');
                     let tip = target.parent().find('.toptd');
+                    for (let i=0;i<tip.length;i++)if(!tip[i] || tip[i].style.display==='none')tip.splice(i,1);
                     top.hide();
                     tip.tooltip('show');
                 },

+ 10 - 1
routes/apiLocal.php

@@ -183,13 +183,22 @@ Route::group(['prefix'=>'demand'],function(){
 
 Route::get('/authority/get','AuthorityController@getAuthoritiesApi')->name('authority.getAuthoritiesApi');
 
-/** 缓存架 */
+/** 栈管理 */
 Route::group(['prefix' => 'station'],function(){
+    /** 缓存架 */
     Route::group(['prefix'=>'cacheShelf'],function(){
         Route::post('pushTask','CacheShelfController@pushTaskApi')->name('station.cacheShelf.pushTaskApi');
+        Route::post('clearTask','CacheShelfController@clearTaskApi')->name('station.cacheShelf.clearTaskApi');
         Route::post('lightOn','CacheShelfController@lightOnApi')->name('station.cacheShelf.lightOnApi');
         Route::get('getTasks/{id}','CacheShelfController@getTasksApi')->name('station.cacheShelf.getTasksApi');
     });
+
+    /** 栈规则 */
+    Route::group(['prefix'=>'rule'],function(){
+        Route::post('store','StationRuleBatchController@storeApi')->name('station.rule.storeApi');
+        Route::put('update','StationRuleBatchController@updateApi')->name('station.rule.updateApi');
+        Route::delete('destroy','StationRuleBatchController@destroyApi')->name('station.rule.destroyApi');
+    });
 });
 
 

+ 12 - 6
routes/web.php

@@ -20,6 +20,9 @@ Route::get('/', function () {
 
 Route::any('test/{method}', 'TestController@method'); //测试
 
+/** 称重广播 */
+Route::post('package/weigh/measureMonitor/speech','MeasureMonitorController@speech')->middleware("check.token");
+
 Auth::routes();
 
 Route::get('/home', 'HomeController@index')->name('home');
@@ -358,11 +361,6 @@ Route::resource('rejected', 'RejectedController');
 
 /** 包裹 */
 Route::group(['prefix'=>'package'],function(){
-    /** 设备 */
-    Route::group(['prefix'=>'measureMonitor'],function(){
-        Route::any('speech','MeasureMonitorController@speech');
-        Route::post('data','MeasureMonitorController@data');
-    });
     /** 统计 */
     Route::group(['prefix'=>'statistics'],function(){
         Route::any('export','WeighController@statisticsExport');
@@ -380,11 +378,13 @@ Route::group(['prefix'=>'package'],function(){
 
     Route::resource('measureMonitor','MeasureMonitorController');
 
+    Route::group(['prefix'=>'measureMonitor'],function(){
+        Route::post('data','MeasureMonitorController@data');
+    });
     Route::group(['prefix' => 'weigh'], function () {
         Route::get('statistics','WeighController@statistics');
         /** 设备 */
         Route::group(['prefix'=>'measureMonitor'],function(){
-            Route::any('speech','MeasureMonitorController@speech');
             Route::post('data','MeasureMonitorController@data');
         });
         /** 统计 */
@@ -804,14 +804,20 @@ Route::group(['prefix'=>'customer'],function(){
 /** 站管理 */
 Route::group(['prefix'=>'station'],function(){
     Route::get('index','StationController@monitorIndex');
+    /** 监视器 */
     Route::group(['prefix'=>'monitor'],function(){
         Route::get('/','StationController@monitorIndex');
         Route::get('/index','StationController@monitorIndex');
         Route::get('/{station}','StationController@monitorShow');
     });
+    /** 缓存架 */
     Route::group(['prefix'=>'cachingShelf'],function(){
         Route::get('/index','CacheShelfController@index');
     });
+    /** 栈规则 */
+    Route::group(['prefix'=>'rule'],function(){
+        Route::get('/index','StationRuleBatchController@index');
+    });
 });
 /** 控制台 */
 Route::group(['prefix'=>'control'],function () {

+ 1 - 1
tests/Feature/LogisticZopSyncTest.php

@@ -39,7 +39,7 @@ class LogisticZopSyncTest extends TestCase
 
     public function test_get()
     {
-        LogisticZopSync::dispatch('75600023806455');
+        LogisticZopSync::dispatch('75467972757443');
     }
 
 

+ 114 - 0
tests/Services/CacheShelfService/ClearTaskTest.php

@@ -0,0 +1,114 @@
+<?php
+
+
+namespace Tests\Services\CacheShelfService;
+
+
+use App\Material;
+use App\MaterialBox;
+use App\Services\CacheShelfService;
+use App\Services\StationTaskChildService;
+use App\Services\StationTaskMaterialBoxService;
+use App\Services\StationTaskService;
+use App\Station;
+use App\StationTask;
+use App\StationTaskChildren;
+use App\StationTaskMaterialBox;
+use App\StationType;
+use Tests\TestCase;
+
+class ClearTaskTest extends TestCase
+{
+
+    /** @var CacheShelfService $service */
+    /** @var StationTaskService $stationTaskService  */
+    /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService  */
+    /** @var StationTaskChildService $stationTaskChildService  */
+    public $service;
+    public $stationTaskService;
+    public $stationTaskMaterialBoxService;
+    public $stationTaskChildService;
+    public $data =[];
+
+    protected function setUp(): void
+    {
+        parent::setUp(); // TODO: Change the autogenerated stub
+        $this->service = app(CacheShelfService::class);
+        $this->stationTaskService = app(StationTaskService::class);
+        $this->stationTaskMaterialBoxService = app(StationTaskMaterialBoxService::class);
+        $this->stationTaskChildService = app(StationTaskChildService::class);
+
+        $stationType = StationType::query()->firstOrCreate(['name'=>'立库']);
+
+        $this->data['LiKuStation'] = factory(Station::class)->create(['station_type_id'=>$stationType['id']]);
+        $this->data['station'] = factory(Station::class)->create();
+
+        $this->data['stationTask'] = [];
+        $this->data['stationTaskMaterialBoxes'] = [];
+        $this->data['materialBox'] = factory(MaterialBox::class)->create();
+
+        $this->data['stationTask'] = $this->stationTaskService->create(1);                                                    // 生成站任务
+        $this->data['stationTaskMaterialBoxes'][] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']);     // 创建料箱任务
+        $this->stationTaskService->registerStations($this->data['stationTask'],[$this->data['station']['id']]);                                            // 注册站任务站
+        $this->data['stationTaskMaterialBoxes'][0]['station_task_id'] = $this->data['stationTask'][0]['id'];
+        $this->data['stationTaskMaterialBoxes'][0]->update();
+        $params = [[
+            'station_task_id'=>$this->data['stationTask'][0]->first()['id'],
+            'station_taskable_type'=>StationTaskMaterialBox::class,
+            'station_taskable_id'=>$this->data['stationTaskMaterialBoxes'][0]['id']
+        ]];
+
+        $this->stationTaskChildService->insert($params);                                                                        // 任务任务注册
+    }
+
+    public function testClearTask()
+    {
+        $result = $this->service->clearTask($this->data['station']->code);
+        $stationTask = StationTask::query()->where('station_id',$this->data['station']['id'])->first();
+        $this->assertEmpty($stationTask);
+        $stationTaskMaterialBox = StationTaskMaterialBox::query()->where('material_box_id',$this->data['materialBox']['id'])->get();
+        $this->assertEmpty($stationTaskMaterialBox);
+    }
+
+    public function testClearTask_taskIsRunning()
+    {
+        StationTask::query()->where('station_id',$this->data['station']['id'])->update(['status' => '处理中']);
+        $result = $this->service->clearTask($this->data['station']->code);
+
+        $stationTask = StationTask::query()->where('station_id',$this->data['station']['id'])->first();
+
+        $this->assertEquals('处理中',$stationTask->status);
+        $this->assertFalse($result['success']);
+    }
+
+
+    protected function tearDown(): void
+    {
+        if($this->data['station']){
+            $stationTasks = StationTask::query()->where('station_id',$this->data['station']['id'])->get();
+            foreach ($stationTasks as $stationTask) {
+                $stationTaskMaterialBoxes = $stationTask->stationTaskMaterialBoxes;
+                foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
+                    StationTaskChildren::query()->where(['station_task_id' => $stationTask['id'],'station_taskable_type'=> StationTaskMaterialBox::class,'station_taskable_id'=>$stationTaskMaterialBox['id']])->delete();
+                    $stationTaskMaterialBox->delete();
+                }
+            }
+            Station::query()->where('id',$this->data['station']['id'])->delete();
+        }
+
+        if($this->data['LiKuStation']){
+            $stationTasks = StationTask::query()->where('station_id',$this->data['LiKuStation']['id'])->get();
+            foreach ($stationTasks as $stationTask) {
+                $stationTaskMaterialBoxes = $stationTask->stationTaskMaterialBoxes;
+                foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
+                    StationTaskChildren::query()->where(['station_task_id' => $stationTask['id'],'station_taskable_type'=> StationTaskMaterialBox::class,'station_taskable_id'=>$stationTaskMaterialBox['id']])->delete();
+                    $stationTaskMaterialBox->delete();
+                }
+            }
+            Station::query()->where('id',$this->data['LiKuStation']['id'])->delete();
+        }
+        if($this->data['materialBox'])MaterialBox::query()->where('id',$this->data['materialBox'])->delete();
+        parent::tearDown(); // TODO: Change the autogenerated stub
+    }
+
+}

+ 4 - 3
tests/Services/LogisticQiaoSFService/LogisticQiaoSFServiceTest.php

@@ -13,7 +13,7 @@ class LogisticQiaoSFServiceTest extends TestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $this->logisticQiaoSFService = new LogisticSFService();
-        \App\OrderPackage::query()->whereIn('logistic_number',['SF1335376515904', 'SF2050377278135', 'SF2060390000049'])->delete();
+        \App\OrderPackage::query()->whereIn('logistic_number', ['SF1335376515904', 'SF2050377278135', 'SF2060390000049'])->delete();
     }
 
 
@@ -25,7 +25,8 @@ class LogisticQiaoSFServiceTest extends TestCase
 //        factory(\App\OrderPackage::class)->create(['logistic_number' => 'SF1335376515904',]);
 //        factory(\App\OrderPackage::class)->create(['logistic_number' => 'SF2050377278135',]);
 //        factory(\App\OrderPackage::class)->create(['logistic_number' => 'SF2060390000049',]);
-        $response = $this->logisticQiaoSFService->get(['SF2040457612903']);
-        $this->assertCount(3, $response);
+        $response = $this->logisticQiaoSFService->get(['SF1333381646256']);
+//        $this->assertCount(3, $response);
+        $this->assertTrue(true);
     }
 }

+ 36 - 0
tests/Services/LogisticSFSync/HandleTest.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Tests\Services\LogisticSFSync;
+use App\Jobs\LogisticSFSync;
+use Tests\TestCase;
+use App\Traits\TestMockSubServices;
+
+class HandleTest extends TestCase
+{
+    use TestMockSubServices;
+    private $data;
+    private $amount=2;
+    function setUp(): void
+    {
+        parent::setUp();
+    }
+
+    public function testReturned()
+    {
+        $this->assertTrue(true);
+    }
+
+    function tearDown(): void
+    {
+        parent::tearDown();
+    }
+
+    /**
+     * @test
+     */
+    public function handle_test()
+    {
+//        LogisticSFSync::dispatch('SF1333381646256');
+        $this->assertTrue(true);
+    }
+}

+ 40 - 0
tests/Services/OrderPackageReceivedSyncService/SyncLogisticRouteTest.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace Tests\Services\OrderPackageReceivedSyncService;
+use App\Services\OrderPackageReceivedSyncService;
+use Tests\TestCase;
+use App\Traits\TestMockSubServices;
+
+class SyncLogisticRouteTest extends TestCase
+{
+    use TestMockSubServices;
+    /** @var OrderPackageReceivedSyncService $service */
+    public $service;
+    private $data;
+    private $amount=2;
+    function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app('OrderPackageReceivedSyncService');
+    }
+
+    public function testReturned()
+    {
+        $this->assertTrue(true);
+    }
+
+    function tearDown(): void
+    {
+        parent::tearDown();
+    }
+
+    /**
+     * @throws \Exception
+     * @test
+     */
+    public function sync_test()
+    {
+//        $this->service->syncLogisticRoute();
+        $this->assertTrue(true);
+    }
+}

+ 0 - 87
tests/Services/OrderPackageReceivedSyncService/TestGetLogisticNumbers.php

@@ -1,87 +0,0 @@
-<?php
-
-namespace Tests\Services\OrderPackageReceivedSyncService;
-
-use App\Order;
-use App\OrderPackage;
-use App\Services\OrderPackageReceivedSyncService;
-
-use Carbon\Carbon;
-use Illuminate\Database\Eloquent\Collection;
-use Tests\TestCase;
-
-class TestGetLogisticNumbers extends TestCase
-{
-
-    protected $orderPackageIds;
-    protected $orderIds;
-
-    /** @var OrderPackageReceivedSyncService $service */
-    public $service;
-
-    function setUp(): void
-    {
-        parent::setUp();
-        $this->service = app(OrderPackageReceivedSyncService::class);
-    }
-
-    public function testReturned()
-    {
-        $this->assertTrue(true);
-    }
-
-    function tearDown(): void
-    {
-        OrderPackage::destroy($this->orderPackageIds);
-        Order::destroy($this->orderPackageIds);
-        parent::tearDown();
-    }
-
-    /**
-     * 初始化测试查询结果 'init_date' => '2020-12-31 23:59:59' 2020-12-31 应改为当前对应的日期
-     * 目前判断顺丰的快递单号
-     * @test
-     */
-    public function init_test()
-    {
-        //插入初始化时间前10天的数据,每天1条 共11条
-        for ($i = 0; $i <= 10; $i++) {
-            $date = Carbon::now()->subDays($i)->toDateTimeString();
-            $order = factory(Order::class)->create(['created_at' => $date, 'logistic_id' => 47]);
-            $orderPackage = factory(OrderPackage::class)->create(['created_at' => $date, 'order_id' => $order->id]);
-            $this->orderPackageIds[] = $orderPackage->id;
-            $this->orderIds[] = $order->id;
-        }
-        $result =$this->service->getLogisticNumbers();
-        dump($result);
-        $this->assertCount(11,$result['SF']);
-    }
-
-    /**
-     * 正常查询结果 'init_date' => '2020-12-30 23:59:59' 2020-12-30 应改为当前对应的日期的前一天
-     * 目前判断顺丰的快递单号
-     * @test
-     */
-    public function normal_test()
-    {
-        //插入初始化时间前10天的数据,每天1条 共11条
-        for ($i = 0; $i <= 10; $i++) {
-            $date = Carbon::now()->subDays($i)->toDateTimeString();
-            $order = factory(Order::class)->create(['created_at' => $date, 'logistic_id' => 47]);
-            $orderPackage = factory(OrderPackage::class)->create(['created_at' => $date, 'order_id' => $order->id]);
-            $this->orderPackageIds[] = $orderPackage->id;
-            $this->orderIds[] = $order->id;
-        }
-
-        //插入初始化时间后10天的数据,每天1条 共10条
-        for ($i = 1; $i <= 10; $i++) {
-            $date = Carbon::now()->addDays($i)->toDateTimeString();
-            $order = factory(Order::class)->create(['created_at' => $date, 'logistic_id' => 47]);
-            $orderPackage = factory(OrderPackage::class)->create(['created_at' => $date, 'order_id' => $order->id]);
-            $this->orderPackageIds[] = $orderPackage->id;
-            $this->orderIds[] = $order->id;
-        }
-        $result =$this->service->getLogisticNumbers();
-        $this->assertCount(11,$result['SF']);
-    }
-}