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

Merge branch 'master' into zengjun

ajun 4 лет назад
Родитель
Сommit
ea47fdbf4f
38 измененных файлов с 372 добавлено и 324 удалено
  1. 2 1
      app/Events/BroadcastToStation.php
  2. 14 5
      app/Http/Controllers/StationController.php
  3. 55 32
      app/Http/Controllers/TestController.php
  4. 2 1
      app/Http/Controllers/WaybillController.php
  5. 1 1
      app/Http/Controllers/WeighController.php
  6. 10 5
      app/Http/Controllers/api/thirdPart/haiq/HaiRoboticsController.php
  7. 1 1
      app/Http/Controllers/api/thirdPart/weight/WeightBaseController.php
  8. 3 0
      app/MaterialBox.php
  9. 2 0
      app/Providers/AppServiceProvider.php
  10. 2 8
      app/Services/BatchService.php
  11. 41 0
      app/Services/ForeignZhenCangService.php
  12. 1 1
      app/Services/LogisticYTOService.php
  13. 3 1
      app/Services/OrderService.php
  14. 3 3
      app/Services/StationRuleBatchService.php
  15. 1 0
      app/Services/StationTaskBatchService.php
  16. 3 3
      app/Services/StationTaskCommodityService.php
  17. 23 0
      app/Services/StationTaskService.php
  18. 4 3
      app/Services/WaybillService.php
  19. 7 2
      app/Services/common/BatchUpdateService.php
  20. 8 0
      app/Station.php
  21. 1 1
      config/haiRou.php
  22. 1 1
      resources/views/package/measureMonitor/index.blade.php
  23. 143 33
      resources/views/station/monitor/show.blade.php
  24. 1 1
      resources/views/transport/waybill/_dailyBilling.blade.php
  25. 3 0
      routes/api/thirdPart/haiq.php
  26. 1 1
      routes/web.php
  27. 4 4
      tests/Services/BatchService/AssignTasksTest.php
  28. 0 38
      tests/Services/StationCacheShelfGrid/GetGridByCodeTest.php
  29. 0 39
      tests/Services/StationCacheShelfGrid/GetLocationTest.php
  30. 0 39
      tests/Services/StationCacheShelfGridService/CancelTaskTest.php
  31. 0 47
      tests/Services/StationCacheShelfGridService/LightOffTest.php
  32. 0 42
      tests/Services/StationCacheShelfGridService/ProcessGridTest.php
  33. 16 5
      tests/Services/StationRuleBatchService/GetBatches_shouldProcessTest.php
  34. 1 1
      tests/Services/StationTaskBatchService/CreateByBatchesTest.php
  35. 0 1
      tests/Services/StationTaskBatchService/RunManyTest.php
  36. 6 4
      tests/Services/StationTaskCommodityService/CreateByBatchTest.php
  37. 3 0
      tests/Services/StationTaskMaterialBoxService/CreateByBatchesTest.php
  38. 6 0
      tests/webApi/weight.http

+ 2 - 1
app/Events/BroadcastToStation.php

@@ -9,6 +9,7 @@ class BroadcastToStation implements ShouldBroadcastNow
 {
     public $json;
     private $id;
+    const ALL_STATION=0;
     /**
      * Create a new event instance.
      *
@@ -18,7 +19,7 @@ class BroadcastToStation implements ShouldBroadcastNow
      */
     public function __construct(int $id, string $json)
     {
-        $this->id = $id;
+        $this->id = $id;// 0意味着通用站,所有站都需要收发的意思
         $this->json = $json;
     }
 

+ 14 - 5
app/Http/Controllers/StationController.php

@@ -54,12 +54,12 @@ class StationController extends Controller
     }
     public function monitorShow(Station $station)
     {
-        $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
+//        $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
         $station->loadMissing([
-            "currentStationTask.stationTaskCommodities.commodity.barcodes",
-            "currentStationTask.stationTaskCommodities.materialBox",
-            "currentStationTask.stationTaskBatches.batch",
-            "currentStationTask.stationTaskMaterialBoxes.materialBox",
+            "stationTasks_today.stationTaskCommodities.commodity.barcodes",
+            "stationTasks_today.stationTaskCommodities.materialBox",
+            "stationTasks_today.stationTaskBatches.batch.owner",
+            "stationTasks_today.stationTaskMaterialBoxes.materialBox",
             "stationTypeBinMonitor",
         ]);
         if (!$station['stationTypeBinMonitor']){
@@ -71,6 +71,15 @@ class StationController extends Controller
             ]);
             $station->load("stationTypeBinMonitor");
         }
+//        dd(
+//            data_get($station['stationTasks_today'],'*.id')
+//            ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.batch.code')
+//            ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.id')
+//            ,data_get($station['stationTasks_today'],'*.stationTaskBatches.*.batch.id')
+//            ,data_get(data_get($station['stationTasks_today'],'*.stationTaskCommodities')[7],'*.id')
+//            ,data_get(data_get($station['stationTasks_today'],'*.stationTaskCommodities')[9],'*.id')
+//        );
+//        $station=$station->toJson();
         return view('station.monitor.show',compact('station'));
     }
 

+ 55 - 32
app/Http/Controllers/TestController.php

@@ -112,29 +112,13 @@ class TestController extends Controller
     }
     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,
-            ]));
+        $orders = Order::query()->where("wms_status","订单完成")->whereBetween("updated_at",["2021-05-21 12:00:00","2021-05-21 23:59:00"])
+            ->whereNotIn("id",OwnerFeeDetail::query()->select("outer_id")->where("outer_table_name","orders")
+                ->whereBetween("worked_at",["2021-05-21 12:00:00","2021-05-21 23:59:00"]))->get();
+        foreach ($orders->chunk(50) as $or){
+            dispatch(new OrderCreateInstantBill($or));
         }
-        dd(1);
+        dd("推进数:".count($orders));
         $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 ".
@@ -420,8 +404,7 @@ class TestController extends Controller
     public function ld()
     {
         dd(
-            json_encode(collect(collect(collect([City::query()->first()]))))
-
+            Carbon::now()->format('Y-m-d')
         );
     }
 
@@ -903,14 +886,13 @@ class TestController extends Controller
 
     public function ld2()
     {
-        $m=MaterialBox::query()->first();
-        dump($m);
-        $m['status'] = '在缓存架';
-        dump($m['status']);
-        $m->update();
-        $m=MaterialBox::query()->first();
-        dump($m['status']);
-
+        $r=new \Illuminate\Support\Collection();
+        $sb = StationTaskBatch::query()->limit(3)->get();
+        dump(data_get($sb,'*.id'));
+        foreach ($sb as $s) {
+            $r->push($s);
+        }
+        dump(data_get($sb,'*.id'));
     }
     public function y111()
     {
@@ -1483,4 +1465,45 @@ TEXT;
         $service = app('OrderPackageExceptionTypeCountingRecordService');
         $service->updateOrCreate(30);
     }
