|
|
@@ -13,16 +13,22 @@ use Illuminate\Support\Facades\Http;
|
|
|
class CacheShelfService
|
|
|
{
|
|
|
use ServiceAppAop;
|
|
|
- protected $modelClass=Station::class;
|
|
|
|
|
|
+ protected $modelClass = Station::class;
|
|
|
+ /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
|
|
|
+ private $stationTaskMaterialBoxService;
|
|
|
+ /** @var StationCacheShelfGridService $stationCacheShelfGridService */
|
|
|
+ private $stationCacheShelfGridService;
|
|
|
+ /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
|
|
|
+ private $foreignHaiRoboticsService;
|
|
|
/**
|
|
|
* 获取现有的缓存架任务
|
|
|
* @param Station $station
|
|
|
*/
|
|
|
public function getTasks(Station $station)
|
|
|
{
|
|
|
- $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id',$station['id'])->where('status',1)->orderBy('grid_id')->get();
|
|
|
- $station->setRelation('grids',$grids);
|
|
|
+ $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id', $station['id'])->where('status', 1)->orderBy('grid_id')->get();
|
|
|
+ $station->setRelation('grids', $grids);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -32,33 +38,32 @@ class CacheShelfService
|
|
|
* @param $pointY
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function lightOn(Station $station,$pointX,$pointY): string
|
|
|
+ public function lightOn(Station $station, $pointX, $pointY): string
|
|
|
{
|
|
|
-
|
|
|
- $locCode = 'HAI'.$station['code'].'-0'.$pointX.'-0'.$pointY;
|
|
|
+ $locCode = 'HAI' . $station['code'] . '-0' . $pointX . '-0' . $pointY;
|
|
|
$params = [
|
|
|
- "areaCode"=> "1004",
|
|
|
- "PTLAction"=> 1, //1是开,0是关
|
|
|
- "PTLSettings"=> [
|
|
|
- "color"=> 1,
|
|
|
- "frequency"=> 1
|
|
|
+ "areaCode" => "1004",
|
|
|
+ "PTLAction" => 1, //1是开,0是关
|
|
|
+ "PTLSettings" => [
|
|
|
+ "color" => 1,
|
|
|
+ "frequency" => 1
|
|
|
],
|
|
|
- "displayInfo"=> [
|
|
|
- "detail01"=> "detail01",
|
|
|
- "detail02"=> "detail02",
|
|
|
- "detail03"=> "detail03",
|
|
|
- "qrCode"=> "qrCode",
|
|
|
- "qty00"=> "11",
|
|
|
- "qty01"=> 1,
|
|
|
- "qty02"=> 2,
|
|
|
- "title"=> "title",
|
|
|
- "uomDesc01"=> "uo",
|
|
|
- "uomDesc02"=> "uo"
|
|
|
+ "displayInfo" => [
|
|
|
+ "detail01" => "detail01",
|
|
|
+ "detail02" => "detail02",
|
|
|
+ "detail03" => "detail03",
|
|
|
+ "qrCode" => "qrCode",
|
|
|
+ "qty00" => "11",
|
|
|
+ "qty01" => 1,
|
|
|
+ "qty02" => 2,
|
|
|
+ "title" => "title",
|
|
|
+ "uomDesc01" => "uo",
|
|
|
+ "uomDesc02" => "uo"
|
|
|
],
|
|
|
- "locCode"=> $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
|
|
|
+ "locCode" => $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
|
|
|
];
|
|
|
|
|
|
- $response = Http::post(config('api.haiq.storage.light'),$params);
|
|
|
+ $response = Http::post(config('api.haiq.storage.light'), $params);
|
|
|
return $response->body();
|
|
|
}
|
|
|
|
|
|
@@ -70,26 +75,21 @@ class CacheShelfService
|
|
|
* @return bool
|
|
|
* @throws ErrorException
|
|
|
*/
|
|
|
- public function putBinToStore(Station $station,MaterialBox $materialBox,StationCacheShelfGrid $grid): bool
|
|
|
+ public function putBinToStore(Station $station, MaterialBox $materialBox, StationCacheShelfGrid $grid): bool
|
|
|
{
|
|
|
- // 生成任务
|
|
|
+ $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
|
|
|
+ $this->instant($this->stationCacheShelfGridService,'StationCacheShelfGridService');
|
|
|
+ $this->instant($this->foreignHaiRoboticsService,'ForeignHaiRoboticsService');
|
|
|
+
|
|
|
/** @var StationTaskMaterialBox $stationTaskMaterialBox */
|
|
|
- $stationTaskMaterialBox = StationTaskMaterialBox::query()->create([
|
|
|
- 'station_id' => $station['id'],
|
|
|
- 'material_box_id' => $materialBox['id'],
|
|
|
- 'status' => '待处理'
|
|
|
- ]);
|
|
|
-
|
|
|
- // 格口状态修改
|
|
|
- $grid->update(['station_id'=>$station['id'],'status'=>1]);
|
|
|
- $station->setRelation('grids',$grid);
|
|
|
- $stationTaskMaterialBox->setRelation('station',$station);
|
|
|
- $stationTaskMaterialBox->setRelation('materialBox',$materialBox);
|
|
|
-
|
|
|
- // 推送任务给海柔
|
|
|
- /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
|
|
|
- $foreignHaiRoboticsService = app(ForeignHaiRoboticsService::class);
|
|
|
- return $foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
|
|
|
+ $stationTaskMaterialBox = $this->stationTaskMaterialBoxService->createByStationMaterialBox($station, $materialBox);
|
|
|
+ $this->stationCacheShelfGridService->processGrid($grid,$station,$materialBox);
|
|
|
+
|
|
|
+ $station->setRelation('grids', $grid);
|
|
|
+ $stationTaskMaterialBox->setRelation('station', $station);
|
|
|
+ $stationTaskMaterialBox->setRelation('materialBox', $materialBox);
|
|
|
+
|
|
|
+ return $this->foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -98,19 +98,18 @@ class CacheShelfService
|
|
|
*/
|
|
|
public function putBinToStoreFinish($params)
|
|
|
{
|
|
|
- $locCode = $params['locCode'];
|
|
|
+ $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
|
|
|
|
|
|
- list($stationCode,$gridId) = StationCacheShelfGrid::getGridByCode($locCode);
|
|
|
- $station = Station::query()->where('code',$stationCode)->first();
|
|
|
+ $locCode = $params['locCode'];
|
|
|
|
|
|
- $stationCacheShelfGrid = StationCacheShelfGrid::query()->with('materialBox')->where('station_id',$station)->where('grid_id',$gridId)->first();
|
|
|
- $stationCacheShelfGrid->update(['status'=>'0','material_box_id' => null]);
|
|
|
+ list($stationCode, $gridId) = StationCacheShelfGrid::getGridByCode($locCode);
|
|
|
+ $station = Station::query()->where('code', $stationCode)->first();
|
|
|
|
|
|
- /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
|
|
|
- $stationTaskMaterialBoxService = app(StationTaskMaterialBoxService::class);
|
|
|
- $StationTaskMaterialBox = StationTaskMaterialBox::query()->where('station_id',$station['id'])->where('material_box_id',$stationCacheShelfGrid['$stationCacheShelfGrid'])->first();
|
|
|
- $stationTaskMaterialBoxService->set($StationTaskMaterialBox,['status'=>'已完成']);
|
|
|
+ $stationCacheShelfGrid = StationCacheShelfGrid::query()->with('materialBox')->where('station_id', $station)->where('grid_id', $gridId)->first();
|
|
|
+ $stationCacheShelfGrid->update(['status' => '0', 'material_box_id' => null]);
|
|
|
|
|
|
+ $StationTaskMaterialBox = StationTaskMaterialBox::query()->where('station_id', $station['id'])->where('material_box_id', $stationCacheShelfGrid['$stationCacheShelfGrid'])->first();
|
|
|
+ $this->stationTaskMaterialBoxService->set($StationTaskMaterialBox, ['status' => '已完成']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -118,11 +117,10 @@ class CacheShelfService
|
|
|
* @param Station $station
|
|
|
* @param array $girds
|
|
|
*/
|
|
|
-
|
|
|
- public function cancelTask(Station $station,array $girds = [])
|
|
|
+ public function cancelTask(Station $station, array $girds = [])
|
|
|
{
|
|
|
- $gridQuery = StationCacheShelfGrid::query()->where('station_id',$station['id']);
|
|
|
- if(count($girds) > 0)$gridQuery->whereIn('grid_id',$girds);
|
|
|
- $gridQuery->update(['material_box_id'=>null,'status'=>0]);
|
|
|
+ $gridQuery = StationCacheShelfGrid::query()->where('station_id', $station['id']);
|
|
|
+ if (count($girds) > 0) $gridQuery->whereIn('grid_id', $girds);
|
|
|
+ $this->stationCacheShelfGridService->cancelTask($gridQuery->get());
|
|
|
}
|
|
|
}
|