| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Services;
- use Illuminate\Support\Collection;
- class StationTaskCommodityService
- {
- /** @var StationService $stationService */
- private $stationService;
- /** @var StationTaskBatchTypeService $stationTaskBatchTypeService */
- private $stationTaskBatchTypeService;
- /** @var BatchService $batchService */
- private $batchService;
- /** @var StationTypeService $stationTypeService */
- private $stationTypeService;
- /** @var StationTaskService $stationTaskService */
- private $stationTaskService;
- /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
- private $stationTaskMaterialBoxService;
- public function __construct(){
- $this->stationService=null;
- $this->stationTypeService=null;
- $this->stationTaskBatchTypeService=null;
- $this->batchService=null;
- $this->stationTaskService=null;
- $this->stationTaskMaterialBoxService=null;
- }
- function get(array $whereParams){
- ksort($whereParams);
- return Cache::remember('stationTaskChild_'.md5(json_encode($whereParams)), config('cache.expirations.oftenChange'), function ()use($whereParams) {
- $query = StationTaskCommodity::query();
- foreach ($whereParams as $column => $value){
- if (is_array($value))$query->whereIn($column,$value);
- else $query->where($column,$value);
- }
- return $query->get();
- });
- }
- function createByBatches(array $batches): Collection
- {
- $stationTaskCommodity_toCreate=new Collection();
- $batches_handled=collect();
- foreach ($batches as $batch){
- $stationType=$this->stationTypeService->getByBatch($batch);
- $station=$this->stationService->getStation_byType($stationType['name']);
- // $materialBox=$this->stationTaskMaterialBoxService->get(['code'=>]);
- // $stationTaskCommodity_toCreate->push([
- // 'station_id'=>$station['id'],
- // 'station_id'=>$station['id'],
- // 'status'=>'待处理'
- // ]);
- $batches_handled->push($batch);
- }
- $this->batchService->updateWhereIn('id',data_get($batches_handled,'*.id'),['status'=>'处理中']);
- }
- }
|