TestController.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\City;
  6. use App\Events\CancelOrder;
  7. use App\Events\WmsReceiveNewEvent;
  8. use App\Http\Controllers\Api\thirdPart\flux\WaybillController;
  9. use App\Logistic;
  10. use App\OracleActTransactionLog;
  11. use App\Order;
  12. use App\Owner;
  13. use App\Package;
  14. use App\Rejected;
  15. use App\RejectedBill;
  16. use App\RejectedBillItem;
  17. use App\Unit;
  18. use App\User;
  19. use App\UserToken;
  20. use App\UserWorkgroup;
  21. use App\Waybill;
  22. use App\OraccleBasCustomer;
  23. use App\WMSReflectReceive;
  24. use App\WMSWaybillOrder;
  25. use Carbon\Carbon;
  26. use Endroid\QrCode\QrCode;
  27. use Endroid\QrCode\Response\QrCodeResponse;
  28. use Illuminate\Database\Query\JoinClause;
  29. use Illuminate\Http\Request;
  30. use Illuminate\Support\Facades\DB;
  31. use function PHPSTORM_META\map;
  32. use Zttp\Zttp;
  33. class TestController extends Controller
  34. {
  35. private $data=[];
  36. public function __construct()
  37. {
  38. $this->data["active_test"]="active";
  39. }
  40. public function method(Request $request,$method)
  41. {
  42. return call_user_func([$this, $method],$request);
  43. }
  44. function t1(Request $request){ //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  45. $waybills=Waybill::all();
  46. $controller=(new WaybillController());
  47. $waybills->each(function ($waybill)use($controller){
  48. $controller->accomplishToWMS($waybill);
  49. });
  50. }
  51. function tj(Request $request){
  52. $a=11;
  53. try{
  54. $b=22;
  55. }catch (\Exception $exception){
  56. $this->log(__METHOD__,'Exception_'.__FUNCTION__,'请求异常:'.$exception->getMessage(),null);
  57. return ['result'=>'false'];
  58. }
  59. echo $a+$b;
  60. }
  61. function injectJS(Request $request){
  62. $items=RejectedBillItem::whereHas('rejectedBill',function($query){
  63. return $query->where('id_owner',2);
  64. })->where('created_at','>','2019-12-23 18:11:00')->where('created_at','<','2019-12-24 11:25:00')->get();
  65. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  66. }
  67. public function tj2(Request $request)
  68. {
  69. $rejected = Rejected::find(10);
  70. $rejectedJianshang=new \App\Http\Controllers\api\jianshang\RejectedController();
  71. dd( $rejectedJianshang->sendRejected($rejected));
  72. }
  73. public function excelIt()
  74. {
  75. $excel=new ExcelController();
  76. return $excel->makeExcel();
  77. }
  78. public function featureIt()
  79. {
  80. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5,2500);
  81. }
  82. public function newSku()
  83. {
  84. $url='http://bswcs/api/sorting/flux/newSku';
  85. $response = Zttp::post($url, [
  86. 'request'=>[
  87. [
  88. "SKU"=> "1234567890",
  89. "NAME"=> "瑞士莲**巧克力",
  90. "Alternate_SKU1"=> "1122334455",
  91. "GrossWeight"=> "1.2",
  92. "Cube"=> "0.75",
  93. "SKULength"=> "0.25",
  94. "SKUWidth"=> "0.15",
  95. "SKUHigh"=> "0.05"
  96. ],
  97. [
  98. "SKU"=> "1234567892",
  99. "NAME"=> "跳跳饼",
  100. "Alternate_SKU1"=> "",
  101. "GrossWeight"=> "1.3",
  102. "Cube"=> "0.75",
  103. "SKULength"=> "0.25",
  104. "SKUWidth"=> "0.15",
  105. "SKUHigh"=> "0.25"
  106. ],
  107. ]
  108. ]);
  109. return $response->json();
  110. }
  111. public function changePackage(){
  112. $packages=Package::where('delivery_number','<>',null)->where('logistic_id',null)->get();
  113. dd($packages);
  114. $packages=Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  115. $logistics=Logistic::get();
  116. $packages->each(function ($package)use($logistics){
  117. $logistics->each(function ($logistic)use($package){
  118. if ($package->WMSReflectPackage->CarrierID==$logistic->code){
  119. $package->logistic_id=$logistic->id;
  120. return;
  121. }
  122. });
  123. });
  124. return "OK";
  125. }
  126. public function tNull(){
  127. }
  128. public function deletePackageAuthority()
  129. {
  130. $authorities=Authority::where('name','like','%包裹信息%')->get();
  131. $authorities->each(function ($authority){
  132. $authority->delete();
  133. });
  134. }
  135. public function test1(){
  136. $waybills=Waybill::select('id','wms_bill_number')->get();
  137. foreach ($waybills as $waybill){
  138. $orders=WMSWaybillOrder::where('OrderNo',$waybill->wms_bill_number)->get();
  139. if (count($orders)>0){
  140. $warehouseWeight=0;
  141. $sign=false;
  142. foreach ($orders as $order){
  143. $warehouseWeight+=$order->Cubic;
  144. if ($order->Cubic==0)$sign=true;
  145. }
  146. if ($sign)unset($warehouseWeight);
  147. }
  148. $waybill=Waybill::find($waybill->id);
  149. if (isset($warehouseWeight)){
  150. if ($waybill){
  151. $waybill->warehouse_weight=$warehouseWeight;
  152. }
  153. }else{
  154. $waybill->warehouse_weight=null;
  155. $waybill->warehouse_weight_unit_id=null;
  156. }
  157. $waybill->update();
  158. }
  159. }
  160. public function test3()
  161. {
  162. $strs=["auibh","aopk","bikon"];
  163. if (!$strs[0])return "";
  164. $len=strlen($strs[0]);
  165. for ($i=1;$i<count($strs);$i++){
  166. if ($len<1)break;
  167. for ($j=0;$j<$len;$j++){
  168. if ($strs[$i][$j]!=$strs[0][$j]){
  169. if ($j==0)return "";
  170. break;
  171. }
  172. $sum=$j+1;
  173. }
  174. $len=isset($sum)?$sum:0;
  175. }
  176. return substr($strs[0],0,$len);
  177. }
  178. public function test4(){
  179. $s="{([{()()[]{}}])[{()()[}]{}}](){[]}";
  180. $map = [
  181. ")" => "(",
  182. "}" => "{",
  183. "]" => "[",
  184. ];
  185. $len = strlen($s);
  186. $stack = [];
  187. if ($len%2!=0)dd(false);
  188. //s中出现map的key则弹出,没有出现则入栈
  189. for ($i =0; $i<$len; $i++) {
  190. var_dump("data:".$s[$i]);
  191. if (isset($map[$s[$i]])){
  192. //s中出现map的key:如果能找到对应的map的值 (,{,[ 则说明有配对,则弹出
  193. if (isset($stack) && $stack[0] == $map[$s[$i]]) {
  194. array_shift($stack);
  195. } else { //仅找到后面的一部分,说明是不匹配的
  196. dd(false);
  197. }
  198. var_dump("value1:".$map[$s[$i]]);
  199. var_dump($stack);
  200. } else {
  201. array_unshift($stack, $s[$i]);
  202. var_dump("value2:".$s[$i]);
  203. var_dump($stack);
  204. }
  205. }
  206. if (count($stack) > 0) {
  207. dd(false);
  208. }
  209. dd(true);
  210. //利用栈的先进后出 一个正确的括号组对应都为1对1或N对N
  211. // 先进后出“([{”入栈,")]}"出栈,轮询到出栈元素去映射栈顶,符合出栈,不符合直接返回
  212. //依次轮询 如果映射正确那么最后栈为空栈 否则返回false
  213. }
  214. }