TestController.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 packageFromLog(Request $request){ //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  45. ini_set('max_execution_time',2500);
  46. ini_set('memory_limit','1526M');
  47. $uploaded=0;
  48. $count=DB::table('logs')->where('operation','like',"%PackageController::new_%" )
  49. ->where('created_at','>',"2020-06-08 15:46:00")
  50. ->where('created_at','<',"2020-06-08 15:47:00")
  51. ->where('type',"request_new_")
  52. ->count();
  53. $requests=DB::table('logs')->where('operation','like',"%PackageController::new_%" )
  54. ->where('created_at','>',"2020-06-08 15:46:00")
  55. ->where('created_at','<',"2020-06-08 15:47:00")
  56. ->where('type',"request_new_")
  57. ->get();
  58. $requests->each(function($request)use(&$uploaded){
  59. $requestJson=json_decode($request->description,true);
  60. $response = Zttp::withHeaders([ 'content-type' => 'application/json',
  61. ])->post('https://was.baoshi56.com/api/thirdPart/flux/package/new',
  62. $requestJson
  63. );
  64. if($response->json()&&$response->json()['response']&&$response->json()['response']['flag']=='Y')
  65. $uploaded+=1;
  66. });
  67. dd($uploaded.'/'.$count);
  68. }
  69. function t2(Request $request){ //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  70. $uploaded=0;
  71. $count=DB::table('logs')->where('operation','like',"%PackageController::new_%" )
  72. ->where('created_at','>',"2020-06-03 14:02:00")
  73. ->where('created_at','<',"2020-06-03 15:05:00")
  74. ->where('type',"request_new_")
  75. ->where('description','like',"%W200603000117%")
  76. ->count();
  77. $requests=DB::table('logs')->where('operation','like',"%PackageController::new_%" )
  78. ->where('created_at','>',"2020-06-03 14:02:00")
  79. ->where('created_at','<',"2020-06-03 15:05:00")
  80. ->where('description','like',"%W200603000117%")
  81. ->where('type',"request_new_")
  82. ->get();
  83. $requests->each(function($request)use(&$uploaded){
  84. $requestJson=json_decode($request->description,true);
  85. $response = Zttp::withHeaders([ 'content-type' => 'application/json',
  86. ])->post('https://was.baoshi56.com/api/thirdPart/flux/package/new',
  87. $requestJson
  88. );
  89. if($response->json()&&$response->json()['response']&&$response->json()['response']['flag']=='Y')
  90. $uploaded+=1;
  91. });
  92. dd($uploaded.'/'.$count);
  93. }
  94. function tj(Request $request){
  95. $waybills=Waybill::where('created_at','like','%2020-05-25%')->orWhere('created_at','like','%2020-05-30%')->get();
  96. $controller=(new WaybillController());
  97. $waybills->each(function ($waybill)use($controller){
  98. $controller->accomplishToWMS($waybill);
  99. });
  100. dd($waybills->count());
  101. }
  102. function injectJS(Request $request){
  103. $items=RejectedBillItem::whereHas('rejectedBill',function($query){
  104. return $query->where('id_owner',2);
  105. })->where('created_at','>','2019-12-23 18:11:00')->where('created_at','<','2019-12-24 11:25:00')->get();
  106. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  107. }
  108. public function tj2(Request $request)
  109. {
  110. $rejected = Rejected::find(10);
  111. $rejectedJianshang=new \App\Http\Controllers\api\jianshang\RejectedController();
  112. dd( $rejectedJianshang->sendRejected($rejected));
  113. }
  114. public function excelIt()
  115. {
  116. $excel=new ExcelController();
  117. return $excel->makeExcel();
  118. }
  119. public function featureIt()
  120. {
  121. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5,2500);
  122. }
  123. public function newSku()
  124. {
  125. $url='http://bswcs/api/sorting/flux/newSku';
  126. $response = Zttp::post($url, [
  127. 'request'=>[
  128. [
  129. "SKU"=> "1234567890",
  130. "NAME"=> "瑞士莲**巧克力",
  131. "Alternate_SKU1"=> "1122334455",
  132. "GrossWeight"=> "1.2",
  133. "Cube"=> "0.75",
  134. "SKULength"=> "0.25",
  135. "SKUWidth"=> "0.15",
  136. "SKUHigh"=> "0.05"
  137. ],
  138. [
  139. "SKU"=> "1234567892",
  140. "NAME"=> "跳跳饼",
  141. "Alternate_SKU1"=> "",
  142. "GrossWeight"=> "1.3",
  143. "Cube"=> "0.75",
  144. "SKULength"=> "0.25",
  145. "SKUWidth"=> "0.15",
  146. "SKUHigh"=> "0.25"
  147. ],
  148. ]
  149. ]);
  150. return $response->json();
  151. }
  152. public function changePackage(){
  153. $packages=Package::where('delivery_number','<>',null)->where('logistic_id',null)->get();
  154. dd($packages);
  155. $packages=Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  156. $logistics=Logistic::get();
  157. $packages->each(function ($package)use($logistics){
  158. $logistics->each(function ($logistic)use($package){
  159. if ($package->WMSReflectPackage->CarrierID==$logistic->code){
  160. $package->logistic_id=$logistic->id;
  161. return;
  162. }
  163. });
  164. });
  165. return "OK";
  166. }
  167. public function tNull(){
  168. }
  169. public function deletePackageAuthority()
  170. {
  171. $authorities=Authority::where('name','like','%包裹信息%')->get();
  172. $authorities->each(function ($authority){
  173. $authority->delete();
  174. });
  175. }
  176. public function test1(){
  177. $waybills=Waybill::select('id','wms_bill_number')->get();
  178. foreach ($waybills as $waybill){
  179. $orders=WMSWaybillOrder::where('OrderNo',$waybill->wms_bill_number)->get();
  180. if (count($orders)>0){
  181. $warehouseWeight=0;
  182. $sign=false;
  183. foreach ($orders as $order){
  184. $warehouseWeight+=$order->Cubic;
  185. if ($order->Cubic==0)$sign=true;
  186. }
  187. if ($sign)unset($warehouseWeight);
  188. }
  189. $waybill=Waybill::find($waybill->id);
  190. if (isset($warehouseWeight)){
  191. if ($waybill){
  192. $waybill->warehouse_weight=$warehouseWeight;
  193. }
  194. }else{
  195. $waybill->warehouse_weight=null;
  196. $waybill->warehouse_weight_unit_id=null;
  197. }
  198. $waybill->update();
  199. }
  200. }
  201. public function test3()
  202. {
  203. $strs=["auibh","aopk","bikon"];
  204. if (!$strs[0])return "";
  205. $len=strlen($strs[0]);
  206. for ($i=1;$i<count($strs);$i++){
  207. if ($len<1)break;
  208. for ($j=0;$j<$len;$j++){
  209. if ($strs[$i][$j]!=$strs[0][$j]){
  210. if ($j==0)return "";
  211. break;
  212. }
  213. $sum=$j+1;
  214. }
  215. $len=isset($sum)?$sum:0;
  216. }
  217. return substr($strs[0],0,$len);
  218. }
  219. public function test4(){
  220. $s="{([{()()[]{}}])[{()()[}]{}}](){[]}";
  221. $map = [
  222. ")" => "(",
  223. "}" => "{",
  224. "]" => "[",
  225. ];
  226. $len = strlen($s);
  227. $stack = [];
  228. if ($len%2!=0)dd(false);
  229. //s中出现map的key则弹出,没有出现则入栈
  230. for ($i =0; $i<$len; $i++) {
  231. var_dump("data:".$s[$i]);
  232. if (isset($map[$s[$i]])){
  233. //s中出现map的key:如果能找到对应的map的值 (,{,[ 则说明有配对,则弹出
  234. if (isset($stack) && $stack[0] == $map[$s[$i]]) {
  235. array_shift($stack);
  236. } else { //仅找到后面的一部分,说明是不匹配的
  237. dd(false);
  238. }
  239. var_dump("value1:".$map[$s[$i]]);
  240. var_dump($stack);
  241. } else {
  242. array_unshift($stack, $s[$i]);
  243. var_dump("value2:".$s[$i]);
  244. var_dump($stack);
  245. }
  246. }
  247. if (count($stack) > 0) {
  248. dd(false);
  249. }
  250. dd(true);
  251. //利用栈的先进后出 一个正确的括号组对应都为1对1或N对N
  252. // 先进后出“([{”入栈,")]}"出栈,轮询到出栈元素去映射栈顶,符合出栈,不符合直接返回
  253. //依次轮询 如果映射正确那么最后栈为空栈 否则返回false
  254. }
  255. }