|
|
@@ -11,6 +11,7 @@ use App\StationType;
|
|
|
use Illuminate\Support\Collection;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
class StationRuleBatchService
|
|
|
@@ -19,8 +20,11 @@ class StationRuleBatchService
|
|
|
protected $modelClass=StationRuleBatch::class;
|
|
|
function getByBatch(?Batch $batch): ?StationRuleBatch
|
|
|
{
|
|
|
+ LogService::log(__METHOD__,'getByBatch','波次任务分配1.21:'.json_encode($batch));
|
|
|
$batchType = $batch['type'] ?? 'null';
|
|
|
$ownerId = $batch['owner_id'] ?? 'null';
|
|
|
+ if(!$this->isLocationOfRobot($batch))return null;
|
|
|
+ LogService::log(__METHOD__,'getByBatch','波次任务分配1.22:'.($this->isLocationOfRobot($batch)));
|
|
|
$batch->loadMissing('stationTaskBatch');
|
|
|
// if($batch['stationTaskBatch'])return null;//? 这行有啥用?
|
|
|
return Cache::remember('stationRuleBatch_batchType_'.$batchType.'_ownerId_'.$ownerId, config('cache.expirations.rarelyChange'),function()use($batch){
|
|
|
@@ -30,9 +34,17 @@ class StationRuleBatchService
|
|
|
&& $batch['type']!='无'){
|
|
|
$builder=$builder->where('batch_type',$batch['type']);
|
|
|
}
|
|
|
+ LogService::log(__METHOD__,'getByBatch','波次任务分配1.23:');
|
|
|
return $builder->first();
|
|
|
});
|
|
|
}
|
|
|
+ function isLocationOfRobot(?Batch $batch): bool
|
|
|
+ {
|
|
|
+ if(!$batch)return false;
|
|
|
+ $sql = "select count(*) as count from order_commodities where location like 'IDE%' and order_id in (select id from orders where batch_id in (select id from batches where id = ?))";
|
|
|
+ $billDetails = DB::select(DB::raw($sql),[$batch['id']]);
|
|
|
+ return $billDetails[0]->count>0;
|
|
|
+ }
|
|
|
|
|
|
function getStationType_toBeTask(Batch $batch): ?StationType{
|
|
|
$stationRuleBatch=$this->getByBatch($batch);
|
|
|
@@ -46,14 +58,17 @@ class StationRuleBatchService
|
|
|
*/
|
|
|
function getBatches_shouldProcess(Collection $batches): Collection
|
|
|
{
|
|
|
+ LogService::log(__METHOD__,'shouldProcess','波次任务分配1.1:'.json_encode($batches));
|
|
|
$batches_toProcess=collect();
|
|
|
$batches_inTask=StationTaskBatch::query()->whereIn('batch_id',data_get($batches,'*.id'))->get();
|
|
|
+ LogService::log(__METHOD__,'shouldProcess','波次任务分配1.2:'.json_encode($batches_inTask));
|
|
|
$batches=$batches->whereNotIn('id',data_get($batches_inTask,'*.id')??[]);
|
|
|
foreach ($batches as $batch){
|
|
|
$stationRuleBatch=$this->getByBatch($batch);
|
|
|
if($stationRuleBatch)
|
|
|
$batches_toProcess->push($batch);
|
|
|
}
|
|
|
+ LogService::log(__METHOD__,'shouldProcess','波次任务分配1.3:'.json_encode($batches_inTask));
|
|
|
return $batches_toProcess;
|
|
|
}
|
|
|
}
|