TestController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\Components\Database;
  5. use App\Components\ErrorPush;
  6. use App\Services\WaybillService;
  7. use App\Waybill;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\DB;
  10. class TestController extends Controller
  11. {
  12. use AsyncResponse, ErrorPush, Database;
  13. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  14. public function __construct()
  15. {
  16. $this->data["active_test"] = "active";
  17. }
  18. public function method(Request $request, $method)
  19. {
  20. try {
  21. return call_user_func([$this, $method], $request);
  22. }catch (\BadMethodCallException $e){
  23. dd("方法不存在");
  24. }
  25. }
  26. public function test(){
  27. $sql = <<<SQL
  28. select * from equipment where id in (
  29. select parent_id from equipment where parent_id in (select id from equipment where info like '%"id":2%' and code like 'H%')
  30. group by parent_id having (count(*)<5)
  31. );
  32. SQL;
  33. $arr = DB::connection("aliyunMysql")->select(DB::raw($sql));
  34. $insert = <<<SQL
  35. insert into equipment(repository_id, code, parent_id, info, depth, width, height, containers, location_tab, created_at, updated_at, tandem)
  36. values (?,?,?,null,?,?,1.8,null,'0-0','2022-01-13 16:08:00','2022-01-13 16:08:00',null)
  37. SQL;
  38. foreach ($arr as $item){
  39. DB::connection("aliyunMysql")->insert($insert, [$item->repository_id,$item->code."-1",$item->id,$item->depth,$item->width]);
  40. }
  41. }
  42. }