TestController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\MaterialBox;
  7. use App\MaterialBoxModel;
  8. use App\Services\RejectedService;
  9. use App\User;
  10. use App\Waybill;
  11. use Illuminate\Database\Capsule\Manager;
  12. use Illuminate\Database\DatabaseManager;
  13. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  14. use Illuminate\Http\Request;
  15. use Illuminate\Support\Facades\DB;
  16. use Illuminate\Support\Facades\Hash;
  17. use Illuminate\Support\Facades\Log;
  18. use Oursdreams\Export\Export;
  19. class TestController extends Controller
  20. {
  21. use AsyncResponse, ErrorPush, Database;
  22. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  23. public function __construct()
  24. {
  25. $this->data["active_test"] = "active";
  26. }
  27. public function method(Request $request, $method)
  28. {
  29. try {
  30. return call_user_func([$this, $method], $request);
  31. }catch (\BadMethodCallException $e){
  32. dd("方法不存在");
  33. }
  34. }
  35. public function test($main, $x)
  36. {
  37. return;
  38. $db = DB::connection("aliyunMysql");
  39. foreach ($db->select(DB::raw("select * from equipments where code like 'W4%' and info is not null and id <= 4972")) as $eq){
  40. $arr = str_split ($eq->code);
  41. if (strlen($main)==2){
  42. $arr1 = str_split ($main);
  43. $arr[4] = $arr1[0];
  44. $arr[5] = $arr1[1];
  45. }else{
  46. $arr[5] = $main;
  47. }
  48. $code = implode("",$arr);
  49. $obj = json_decode($eq->info);
  50. $obj->x +=$x;
  51. $db->insert("insert into equipments(code,parent_id,info,depth,width,created_at,updated_at,warehouse_detail_id)
  52. values(?,null,?,?,?,?,?,1)",[$code,json_encode($obj),$eq->depth,$eq->width,now()->toDateTimeString(),now()->toDateTimeString()]);
  53. $a = $db->selectOne("select * from equipments where parent_id is null and code = ? ",[$code]);
  54. foreach ($db->select("select * from equipments where parent_id = ?",[$eq->id]) as $item){
  55. $arr = str_split ($item->code);
  56. if (strlen($main)==2){
  57. $arr1 = str_split ($main);
  58. $arr[4] = $arr1[0];
  59. $arr[5] = $arr1[1];
  60. }else{
  61. $arr[5] = $main;
  62. }
  63. $code = implode("",$arr);
  64. $db->insert("insert into equipments(code,parent_id,info,depth,width,height,location_tab,created_at,updated_at,warehouse_detail_id)
  65. values(?,?,null,?,?,?,?,?,?,2)",[$code,$a->id,$item->depth,$item->width,$item->height,$item->location_tab,now()->toDateTimeString(),now()->toDateTimeString()]);
  66. }
  67. }
  68. }
  69. public function test2(){
  70. return;
  71. $db = DB::connection("aliyunMysql");
  72. foreach ($db->select("select * from equipments where (code like 'W3%') and info is not null") as $eq){
  73. $obj = json_decode($eq->info);
  74. $obj->x -= 105;
  75. $db->update("UPDATE equipments SET info = ? where id = ?",[json_encode($obj),$eq->id]);
  76. }
  77. }
  78. public function test1(Request $request){
  79. return;
  80. $x = 0;
  81. $a1 = 8 + 30;
  82. $a2 = 80 + 30;
  83. $a3 = 32 + 30;
  84. }
  85. use AuthenticatesUsers;
  86. public function test3($request){
  87. dd(Hash::make("wangyan"));
  88. }
  89. }