|
|
@@ -2,12 +2,10 @@
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
-use App\Events\BroadcastToStation;
|
|
|
use App\Exceptions\ErrorException;
|
|
|
use App\MaterialBox;
|
|
|
use App\Station;
|
|
|
use App\StationCacheShelfGrid;
|
|
|
-use App\StationTask;
|
|
|
use App\StationTaskMaterialBox;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
@@ -17,29 +15,6 @@ class CacheShelfService
|
|
|
use ServiceAppAop;
|
|
|
protected $modelClass=Station::class;
|
|
|
|
|
|
- /**
|
|
|
- * 缓存架上架料箱
|
|
|
- * @param Station $station
|
|
|
- * @param MaterialBox $materialBox
|
|
|
- * @param $pointX
|
|
|
- * @param $pointY
|
|
|
- * @return string
|
|
|
- * @throws ErrorException
|
|
|
- */
|
|
|
- public function pushTask(Station $station,MaterialBox $materialBox,$pointX, $pointY)
|
|
|
- {
|
|
|
- $grid = (3-$pointX)*3 + (3-$pointX);
|
|
|
- $params = ['station'=>$station['id'],'grid_id'=>$grid];
|
|
|
- $stationCacheShelfGrid = StationCacheShelfGrid::query()->firstOrCreate($params,$params);
|
|
|
- $stationCacheShelfGrid->update(['material_box_id' => $materialBox['id'],'status'=> 0]);
|
|
|
- /** 推送任务至海柔机器人 */
|
|
|
- if($this->putBinToStore($station,$materialBox)){
|
|
|
- $stationCacheShelfGrid->update(['material_box_id' => $materialBox['id'],'status'=> 1]);
|
|
|
- /** 亮灯 */
|
|
|
- return $this->lightOn($station,$pointX, $pointY);
|
|
|
- }
|
|
|
- else return false;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取缓存架任务
|
|
|
@@ -58,7 +33,7 @@ class CacheShelfService
|
|
|
* @param $pointY
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function lightOn(Station $station,$pointX,$pointY): string
|
|
|
+ public function lightOnApi(Station $station,$pointX,$pointY): string
|
|
|
{
|
|
|
$locCode = 'HAI'.$station['code'].'-0'.$pointX.'-0'.$pointY;
|
|
|
$params = [
|
|
|
@@ -88,15 +63,24 @@ class CacheShelfService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 推送到海柔的任务
|
|
|
+ * 推送到海柔机器人的任务
|
|
|
* @param Station $station
|
|
|
* @param MaterialBox $materialBox
|
|
|
+ * @param StationCacheShelfGrid $grid
|
|
|
* @return bool
|
|
|
* @throws ErrorException
|
|
|
*/
|
|
|
- public function putBinToStore(Station $station,MaterialBox $materialBox): bool
|
|
|
+ public function putBinToStore(Station $station,MaterialBox $materialBox,StationCacheShelfGrid $grid): bool
|
|
|
{
|
|
|
- $stationTaskMaterialBox = new StationTaskMaterialBox();
|
|
|
+ // 生成任务
|
|
|
+ /** @var StationTaskMaterialBox $stationTaskMaterialBox */
|
|
|
+ $stationTaskMaterialBox = StationTaskMaterialBox::query()->create([
|
|
|
+ 'station_id' => $station['id'],
|
|
|
+ 'material_box_id' => $materialBox['id'],
|
|
|
+ 'status' => '待处理'
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $station->setRelation('grids',$grid);
|
|
|
$stationTaskMaterialBox->setRelation('station',$station);
|
|
|
$stationTaskMaterialBox->setRelation('materialBox',$materialBox);
|
|
|
|