|
|
@@ -5,6 +5,7 @@ namespace App\Services;
|
|
|
|
|
|
|
|
|
use App\Batch;
|
|
|
+use App\Log;
|
|
|
use App\Station;
|
|
|
use App\StationTaskBatch;
|
|
|
use App\StationTaskBatchType;
|
|
|
@@ -20,34 +21,39 @@ class StationTaskBatchService
|
|
|
private $stationTaskBatchTypeService;
|
|
|
/** @var BatchService $batchService */
|
|
|
private $batchService;
|
|
|
+ /** @var StationTypeService $stationTypeService */
|
|
|
+ private $stationTypeService;
|
|
|
public function __construct(){
|
|
|
$this->stationService=null;
|
|
|
+ $this->stationTypeService=null;
|
|
|
$this->stationTaskBatchTypeService=null;
|
|
|
$this->batchService=null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param $batches Batch[]
|
|
|
- * @param Station $station
|
|
|
* @return Collection
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public function createByBatches(array $batches,Station $station): Collection
|
|
|
+ function createByBatches(array $batches): Collection
|
|
|
{
|
|
|
$this->stationService=app('StationService');
|
|
|
+ $this->stationTypeService=app('StationTypeService');
|
|
|
$this->stationTaskBatchTypeService=app('StationTaskBatchTypeService');
|
|
|
$this->batchService=app('BatchService');
|
|
|
|
|
|
$stationMissionBatches_toCreate=new Collection();
|
|
|
-// $station=$this->stationService->getDefaultStation('料箱出货口');
|
|
|
- $id_stationMissionBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
|
|
|
+ $id_stationTaskBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
|
|
|
|
|
|
$batches_handled=[];
|
|
|
foreach ($batches as $batch){
|
|
|
if ($batch['status']=='未处理'){
|
|
|
+ $stationType=$this->stationTypeService->getByBatch($batch);
|
|
|
+ $station=$this->stationService->getStation_byType($stationType['name']);
|
|
|
$stationMissionBatches_toCreate->push([
|
|
|
'batch_id'=>$batch['id'],
|
|
|
'station_id'=>$station['id'],
|
|
|
- 'station_mission_batch_type_id'=> $id_stationMissionBatchType,
|
|
|
+ 'station_task_batch_type_id'=> $id_stationTaskBatchType,
|
|
|
'status'=>'待处理'
|
|
|
]);
|
|
|
$batches_handled[]=$batch;
|
|
|
@@ -55,10 +61,15 @@ class StationTaskBatchService
|
|
|
}
|
|
|
$this->batchService->updateWhereIn('id',data_get($batches_handled,'*.id'),['status'=>'处理中']);
|
|
|
$this->insert($stationMissionBatches_toCreate->toArray());
|
|
|
+
|
|
|
return $stationMissionBatches_toCreate;
|
|
|
}
|
|
|
|
|
|
- public function insert(array $stationMissionBatches_inArray){
|
|
|
- return StationTaskBatch::query()->insert($stationMissionBatches_inArray);
|
|
|
+ public function insert(array $stationMissionBatches): bool
|
|
|
+ {
|
|
|
+ $inserted = StationTaskBatch::query()->insert($stationMissionBatches);
|
|
|
+ LogService::log(__METHOD__,__FUNCTION__,json_encode($stationMissionBatches).
|
|
|
+ '||'.json_encode(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),0,3)));
|
|
|
+ return $inserted;
|
|
|
}
|
|
|
}
|