|
|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
use App\Batch;
|
|
|
+use App\Events\BroadcastToStation;
|
|
|
use App\Exceptions\ErrorException;
|
|
|
use App\Jobs\BatchTaskJob;
|
|
|
use App\OracleActAllocationDetails;
|
|
|
@@ -64,7 +65,6 @@ class BatchService
|
|
|
public function assignTasks($batches)
|
|
|
{
|
|
|
try{
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配1:'.json_encode($batches));
|
|
|
$batches = collect($batches);
|
|
|
|
|
|
$this->instant($this->stationTaskBatchService,'StationTaskBatchService');
|
|
|
@@ -76,9 +76,7 @@ class BatchService
|
|
|
$stationTaskBatches=null;
|
|
|
$batches_shouldProcess = $this->stationRuleBatchService->getBatches_shouldProcess($batches); //按规则过滤需要的波次
|
|
|
if($batches_shouldProcess->isEmpty()) return;
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配2:'.json_encode($batches));
|
|
|
$stationTaskMaterialBoxes_occupied = $this->stationTaskMaterialBoxService->getOccupied_byBatches($batches_shouldProcess); //按规则过滤需要的波次
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配2b:'.json_encode($batches));
|
|
|
if($stationTaskMaterialBoxes_occupied->isNotEmpty()) {
|
|
|
foreach ($batches_shouldProcess as $batch){
|
|
|
Cache::tags(['波次防重叠'.$batch['id']])->flush();
|
|
|
@@ -89,17 +87,13 @@ class BatchService
|
|
|
}
|
|
|
DB::transaction(function ()use($batches,&$stationTaskBatches,&$batches_shouldProcess){
|
|
|
$stationTasks = $this->stationTaskService->create($batches_shouldProcess->count()); //生成总任务
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配3:'.json_encode($batches));
|
|
|
$stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配4:'.json_encode($batches));
|
|
|
$stationTaskMaterialBoxes=$this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配5:'.json_encode($stationTaskMaterialBoxes).json_encode($batches));
|
|
|
$stationTaskCommodities=$this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配6:'.json_encode($batches));
|
|
|
});
|
|
|
|
|
|
+// broadcast(new BroadcastToStation(BroadcastToStation::ALL_STATION, $json));
|
|
|
// $ran=$this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
|
|
|
- LogService::log(__METHOD__,'assignTasks','波次任务分配7:'.json_encode($batches));
|
|
|
}catch(Exception $e){
|
|
|
$batchesJson='';
|
|
|
foreach ($batches as $batch){
|