LD 5 лет назад
Родитель
Сommit
e5801ddb1a

+ 1 - 1
app/Console/Commands/SyncBatchTask.php

@@ -250,7 +250,7 @@ sql;
             app("OrderService")->batchUpdate($updateOrder);//反向修改订单
             LogService::log(__METHOD__,"波次同步-修改订单波次号",json_encode($updateOrder));
             LogService::log(__METHOD__,"修改过的波次_",json_encode($updateBatch));
-            //            BatchTaskJob::dispatch($updateBatch);    //在这里为波次注册队列任务!
+            BatchTaskJob::dispatch($updateBatch);    //在这里为波次注册队列任务!
         }
 
         if ($map){

+ 2 - 1
app/Exceptions/Exception.php

@@ -24,7 +24,8 @@ class Exception extends \Exception
             $className,
             $functionName,
             $tracesAll
-            )           =(function()use($exception){
+            )
+            =(function()use($exception){
             $traces=method_exists($exception,'getTraceAsString')
                 ?($exception->getTraceAsString()??'')
                 :'';

+ 6 - 2
app/Http/Controllers/api/thirdPart/goodscan/PackageController.php

@@ -5,10 +5,12 @@ namespace App\Http\Controllers\api\thirdPart\goodscan;
 
 use App\Events\WeighedEvent;
 use App\Http\Controllers\LogisticNumberFeatureController;
+use App\Jobs\WeightUpdateInstantBill;
 use App\MeasuringMachine;
 use App\OracleDOCOrderHeader;
 use App\Order;
 use App\OrderPackage;
+use App\Services\LogService;
 use App\Services\OrderService;
 use App\Waybill;
 use Carbon\Carbon;
@@ -19,12 +21,12 @@ class PackageController
 {
     public function new_(Request $request)
     {
+        app('LogService')->log(__METHOD__,'GoodScan weightApi add'.__FUNCTION__,json_encode($request->getContent()));
         $requestInput = [];
         foreach ($request->input() as $key=>$item) {
             $requestInput[strtolower($key)] = $item;
         }
 
-        app('LogService')->log(__METHOD__,'GoodScan weightApi add'.__FUNCTION__,json_encode($request->getContent()));
         $errors = $this->validatorWeight($requestInput)->errors(); // 参数校验
         $weight = $requestInput['weight']??'';
         if($weight == '-9.9'){   // 称重异常校验
@@ -68,8 +70,10 @@ class PackageController
             Waybill::setWeightByOrderCode($orderPackage->order->code,$orderPackage->weight);
         }
         event(new WeighedEvent($orderPackage));
+        dispatch(new WeightUpdateInstantBill($orderPackage));
         $response=["code"=>0,'error'=>'upload success'];
-        app('LogService')->log(__METHOD__,__FUNCTION__,"下发写入包裹成功:".json_encode($request->getContent()).'||'.json_encode($response),null);
+        app('LogService')->log(__METHOD__,__FUNCTION__,"异方下发写入包裹成功:".json_encode($request->getContent()).'||'.json_encode($response),null);
+
         return json_encode($response,JSON_UNESCAPED_UNICODE);
     }
 

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

@@ -21,7 +21,7 @@ class PickStationController
 
     public function processed(ForeignHaiRobotic_processedRequest $request): array
     {
-        LogService::log('海柔请求','processed',
+        LogService::log('海柔请求','processed1',
             json_encode($request->all()));
         $failed=
             ($processedResult=
@@ -39,6 +39,8 @@ class PickStationController
             $result["code"] = 400;
             $result["errMsg"] = $processedResult;
         }
+        LogService::log('海柔请求','processed2',
+            json_encode($result));
         return $result;
     }
 

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

@@ -282,9 +282,10 @@ class StorageController
         LogService::log('海柔请求','taskUpdate',
             json_encode($request->all()));
         try{
+            $stationTaskMaterialBox_id = explode('_',$request['taskCode'])[0];
             $this->service->taskUpdate(
 //                $request['groupCode']
-                $request['taskCode']
+                $stationTaskMaterialBox_id
                 ,$request['updateEventType']
                 ,$request['status']
                 ,$request['binCode']

+ 42 - 25
app/Services/ForeignHaiRoboticsService.php

@@ -67,7 +67,7 @@ class ForeignHaiRoboticsService
         })();
         $bins=$taskMaterialBoxes->map(function (StationTaskMaterialBox $taskMaterialBox)use($timestampSuffix,$fromLocation,$toLocation){
             return [
-                "taskCode"  =>$taskMaterialBox['id'],
+                "taskCode"  =>$taskMaterialBox['id'].'_'.$timestampSuffix,
                 "binCode"   => $taskMaterialBox['materialBox']['code'],
                 "fromLocCode" => $fromLocation??'',
                 "toLocCode" => $toLocation??'',
@@ -76,7 +76,7 @@ class ForeignHaiRoboticsService
         return [[
             "taskMode"  =>$taskMode,
             "bins"=>$bins,
-            "groupCode"=>$groupId.$timestampSuffix,
+            "groupCode"=>$groupId.'_'.$timestampSuffix,
             "priority"=>$priority,
             "sequenceFlag"=>$isSequenced,
         ]];
@@ -110,20 +110,31 @@ class ForeignHaiRoboticsService
         $is_in_plan
     ): bool
     {
+        LogService::log('海柔请求','markBinProcessed1.1',
+            '');
         $this->instant($this->stationService,'StationService');
         $this->instant($this->materialBoxService,'MaterialBoxService');
         $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
         $this->instant($this->stationTaskCommoditiesService,'StationTaskCommodityService');
         try{
+            LogService::log('海柔请求','markBinProcessed1.2',
+                json_encode([$binCode,$success,$exception,$is_in_plan]));
             if($failed
                 =!$success)
                 throw new ErrorException('海柔任务失败:'.$exception);
-            if($NotInPlan
-                =!$is_in_plan)
-                throw new ErrorException('海柔认为是计划外的料箱:'.$exception);
+            LogService::log('海柔请求','markBinProcessed1.3',
+                $failed);
+//            if($NotInPlan
+//                =!$is_in_plan)
+//                throw new ErrorException('海柔认为是计划外的料箱:'.$exception);
+
+            LogService::log('海柔请求','markBinProcessed1.4',
+                '$NotInPlan');
 
             $materialBox=
                 $this->materialBoxService->get(['code'=>$binCode])->first();
+            LogService::log('海柔请求','markBinProcessed1.5',
+                json_encode($materialBox));
             $stationTaskMaterialBox
                 =(function()use($materialBox){
                 return $stationTaskMaterialBox=
@@ -135,6 +146,8 @@ class ForeignHaiRoboticsService
                             ]
                         )->first();
             })();
+            LogService::log('海柔请求','markBinProcessed1.6',
+                json_encode($stationTaskMaterialBox));
             if(!$stationTaskMaterialBox){
                 throw new ErrorException('该料箱没有安排在处理队列中');
             }
@@ -143,11 +156,15 @@ class ForeignHaiRoboticsService
                 :(function(){throw new ErrorException('呼叫机器人回收U型线料箱失败');})();
             $this->stationTaskMaterialBoxService
                 ->markProcessed($stationTaskMaterialBox);
+            LogService::log('海柔请求','markBinProcessed1.7',
+                json_encode($stationTaskMaterialBox));
             $stationTaskMaterialBox_next=
                 $this->stationTaskMaterialBoxService
                     ->processNextQueued($stationTaskMaterialBox); //找到队列中下一个料箱,并标记为处理中
             $this->stationTaskCommoditiesService
                 ->markProcessed($stationTaskMaterialBox['stationTaskCommodities']);
+            LogService::log('海柔请求','markBinProcessed1.8',
+                json_encode($stationTaskMaterialBox));
             if($stationTaskMaterialBox_next)
                 $this->stationTaskCommoditiesService
                     ->markProcessing($stationTaskMaterialBox_next['stationTaskCommodities']);//因为上边商品任务被标记完成了,所以这里要将队列中找出正在处理的料箱对应的标记为“处理中”
@@ -155,7 +172,11 @@ class ForeignHaiRoboticsService
                 $this->instant($this->stationTaskService,'StationTaskService');
                 $this->stationTaskService->markProcessed($stationTaskMaterialBox['stationTask']);
             }
+            LogService::log('海柔请求','markBinProcessed1.9',
+                json_encode($stationTaskMaterialBox_next));
             $this->stationService->broadcastBinMonitor($stationTaskMaterialBox['station_id'],$stationTaskMaterialBox['stationTask']);
+            LogService::log('海柔请求','markBinProcessed1.99',
+                json_encode($stationTaskMaterialBox_next));
             return true;
         }catch (\Exception $e){
             $stationTaskMaterialBox = $stationTaskMaterialBox??$materialBox??null;
@@ -175,14 +196,20 @@ class ForeignHaiRoboticsService
 
     public function putBinToStore(?StationTaskMaterialBox $stationTaskMaterialBox): bool
     {
+        LogService::log('海柔请求','putBinToStore1',
+            '');
+        LogService::log('海柔请求','putBinToStore2',
+            json_encode($stationTaskMaterialBox));
         $this->instant($this->stationService,'StationService');
         $dataToPost=$this->makeJson_move(
             collect([$stationTaskMaterialBox]),
-            '缓存架入立架',
+            '输送线入立架',
             'BIN-IN1',//TODO:这里应该是动态取得,参考出立架getULineExit()方法,不然不能从站获得对应的出口,而且要改Station的child为children
             '',
             $stationTaskMaterialBox['stationTaskBatch']['id']
         );
+        LogService::log('海柔请求','putBinToStore3',
+            json_encode($dataToPost));
         return $this->controlHaiRobot($dataToPost);
     }
 
@@ -193,7 +220,7 @@ class ForeignHaiRoboticsService
         $status,            //0:任务成功1:任务失败
         $binCode
     ):bool{
-        LogService::log('海柔请求','taskUpdateIn1',
+        LogService::log('海柔请求','taskUpdateIn',
             json_encode([
                 $stationTaskMaterialBox_id,
                 $updateEventType,
@@ -206,8 +233,6 @@ class ForeignHaiRoboticsService
                     =$status)==1){
                 throw new ErrorException('海柔任务失败');
             }
-            LogService::log('海柔请求','taskUpdateIn2',
-                $failed);
             if($料箱不匹配=
                 !$stationTaskMaterialBox
                     =(function()use($stationTaskMaterialBox_id,$binCode){
@@ -222,29 +247,21 @@ class ForeignHaiRoboticsService
                         ->get()
                         ->toJson());
             }
-            LogService::log('海柔请求','taskUpdateIn2',
-                $料箱不匹配);
             ($标记已放置在库外=
                 function()use($updateEventType,$stationTaskMaterialBox){
                     if(($isPut
-                            =$updateEventType)==0){
+                            =$updateEventType)==1){
                         $this->stationTaskMaterialBoxService->markHasTaken($stationTaskMaterialBox);
                     }
                 })();
-            LogService::log('海柔请求','taskUpdateIn3',
-                $标记已放置在库外);
             ($标记已入立架=
                 function()use($updateEventType,$stationTaskMaterialBox){
                     if(($isGet
-                            =$updateEventType)==1){
+                            =$updateEventType)==0){
                         $this->stationTaskMaterialBoxService->markPutStored($stationTaskMaterialBox);
                     }
                 })();
-            LogService::log('海柔请求','taskUpdateIn4',
-                $标记已入立架);
         }catch (\Exception $e){
-            LogService::log('海柔请求','taskUpdateIn555',
-                $e->getMessage());
             $this->excepted($stationTaskMaterialBox_id, $binCode, $e->getMessage());
             return false;
         }
@@ -281,21 +298,21 @@ class ForeignHaiRoboticsService
      */
     public function controlHaiRobot(array $dataToPost): bool
     {
-        LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c1:'.json_encode($dataToPost));
+        LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1:'.json_encode($dataToPost));
         try{
-            LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c1.51:');
+            LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1.51:');
             $a = json_encode($dataToPost);
             $response = Http::post(config('api.haiq.storage.moveBin'), $dataToPost);
             if(isset($response->json()['code'])&&$response->json()['code']==500)
                 throw new ErrorException('机器人500错误:'.json_encode($response->json()));
             $b=json_encode($response->json());
-            LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c1.52:');
+            LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1.52:');
             LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c1.53:'.json_encode($response->json()));
         }catch (\Exception $e){
-            LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c1.54:');
+            LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1.54:'.json_encode($dataToPost).$e->getMessage());
             throw new ErrorException('海柔机器人任务执行失败:'.json_encode($dataToPost).$e->getMessage());
         }
-        LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c2:'.json_encode($dataToPost));
+        LogService::log('海柔请求','runMany','波次任务分配6.r5f2c2:'.json_encode($dataToPost));
         $errMsg = (function () use ($response) {
             if ($response->ok()) return '';
             $errMsg = '错误: ';
@@ -318,7 +335,7 @@ class ForeignHaiRoboticsService
                 . ' response:' . json_encode($response->headers());
             return $errMsg . $responseDetails;
         })();
-        LogService::log(__METHOD__,'runMany','波次任务分配6.r5f2c3:'.json_encode($errMsg));
+        LogService::log('海柔请求','runMany','波次任务分配6.r5f2c3:'.json_encode($errMsg));
 
         LogService::log(__METHOD__, __FUNCTION__,
             $errMsg ?? ''

+ 2 - 1
app/Services/StationTaskMaterialBoxService.php

@@ -108,8 +108,9 @@ class StationTaskMaterialBoxService
         $this->instant($this->stationTaskService,'StationTaskService');
         $this->instant($this->stationService,'StationService');
         try{
+            LogService::log('海柔请求','markHasTaken1','');
             $taskType=$this->getServingTaskType($stationTaskMaterialBox);
-            LogService::log('海柔请求','markHasTaken',
+            LogService::log('海柔请求','markHasTaken2',
                 json_encode($taskType));
             switch ($taskType){
                 case '分波次':

+ 24 - 16
resources/views/station/monitor/show.blade.php

@@ -34,7 +34,7 @@
                         </div>
                         <div class="row">
                             <div class="col py-3 text-muted text-center">
-                                <img id="barcode" alt="">
+                                <img id="barcode" alt="" :data-refresh="batchCode">
                             </div>
                         </div>
                         <div class="row">
@@ -237,8 +237,8 @@
             color: #fff;
         }
         .box-spot-color.n1{
-            background: #1d0939;
-            fill: #1d0939;
+            background: #d7e3ff;
+            fill: #d7e3ff;
         }
         .box-spot-color.n2{
             background: #393409;
@@ -311,7 +311,7 @@
                         let json = JSON.parse(msg.json);
                         if(!json||json.length===0)return;
                         this.station['current_station_task']=json;
-                        console.log(json);
+                        console.log((new Date()).toTimeString(),json);
                     });
                 },
             },
@@ -320,6 +320,18 @@
                     if(!this.station['current_station_task'])return null;
                     return this.station['current_station_task'];
                 },
+                batchCode(){
+                    let batches = this.task.station_task_batches;
+                    if(batches
+                        && Array.isArray(batches)
+                        && batches.length>0
+                    ){
+                        setTimeout(function (){
+                            setBarcode(batches[0].batch.code,"#barcode",1,50,false);
+                        })
+                    }
+                    return batches[0].batch.code;
+                },
                 taskCommodities(){
                     if(!this.task)return [];
                     return this.station['current_station_task']['station_task_commodities'];
@@ -385,25 +397,21 @@
                 },
                 processedCommodities(){
                     if(!this.task)return 0;
-                    return this.task['station_task_commodities'].reduce(function (item, taskCommodity) {
-                        if (typeof (item) === 'object' && item.status === '完成') {
-                            return item.amount;
-                        }
-                        if (typeof (item) === 'object') {
-                            return 0;
-                        }
+                    let processedAmount=0;
+                    this.task['station_task_commodities'].forEach(function (taskCommodity) {
                         if (taskCommodity.status === '完成') {
-                            return item + taskCommodity.amount;
+                            processedAmount+=taskCommodity.amount;
                         }
-                        return item;
                     })
+                    return processedAmount;
                 },
                 totalCommodities(){
                     if(!this.task)return 0;
-                    return this.task['station_task_commodities'].reduce(function(item,taskCommodity){
-                        if(typeof(item)==='object')item=item.amount;
-                        return item+taskCommodity.amount;
+                    let amount=0;
+                    this.task['station_task_commodities'].forEach(function (taskCommodity) {
+                        amount+=taskCommodity.amount;
                     })
+                    return amount;
                 },
                 processingTaskMaterialBox(){
                     if(!this.task)return [];