StorageService.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <?php
  2. namespace App\Services;
  3. use App\CommodityMaterialBoxModel;
  4. use App\Log;
  5. use App\Station;
  6. use App\StationTask;
  7. use App\StationTaskMaterialBox;
  8. use App\TaskTransaction;
  9. use App\Traits\ServiceAppAop;
  10. use App\Storage;
  11. use App\ValueStore;
  12. use Illuminate\Database\Eloquent\Model;
  13. use Illuminate\Support\Collection;
  14. use Illuminate\Support\Facades\Auth;
  15. use Illuminate\Support\Facades\DB;
  16. class StorageService
  17. {
  18. use ServiceAppAop;
  19. protected $modelClass=Storage::class;
  20. /**
  21. * 填充缓存架
  22. *
  23. * @param \Illuminate\Database\Eloquent\Collection $stations
  24. */
  25. public function paddingCacheShelf($stations)
  26. {
  27. $collection = new Collection();
  28. $stationCollection = new Collection();
  29. $blacklist = [];
  30. foreach ($stations as $station){
  31. $box = app("MaterialBoxService")->getAnEmptyBox($blacklist);
  32. if (!$box)continue;
  33. $task = StationTask::query()->create([
  34. 'status' => "待处理",
  35. 'station_id' => $station->id,
  36. ]);
  37. $collection->add(StationTaskMaterialBox::query()->create([
  38. 'station_id' => $station->id,
  39. 'material_box_id'=>$box->id,
  40. 'status'=>"待处理",
  41. 'type' => '取',
  42. 'station_task_id' => $task->id,
  43. ]));
  44. $stationCollection->add($station->code);
  45. $blacklist[] = $box->id;
  46. }
  47. app("ForeignHaiRoboticsService")->fetchGroup_multiLocation($stationCollection,$collection,'','立架出至缓存架');
  48. }
  49. /**
  50. * 缓存架放置记录
  51. *
  52. * @param StationTaskMaterialBox|\stdClass $stationTaskMaterialBox
  53. */
  54. public function putCacheShelf($stationTaskMaterialBox)
  55. {
  56. DB::beginTransaction();
  57. try{
  58. $storage = Storage::query()->where("material_box_id",$stationTaskMaterialBox->material_box_id)->lockForUpdate()->first();
  59. if ($storage)$storage->update(["station_id"=>$stationTaskMaterialBox->station_id,'status'=>0]);
  60. else Storage::query()->create([
  61. "station_id" => $stationTaskMaterialBox->station_id,
  62. "material_box_id" => $stationTaskMaterialBox->material_box_id,
  63. ]);
  64. $stationTaskMaterialBox->loadMissing("station");
  65. //清理原有任务
  66. app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]);
  67. DB::commit();
  68. }catch (\Exception $e){
  69. DB::rollBack();
  70. }
  71. }
  72. /**
  73. * 释放库位占用
  74. *
  75. * @param StationTaskMaterialBox|\stdClass $stationTaskMaterialBox
  76. */
  77. public function releaseOccupation($stationTaskMaterialBox)
  78. {
  79. if ($stationTaskMaterialBox->station->station_type_id != 5)return;
  80. $storage = Storage::query()->where("material_box_id",$stationTaskMaterialBox->material_box_id)->first();
  81. if (!$storage)return;
  82. $update = [];
  83. if ($storage->status == 1)$update["status"] = 0;
  84. if ($storage->station_id)$update["station_id"] = null;
  85. if ($update)$storage->update($update);
  86. }
  87. /**
  88. * 检查临时事务标记处理一些特殊情况
  89. *
  90. * @param StationTaskMaterialBox|\stdClass $stationTaskMaterialBox
  91. */
  92. public function checkMark($stationTaskMaterialBox)
  93. {
  94. $task = TaskTransaction::query()->where("material_box_id",$stationTaskMaterialBox->material_box_id)
  95. ->where("status",0)->first();
  96. if (!$task)return;
  97. //蓝灯闪烁
  98. if ($task->type == '入库' && $task->mark == 1)app("CacheShelfService")->stationLightUp($stationTaskMaterialBox->station->code,null,'2','2');
  99. }
  100. /**
  101. * 检查存储 根据事务表做处理
  102. *
  103. * @param Station|\stdClass $station
  104. *
  105. * @return bool
  106. *
  107. * @throws
  108. */
  109. public function checkStorage($station)
  110. {
  111. $task = TaskTransaction::query()->with("materialBox")->where("fm_station_id",$station->id)
  112. ->where("status",0)->first();
  113. if (!$task)return true;
  114. //建立入库任务,通知入库,完善库存
  115. if ($task->type == '入库' && $task->mark == 1){
  116. DB::beginTransaction();
  117. try{
  118. //get flux
  119. $asns = $this->getFluxTask($task->doc_code,$task->bar_code,$task->amount);
  120. if (!$asns)return false;
  121. $ide = $task->materialBox->code;
  122. DB::connection("oracle")->beginTransaction();
  123. try{
  124. foreach ($asns as $asn)if (!$this->fluxPA($asn,$ide,(int)$asn->fmqty)){
  125. DB::connection("oracle")->rollBack();
  126. return false;
  127. };
  128. }catch(\Exception $e){
  129. DB::connection("oracle")->rollBack();
  130. return false;
  131. }
  132. $taskMaterialBox = $this->createWarehousingTask($station->id,$task->material_box_id);//建立入库任务
  133. if (!$this->enterWarehouse($station->id,$task->material_box_id,$task->commodity_id,$task->amount))throw new \Exception("库存异常"); //处理库存
  134. $task->update([
  135. "task_id" => $taskMaterialBox->id,
  136. "status" => 1,
  137. "user_id" => Auth::id(),
  138. ]);//标记事务完成
  139. $collection = new Collection([$taskMaterialBox]);
  140. app("ForeignHaiRoboticsService")->fetchGroup($station->code,$collection,'','缓存架入立架'); //呼叫机器人入库
  141. DB::commit();
  142. DB::connection("oracle")->commit();
  143. return true;
  144. }catch(\Exception $e){
  145. DB::rollBack();
  146. DB::connection("oracle")->rollBack();
  147. return false;
  148. }
  149. }
  150. return true;
  151. }
  152. /**
  153. * 建立入库任务
  154. *
  155. * @param $stationId
  156. * @param $boxId
  157. *
  158. * @return Model|\stdClass
  159. */
  160. public function createWarehousingTask($stationId,$boxId)
  161. {
  162. /** @var StationTask|\stdClass $task */
  163. $task = StationTask::query()->create([
  164. 'status' => "待处理",
  165. 'station_id' => $stationId,
  166. ]);
  167. return StationTaskMaterialBox::query()->create([
  168. 'station_id' => $stationId,
  169. 'material_box_id'=>$boxId,
  170. 'status'=>"待处理",
  171. 'type' => '放',
  172. 'station_task_id' => $task->id,
  173. ]);
  174. }
  175. /**
  176. * 库存入库
  177. *
  178. * @param integer $stationId
  179. * @param integer $boxId
  180. * @param integer $commodityId
  181. * @param integer $amount
  182. * @param integer $modelId
  183. *
  184. * @return bool
  185. */
  186. public function enterWarehouse($stationId, $boxId, $commodityId, $amount, $modelId = null)
  187. {
  188. DB::beginTransaction();
  189. try{
  190. $storage = Storage::query()->where("material_box_id",$boxId)->lockForUpdate()->first();
  191. $obj = [
  192. "station_id" => $stationId,
  193. "material_box_id" => $boxId,
  194. "commodity_id" => $commodityId,
  195. "amount" => $amount,
  196. "status" => 1,
  197. ];
  198. if ($storage){
  199. $amountTemp = (int)$storage->amount + (int)$amount;
  200. $obj["amount"] = DB::raw("amount+{$amount}");
  201. $storage->update($obj);
  202. $amount = $amountTemp;
  203. } else Storage::query()->create($obj);
  204. if ($commodityId && $modelId){
  205. //维护料箱最大上限 用于半箱补货
  206. $model = CommodityMaterialBoxModel::query()->select("maximum")->where("commodity_id",$commodityId)
  207. ->where("material_box_model_id",$modelId)->first();
  208. if (!$model)CommodityMaterialBoxModel::query()->create(["commodity_id"=>$commodityId,"material_box_model_id"=>$modelId,"maximum"=>$amount]);
  209. if ($model && $model->maximum < $amount)$model->update(["maximum"=>$amount]);
  210. }
  211. DB::commit();
  212. LogService::log(__CLASS__,"库存增加",$storage->toJson()." | ".json_encode([$stationId, $boxId, $commodityId, $amount, $modelId]));
  213. return true;
  214. }catch(\Exception $e){
  215. DB::rollBack();
  216. return false;
  217. }
  218. }
  219. /**
  220. * 获取FLUX上架任务列表
  221. *
  222. * @param string $asn
  223. * @param string $barCode
  224. * @param int $amount
  225. *
  226. * @return array|null
  227. */
  228. public function getFluxTask($asn,$barCode,$amount):?array
  229. {
  230. $sql = <<<sql
  231. SELECT * FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
  232. LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
  233. WHERE ASNNO = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?) AND RECEIVEDQTY >= ?
  234. AND TASKPROCESS = '00' AND TASKTYPE = 'PA'
  235. sql;
  236. $asns = DB::connection("oracle")->select(DB::raw($sql),[$asn,$barCode,$barCode,$barCode,$amount]);
  237. if (!$asns)return null;
  238. $nums = [];
  239. foreach ($asns as $asn){
  240. if ((int)$asn->fmqty == $amount)return [$asn];
  241. $nums[] = (int)$asn->fmqty;
  242. }
  243. $result = $this->twoSum($nums,$amount);
  244. if ($result)return [$asns[$result[0]],$asns[$result[1]]];
  245. return null;
  246. }
  247. /**
  248. * 获取匹配数字
  249. *
  250. * @param Integer[] $nums
  251. * @param Integer $target
  252. * @return Integer[]|null
  253. */
  254. protected function twoSum($nums, $target) {
  255. $map=[];
  256. for($i=0;$i<count($nums);$i++){
  257. $complement=$target-$nums[$i];
  258. if(array_key_exists($complement,$map)){
  259. return [$map[$complement],$i];
  260. }
  261. $map[$nums[$i]]=$i;
  262. }
  263. return null;
  264. }
  265. /**
  266. * 将任务在flux上架
  267. *
  268. * @param $asn
  269. * @param $ide
  270. * @param $amount
  271. * @return bool
  272. * @throws \Throwable
  273. */
  274. public function fluxPA($asn,$ide,$amount)
  275. {
  276. if (!$asn->taskid)return false;//ASN单无此入库信息,禁止上架
  277. $sql = <<<sql
  278. SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND traceid = ? AND customerid= ? and sku = ? and qty = {$amount}
  279. sql;
  280. $inv = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn->fmlotnum,$asn->plantoid,$asn->customerid,$asn->sku]);
  281. if (!$inv)return false;//余量与入库不符
  282. DB::connection("oracle")->transaction(function ()use($inv,$amount,$ide,$asn,&$who){
  283. $db = DB::connection("oracle");
  284. /*$qty = $amount;
  285. foreach ($inv as $in){
  286. if ($qty==0)break;
  287. if ($in->qty > $qty){
  288. $db->update(DB::raw("update inv_lot_loc_id set qty = qty-?,qtymvout = qty-? where lotnum = ? and locationid = ? and traceid = ?"),[
  289. $qty,$qty,$in->lotnum,$in->locationid,$in->traceid
  290. ]);
  291. $in->qty = $in->qty-$qty;
  292. $qty = 0;
  293. }else{
  294. $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? and locationid = ? and traceid = ?"),[
  295. $in->lotnum,$in->locationid,$in->traceid
  296. ]);
  297. $qty = $qty-$in->qty;
  298. }
  299. }*/
  300. $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? AND traceid = ? AND traceid != '*' AND qty = 0"),[
  301. $inv->lotnum,$inv->traceid
  302. ]);
  303. $invHistory = $db->selectOne(DB::raw("SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND locationid = ? AND customerid = ? AND sku = ? AND traceid = '*' FOR UPDATE"),[
  304. $inv->lotnum,$ide,$inv->customerid,$inv->sku
  305. ]);
  306. $who = 'WAS'.(Auth::user() ? '-'.Auth::user()["name"] : '');
  307. if ($invHistory)$db->update(DB::raw("UPDATE inv_lot_loc_id SET qty = qty+? WHERE lotnum = ? AND locationid = ? AND traceid = '*'"),[
  308. (int)$amount,$inv->lotnum,$ide
  309. ]);
  310. else $db->insert(DB::raw("INSERT INTO inv_lot_loc_id VALUES(?,?,'*',?,?,?,0,0,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,0,'*',0,null)"),[
  311. $inv->lotnum,$ide,$inv->customerid,$inv->sku,$amount,date("Y-m-d H:i:s"),$who,
  312. date("Y-m-d H:i:s"),$who
  313. ]);
  314. $sql = <<<sql
  315. INSERT INTO ACT_TRANSACTION_LOG VALUES(?,'PA',?,?,?,?,'ASN',?,?,?,?,?,?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,
  316. TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,?,null,null,null,'*',?,?,?,?,?,?,?,
  317. ?,?,?,?,?,'N',null,?,?,?,?,?,?,?,null,null)
  318. sql;
  319. list($trid,$max) = $this->getTrNumber();
  320. $db->insert(DB::raw($sql),[
  321. $trid,$asn->customerid,$asn->sku,
  322. $asn->asnno,$asn->asnlineno,$inv->lotnum,$asn->fmlocation,$asn->plantoid,$asn->packid,$asn->uom,$amount,$amount,'99',date("Y-m-d H:i:s"),$who,
  323. date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),$asn->customerid,$asn->sku,$ide,$who,$asn->packid,$asn->uom,$amount,$amount,$inv->lotnum,
  324. '*','0','N','*',$asn->taskid_sequence,$asn->warehouseid,$asn->userdefine1,$asn->userdefine2,
  325. $asn->userdefine3,$asn->userdefine4,$asn->userdefine5,'O'
  326. ]);
  327. $this->setTrNumber($max);
  328. $sql = <<<sql
  329. update TSK_TASKLISTS set TASKPROCESS = '99',REASONCODE = 'OK',PLANTOLOCATION = ?,PLANLOGICALTOSEQUENCE = ?,
  330. CREATE_TRANSACTIONID = ?,OPENWHO = ?,OPENTIME = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),
  331. CLOSEWHO = ?,CLOSETIME = ?,EDITTIME = ?,EDITWHO = ?
  332. where taskid = ? AND TASKID_SEQUENCE = ?
  333. sql;
  334. $db->update(DB::raw($sql),[
  335. $ide,$ide,$trid,$who,date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),$who,$asn->taskid,$asn->taskid_sequence
  336. ]);
  337. });
  338. //成功后应去修改ASN状态及数量 暂时不知上架后ASN应为状态
  339. /* $sql = <<<sql
  340. UPDATE doc_asn_details SET linestatus = ?,edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ? AND asnlineno = ?
  341. sql;*/
  342. //if ($asn->expectedqty>$asn->receivedqty && $asn->linestatus!='30')DB::connection("oracle")->update(DB::raw($sql),['30',date("Y-m-d H:i:s"),$who,$asn->asnno,$asn->asnlineno]);
  343. if ($asn->expectedqty==$asn->receivedqty && $asn->linestatus=='40'){
  344. //DB::connection("oracle")->update(DB::raw($sql),['40',date("Y-m-d H:i:s"),$who,$asn->asnno,$asn->asnlineno]);
  345. $check = DB::connection("oracle")->selectOne(DB::raw("SELECT 1 FROM DOC_ASN_DETAILS WHERE ASNNO = ? AND LINESTATUS != '40'"),[$asn->asnno]);
  346. if (!$check){
  347. $logs = DB::connection("oracle")->select(DB::raw("SELECT SUM(FMQTY) qty,TRANSACTIONTYPE FROM ACT_TRANSACTION_LOG WHERE DOCNO = ? AND TRANSACTIONTYPE IN ('PA','IN') GROUP BY TRANSACTIONTYPE"),[$asn->asnno]);
  348. $paQty = 0;
  349. $inQty = 0;
  350. foreach ($logs as $log){
  351. if ($log->transactiontype == 'IN')$inQty = $log->qty;
  352. else $paQty = $log->qty;
  353. }
  354. if ($paQty == $inQty){
  355. DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
  356. [date("Y-m-d H:i:s"),$who,$asn->asnno]);
  357. DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_DETAILS SET linestatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
  358. [date("Y-m-d H:i:s"),$who,$asn->asnno]);
  359. }
  360. }
  361. }
  362. return true;
  363. }
  364. /**
  365. * put cache rack box to warehousing(将缓存架料箱入库)
  366. *
  367. * @param string $fromLocation
  368. * @param integer $boxId
  369. *
  370. * @return int
  371. */
  372. public function putWareHousing(string $fromLocation, $boxId):?int
  373. {
  374. $station = Station::query()->select("id")
  375. ->where("station_type_id",5)->where("code",$fromLocation)->first();
  376. if (!$station)return null;
  377. if (StationTask::query()->select("id")->where("status","!=",'完成')->where("station_id",$station->id)->first())return null;
  378. /** @var StationTaskMaterialBox|\stdClass $stmb */
  379. $stmb = $this->createWarehousingTask($station->id,$boxId);
  380. return $stmb->id;
  381. }
  382. /**
  383. * 获取事务现号
  384. *
  385. * @return array
  386. */
  387. private function getTrNumber()
  388. {
  389. $val = ValueStore::query()->select("value")->where("name","flux_tr_number")->first();
  390. if (!$val)$val = ValueStore::query()->create(["name"=>"flux_tr_number","value"=>'0']);
  391. $max = $val->value+1;
  392. $number = sprintf("%09d", $max);
  393. return array('W'.$number,$max);
  394. }
  395. /**
  396. * 设置事务现号
  397. *
  398. * @param integer $max
  399. */
  400. private function setTrNumber($max)
  401. {
  402. ValueStore::query()->select("value")->where("name","flux_tr_number")->update(["value"=>(string)((int)$max+1)]);
  403. }
  404. /**
  405. * 入库
  406. *
  407. * @param integer $boxId
  408. * @param integer $amount
  409. * @param integer $commodityId
  410. *
  411. * @return bool
  412. */
  413. public function warehousing($boxId, $amount, $commodityId = null):bool
  414. {
  415. DB::beginTransaction();
  416. try{
  417. $storage = Storage::query()->where("material_box_id",$boxId)->lockForUpdate()->first();
  418. if (!$storage && !$commodityId)return false;
  419. if (!$storage){
  420. Storage::query()->create([
  421. "station_id" => null,
  422. "material_box_id" => $boxId,
  423. "commodity_id" => $commodityId,
  424. "amount" => $amount,
  425. ]);
  426. return true;
  427. }
  428. if ($commodityId && $storage->commodity_id && $storage->commodity_id!=$commodityId)return false;
  429. $obj = [
  430. "station_id" => null,
  431. "amount" => DB::raw("amount + {$amount}"),
  432. ];
  433. if (!$storage->commodity_id && $commodityId)$obj["commodity_id"] = $commodityId;
  434. $storage->update($obj);
  435. DB::commit();
  436. return true;
  437. }catch (\Exception $e){
  438. DB::rollBack();
  439. return false;
  440. }
  441. }
  442. /**
  443. * 出库
  444. *
  445. * @param integer $boxId
  446. * @param integer $amount
  447. * @param integer $commodityId
  448. *
  449. * @return bool
  450. */
  451. public function outWarehousing($boxId, $amount, $commodityId = null):bool
  452. {
  453. DB::beginTransaction();
  454. try{
  455. $storage = Storage::query()->where("material_box_id",$boxId)->lockForUpdate()->first();
  456. if (!$storage)return false;
  457. if ($commodityId && $storage->commodity_id && $storage->commodity_id!=$commodityId)return false;
  458. $obj = [
  459. "station_id" => null,
  460. "amount" => DB::raw("amount - {$amount}"),
  461. ];
  462. if (!$storage->commodity_id && $commodityId)$obj["commodity_id"] = $commodityId;
  463. $storage->update($obj);
  464. DB::commit();
  465. return true;
  466. }catch (\Exception $e){
  467. DB::rollBack();
  468. return false;
  469. }
  470. }
  471. /**
  472. * 清除任务
  473. *
  474. * @param array $stationCodes
  475. */
  476. public function clearTask(array $stationCodes)
  477. {
  478. //清除海柔信息,标记料箱为出库
  479. DB::connection("mysql_haiRobotics")->table("ks_bin")->whereIn("ks_bin_space_code",$stationCodes)
  480. ->where("status",1)->update([
  481. "ks_bin_space_code" => null,"ks_bin_space_id"=>null,"orig_ks_bin_space_code"=>null,"orig_ks_bin_space_id"=>null,
  482. "status"=>4,
  483. ]);
  484. //WAS任务清除
  485. $station = Station::query()->select("id")->whereIn("code",$stationCodes);
  486. $task = StationTask::query()->select("id")->where("status","!=",'完成')->whereIn("station_id",$station);
  487. StationTaskMaterialBox::query()->where("status","!=",'完成')->whereIn("station_task_id",$task)->update([
  488. "status" => "完成"
  489. ]);
  490. StationTask::query()->where("status","!=",'完成')->whereIn("station_id",$station)->update([
  491. "status" => "完成"
  492. ]);
  493. Storage::query()->whereIn("station_id",$station)->update([
  494. "status" => 1,
  495. "station_id" => null,
  496. ]);
  497. return true;
  498. }
  499. }