+    public function testForeignZhenCang($batches)
+    {
+
+        $batches=Batch::query()
+            ->with(['orders.orderCommodities.commodity.barcodes'])
+            ->find(111953);
+        $body=[];
+        $body['id']=$batches->code;
+        $body['orders'] = [];
+        foreach ($batches->orders as $order){
+            $orderArr = [];
+            $orderArr['id']=$order->code??'';
+            $orderArr['createdAt']=Carbon::parse($order->created_at)->toDateTimeString()??'';
+            $orderArr['barcodes'] = [];
+            foreach ($order->orderCommodities as $orderCommodity){
+                $barcode=[];
+                $barcode['id']=$orderCommodity->id;
+                $barcode['barcode']=$orderCommodity->commodity ? ($orderCommodity->commodity->barcodes?$orderCommodity->commodity->barcodes->first()['code']:'') : '';
+                $barcode['name']=$orderCommodity->commodity->name??'';
+                $barcode['sku']=$orderCommodity->commodity->sku??'';
+                $barcode['amount']=$orderCommodity->amount??'';
+                $barcode['location']=$orderCommodity->location??'';
+                $orderArr['barcodes'][]=$barcode;
+            }
+            $body['orders'][] = $orderArr;
+        }
+        $response = Http::withHeaders([
+            'Host' => 'zc-it.com',
+        ])->post('http://1.116.164.201:8080/api/createBatch',$body);
+        dd(json_decode($response->body()));
+    }
+
+    public function updateBulk()
+    {
+        $orderPackages=OrderPackage::query()->where('measuring_machine_id',16)->get();
+        foreach ($orderPackages as $orderPackage){
+            $orderPackage->update([
+                'bulk'=>$orderPackage['length']*$orderPackage['width']*$orderPackage['height']
+            ]);
+        }
+    }
 }

+ 2 - 1
app/Http/Controllers/WaybillController.php

@@ -947,10 +947,11 @@ class WaybillController extends Controller
         if(!Gate::allows('运输管理-运单-按日计算专线费')){return ['success'=>false,'message'=>'没有权限'];}
         $dailyBilling=$request->input('param');
         $waybills=app('waybillService')->dailyBilling($dailyBilling);
+        if ($waybills==false)return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         return ['success'=>true,'data'=>$waybills];
     }
-    public function countPickUpFee(Request $request)
+    public function countPickUpFee(Request $request): array
     {
         if(!Gate::allows('运输管理-运单-查询')){ return ['success'=>false,'message'=>'没有权限'];  }
         $param=$request->input('param');

+ 1 - 1
app/Http/Controllers/WeighController.php

@@ -184,7 +184,7 @@ class WeighController extends Controller
         }else{
             $sql=app('PackageService')->getSql(['id'=>$request->data]);
         }
-        $row = ["货主","快递单号","波次号","订单号","物流公司","设备","重(KG)","长(cm)","宽(cm)","高(cm)","体积(cm³)","纸箱","状态","波次规则","称重时间","收件人","收件人电话"];
+        $row = ["货主","快递单号","波次号","订单号","物流公司","设备","重(KG)","长(mm)","宽(mm)","高(mm)","体积(mm³)","纸箱","状态","波次规则","称重时间","收件人","收件人电话"];
         $column = ["owner_name", "logistic_number", "batch_number", "order_code", "logistic_name","measuring_machine_name",
             "weight", "length", "width", "height", "bulk", "paper_box_name", "status","batch_rule","weighed_at","order_consignee_name","order_consignee_phone"];
         $rule = ["weighed_at"=> "mysqlDate"];

+ 10 - 5
app/Http/Controllers/ForeignHaiRoboticsController.php → app/Http/Controllers/api/thirdPart/haiq/HaiRoboticsController.php

@@ -1,25 +1,30 @@
 <?php
 
 
-namespace App\Http\Controllers;
+namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 use App\Services\StationTaskBatchService;
 use App\StationTaskBatch;
 use Illuminate\Http\Request;
 use App\Traits\TestableInstant;
