StationController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Station;
  4. use App\StationTypeBinMonitor;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Contracts\Foundation\Application;
  8. use Illuminate\Contracts\View\Factory;
  9. use Illuminate\View\View;
  10. class StationController extends Controller
  11. {
  12. /**
  13. * Display a listing of the resource.
  14. *
  15. * @return void
  16. */
  17. public function index()
  18. {
  19. }
  20. public function monitorIndex()
  21. {
  22. $stations = Station::query()->with('stationType:name','parent:name')->whereHas('stationType',function($query){
  23. /** @var Builder $query */
  24. $query->where('name','料箱监视器');
  25. })->paginate(100);
  26. return view('station.monitor.index',compact('stations'));
  27. }
  28. /**
  29. * 缓存货架
  30. * @return Application|Factory|View
  31. */
  32. public function cachingShelfIndex()
  33. {
  34. $stations = Station::query()->with('stationType:name','parent:name')->whereHas('stationType',function($query){
  35. /** @var Builder $query */
  36. $query->where('name','缓存架');
  37. })->paginate(100);
  38. return view('station.cachingShelf.list.index',compact('stations'));
  39. }
  40. /**
  41. * Show the form for creating a new resource.
  42. *
  43. * @return \Illuminate\Http\Response
  44. */
  45. public function create()
  46. {
  47. //
  48. }
  49. /**
  50. * Store a newly created resource in storage.
  51. *
  52. * @param \Illuminate\Http\Request $request
  53. * @return \Illuminate\Http\Response
  54. */
  55. public function store(Request $request)
  56. {
  57. //
  58. }
  59. public function show(Station $station)
  60. {
  61. //
  62. }
  63. public function monitorShow(Station $station)
  64. {
  65. $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
  66. $station->loadMissing([
  67. "currentStationTask.stationTaskCommodities.commodity.barcodes",
  68. "currentStationTask.stationTaskCommodities.materialBox",
  69. "currentStationTask.stationTaskBatches.batch",
  70. "currentStationTask.stationTaskMaterialBoxes.materialBox",
  71. "stationTypeBinMonitor",
  72. ]);
  73. if (!$station['stationTypeBinMonitor']){
  74. StationTypeBinMonitor::query()->create([
  75. 'station_id' => $station['id'],
  76. 'bin_row_length' => 4,
  77. 'bin_column_length' => 5,
  78. 'bin_wall_amount' => 2,
  79. ]);
  80. $station->load("stationTypeBinMonitor");
  81. }
  82. return view('station.monitor.show',compact('station'));
  83. }
  84. /**
  85. * Show the form for editing the specified resource.
  86. *
  87. * @param \App\Station $station
  88. * @return \Illuminate\Http\Response
  89. */
  90. public function edit(Station $station)
  91. {
  92. //
  93. }
  94. /**
  95. * Update the specified resource in storage.
  96. *
  97. * @param \Illuminate\Http\Request $request
  98. * @param \App\Station $station
  99. * @return \Illuminate\Http\Response
  100. */
  101. public function update(Request $request, Station $station)
  102. {
  103. //
  104. }
  105. /**
  106. * Remove the specified resource from storage.
  107. *
  108. * @param \App\Station $station
  109. * @return \Illuminate\Http\Response
  110. */
  111. public function destroy(Station $station)
  112. {
  113. //
  114. }
  115. /**
  116. * @param Request $request
  117. * @param $id
  118. * @return array
  119. */
  120. public function cachingShelfApi(Request $request,$id): array
  121. {
  122. $station = Station::query()->where('id',$id)->with([
  123. 'stationTypeBinMonitor',
  124. 'currentStationTask'=>function($query){
  125. /** @var Builder $query */
  126. $query->with(['stationTaskCommodities'=>function($query){
  127. /** @var Builder $query */
  128. $query->with(['commodity.barcodes','materialBox','batch','materialBox']);
  129. }]);
  130. }
  131. ])->first();
  132. return ['success' => true,'data' => $station];
  133. }
  134. }