|
|
@@ -5,10 +5,12 @@ namespace App\Services;
|
|
|
|
|
|
|
|
|
use App\Batch;
|
|
|
+use App\Events\BroadcastToStation;
|
|
|
use App\Exceptions\ErrorException;
|
|
|
use App\Exceptions\Exception;
|
|
|
use App\MaterialBox;
|
|
|
use App\OrderCommodity;
|
|
|
+use App\StationCacheShelfGrid;
|
|
|
use App\StationTask;
|
|
|
use App\StationTaskBatch;
|
|
|
use App\StationTaskMaterialBox;
|
|
|
@@ -33,6 +35,8 @@ class StationTaskMaterialBoxService
|
|
|
private $stationTaskCommodityService;
|
|
|
/** @var MaterialBoxService $materialBoxService */
|
|
|
private $materialBoxService;
|
|
|
+ /** @var StationCacheShelfGridService $stationCacheShelfGridService */
|
|
|
+ private $stationCacheShelfGridService;
|
|
|
public function __construct(){
|
|
|
$this->stationService=null;
|
|
|
$this->stationTypeService=null;
|
|
|
@@ -42,6 +46,15 @@ class StationTaskMaterialBoxService
|
|
|
$this->stationTaskCommodityService=null;
|
|
|
}
|
|
|
|
|
|
+ function createByStationMaterialBox($station,$materialBox)
|
|
|
+ {
|
|
|
+ return StationTaskMaterialBox::query()->create([
|
|
|
+ 'station_id' => $station['id'],
|
|
|
+ 'material_box_id' => $materialBox['id'],
|
|
|
+ 'status' => '待处理'
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
function createByBatches(Collection $batches,Collection $stationTasks_toAttach): Collection
|
|
|
{
|
|
|
$this->instant($this->stationTaskService,'StationTaskService');
|
|
|
@@ -136,9 +149,28 @@ class StationTaskMaterialBoxService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function markHasTaken($stationTaskMaterialBox){
|
|
|
+ function markHasTaken($stationTaskMaterialBox)
|
|
|
+ {
|
|
|
//TODO: 标记 料箱位置(需要其字段存在)$stationTaskMaterialBox['materialBox']['position']
|
|
|
+
|
|
|
+ $this->instant($this->stationCacheShelfGridService,'StationCacheShelfGridService');
|
|
|
+
|
|
|
+ // 料箱从缓存架上拿走
|
|
|
+ if($stationTaskMaterialBox['station']['stationType']['name']=='缓存架'){
|
|
|
+ $stationTaskMaterialBox['status'] = '完成';
|
|
|
+
|
|
|
+ $json = json_encode([
|
|
|
+ 'station_id'=>$stationTaskMaterialBox['station_id'],
|
|
|
+ 'code' => $stationTaskMaterialBox['materialBox']['code'],
|
|
|
+ 'status' => '完成'
|
|
|
+ ]);
|
|
|
+ $grids = StationCacheShelfGrid::query()->where(['station_id'=>$stationTaskMaterialBox['station_id'],'material_box_id'=>$stationTaskMaterialBox['material_box_id']])->get();
|
|
|
+ $this->stationCacheShelfGridService->cancelTask($grids);
|
|
|
+ broadcast(new BroadcastToStation($stationTaskMaterialBox['station_id'], $json));
|
|
|
+ $this->markProcessed($stationTaskMaterialBox);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
function processNextQueued(StationTaskMaterialBox $stationTaskMaterialBox_lastProcessed){
|
|
|
$station_id=$stationTaskMaterialBox_lastProcessed['station_id'];
|
|
|
$stationTaskMaterialBox_next=StationTaskMaterialBox::query()
|