data["active_test"] = "active"; } public function method(Request $request, $method) { return call_user_func([$this, $method], $request); } public function lightUp() { app("CacheShelfService")->lightUp('HAIB1-02-02','3','0'); } public function lightOff() { $params = [ "areaCode" => "1004", 'locCode' => "HAIB1-02-02", 'PTLAction' => 0, ]; $response = Http::post(config('api.haiq.storage.light'), $params); return json_decode($response->body()); } public function test() { app("CacheShelfService")->_stationCacheLightOff("HAIB1-01-01"); app("CacheShelfService")->_stationCacheLightOff("HAIB1-01-02"); app("CacheShelfService")->_stationCacheLightOff("HAIB1-02-02"); dd(1); $stationTaskMaterialBox = StationTaskMaterialBox::query()->find(70370); DB::beginTransaction(); try{ $stationTaskMaterialBox->loadMissing("station"); //如果为半箱位置 清理原有任务 if (!$stationTaskMaterialBox->station)return; if (app("StationService")->isHalfBoxLocation($stationTaskMaterialBox->station)){ app("StationService")->locationOccupy($stationTaskMaterialBox->station->code,$stationTaskMaterialBox->material_box_id); //清除海柔库位信息 app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]); $stationId = $stationTaskMaterialBox->station_id; $tasks = TaskTransaction::query()->with("materialBox")->where(function ($query)use($stationId){ $query->where("fm_station_id",$stationId)->orWhere("to_station_id",$stationId); })->where("status",0)->get(); if ($tasks->count()!=0){ $options = []; switch ($tasks[0]->mark){ case 1: $options["title"] = '上架任务'; break; case 2: $options["title"] = '出库任务'; break; default: $options["title"] = '未知类型'; } switch ($tasks->count()){ case 1: $task = $tasks[0]; $options["detail01"] = $task->materialBox->code ?? ''; $options["detail02"] = $task->doc_code ?: '跟踪:‘'.$task->track_num."’ 批次:‘".$task->lot_num."’"; $options["detail03"] = $task->bar_code; $options["qty01"] = $task->amount; $options["uomDesc01"] = '件'; $options["qty02"] = $task->bin_number; $options["uomDesc02"] = '号'; break; default: $count = count(array_unique(array_column($tasks->toArray(),"commodity_id"))); if ($count==1){ $options["detail01"] = $tasks[0]->bar_code; $options["detail02"] = ""; $options["detail03"] = ""; $amount = 0; foreach ($tasks as $task){ if (mb_strlen($options["detail02"])>20){ $options["detail03"] .= $task->bin_number."号-".$task->amount."件,"; }else $options["detail02"] .= $task->bin_number."号-".$task->amount."件,"; $amount += $task->amount; } $options["detail02"] = rtrim($options["detail02"],","); $options["detail03"] = rtrim($options["detail03"],","); $options["qty02"] = $amount; $options["uomDesc02"] = '件'; }else{ $task = $tasks[0]; $options["detail01"] = $task->materialBox->code ?? ''; $options["detail02"] = "货品过多请自行核对"; $options["detail03"] = "波次:".$task->doc_code ? (Order::query()->with("batch")->where("code",$task->doc_code)->first()->batch->code ?? '无') : '无'; } break; } app("CacheShelfService")->lightUp($stationTaskMaterialBox->station->code,'2','0',$options); Cache::forget("CACHE_SHELF_OCCUPANCY_{$stationTaskMaterialBox->station->id}");//关闭无限亮灯 } }else app("StationService")->locationFreed($stationTaskMaterialBox->station->code); //释放库位占用 DB::commit(); dd("OK"); }catch (\Exception $e){ DB::rollBack(); dd($e->getTrace()); } } //快递称重 生成历史数据 public function addRecord(Request $request) { ini_set('max_execution_time',-1); OrderPackageCountingRecord::query()->truncate(); $start = Carbon::parse(request("month"))->startOfMonth(); $end = Carbon::parse(request('month'))->endOfMonth(); foreach (CarbonPeriod::create($start,$end) as $date){ /** @var $date Carbon */ $yesterday = $date->format("Y-m-d"); $sql = << $yesterday, "un_weigh_count" => 0, "total_count" => 0, "measuring_machine_id" => 0, "owner_id" => 0 ]; $model = OrderPackageCountingRecord::query()->create($obj); Cache::put("weight.".$yesterday, $obj); }else{ $objs = []; foreach ($result as $v){ $obj = [ "targeted_at" => $v->date, "un_weigh_count" => $v->count, "total_count" => $v->total, "measuring_machine_id" => $v->measuring_machine_id, "owner_id" => $v->owner_id ]; $model = OrderPackageCountingRecord::query()->create($obj); array_push($objs, $obj); } Cache::put("weight.".$yesterday, $objs); } } } public function redis() { $start = 1606752000;$end = 1627747200; $len = ($end - $start) / 86400; for ($i=0; $i <= $len ; $i ++){ $date = date("Y-m-d", $start + $i * 86400); Cache::pull('weight.'.$date); } } }