TestController.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Commodity;
  5. use App\CommodityMaterialBoxModel;
  6. use App\Components\AsyncResponse;
  7. use App\Components\ErrorPush;
  8. use App\ErrorTemp;
  9. use App\Feature;
  10. use App\Http\ApiControllers\LoginController;
  11. use App\Http\Requests\OrderDelivering;
  12. use App\Jobs\CacheShelfTaskJob;
  13. use App\Jobs\OrderCreateInstantBill;
  14. use App\Jobs\OrderCreateWaybill;
  15. use App\Jobs\SettlementBillReportTask;
  16. use App\Jobs\StoreCreateInstantBill;
  17. use App\Jobs\WeightUpdateInstantBill;
  18. use App\MaterialBox;
  19. use App\MaterialBoxModel;
  20. use App\Order;
  21. use App\OrderPackage;
  22. use App\Owner;
  23. use App\OwnerFeeDetail;
  24. use App\OwnerFeeDetailLogistic;
  25. use App\OwnerFeeExpress;
  26. use App\OwnerFeeLogistic;
  27. use App\OwnerFeeOperation;
  28. use App\OwnerFeeOperationDetail;
  29. use App\OwnerFeeStorage;
  30. use App\OwnerPriceOperation;
  31. use App\OrderPackageCountingRecord;
  32. use App\RejectedBill;
  33. use App\Services\CacheShelfService;
  34. use App\Services\ForeignHaiRoboticsService;
  35. use App\Services\OrderPackageReceivedSyncService;
  36. use App\Services\OrderService;
  37. use App\Services\OwnerFeeTotalService;
  38. use App\Services\OwnerLogisticFeeReportService;
  39. use App\Services\OwnerPriceOperationService;
  40. use App\Services\OwnerStoreFeeReportService;
  41. use App\Services\OwnerStoreOutFeeReportService;
  42. use App\Services\StationService;
  43. use App\Services\StorageService;
  44. use App\Station;
  45. use App\StationTask;
  46. use App\StationTaskMaterialBox;
  47. use App\Store;
  48. use App\TaskTransaction;
  49. use App\Unit;
  50. use App\User;
  51. use App\UserDetail;
  52. use App\UserDutyCheck;
  53. use App\ValueStore;
  54. use App\Waybill;
  55. use Carbon\Carbon;
  56. use Carbon\CarbonPeriod;
  57. use Firebase\JWT\JWT;
  58. use Illuminate\Database\Eloquent\Collection;
  59. use Illuminate\Foundation\Http\FormRequest;
  60. use Illuminate\Http\Request;
  61. use Illuminate\Support\Facades\Cache;
  62. use Illuminate\Support\Facades\Auth;
  63. use Illuminate\Support\Facades\Cookie;
  64. use Illuminate\Support\Facades\DB;
  65. use Illuminate\Support\Facades\Http;
  66. use Illuminate\Support\Facades\URL;
  67. use Illuminate\Support\Facades\Validator;
  68. use Laravel\Horizon\Events\JobFailed;
  69. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  70. class TestController extends Controller
  71. {
  72. use AsyncResponse, ErrorPush;
  73. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  74. public function __construct()
  75. {
  76. $this->data["active_test"] = "active";
  77. }
  78. public function method(Request $request, $method)
  79. {
  80. return call_user_func([$this, $method], $request);
  81. }
  82. public function test2(){
  83. /* Station::query()
  84. ->where("id",11)->update(["status"=>0]);
  85. $a = new CacheShelfService();
  86. $a->_stationCacheLightOff("HAIB1-01-01");
  87. dd(1);*/
  88. StationTaskMaterialBox::query()->get();
  89. $task1 = StationTaskMaterialBox::query()->find(85010);
  90. $foreignHaiRoboticsService = new ForeignHaiRoboticsService();
  91. $toLocation = collect(["HAIB1-01-01"]);
  92. $taskMaterialBoxes = collect([$task1]);
  93. $foreignHaiRoboticsService->
  94. fetchGroup_multiLocation($toLocation, $taskMaterialBoxes, '', '立架出至缓存架',20);
  95. foreach ($toLocation as $value){
  96. app("CacheShelfService")->lightUp($value,'3','0',["title"=>"机器人取箱中,禁止操作"]);
  97. Cache::forever("CACHE_SHELF_OCCUPANCY_11",true);
  98. }
  99. app("StationService")->locationOccupyMulti($toLocation->toArray());
  100. dd("OK");
  101. }
  102. public function test()
  103. {
  104. $code1 = "IDE0000224";
  105. $code2 = "IDE0000176";
  106. Station::query()->where("station_type_id",5)->whereNotNull("parent_id")
  107. ->where("id","!=",11)->update(["status"=>1]);
  108. Cache::forget("CACHE_SHELF_AVAILABLE");
  109. Cache::forget("CACHE_SHELF_MAPPING");
  110. $dateTime = date("Y-m-d H:i:s");
  111. $materialBox1 = MaterialBox::query()->where("code",$code1)->first();
  112. $materialBox2 = MaterialBox::query()->where("code",$code2)->first();
  113. $task1 = StationTaskMaterialBox::query()->create([
  114. 'station_id'=>11,
  115. 'material_box_id'=>$materialBox1->id,
  116. 'station_task_batch_id'=>1,
  117. 'status'=>'待处理'
  118. ]);
  119. $task2=StationTaskMaterialBox::query()->create([
  120. 'station_id'=>6,
  121. 'material_box_id'=>$materialBox2->id,
  122. 'station_task_batch_id'=>1,
  123. 'status'=>'待处理'
  124. ]);
  125. TaskTransaction::query()->insert([[
  126. "doc_code" => "test",
  127. "bar_code" => "test",
  128. "to_station_id" => 11,
  129. "material_box_id" => $materialBox1->id,
  130. "task_id" => $task1->id,
  131. "commodity_id" => 505012,//XUNI03
  132. "amount" => 1,
  133. "type" => "出库",
  134. "status" => 0,
  135. "mark" => 2,
  136. "bin_number"=>1,
  137. "created_at"=>$dateTime,
  138. "updated_at"=>$dateTime,
  139. ],[
  140. "doc_code" => "test",
  141. "bar_code" => "test",
  142. "to_station_id" => 6,
  143. "material_box_id" => $materialBox2->id,
  144. "task_id" => $task2->id,
  145. "commodity_id" => 505012,//XUNI03
  146. "amount" => 1,
  147. "type" => "出库",
  148. "status" => 3,
  149. "mark" => 2,
  150. "bin_number"=>1,
  151. "created_at"=>$dateTime,
  152. "updated_at"=>$dateTime,
  153. ]]);
  154. $foreignHaiRoboticsService = new ForeignHaiRoboticsService();
  155. $toLocation = collect(["HAIB1-01-01"]);
  156. $taskMaterialBoxes = collect([$task1]);
  157. $foreignHaiRoboticsService->
  158. fetchGroup_multiLocation($toLocation, $taskMaterialBoxes, '', '立架出至缓存架',20);
  159. foreach ($toLocation as $value){
  160. app("CacheShelfService")->lightUp($value,'3','0',["title"=>"机器人取箱中,禁止操作"]);
  161. Cache::forever("CACHE_SHELF_OCCUPANCY_11",true);
  162. }
  163. app("StationService")->locationOccupyMulti($toLocation->toArray());
  164. }
  165. public function _stationCacheLightOff($locCode)
  166. {
  167. if (!$locCode) return null;
  168. $params = [
  169. "areaCode" => "1004",
  170. 'locCode' => $locCode,
  171. 'PTLAction' => 0,
  172. ];
  173. $response = Http::post(config('api.haiq.storage.light'), $params);
  174. return json_decode($response->body());
  175. }
  176. }