-class ForeignHaiRoboticsController
+class HaiRoboticsController
 {
     use TestableInstant;
 
     /** @var StationTaskBatchService $stationTaskBatchService */
     private $stationTaskBatchService=null;
 
-    function runBatch(Request $request){
+    function runTaskBatch(Request $request){
+        $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
         $request->validate(
-            ['id'=>'required|exists:station_task_batches,id']
+            ['station_task_batch_id'=>'required|exists:station_task_batches,id']
         );
-        $batchTask=StationTaskBatch::query()->first($request['id']);
+        if(!$request['station_task_batch_id'])return [
+            'success'=>false,
+            'errorMsg'=>'波次任务不能为空'
+        ];
+        $batchTask=StationTaskBatch::query()->find($request['station_task_batch_id']);
         $batchesFailed=$this->stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务
         if($batchesFailed && $batchesFailed->isNotEmpty()){
             return [

+ 1 - 1
app/Http/Controllers/api/thirdPart/weight/WeightBaseController.php

@@ -257,7 +257,7 @@ class WeightBaseController
         $orderPackage['width'] = $edges[1];
         $orderPackage['height'] = $edges[2];
         $orderPackage['weighed_at'] = $req_date;
-        $orderPackage['bulk'] = $edges[0] * $edges[1] * $edges[2];
+        $orderPackage['bulk'] = $edges[0] * $edges[1] * $edges[2] ;
         return $orderPackage->save();
     }
 

+ 3 - 0
app/MaterialBox.php

@@ -14,6 +14,7 @@ class MaterialBox extends Model
 
     static public $enums=[
         'status'=>[
+            ''=>0,
             '在库外'=>1,
             '在U型线'=>2,
             '在缓存架'=>3,
@@ -34,10 +35,12 @@ class MaterialBox extends Model
 
     public function getStatusAttribute($value)
     {
+        if(!$value)return '';
         return self::$enums['status'][$value];
     }
     public function setStatusAttribute($value)
     {
+        if(!$value)return 0;
         $this->attributes['status']=self::$enums['status'][$value];
     }
 }

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -115,6 +115,7 @@ use App\Services\SupplierService;
 use App\Services\OrderPackageCommoditySerialNumberService;
 use App\Services\OrderPackageExceptionTypeCountingRecordService;
 use App\Services\LogisticYDService;
+use App\Services\ForeignZhenCangService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -182,6 +183,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('FacilitatorService',FacilitatorService::class);
         app()->singleton('FeatureService',FeatureService::class);
         app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
+        app()->singleton('ForeignZhenCangService',ForeignZhenCangService::class);
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
         app()->singleton('InventoryCompareService',InventoryCompareService::class);
         app()->singleton('InventoryDailyLogService',InventoryDailyLogService::class);

+ 2 - 8
app/Services/BatchService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 
 use App\Batch;
+use App\Events\BroadcastToStation;
 use App\Exceptions\ErrorException;
 use App\Jobs\BatchTaskJob;
 use App\OracleActAllocationDetails;
@@ -64,7 +65,6 @@ class BatchService
     public function assignTasks($batches)
     {
         try{
-            LogService::log(__METHOD__,'assignTasks','波次任务分配1:'.json_encode($batches));
             $batches = collect($batches);
 
             $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
@@ -76,9 +76,7 @@ class BatchService
             $stationTaskBatches=null;
             $batches_shouldProcess = $this->stationRuleBatchService->getBatches_shouldProcess($batches); //按规则过滤需要的波次
             if($batches_shouldProcess->isEmpty()) return;
-            LogService::log(__METHOD__,'assignTasks','波次任务分配2:'.json_encode($batches));
             $stationTaskMaterialBoxes_occupied = $this->stationTaskMaterialBoxService->getOccupied_byBatches($batches_shouldProcess); //按规则过滤需要的波次
-            LogService::log(__METHOD__,'assignTasks','波次任务分配2b:'.json_encode($batches));
             if($stationTaskMaterialBoxes_occupied->isNotEmpty()) {
                 foreach ($batches_shouldProcess as $batch){
                     Cache::tags(['波次防重叠'.$batch['id']])->flush();
@@ -89,17 +87,13 @@ class BatchService
             }
             DB::transaction(function ()use($batches,&$stationTaskBatches,&$batches_shouldProcess){
                 $stationTasks =  $this->stationTaskService->create($batches_shouldProcess->count()); //生成总任务
-                LogService::log(__METHOD__,'assignTasks','波次任务分配3:'.json_encode($batches));
                 $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
-                LogService::log(__METHOD__,'assignTasks','波次任务分配4:'.json_encode($batches));
                 $stationTaskMaterialBoxes=$this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
-                LogService::log(__METHOD__,'assignTasks','波次任务分配5:'.json_encode($stationTaskMaterialBoxes).json_encode($batches));
                 $stationTaskCommodities=$this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
-                LogService::log(__METHOD__,'assignTasks','波次任务分配6:'.json_encode($batches));
             });
 
+//            broadcast(new BroadcastToStation(BroadcastToStation::ALL_STATION, $json));
 //            $ran=$this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
-            LogService::log(__METHOD__,'assignTasks','波次任务分配7:'.json_encode($batches));
         }catch(Exception $e){
             $batchesJson='';
             foreach ($batches as $batch){

+ 41 - 0
app/Services/ForeignZhenCangService.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Services;
+
+use App\Traits\ServiceAppAop;
+use App\ForeignZhenCang;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Http;
+
+class ForeignZhenCangService
+{
+    use ServiceAppAop;
+//    protected $modelClass=ForeignZhenCang::class;
+
+    public function broadcastBatch($batches)
+    {
+        $body=[];
+        $body['id']=$batches->code;
+        $body['orders'] = [];
+        foreach ($batches->orders as $order){
+            $orderArr = [];
+            $orderArr['id']=$order->code??'';
+            $orderArr['createdAt']=Carbon::parse($order->created_at)->toDateTimeString()??'';
+            $orderArr['barcodes'] = [];
+            foreach ($order->orderCommodities as $orderCommodity){
+                $barcode=[];
+                $barcode['id']=$orderCommodity->id;
+                $barcode['barcode']=$orderCommodity->commodity ? ($orderCommodity->commodity->barcodes?$orderCommodity->commodity->barcodes->first()['code']:'') : '';
+                $barcode['name']=$orderCommodity->commodity->name??'';
+                $barcode['sku']=$orderCommodity->commodity->sku??'';
+                $barcode['amount']=$orderCommodity->amount??'';
+                $barcode['location']=$orderCommodity->location??'';
+                $orderArr['barcodes'][]=$barcode;
+            }
+            $body['orders'][] = $orderArr;
+        }
+        $response = Http::withHeaders([
+            'Host' => 'zc-it.com',
+        ])->post('http://1.116.164.201:8080/api/createBatch',$body);
+    }
+}

+ 1 - 1
app/Services/LogisticYTOService.php

@@ -48,7 +48,7 @@ class LogisticYTOService
         if (is_object($response) && $response->code=='1001') {return [];}
         else {
             try {
-                $result['logistic_number'] = $response[0]->waybill_No;
+                if (is_array($response))$result['logistic_number'] = $response[0]->waybill_No;
             } catch (\Exception $e) {
                 LogService::log(LogisticYTOService::class, "YTO快递信息异常", $response);
             }

+ 3 - 1
app/Services/OrderService.php

@@ -622,7 +622,9 @@ class OrderService
 
     public function pushQueue($orderHeaders){
         $orders = Order::query()->with(["logistic","packages.commodities.commodity"])->where('wms_status','订单完成')->whereIn('code',data_get($orderHeaders,'*.orderno'))->get();
-        dispatch(new OrderCreateInstantBill($orders));
+        foreach ($orders->chunk(50) as $or){
+            dispatch(new OrderCreateInstantBill($or));
+        }
     }
 
     public function syncOrderByWMSOrderHeaders(&$orderHeaders)

+ 3 - 3
app/Services/StationRuleBatchService.php

@@ -61,9 +61,9 @@ class StationRuleBatchService
     {
         LogService::log(__METHOD__,'shouldProcess','波次任务分配1.1:'.json_encode($batches));
         $batches_toProcess=collect();
-        $batches_inTask=StationTaskBatch::query()->whereIn('batch_id',data_get($batches,'*.id'))->get();
-        LogService::log(__METHOD__,'shouldProcess','波次任务分配1.2:'.json_encode($batches_inTask));
-        $batches=$batches->whereNotIn('id',data_get($batches_inTask,'*.id')??[]);
+        $stationTaskBatches_inTask=StationTaskBatch::query()->whereIn('batch_id',data_get($batches,'*.id'))->get();
+        LogService::log(__METHOD__,'shouldProcess','波次任务分配1.2:'.json_encode($stationTaskBatches_inTask));
+        $batches=$batches->whereNotIn('id',data_get($stationTaskBatches_inTask,'*.batch_id')??[]);
         foreach ($batches as $batch){
             $stationRuleBatch=$this->getByBatch($batch);
             if(!$stationRuleBatch)continue;

+ 1 - 0
app/Services/StationTaskBatchService.php

@@ -75,6 +75,7 @@ class StationTaskBatchService
             }
         }
         $this->batchService->updateWhereIn('id', data_get($batches_handled, '*.id'), ['status' => '处理中']);
+        $stationTaskBatches_toCreate=$stationTaskBatches_toCreate->reverse();
         $this->insert($stationTaskBatches_toCreate->toArray());
 
         $stationTaskBatches_toCreate=$this->getAndAttachIds($stationTaskBatches_toCreate);

+ 3 - 3
app/Services/StationTaskCommodityService.php

@@ -51,17 +51,17 @@ class StationTaskCommodityService
     function createByBatches(Collection $batches,Collection $stationTasks_toAttach): Collection
     {
         $this->instant($this->stationTaskService,'StationTaskService');
-        $stationTaskCommodities_listByBatch=new Collection();
+        $stationTaskCommodities_lists_ByBatch=new Collection();
         $stationTaskCommodities=new Collection();
         foreach ($batches as $batch){
             $taskCommodities = $this->createByBatch($batch);
             $stationTaskCommodities= $stationTaskCommodities->merge($taskCommodities);
-            $stationTaskCommodities_listByBatch->push($taskCommodities);
+            $stationTaskCommodities_lists_ByBatch->push($taskCommodities);
         }
 //        $stationTaskCommodities=$this->getAndAttachIds($stationTaskCommodities);
         $this->stationTaskService->registerSubTasks(
             $stationTasks_toAttach,
-            $stationTaskCommodities_listByBatch);
+            $stationTaskCommodities_lists_ByBatch);
         return $stationTaskCommodities;
 
     }

+ 23 - 0
app/Services/StationTaskService.php

@@ -45,6 +45,29 @@ class StationTaskService
      * @param Collection $subTaskLists 二维数组,第一维是对应注册的任务
      */
     function registerSubTasks(Collection $tasks, iterable $subTaskLists)
+    {
+        $this->instant($this->stationTaskChildService,'StationTaskChildService');
+        $taskChildren_toInsert=collect();
+        foreach ($subTaskLists as $i=>$subTaskList){
+            foreach ($subTaskList as $subTask){
+                $subTaskId = $subTask['id'];
+                $subTaskClass = get_class($subTask);
+                $paramToInsert = [
+                    'station_task_id' => $tasks[$i]['id'],
+                    'station_taskable_type' => $subTaskClass,
+                    'station_taskable_id' => $subTaskId,
+                ];
+                $taskChild_existed=$this->stationTaskChildService->get($paramToInsert)->first();
+                if(!$taskChild_existed){
+                    $taskChildren_toInsert->push($paramToInsert);
+                    $subTask['station_task_id']=$tasks[$i]['id'];
+                    $subTask->save();
+                }
+            }
+        }
+        $this->stationTaskChildService->insert($taskChildren_toInsert->toArray());
+    }
+    function registerCommoditiesSubTasks(Collection $tasks, iterable $subTaskLists)
     {
         $this->instant($this->stationTaskChildService,'StationTaskChildService');
         $taskChildren_toInsert=collect();

+ 4 - 3
app/Services/WaybillService.php

@@ -161,13 +161,14 @@ class WaybillService
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc')
-            ->where('waybills.created_at','like',$param['screenDate'].'%')
+//            ->where('waybills.created_at','like',$param['screenDate'].'%')
             ->where('waybills.type','专线')
-            ->whereNotNull('waybills.deliver_at')
+            ->where('waybills.deliver_at','like',$param['screenDate'].'%')
             ->get();
+        if ($waybills->isEmpty()) return false;
         foreach ($waybills as $waybill){
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;
-            if (!$waybill['carrier_weight_other']) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.4);
+            if (!$waybill['carrier_weight_other']) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.004);
         }
         $daily_total_weight=$waybills->sum('carrier_weight_other');
         $updateParams = [['id','pick_up_fee','updated_at']];

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

@@ -61,13 +61,18 @@ class BatchUpdateService
         $bindings = array_merge($bindings, $whereIn);
         $whereIn = rtrim(str_repeat('?,', count($whereIn)), ',');
         $updateSql = rtrim($updateSql, ", ") . " WHERE `" . $referenceColumn . "` IN (" . $whereIn . ")";
+
+        $debug = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT ,1)[0];
+        unset($debug["object"]);
+        unset($debug["args"]);
+
         try {
             // DB::update
             $bool = DB::connection($connection)->update($updateSql, $bindings);
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新:' . $tableName . ' | '.json_encode($multipleData));
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新:' . $tableName . ' | '.json_encode($multipleData).' | 溯源:'.json_encode($debug));
             return $bool;
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败' . $tableName . ' | '.json_encode($multipleData) . $e->getMessage() . $e->getTraceAsString());
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败' . $tableName . ' | '.json_encode($multipleData).' | 溯源:'.json_encode($debug) . $e->getMessage() . $e->getTraceAsString());
             return false;
         }
     }

+ 8 - 0
app/Station.php

@@ -3,6 +3,7 @@
 namespace App;
 
 use App\Traits\ModelTimeFormat;
+use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\HasOne;
 use App\Traits\ModelLogChanging;
@@ -27,6 +28,13 @@ class Station extends Model
         return $this->hasOne(StationTask::class)
             ->where('status','=','处理中');
     }
+    public function stationTasks_today(){
+        return $this->hasMany(StationTask::class)
+            ->where('created_at','>=',now()->format('Y-m-d'))
+            ->orderBy('status')
+            ->orderByDesc('id')
+            ;
+    }
     public function stationTypeBinMonitor(){
         return $this->hasOne(StationTypeBinMonitor::class);
     }

+ 1 - 1
config/haiRou.php

@@ -1,5 +1,5 @@
 <?php
 
 return [
-    "波次防重叠时间_秒" => 1200,
+    "波次防重叠时间_秒" => 1800,
 ];

+ 1 - 1
resources/views/package/measureMonitor/index.blade.php

@@ -138,7 +138,7 @@
                             },10);
                         }else {
                             window.tempTip.setDuration(3000);
-                            window.axios.post('package/weigh/measureMonitor/speech',{logistic:logistic_name})
+                            window.axios.post("{{url('package/weigh/measureMonitor/speech')}}",{logistic:logistic_name})
                                 .then(function (response) {
                                     if (response.data){
                                         _this.logisticAudioURL[logistic_name]=response.data;

+ 143 - 33
resources/views/station/monitor/show.blade.php

@@ -26,19 +26,67 @@
                     <div class="col-4">
                         <div class="row">
                             <div class="col py-3 h4">
-                                <div>波次号:</div>
-                                <div class=" text-center">
-                                    <b v-if="task&&task.station_task_batches">
-                                        <div v-for="taskBatch in task.station_task_batches">
-                                            @{{ taskBatch.batch.code }}
+                                <div class="row">
+                                    <div class="col">选择执行波次:</div>
+                                </div>
+                                <div class="row" v-if="current_stationTaskBatch">
+                                    <div class="col font-weight-bold text-center position-relative"
+                                         :style="[
+                                                    {opacity:
+                                                        current_stationTaskBatch.status==='完成'?'0.5':'1'
+                                                    },
+                                                ]"
+                                         :class="[
+                                            (current_stationTaskBatch.runningStatus==='')?'text-info':'',
+                                            (current_stationTaskBatch.runningStatus==='请求中')?'text-dark':'',
+                                            (current_stationTaskBatch.runningStatus==='请求失败')?'text-danger':'',
+                                            (current_stationTaskBatch.runningStatus==='请求成功')?'text-success':'',
+                                            (current_stationTaskBatch.runningStatus==='请求异常')?'text-danger':'',
+                                         ]"
+                                    >
+                                        <div class="text-center mt-2">@{{ current_stationTaskBatch.batch.code }}</div>
+                                        <div class="text-center" style="font-size: 12px;">
+                                            @{{ current_stationTaskBatch.batch.owner.name }}
+                                        </div>
+                                        <div class="col text-muted text-left">
+                                            <img id="barcode" :alt="batchCode">
                                         </div>
-                                    </b>
+                                    </div>
+                                    <div class="col text-center">
+                                            <button class="btn btn-lg mt-4" @click="runTheTaskBatch()"
+                                                    :class="[
+                                            (current_stationTaskBatch.runningStatus==='')?'btn-info':'',
+                                            (current_stationTaskBatch.runningStatus==='请求中')?'btn-dark':'',
+                                            (current_stationTaskBatch.runningStatus==='请求失败')?'btn-danger':'',
+                                            (current_stationTaskBatch.runningStatus==='请求成功')?'btn-success':'',
+                                            (current_stationTaskBatch.runningStatus==='请求异常')?'btn-danger':'',
+                                         ]"
+                                            >
+                                                <span v-if="!current_stationTaskBatch.runningStatus">执行</span>
+                                                <span v-if="current_stationTaskBatch.runningStatus==='请求中'">请求中</span>
+                                                <span v-if="current_stationTaskBatch.runningStatus==='请求失败'">(失败)重新执行</span>
+                                                <span v-if="current_stationTaskBatch.runningStatus==='请求成功'">(请求成功)重新执行</span>
+                                                <span v-if="current_stationTaskBatch.runningStatus==='请求异常'">(请求异常)重新执行</span>
+                                            </button>
+                                    </div>
+                                </div>
+                                <div class="text-center my-2" style="overflow-y: scroll;max-height:200px;">
+                                    <div class="flex flex-column flex-wrap" v-if="stationTaskBatches">
+                                        <button v-for="stationTaskBatch in stationTaskBatches"
+                                                @click="selectBatch(stationTaskBatch)"
+                                                class="btn"
+                                                :class="[
+                                                    (current_stationTaskBatch&&current_stationTaskBatch.id===stationTaskBatch.id)?'btn-outline-info':'btn-outline-dark',
+                                                ]"
+                                                :style="[
+                                                    {opacity:
+                                                        stationTaskBatch.status==='完成'?'0.5':'1'
+                                                    },
+                                                ]"
+                                        >
+                                            @{{stationTaskBatch.batch.code | simplifyBatchCode}}</button>
+                                    </div>
                                 </div>
-                            </div>
-                        </div>
-                        <div class="row">
-                            <div class="col py-3 text-muted text-center">
-                                <img id="barcode" alt="" :data-refresh="batchCode">
                             </div>
                         </div>
                         <div class="row">
@@ -157,7 +205,7 @@
                                 <div class="text-left">
                                     <div >
                                         <div class="btn btn-outline-info" @click="
-                                        (inputs.manuallyTakeBox.visible=true)
+                                        (inputs.manuallyTakeBox.visible=!inputs.manuallyTakeBox.visible)
                                         &&(inputs.manuallyTakeBox.text='')">手动出库</div>
                                         <div class="position-relative bg-white" v-if="inputs.manuallyTakeBox.visible">
                                 <textarea  name="" id="" cols="30" rows="3" class="form-control" v-model="inputs.manuallyTakeBox.text"
@@ -286,16 +334,20 @@
         $vue=new Vue({
             el:"#container",
             data:{
-                broadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
+                taskBroadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
+                allTaskBroadcastName : "{{config('database.redis.options.prefix').'station-0'}}",
                 channelName : ".App\\Events\\BroadcastToStation",
                 error:"",
-                station:{!! $station??[] !!},
+                station:{!! $station !!},
                 inputs:{
                     manuallyTakeBox:{
                         visible:false,
                         text:'',
                     }
                 },
+                current_stationTaskBatch: null,
+                stationTask_indexByBatch: [],
+                stationTaskBatch_index: [],
                 grids:{
                     single:{status:'',},
                     half:{
@@ -315,7 +367,9 @@
             },
             mounted() {
                 this._makeMenuHiding();
-                this._listenBroadcast();
+                initEcho();
+                this._listenTaskBroadcast();
+                this._listenAllTaskBroadcast();
             },
             methods:{
                 _makeMenuHiding(){
@@ -327,21 +381,33 @@
                         $('.navbar,.nav1,.nav2').hide();
                     });
                 },
-                _listenBroadcast(){
-                    initEcho();
-                    window.Echo.channel(this.broadcastName).listen(this.channelName,(msg)=> {
+                _listenTaskBroadcast(){
+                    window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
+                        // console.log((new Date()).toTimeString(),msg);
+                        let json = JSON.parse(msg.json);
+                        if(!json||json.length===0)return;
+                        this.task=json;
+                    });
+                },
+                _listenAllTaskBroadcast(){
+                    window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
                         console.log((new Date()).toTimeString(),msg);
                         let json = JSON.parse(msg.json);
                         if(!json||json.length===0)return;
-                        this.station['current_station_task']=json;
+                        this.task=json;
                     });
                 },
+                selectBatch(stationTaskBatch){
+                    this.current_stationTaskBatch=stationTaskBatch;
+                    if(typeof(this.current_stationTaskBatch.runningStatus)==='undefined')
+                        this.current_stationTaskBatch.runningStatus=''
+                },
                 manuallyTakeBoxOut(){
                     let text = this.inputs.manuallyTakeBox.text.trim();
                     if(!text){
                         alert('请输入料箱号')
                         return
-                    };
+                    }
                     axios.post('{{url('/api/thirdPart/haiq/storage/takeOutToULine')}}',{codes:text})
                         .then(function(response){
                             tempTip.okWindow(response.data.result,'确定')
@@ -351,36 +417,74 @@
                         this.inputs.manuallyTakeBox.text='';
                     })
                 },
+                runTheTaskBatch(){
+                    let _this=this;
+                    _this.current_stationTaskBatch.runningStatus='请求中';
+                    _this.$forceUpdate();
+                    axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:_this.current_stationTaskBatch.id})
+                        .then(function(response){
+                            if(!response.data.success){
+                                _this.current_stationTaskBatch.runningStatus='请求失败';
+                                return;
+                            }
+                            _this.current_stationTaskBatch.runningStatus='请求成功'
+                        }).catch(function(err){
+                        _this.current_stationTaskBatch.runningStatus='请求异常'
+                        tempTip.okWindow(err+': 服务器代码出错,请联系开发部门负责人','确定')
+                    }).finally(function(){
+                        _this.$forceUpdate();
+                    });
+                },
             },
             computed:{
                 task(){
-                    if(!this.station['current_station_task'])return null;
-                    return this.station['current_station_task'];
+                    if(!this.current_stationTaskBatch||typeof(this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id])==='undefined')return null;
+                    return this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id];
+                },
+                stationTasks(){
+                    if(!this.station)return;
+                    return this.station.station_tasks_today;
+                },
+                stationTaskBatches(){
+                    if(!this.stationTasks)return;
+                    let _this=this;
+                    let stationTaskBatches=[];
+                    this.stationTasks.forEach(function(stationTask){
+                        if(!stationTask.station_task_batches)return;
+                        stationTask.station_task_batches.forEach(function(stationTaskBatch){
+                            if(typeof(_this.stationTaskBatch_index['_'+stationTaskBatch.batch_id])==='undefined'){
+                                // if(stationTaskBatch_index['_'+stationTaskBatch.batch_id]['status']==='完成')return;
+                                stationTaskBatches.push(stationTaskBatch)
+                                _this.stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
+                                _this.stationTask_indexByBatch['_'+stationTaskBatch.batch_id]=stationTask;
+                            }
+                        })
+                    });
+                    return stationTaskBatches;
                 },
                 batchCode(){
-                    if(!this.task)return;
-                    let batches = this.task.station_task_batches;
-                    if(batches
-                        && Array.isArray(batches)
-                        && batches.length>0
+                    let _this=this;
+                    if(!this.current_stationTaskBatch)return;
+                    if(typeof(this.current_stationTaskBatch)!=='undefined'
+                        && typeof(this.current_stationTaskBatch.batch)!=='undefined'
                     ){
                         setTimeout(function (){
-                            setBarcode(batches[0].batch.code,"#barcode",1,50,false);
+                            setBarcode(_this.current_stationTaskBatch.batch.code,"#barcode",1,50,false);
                         })
                     }
-                    return batches[0].batch.code;
+                    return this.current_stationTaskBatch.batch.code;
                 },
                 taskCommodities(){
                     if(!this.task)return [];
-                    return this.station['current_station_task']['station_task_commodities'];
+                    return this.task['station_task_commodities'];
                 },
                 taskCommoditiesListByBin(){
                     if(!this.task)return [];
                     function reIndexByBin() {
                         this.taskCommoditiesListByBinVar = [];
-                        this.taskCommoditiesListByBinVar.md5 = md5(JSON.stringify(this.station['current_station_task']['station_task_commodities']));
+                        this.taskCommoditiesListByBinVar.md5 = md5(JSON.stringify(this.task['station_task_commodities']));
                         let _this=this;
-                        this.station['current_station_task']['station_task_commodities']
+                        this.task['station_task_commodities']
                             .forEach(function (taskCommodity) {
                                 if (typeof (_this.taskCommoditiesListByBinVar[taskCommodity['bin_number']]) === 'undefined') {
                                     _this.taskCommoditiesListByBinVar[taskCommodity['bin_number']] = null;
@@ -393,7 +497,7 @@
                     if((typeof this.taskCommoditiesListByBinVar)==='undefined'||!this.taskCommoditiesListByBinVar){
                         return reIndexByBin.call(this);
                     }
-                    let md5Now = md5(JSON.stringify(this.station['current_station_task']['station_task_commodities']));
+                    let md5Now = md5(JSON.stringify(this.task['station_task_commodities']));
 
                     if(this.taskCommoditiesListByBinVar.md5!==md5Now){
                         return reIndexByBin.call(this);
@@ -556,6 +660,12 @@
                     }
 
                 },
+            },
+            filters:{
+                simplifyBatchCode(val){
+                    if(!val){return ''}
+                    return val.replace(/W\d{6}0*/,'').trim()
+                }
             }
         });
     </script>

+ 1 - 1
resources/views/transport/waybill/_dailyBilling.blade.php

@@ -9,7 +9,7 @@
             </div>
             <div class="modal-body">
                 <div class="form-group row">
-                    <label for="screenDate" class="col-2 col-form-label text-right">选定日期</label>
+                    <label for="screenDate" class="col-2 col-form-label text-right">选定发货日期</label>
                     <div class="col-8">
                         <input type="date" class="form-control" :class="error.screenDate ? 'is-invalid' : ''" name="screenDate" autocomplete="off"  v-model="dailyBilling.screenDate" >
                         <span class="invalid-feedback" role="alert" v-if="error.screenDate">

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

@@ -27,3 +27,6 @@ Route::group(['prefix'=>'pickStation'],function(){
 Route::group(['prefix'=>'light'],function(){
     Route::post('update', "LightController@update");//移库
 });
+
+
+Route::post('runTaskBatch', "HaiRoboticsController@runTaskBatch");//启动taskBatch任务

+ 1 - 1
routes/web.php

@@ -21,7 +21,7 @@ Route::get('/', function () {
 Route::any('test/{method}', 'TestController@method'); //测试
 
 /** 称重广播 */
-Route::post('package/weigh/measureMonitor/speech','MeasureMonitorController@speech')->middleware("check.token");
+Route::post('package/weigh/measureMonitor/speech','MeasureMonitorController@speech');
 
 Auth::routes();
 

+ 4 - 4
tests/Services/BatchService/AssignTasksTest.php

@@ -24,8 +24,8 @@ class AssignTasksTest extends TestCase
     /** @var BatchService $service */
     public $service;
     private $data;
-    private $batchAmount=2;
-    private $orderAmount=4;
+    private $batchAmount=3;
+    private $orderAmount=5;
     private $orderCommodityAmount=8;
     function setUp(): void
     {
@@ -82,8 +82,8 @@ class AssignTasksTest extends TestCase
         $this->service->assignTasks($this->data['batches']);
         ($波次任务指向了波次=function(){
             $this->data['batches']->load('stationTaskBatch');
-            dump(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id'));
-            dd(array_diff(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id')));
+//            dump(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id'));
+//            dd(array_diff(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id')));
             $this->assertEquals(
                 data_get($this->data['batches'],'*.id'),
                 data_get($this->data['batches'],'*.stationTaskBatch.batch_id')

+ 0 - 38
tests/Services/StationCacheShelfGrid/GetGridByCodeTest.php

@@ -1,38 +0,0 @@
-<?php
-
-
-namespace Tests\Services\StationCacheShelfGrid;
-
-use App\Services\StationCacheShelfGridService;
-use App\StationCacheShelfGrid;
-use Tests\TestCase;
-
-class GetGridByCodeTest extends TestCase
-{
-    protected $data = [];
-
-    protected function setup(): void
-    {
-        parent::setUp();
-        $this->data['stationCode'] = 'station001';
-        $this->data['grid'] = 6;
-        $this->data['x'] = 2;
-        $this->data['y'] = 3;
-        $this->data['code'] = 'HAI'.$this->data['stationCode'].'-0'.$this->data['y'].'-0'.$this->data['x'];
-
-    }
-
-    function testGetGridByCodeTest()
-    {
-        list($stationCode, $gridId, $x, $y) = StationCacheShelfGrid::getGridByCode($this->data['code']);
-        $this->assertEquals($stationCode,$this->data['stationCode']);
-        $this->assertEquals($gridId,$this->data['grid']);
-        $this->assertEquals($x,$this->data['x']);
-        $this->assertEquals($y,$this->data['y']);
-    }
-
-    protected function tearDown(): void
-    {
-        parent::tearDown();
-    }
-}

+ 0 - 39
tests/Services/StationCacheShelfGrid/GetLocationTest.php

@@ -1,39 +0,0 @@
-<?php
-
-
-namespace Tests\Services\StationCacheShelfGrid;
-
-use App\Station;
-use App\StationCacheShelfGrid;
-use Tests\TestCase;
-
-class GetLocationTest extends TestCase
-{
-
-    protected $data = [];
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $row = 3;
-        $col = 2;
-        $this->data['grid_id'] = ($row-1)*3+$col;
-        $this->data['station'] = factory(Station::class)->create();
-        $this->data['grid'] = factory(StationCacheShelfGrid::class)->create(['station_id'=>$this->data['station']['id'],'grid_id'=>$this->data['grid_id']]);
-        $this->data['code'] = 'HAI'.$this->data['station']['code'].'-0'. (2 - $col + 1).'-0'.(2-$row+1);
-    }
-
-    function testGetLocation()
-    {
-        $location = StationCacheShelfGrid::getLocation($this->data['station'],$this->data['grid']);
-        $this->assertEquals($this->data['grid_id'],$this->data['grid']['grid_id']);
-        $this->assertEquals($this->data['code'],$location);
-    }
-
-    protected function tearDown(): void
-    {
-        Station::query()->where('id',$this->data['station']['id'])->delete();
-        StationCacheShelfGrid::query()->where('id',$this->data['grid']['id'])->delete();
-        parent::tearDown();
-    }
-}

+ 0 - 39
tests/Services/StationCacheShelfGridService/CancelTaskTest.php

@@ -1,39 +0,0 @@
-<?php
-
-
-namespace Tests\Services\StationCacheShelfGridService;
-
-use App\Services\StationCacheShelfGridService;
-use App\StationCacheShelfGrid;
-use App\Traits\TestMockSubServices;
-use Tests\TestCase;
-
-class CancelTaskTest extends TestCase
-{
-    use TestMockSubServices;
-    /** @var StationCacheShelfGridService $stationCacheShelfGridService */
-    protected $stationCacheShelfGridService;
-    protected $data =[];
-
-    protected function setup(): void
-    {
-        parent::setUp();
-        $this->stationCacheShelfGridService = app(StationCacheShelfGridService::class);
-        $this->data['grids'] = factory(StationCacheShelfGrid::class)->times(3)->create();
-
-    }
-
-    public function testCancelTask()
-    {
-        $this->stationCacheShelfGridService->cancelTask($this->data['grids']);
-        $grids = StationCacheShelfGrid::query()->whereIn('id',data_get($this->data['grids'],'*.id'))->whereNull('material_box_id')->where('status',0)->count();
-        $this->assertEquals($grids, count($this->data['grids']));
-    }
-
-    protected function tearDown(): void
-    {
-        StationCacheShelfGrid::query()->where('id',data_get($this->data['grids'],'*.id'))->delete();
-        parent::tearDown();
-    }
-
-}

+ 0 - 47
tests/Services/StationCacheShelfGridService/LightOffTest.php

@@ -1,47 +0,0 @@
-<?php
-
-
-namespace Tests\Services\StationCacheShelfGridService;
-use App\Services\StationCacheShelfGridService;
-use App\Station;
-use App\StationCacheShelfGrid;
-use Tests\TestCase;
-
-class LightOffTest extends TestCase
-{
-    /** @var StationCacheShelfGridService $stationCacheShelfGridService */
-    protected $stationCacheShelfGridService;
-    protected $data = [];
-
-    protected function setup(): void
-    {
-        parent::setUp();
-        $this->stationCacheShelfGridService = app(StationCacheShelfGridService::class);
-        $row = 2;
-        $col = 1;
-        $gridIndex = ($row-1)*3 + (3-$col);
-        $this->data['station'] = factory(Station::class)->create();
-        $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create(['station_id' => $this->data['station']['id'],'grid_id'=>$gridIndex]);
-        $this->data['locCode'] = 'HAI'.$this->data['station']['code'].'-0'.$col.'-0'.$row;
-        $this->data['PTLAction'] = 0;
-    }
-
-    public function testLightOff()
-    {
-        $this->stationCacheShelfGridService->lightOff($this->data['locCode'],$this->data['PTLAction']);
-        $grid = StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->first();
-        $this->assertEquals($grid['id'],$this->data['stationCacheShelfGrid']['id']);
-        $this->assertEquals($grid['station']['id'],$this->data['stationCacheShelfGrid']['station_id']);
-        $this->assertEquals($grid['material_box_id'],null);
-        $this->assertEquals($grid['status'],0);
-
-    }
-
-    protected function tearDown(): void
-    {
-        Station::query()->where('id',$this->data['station']['id'])->delete();
-        StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
-        parent::tearDown(); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 42
tests/Services/StationCacheShelfGridService/ProcessGridTest.php

@@ -1,42 +0,0 @@
-<?php
-
-
-namespace Tests\Services\StationCacheShelfGridService;
-use App\MaterialBox;
-use App\Services\StationCacheShelfGridService;
-use App\Station;
-use App\StationCacheShelfGrid;
-use Tests\TestCase;
-
-
-class ProcessGridTest extends TestCase
-{
-    /** @var StationCacheShelfGridService $stationCacheShelfGridService */
-    protected $stationCacheShelfGridService;
-    protected $data = [];
-
-    protected function setup(): void
-    {
-        parent::setUp();
-        $this->stationCacheShelfGridService = app(StationCacheShelfGridService::class);
-        $this->data['station'] = factory(Station::class)->create();
-        $this->data['materialBox'] = factory(MaterialBox::class)->create();
-        $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create();
-    }
-
-    public function test()
-    {
-        $this->stationCacheShelfGridService->processGrid($this->data['stationCacheShelfGrid'],$this->data['station'],$this->data['materialBox']);
-        $grid = StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->first();
-        $this->assertEquals($grid['id'],$this->data['stationCacheShelfGrid']['id']);
-        $this->assertEquals($grid['station_id'],$this->data['station']['id']);
-        $this->assertEquals($grid['material_box_id'],$this->data['materialBox']['id']);
-    }
-    protected function tearDown(): void
-    {
-        Station::query()->where('id',$this->data['station']['id'])->delete();
-        MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
-        StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
-        parent::tearDown();
-    }
-}

+ 16 - 5
tests/Services/StationRuleBatchService/GetBatches_shouldProcessTest.php

@@ -3,10 +3,13 @@
 namespace Tests\Services\StationRuleBatchService;
 
 use App\Batch;
+use App\Order;
+use App\OrderCommodity;
 use App\Owner;
 use App\Services\BatchService;
 use App\Services\StationRuleBatchService;
 use App\StationRuleBatch;
+use App\StationTaskBatch;
 use Tests\TestCase;
 
 class GetBatches_shouldProcessTest extends TestCase
@@ -24,7 +27,6 @@ class GetBatches_shouldProcessTest extends TestCase
         $this->service = app('StationRuleBatchService');
         $this->batchService = app('BatchService');
         $this->data['owner_target'] = factory(Owner::class)->create();
-        $this->data['owner_none_target'] = factory(Owner::class)->create();
         $this->data['stationRuleBatch'] = factory(StationRuleBatch::class)
             ->create([
                 'owner_id' => $this->data['owner_target']['id'],
@@ -32,9 +34,16 @@ class GetBatches_shouldProcessTest extends TestCase
         $this->data['batches'] = factory(Batch::class, $this->amountOfInRule)->create([
             'owner_id' => $this->data['owner_target']['id'],
         ]);
-        $this->data['batches'][]=factory(Batch::class)->create([
-            'owner_id' => $this->data['owner_none_target']['id'],
-        ]);
+        $this->data['stationTaskBatch']=collect();
+        $this->data['order']=collect();
+        foreach ($this->data['batches'] as $batch){
+            $this->data['stationTaskBatch'] ->push(factory(StationTaskBatch::class)->create(['batch_id' => $batch['id'],]));
+            $this->data['order']->push(factory(Order::class)->create(['batch_id' => $batch['id'],]));
+        }
+        $this->data['orderCommodities'] =collect();
+        foreach ($this->data['order'] as $order){
+            $this->data['orderCommodities']->push( factory(OrderCommodity::class)->create(['order_id'=>$order['id'],'location'=>'IDE100']));
+        }
     }
 
     public function testFilteredOut()
@@ -48,8 +57,10 @@ class GetBatches_shouldProcessTest extends TestCase
 
         Owner::query()->whereIn('id',[
             $this->data['owner_target']['id'],
-            $this->data['owner_none_target']['id'],
         ])->delete();
+        OrderCommodity::query()->whereIn('id',data_get($this->data['orderCommodities'],'*.id'))->delete();
+        StationTaskBatch::query()->whereIn('batch_id',data_get($this->data['batches'],'*.id'))->delete();
+        Order::query()->whereIn('batch_id',data_get($this->data['batches'],'*.id'))->delete();
         StationRuleBatch::query()->where('id',$this->data['stationRuleBatch']['id'])->delete();
         Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id'))->delete();
         parent::tearDown(); // TODO: Change the autogenerated stub

+ 1 - 1
tests/Services/StationTaskBatchService/CreateByBatchesTest.php

@@ -71,10 +71,10 @@ class CreateByBatchesTest extends TestCase
     public function tearDown(): void
     {
         Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id')??[])->delete();
+        StationRuleBatch::query()->where('owner_id',$this->data['owner']['id']??'')->delete();
         StationTask::query()->whereIn('id',data_get($this->data['stationTask'],'*.id')??[])->delete();
         StationTaskBatch::query()->whereIn('id',data_get($this->data['stationTaskBatches'],'*.id')??[])->delete();
         StationTaskChild::query()->whereIn('station_task_id',data_get($this->data['stationTask'],'*.id')??[])->delete();
-        $this->data['stationRuleBatch']->delete();
         Owner::query()->where('id',$this->data['owner']['id']??'')->delete();
         parent::tearDown();
     }

+ 0 - 1
tests/Services/StationTaskBatchService/RunManyTest.php

@@ -74,7 +74,6 @@ class RunManyTest extends TestCase
         $this->data['stationTaskMaterialBoxes']=$this->stationTaskMaterialBoxService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册料箱任务
         $this->data['stationTaskBathes']=$this->stationTaskBatchService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册波次任务
 
-
     }
 
     public function testReturned()

+ 6 - 4
tests/Services/StationTaskCommodityService/CreateByBatchTest.php

@@ -67,8 +67,8 @@ class CreateByBatchTest extends TestCase
             ]
         ]);
 
-        $this->data['stationTaskCommodities']
-            =(function(){
+//        $this->data['stationTaskCommodities']
+//            =(function(){
             if(!isset($this->data['stationTaskCommodities']))
                 $this->data['stationTaskCommodities'] = collect();
             foreach($this->data['batches'] as $batch){
@@ -77,8 +77,10 @@ class CreateByBatchTest extends TestCase
                     $this->service->createByBatch($batch)
                 );
             }
-            return $this->data['stationTaskCommodities'];
-        })();
+//            return $this->data['stationTaskCommodities'];
+//        })();
+
+        $this->data['stationTaskCommodities']=StationTaskCommodity::query()->whereIn('order_id',data_get($this->data['orders'],'*.id')??[])->get();
         $this->assertEquals($this->orderCommodityAmount, $this->data['stationTaskCommodities']->count());
     }
 

+ 3 - 0
tests/Services/StationTaskMaterialBoxService/CreateByBatchesTest.php

@@ -79,6 +79,9 @@ class CreateByBatchesTest extends TestCase
         StationTask::query()
             ->whereIn('id',data_get($this->data['stationTask'],'*.id')??[])
             ->delete();
+        Batch::query()
+            ->whereIn('id',data_get( $this->data['batches'],'*.id')??[])
+            ->delete();
         parent::tearDown();
     }
 }

+ 6 - 0
tests/webApi/weight.http

@@ -11,6 +11,12 @@ Content-Type: application/json
 {"barcode":"testChannel11","weight":"5","id":"00C66186389","key":"2C7FACD3AFC3FFE547FC54CDA076A25D","time":"2020-2-26 14:17:07"}
 
 ###
+POST http://unsafe.baoshi56.com/package/measureMonitor/data
+Content-Type: application/json
+
+{"barcode":"testChannel11","weight":"5","id":"00C66186389","key":"2C7FACD3AFC3FFE547FC54CDA076A25D","time":"2020-2-26 14:17:07"}
+
+###