TestController.php 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Commodity;
  5. use App\CommodityBarcode;
  6. use App\Customer;
  7. use App\Feature;
  8. use App\Log;
  9. use App\Logistic;
  10. use App\OracleActAllocationDetails;
  11. use App\OracleDOCOrderHeader;
  12. use App\OracleDocOrderPackingSummary;
  13. use App\OracleDOCWaveDetails;
  14. use App\Order;
  15. use App\OrderIssue;
  16. use App\OrderPackage;
  17. use App\Owner;
  18. use App\Package;
  19. use App\Process;
  20. use App\ProcessDaily;
  21. use App\ProcessStatistic;
  22. use App\RejectedBill;
  23. use App\RejectedBillItem;
  24. use App\Services\CacheService;
  25. use App\Services\common\DataHandlerService;
  26. use App\Services\InventoryCompareService;
  27. use App\Services\OracleDOCOrderHeaderService;
  28. use App\Services\OrderPackageService;
  29. use App\Services\OrderService;
  30. use App\Services\OrderTrackingOwnerService;
  31. use App\Services\OrderTrackingService;
  32. use App\Services\OwnerPriceOperationService;
  33. use App\Unit;
  34. use App\User;
  35. use App\Warehouse;
  36. use Carbon\Carbon;
  37. use Illuminate\Database\Eloquent\Builder;
  38. use Illuminate\Support\Facades\Auth;
  39. use Illuminate\Support\Facades\Cache;
  40. use Illuminate\Http\Request;
  41. use Illuminate\Support\Facades\DB;
  42. use Illuminate\Support\Facades\Hash;
  43. use Illuminate\Support\Str;
  44. use Ramsey\Collection\Collection;
  45. use Ramsey\Uuid\Uuid;
  46. use Zttp\Zttp;
  47. class TestController extends Controller
  48. {
  49. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  50. private $data = [];
  51. public function __construct()
  52. {
  53. $this->data["active_test"] = "active";
  54. }
  55. public function method(Request $request, $method)
  56. {
  57. return call_user_func([$this, $method], $request);
  58. }
  59. public function test4(){
  60. $a = DB::connection("oracle")->select(DB::raw("select * from INV_LOT_LOC_ID where sku in ('6936352541219',
  61. '6971503541571','A1BY1453R3S','A1BY1453R4S','A1FC0811C2090','AB11A4044C5100',
  62. 'AB11A4044D4090','AB11A4044E5100','AB11A4044M5090','AB11A4044M5100','AE02B3014C019120',
  63. 'AE02B3014E013100','AG01B1023C005110','AG01B1023F002090','AG08B3037C017120','AG08B3037G028110',
  64. 'AG08B3070R082100','AG14B3058J006002','AG22B1027R006120','AG22B1027R054120',
  65. 'AG22B1027R058100','AG22B3001R084090','AG22B3001R084100','AG22B3001R084110',
  66. 'AG22B3001R084130','AG22B3001R085100','AG22B3001R085140','AG22B3001R086120',
  67. 'AG22B3001R087090','AG22B3001R087110','AG22B3001R087120','AG22B3001R088090','AG22B3001R088100',
  68. 'AG22B3001R088110','AG22B3001R088120','AG22B3001R089100','AG22B3001R089110','AG22B3001R094090',
  69. 'AG22B3001R094100','AG22B3001R094110','AG22B3001R094130',
  70. 'AG22B3002A009090','AG22B3002A009100','AG22B3002A009110',
  71. 'AG22B3002A009120','AG22B3002A009130','AG22B3002A009150',
  72. 'AG22B3002R097100','AG22B3002R097110','AG22B3002R097120',
  73. 'AG22B3002R097130','AG22B3002R100090','AG22B3002R100100',
  74. 'AG22B3002R100110','AG22B3002R100120','AG22B3002R100140',
  75. 'AG22B3002R111120','AG22B3002R111130','AG22B3002R111140','AG22B3002R111150','AG22B3002R113120','AG22B3002R114090','AG22B3002R114100','AG22B3002R114110','AG22B3002R114120','AG22B3002R114130','AG22B3002R114140','AG22B3002R115090','AG22B3002R115120','AG22B3002R115130','AG22B3002R115140','AH08A4009D4100','AH08B4026B001110','AH08B4026B001120','AH08B4026D011100','AH08B4026G027090','AH08B4026G027120','AH08B4026G027130','AH08B4026G027140','AH08B4026G027150','AH08B4026H005110','AH08B4026H005150','AH08B4026J016090','AH08B4026J016100','AH08B4026J016110','AH08B4026J016120','AH08B4026J017100','AH08B4026J017110','AH08B4026J017120','AH08B4026J017150','AH08B4026M002100','AH08B4026M002110','AH08B4026M002120','AH08B4026M002130','AH08B4026M002150','AH08B4027B001090','AH08B4027G027150','AH08B4027M002090','AH08B4027M002150','AH08B4063B001090','AH08B4066D016140','AJ08B3035C017110','AJ08B3035C017120','AJ08B3035C017130','AJ08B3035J006090','AJ08B3035M002090','AJ08B3074R091090','AJ08B3074R091120','AK01B2001A004120','AK01B2001A004140','AK01B2001R045100','AK08B1018R012090','AK08B1018R012100','AP03B3041B002110','AP03B3041B002120','AP03B3041B002130','AP03B3041B002150','AP03B3041C021090','AP03B3041C021100','AP03B3041C021110','AP03B3041C021120','AP03B3041C021130','AP03B3041C021140','AP03B3041C021150','AP03B3041E020100','AP03B3041E020110','AP03B3041E020120','AP03B3041E020130','AP03B3041E020140','AP03B3041E020150','AP03B3041F016090','AP03B3041F016100','AP03B3041F016110','AP03B3041F016120','AP03B3041F016130','AP03B3041G031100','AP03B3041G031110','AP03B3041G031120','AP03B3041G031130','AP03B3041G031140','AP03B3041H004090','AP03B3041H004100','AP03B3041H004110','AP03B3041H004120','AP03B3041H004130','AP03B3041H004140','AP03B3041H004150','AP03B3041J009110','AP03B3041J009120','AP03B3041J009130','AP03B3041J009150','AP04A3014J1110','AP04A3015G1100','AP04A3015H2100','AP04A3015H2110','AP05A4021C6090','AP05A4021C6100','AP05A4021C6110','AP05A4021C6120','AP05A4021C6140','AP05A4021F4100','AP05A4021F4110','AP05A4021F4120','AP05A4021F4140','AP05A4021H4110','AP05A4021H4120','AP05A4021J3100','AP05A4021J3110','AP05A4027E8100','AP05A4084B4120','AP06A4029CB100','AP06A4029CB110','AP06A4029D5100','AP06A4029D5120','AP06A4102QN100','AP07A4022C6090','AP07B3040C021100','AP07B3040C021120','AP07B3040C021140','AP07B3040E020110','AP07B3040F016100','AP07B3040H004110','AP07B3040H004120','AP07B3040H004130','AP07B3040J009110','AP07B3040J009120','AVA00109P10','AVA00109P12','AY11A3034C1100','AY11A3035J2100','AY11B1044E002090','AY11B1044E002120','AY11B1044E002130','AY11B1044F005110','AY11B1044G007110','AY11B3024Q010090','AY11B3024Q010100','AY11B3024Q010110','AY11B3024Q010120','AY11B3024Q010130','AY11B3024Q010140','AY11B3024Q010150','AY11B3024Q017090','AY11B3024Q017100','AY11B3024Q017110','AY11B3024Q017140','AY11B3024Q017150','AY11B3024Q018100','AY11B3024Q018110','AY11B3024Q018120','AY11B3024Q018130','AY11B3076R073090','AY14A3054C1001','BB03B4010A013130','BB03B4010D014090','BB07B3030C019090','BB07B3030C019110','BB07B3030C019120','BB07B3030C019130','BB07B3030E008110','BB07B3030E008120','BB07B3030E015090','BB07B3030E015100','BB07B3030N006100','BB07B3030N006120','BB11A4048E5090','BB11B3029C019090','BB11B3029C019110','BB11B3029C019140','BB11B3029E008110','BB11B3029E008120','BB11B3029E015090','BB11B3029E015100','BB11B3029E016130','BB11B3029E016140','BB11B3029E016150','BB11B3029N006130','BB25B3068C019000','BB25B3068E008000','BB25B3068E015000','BB25B3068N006000','BD08B3048G014090','BD08B3048G014100','BD08B3048G014110','BD08B3048G014120','BD08B3048G014130','BD08B3048G014140','BD08B3049G014120','BD08B4031J007090','BD08B4031J007100','BD08B4031J007110','BD08B4031J007120','BD08B4031J007130','BE02A3020J6110','BF08A3005D3110','BF08A3005D3130','BF08A3005F4110','BG01B1026A001140','BG01B1026C004140','BG01B1026F001140','BG01B1026N003100','BG02B1003E003100','BG02B3008C015110','BG02B3008C015140','BG02B3008C015150','BG02B3008D008090','BG02B3008D008100','BG02B3008D008120','BG02B3008D013100','BG02B3008D013110','BG02B3008D013120','BG02B3008D013150','BG02B3008F010090','BG02B3008G025130','BG02B3008G025150','BG02B3013Q013110','BG02B3013Q016120','BG13B1008F005130','BG14B3059E017001','BG21B1017F004110','BH08B4025G003130','BH08B4025J020120','BH08B4029D011100','BH08B4029D011110','BH08B4029D011130','BH08B4029E021100','BH08B4029E021120','BH08B4029E021130','BH08B4029E021140','BH08B4029J016110','BH08B4038B004090','BH08B4038B004100','BH08B4038B004110','BH08B4038B004120','BH08B4038B004130','BH08B4038G003100','BH08B4038G003110','BH08B4038G003130','BH08B4038G003140','BH08B4038G003150','BH08B4038J020090','BH08B4038J020100','BH08B4038J020110','BH08B4038J020120','BI03B3032J013090','BI03B3032J013100','BI03B3032J013110','BI03B3032J013140','BI03B3032J014090','BI03B3032J014100','BI03B3032J014140','BI03B3032K005150','BI03B4011C024120','BI03B4011C024130','BI03B4011C024140','BI03B4011D018090','BI03B4011D018110','BI03B4011G037100','BI03B4011G037110','BI03B4011G037120','BI11A4046D5100','BI11B4001J019110','BI11B4002N008130','BI11B4003D011100','BI11B4003D011110','BI11B4003D011120','BI11B4003D011130','BI11B4003N009100','BI11B4003N009110','BI11B4003N009120','BI11B4003N009130','BI11B4004T001090','BI11B4004T001110','BI11B4004T001130','BI11B4004T001140','BI11B4006L011090','BI11B4006L011100','BI11B4006L011120','BI11B4008S030110','BI11B4008S030130','BJ03A3013H2120','BJ03B4042C023100','BJ03B4042C023110','BJ03B4042C023120','BJ03B4042C023140','BJ03B4042E023090','BJ03B4042E023110','BJ03B4042E023130','BJ03B4042G036100','BJ03B4042G036110','BJ03B4042G036120','BJ03B4042G036130','BJ08A4007D4090','BJ08A4007FE100','BJ08A4007FE130','BJ13B3080R070100','BK01B2006A006100','BK01B2006R043100','BL01B2013Q011110','BL18B2028N004130','BM25B2024R040000','BP03B3046C017110','BP03B3046C017120','BP03B3046C017140','BP03B3046C017150','BP03B3046E018090','BP03B3046E018100','BP03B3046E018110','BP03B3046E018120','BP03B3046E018130','BP03B3046E018140','BP03B3046E018150','BP03B3046G026100','BP03B3046G026120','BP03B3046G026130','BP03B3046G026140','BP03B3046N005090','BP03B3046N005100','BP03B3046N005110','BP03B3046N005120','BP03B3046N005150','BP03B4034D015090','BP03B4034D015100','BP03B4034D015110','BP03B4034D015130','BP03B4034D015140','BP03B4034M011130','BP05B3088B001110','BP05B3088C022100','BP05B3088C022120','BP05B3088C022130','BP05B3088D008090','BP05B3088D008110','BP05B3088D008130','BP05B3088D008140','BP05B3088D008150','BP05B3088G007110','BP05B3089S026110','BP05B3089S026120','BP05B3089S026130','BP05B4014B001100','BP05B4014B001110','BP05B4014B001130','BP05B4014D008100','BP05B4014D008110','BP05B4014D008120','BP05B4014D008130','BP05B4014D008150','BP05B4035B001090','BP05B4035B001100','BP05B4035B001110','BP05B4035B001120','BP05B4035B001130','BP05B4035B001140','BP05B4035B001150','BP05B4035D008090','BP05B4035D008100','BP05B4035D008110','BP05B4035D008120','BP05B4035D008130','BP05B4035D008150','BP06A4028E9110','BP06A4028FC100','BP06A4028FC110','BP06A4028FC120','BP06B4017D015090','BP06B4017D015100','BP07B4015C022110','BP07B4015D008100','BP07B4015D008120','BP07B4015D008130','BP07B4015D008140','BP07B4015G007110','BP07B4015G007120','BP07B4015G007140','BP07B4018F012090','BP08B4056D016090','BP08B4056D016120','BP08B4056G041100','BP08B4056G041120','BP08B4056G041150','BP08B4056J017090','BP08B4056J017120','BP08B4056J017130','BP08B4056J018090','BP08B4056J018110','BP08B4056J018130','BP08B4056J018150','BY11B1046Q002110','BY14B1072S007002','BY25B3027G019001','CC08B3051E021110','CC08B3051E021120','CC08B3051E021140','CC08B3051F011090','CC08B3051J010090','CC08B3051J010100','CC08B3051J010110','CC08B3051J010120','CC08B3051J010130','CC08B3051L008100','CC08B3051L008110','CC08B3051L008120','CC08B3051L008140','CC08B3051L008150','CE02A3024D1100','CF18A4015D6110','CI03B4007D011090','CI03B4007D011100','CI03B4007D011110','CI03B4007L010110','CJ03A4130R4100','CJ03A4130R5100','CJ03B3090E013090','CJ08A4124T4090','CJ13A4126CC100','CJ13A4126EF100','CK01B2086S012110','CK32B1019E004110','CL09B2021R036120','CN03A4033SA110','CN03A4033SA120','CN03A4034D4110','CN03A4034D4120','CN03A4034D4140','CP03B1048S003110','CP08B4032G036120','CP13A4086L4110','CP13A4086L4130','CY06A4105D5090','CY06A4105D5120','CY08B3039S021001','CY11A4003M1090','CY11A4003M1100','CY11B4037C017001','CY11B4037C017002','CY11B4037D011001','CY11B4037D011002','CY11B4037G039001','CY11B4037G039002','DAW08568P11','DAW08568P19','DB11A4044E5160','DD10B2042G018120','DG02B3013Q013160','DG22B3001R065160','DP03B3041J009155','DP03B3041J009160','DP03B3046N005155','DP05B3088B001155','DP05B3088B001160','DP05B3088G007155','DP05B4014B001160','DP05B4014D008160','EA25B1073A011000','EA25B1073A015000','EF08A3061K1110','EF08A3061L3110','EK01B2094C011110','EVA05127P19','EVA05136P10','EVA05136P13','EVA051B27P19','EVA051B36P12','EVA051B36P13','EVA05356P19','EVA05615P11','EVA05615P12','EVA05637P11','EVA05637P19','EVA05966P50',
  76. 'HP03B3041B002175','HP03B3041J009170','HP03B3041J009175',
  77. 'HP03B3046G026170','QTCM0055','QTCM0082')
  78. and CUSTOMERID = 'ALLBLU'
  79. and TRACEID like '1605%' and addtime > to_date('2020-11-20 00:00:00','yyyy-mm-dd hh24:mi:ss')
  80. and addtime < to_date('2020-11-21 13:41:00','yyyy-mm-dd hh24:mi:ss')"));
  81. $map = [];
  82. $o = [];
  83. foreach ($a as $b){
  84. if (isset($map[$b->lotnum."_".$b->locationid."_".$b->customerid."_".$b->sku])){
  85. $o[] = "'".$b->traceid."'";
  86. }else{
  87. $map[$b->lotnum."_".$b->locationid."_".$b->customerid."_".$b->sku] = $b->traceid;
  88. };
  89. }
  90. dd(implode(',',$o));
  91. $model1 = factory(Feature::class,2)->create([[
  92. "type" => "商品名称",
  93. "logic" => "包含",
  94. "describe"=>"衣服",
  95. ],[
  96. "type" => "订单类型",
  97. "logic" => "不包含",
  98. "describe"=>"创建",
  99. ]]);
  100. dd($model1);
  101. }
  102. public function test2(){
  103. $b = Logistic::query()->first();
  104. $a = OrderPackage::query()->with("order")->first();
  105. $a->bulk = 521;
  106. $a->save();
  107. if (!$a->order) $a->order = new Order();
  108. dd($a);
  109. if (!$a->order->logistic)$a->order->logistic = $b;
  110. dd($a->order->logistic);
  111. dd($a);
  112. $a->save();
  113. dd($a);
  114. }
  115. function packageFromLog(Request $request)
  116. { //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  117. ini_set('max_execution_time', 2500);
  118. ini_set('memory_limit', '1526M');
  119. $uploaded = 0;
  120. $count = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  121. ->where('created_at', '>', "2020-06-08 15:46:00")
  122. ->where('created_at', '<', "2020-06-08 15:47:00")
  123. ->where('type', "request_new_")
  124. ->count();
  125. $requests = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  126. ->where('created_at', '>', "2020-06-08 15:46:00")
  127. ->where('created_at', '<', "2020-06-08 15:47:00")
  128. ->where('type', "request_new_")
  129. ->get();
  130. $requests->each(function ($request) use (&$uploaded) {
  131. $requestJson = json_decode($request->description, true);
  132. $response = Zttp::withHeaders(['content-type' => 'application/json',
  133. ])->post('https://was.baoshi56.com/api/thirdPart/flux/package/new',
  134. $requestJson
  135. );
  136. if ($response->json() && $response->json()['response'] && $response->json()['response']['flag'] == 'Y')
  137. $uploaded += 1;
  138. });
  139. dd($uploaded . '/' . $count);
  140. }
  141. function wmsSql()
  142. {
  143. $owner=Owner::first();
  144. // $owner['phone_number'] ?? $owner['phone_number'] = '31115';
  145. // $owner->update();
  146. dd($owner);
  147. }
  148. function issues()
  149. {
  150. /** @var OrderPackageService $orderPackageService */
  151. $orderPackageService = app('OrderPackageService');
  152. $ids = [741, 739, 738, 736, 735, 733, 732, 731, 730, 729, 728, 725, 724, 723, 721, 720, 719, 718, 717, 715, 714, 713, 712, 711, 710, 705, 703, 702, 701, 700, 699, 698, 696, 694, 693, 692, 691, 690];
  153. $orderIssues = OrderIssue::query()->whereIn('id', $ids)->get();
  154. $order_ids = data_get($orderIssues, '*.order_id');
  155. $orders = Order::query()->whereIn('id', $order_ids)->get();
  156. foreach ($orders as $item) {
  157. $orderPackageService->createdByOrder($item);
  158. }
  159. }
  160. function t2(Request $request)
  161. { //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  162. $inventoryCompareService = new InventoryCompareService();
  163. echo ($inventoryCompareService)->getCreatingMissionCode('安桥主品');
  164. echo ($inventoryCompareService)->getCreatingMissionCode('安桥主品');
  165. echo ($inventoryCompareService)->getCreatingMissionCode('安桥主品');
  166. echo ($inventoryCompareService)->getCreatingMissionCode('安桥主品');
  167. }
  168. function tlog(Request $request)
  169. {
  170. app('LogService')->log(__METHOD__,'cczdelme'.__FUNCTION__,json_encode($request->all()),null);
  171. }
  172. function setCache(Request $request)
  173. {
  174. $today = now();
  175. Cache::put('storedTest', $today);
  176. return "cacheing:'$today'<script>localStorage.setItem('storedTest','{$today}')</script>";
  177. }
  178. function getCache(Request $request)
  179. {
  180. $cache = Cache::get('storedTest');
  181. return "cacheing get:'$cache'<script>document.write('<br>localStorage:'+localStorage.getItem('storedTest'))</script>";
  182. }
  183. function t1(Request $request)
  184. {
  185. {
  186. $username = config('database.connections.oracle.username');
  187. $password = config('database.connections.oracle.password');
  188. $host = config('database.connections.oracle.host');
  189. $service_name = config('database.connections.oracle.service_name');
  190. $conn = oci_connect($username, $password, $host . '/' . $service_name); //连接oracle数据库
  191. $IN_WarehouseID = '';
  192. $IN_TraceID = '';
  193. $IN_WavenNo = '';
  194. $IN_UserID = '';
  195. $IN_Language = '';
  196. $OUT_Return_Code = '';
  197. $sql_sp = "begin SPCUS_EDI_WCS001(:IN_WarehouseID,:IN_Process_Action_C,:IN_Process_By_C,
  198. :IN_WaveNO_C,:IN_OrderNO_C,:IN_OrderLineNO_C,:IN_AllocationDetailsID,:IN_Language,:IN_UserID,:OUT_Return_Code); end;";
  199. $stmt = oci_parse($conn, $sql_sp);
  200. oci_bind_by_name($stmt, ':IN_Warehouse', $IN_WarehouseID);
  201. oci_bind_by_name($stmt, ':IN_TraceID', $IN_TraceID);
  202. oci_bind_by_name($stmt, ':IN_WavenNo', $IN_WavenNo);
  203. oci_bind_by_name($stmt, ':IN_Language', $IN_Language);
  204. oci_bind_by_name($stmt, ':IN_UserID', $IN_UserID);
  205. oci_bind_by_name($stmt, ':OUT_Return_Code', $OUT_Return_Code);
  206. return oci_execute($stmt);
  207. }
  208. }
  209. function packageT(Request $request)
  210. {
  211. $package = Package::where('created_at', '<', '2020-07-08')->whereNotNull('logistic_number')->first();
  212. $package->fetchLogistic();
  213. }
  214. function injectJS(Request $request)
  215. {
  216. $items = RejectedBillItem::whereHas('rejectedBill', function ($query) {
  217. return $query->where('id_owner', 2);
  218. })->where('created_at', '>', '2019-12-23 18:11:00')->where('created_at', '<', '2019-12-24 11:25:00')->get();
  219. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  220. }
  221. public function tj2(Request $request)
  222. {
  223. $numbersesOfBatch = OracleDOCWaveDetails::select('picktotraceid as logistic_number', 'act_allocation_details.orderno')->where('doc_wave_details.waveno', 'W190630000042')
  224. ->leftJoin('act_allocation_details', 'doc_wave_details.orderno', 'act_allocation_details.orderno')->get();
  225. $oneIdxAsrsReceive = OracleDocOrderPackingSummary::where('traceid', $numbersesOfBatch[0]['logistic_number'])->first();
  226. if (!$oneIdxAsrsReceive) {
  227. $inserts = '';
  228. $values = [];
  229. foreach ($numbersesOfBatch as $numbers) {
  230. $inserts .= " into doc_order_packing_summary (traceid,orderno,grossweight,addwho,addtime,editwho,edittime)values(?,?,?,?,?,?,?) ";
  231. $values[] = $numbers['logistic_number'] ?? '';
  232. $values[] = $numbers['orderno'] ?? '';
  233. $values[] = 12;
  234. $values[] = 'WAS';
  235. $values[] = Carbon::now();
  236. $values[] = 'WAS';
  237. $values[] = Carbon::now();
  238. }
  239. DB::connection('oracle')->insert("insert all {$inserts} select * from dual", $values);
  240. } else {
  241. $logisticNumbers = $numbersesOfBatch->map(function ($numbers) {
  242. return $numbers['logistic_number'];
  243. });
  244. OracleDocOrderPackingSummary::whereIn('traceid', $logisticNumbers)->update(['grossweight' => 32]);
  245. }
  246. }
  247. public function delme()
  248. {
  249. $fields = [
  250. 'doc_order_header.userdefine1',
  251. 'doc_order_header.userdefine2',
  252. 'doc_order_header.SOReference5',
  253. 'doc_order_header.waveno',
  254. 'doc_order_header.orderno',
  255. 'doc_order_header.customerid',
  256. 'doc_order_header.Consigneename'
  257. ];
  258. if ('') {
  259. $resultOracleObj = OracleDOCOrderHeader::select($fields)->where('orderno', 'SO200603004708');
  260. } else {
  261. $resultOracleObj = OracleActAllocationDetails::select($fields);
  262. $resultOracleObj->where('picktotraceid', '546152742096');
  263. $resultOracleObj->leftJoin('DOC_Order_Header', 'act_allocation_details.orderno', 'doc_order_header.orderno');
  264. }
  265. $_temOracleInfo = $resultOracleObj->first();
  266. dd($_temOracleInfo);
  267. }
  268. public function mergerPackageData()
  269. {
  270. ini_set('max_execution_time', 36000);
  271. ini_set('memory_limit', '1526M');
  272. $number = 3000;
  273. $start_at = 1;
  274. $sum = Package::query()->where('id', '>', $start_at)->count();
  275. $len = ceil($sum / $number);
  276. $id = $start_at;
  277. for ($i = 1; $i <= $len; $i++) {
  278. $packages = Package::query()->orderBy('id')->where('id', '>', $id)->limit($number)->get();
  279. $error = [];
  280. foreach ($packages as $package) {
  281. /** @var $service OrderPackageService */
  282. $service = app('OrderPackageService');
  283. $orderPackage = $service->firstOrCreate($package->logistic_number,
  284. ['batch_number' => $package->batch_number,
  285. 'batch_rule' => $package->batch_rule,
  286. 'bulk' => $package->bulk,
  287. 'weight' => $package->weight,
  288. 'length' => $package->length,
  289. 'width' => $package->width,
  290. 'height' => $package->height,
  291. 'paper_box_id' => $package->paper_box_id,
  292. 'measuring_machine_id' => $package->measuring_machine_id,
  293. 'weighed_at' => $package->weighed_at,
  294. 'status' => $package->status]);
  295. if (!$orderPackage) array_push($error, $package->id);
  296. }
  297. app('LogService')->log(__METHOD__, "同步时WMS中未找到这些订单", json_encode($error));
  298. $id = $packages[count($packages) - 1]->id;
  299. echo $number . ' a bunch done at:' . now()->toFormattedDateString() . '<br>';
  300. }
  301. }
  302. public function excelIt()
  303. {
  304. $excel = new ExcelController();
  305. return $excel->makeExcel();
  306. }
  307. public function featureIt()
  308. {
  309. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5, 2500);
  310. }
  311. public function newSku()
  312. {
  313. $url = 'http://bswcs/api/sorting/flux/newSku';
  314. $response = Zttp::post($url, [
  315. 'request' => [
  316. [
  317. "SKU" => "1234567890",
  318. "NAME" => "瑞士莲**巧克力",
  319. "Alternate_SKU1" => "1122334455",
  320. "GrossWeight" => "1.2",
  321. "Cube" => "0.75",
  322. "SKULength" => "0.25",
  323. "SKUWidth" => "0.15",
  324. "SKUHigh" => "0.05"
  325. ],
  326. [
  327. "SKU" => "1234567892",
  328. "NAME" => "跳跳饼",
  329. "Alternate_SKU1" => "",
  330. "GrossWeight" => "1.3",
  331. "Cube" => "0.75",
  332. "SKULength" => "0.25",
  333. "SKUWidth" => "0.15",
  334. "SKUHigh" => "0.25"
  335. ],
  336. ]
  337. ]);
  338. return $response->json();
  339. }
  340. public function changePackage()
  341. {
  342. $packages = Package::where('delivery_number', '<>', null)->where('logistic_id', null)->get();
  343. $packages = Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  344. $logistics = Logistic::get();
  345. $packages->each(function ($package) use ($logistics) {
  346. $logistics->each(function ($logistic) use ($package) {
  347. if ($package->WMSReflectPackage->CarrierID == $logistic->code) {
  348. $package->logistic_id = $logistic->id;
  349. return;
  350. }
  351. });
  352. });
  353. return "OK";
  354. }
  355. public function tNull()
  356. {
  357. User::query()->get()->toArray();
  358. User::query()->get()->toJson();
  359. }
  360. public function deletePackageAuthority()
  361. {
  362. $authorities = Authority::where('name', 'like', '%包裹信息%')->get();
  363. $authorities->each(function ($authority) {
  364. $authority->delete();
  365. });
  366. }
  367. function test()
  368. {
  369. $ids = [];
  370. $logs = Log::query()->select('description')->where('type', '同步时WMS中未找到这些订单')->get();
  371. foreach ($logs as $log) {
  372. $arr = [];
  373. eval("\$arr = " . $log->description . '; ');
  374. if (count($arr) < 1) continue;
  375. $ids = array_merge($ids, $arr);
  376. }
  377. $ids = array_unique($ids);
  378. $error = [];
  379. foreach ($ids as $id) {
  380. $package = Package::query()->find($id);
  381. /** @var OrderPackageService */
  382. $orderPackage = app('OrderPackageService')->firstOrCreate($package->logistic_number,
  383. ['batch_number' => $package->batch_number,
  384. 'batch_rule' => $package->batch_rule,
  385. 'bulk' => $package->bulk,
  386. 'weight' => $package->weight,
  387. 'length' => $package->length,
  388. 'width' => $package->width,
  389. 'height' => $package->height,
  390. 'paper_box_id' => $package->paper_box_id,
  391. 'measuring_machine_id' => $package->measuring_machine_id,
  392. 'weighed_at' => $package->weighed_at,
  393. 'status' => $package->status]);
  394. if (!$orderPackage) array_push($error, $package->id);
  395. }
  396. if (count($error) > 0) app('LogService')->log(__METHOD__, "同步时WMS中未找到这些订单_two", json_encode($error));
  397. }
  398. function test1()
  399. {
  400. $statistics = ProcessStatistic::query()->whereNull('revenue')->get();
  401. $id = array_column($statistics->toArray(), 'process_id');
  402. $processes = Process::query()->where(function (Builder $query) {
  403. $query->where('status', '待交接')->orWhere('status', '交接完成');
  404. })->whereIn('id', $id)->get();
  405. $sign_end = true;
  406. foreach ($processes as $process) {
  407. if (count($process->processDailies) > 0) {
  408. $completed_amount = 0;
  409. foreach ($process->processDailies as $processDaily) {
  410. $completed_amount = $completed_amount + ($processDaily->output);
  411. }
  412. $process->completed_amount = $completed_amount;
  413. }
  414. //统计:
  415. $revenue = ($process->unit_price) * ($process->completed_amount); //收入合计
  416. $processDailies = ProcessDaily::with('processDailyParticipants')->where('process_id', $process->id)->where('output', '>', 0)->get();
  417. $duration_days = count($processDailies); //完成天数
  418. $duration_man_hours = 0; //总工时
  419. $total_cost = 0; //合计成本
  420. foreach ($processDailies as $processDailyOne) {
  421. foreach ($processDailyOne->processDailyParticipants as $processDailyParticipant) {
  422. if (!$processDailyParticipant->unit_price && !$processDailyParticipant->hour_price) continue;
  423. $duration_man_hours += $processDailyParticipant->hour_count;
  424. if ($processDailyParticipant->unit_count) {
  425. $total_cost += ($processDailyParticipant->unit_count) * ($processDailyParticipant->unit_price);
  426. continue;
  427. }
  428. $total_cost += ($processDailyParticipant->hour_count) * ($processDailyParticipant->hour_price);
  429. }
  430. };
  431. $processStatistic = ProcessStatistic::query()->find($process->id);
  432. $processStatistic->revenue = $revenue;
  433. $processStatistic->duration_days = $duration_days;
  434. $processStatistic->duration_man_hours = $duration_man_hours;
  435. if ($sign_end) $processStatistic->ended_at = date('Y-m-d H:i:s');
  436. if (!$revenue || !$total_cost) {
  437. $processStatistic->update();
  438. continue;
  439. }
  440. $gross_profit = $revenue - $total_cost; //毛利润
  441. if ($gross_profit != 0) $gross_profit_rate = $gross_profit / $revenue; //毛利率;
  442. else $gross_profit_rate = 0;
  443. $processStatistic->total_cost = $total_cost;
  444. $processStatistic->gross_profit = $gross_profit;
  445. $processStatistic->gross_profit_rate = $gross_profit_rate;
  446. $processStatistic->update();
  447. app('LogService')->log(__METHOD__, "修改二次加工单统计单_" . __FUNCTION__, json_encode($processStatistic), Auth::user()['id']);
  448. }
  449. }
  450. public function test5(){
  451. ini_set('max_execution_time',2500);
  452. ini_set('memory_limit','1526M');
  453. //清理冗余条码
  454. // $this->cleanBarcode();
  455. while(true){
  456. $toDay = Carbon::now();
  457. $skus = DB::select(DB::raw('select sku from commodities group by sku,owner_id having count(*)>1 limit 500 '));
  458. $skus = array_column($skus,'sku');
  459. $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku',$skus)->get();
  460. if (count($commodities) < 1)return "SUCCESS";
  461. $commodityMap = [];
  462. $commodityDel = [];
  463. $commodityTag = [];
  464. $commodityBar = [];
  465. $createBarcodes = [];
  466. $logs = [];
  467. foreach ($commodities as $commodity){
  468. if ($commodityMap[$commodity->sku.'_'.$commodity->owner_id] ?? false){
  469. $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
  470. $logs[] = [
  471. 'id' => $commodity->id,
  472. 'sku' => $commodity->sku,
  473. 'owner_id'=>$commodity->owner_id,
  474. 'code'=>$codes,
  475. ];
  476. $commodityDel[] = $commodity->id;
  477. $commodityTag[$commodity->id] = $commodityMap[$commodity->sku.'_'.$commodity->owner_id];
  478. $arr = array_diff($codes,$commodityBar[$commodity->sku.'_'.$commodity->owner_id]);
  479. foreach ($arr as $code){
  480. if (!$code)continue;
  481. $createBarcodes[] = [
  482. 'code' => $code,
  483. 'commodity_id' => $commodityMap[$commodity->sku.'_'.$commodity->owner_id],
  484. 'created_at' => $toDay,
  485. ];
  486. }
  487. }else{
  488. $commodityMap[$commodity->sku.'_'.$commodity->owner_id] = $commodity->id;
  489. $commodityBar[$commodity->sku.'_'.$commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
  490. }
  491. }
  492. dd($commodityMap,$commodityDel,$commodityTag);
  493. app('LogService')->log(__METHOD__,'清理商品',json_encode($logs,JSON_UNESCAPED_UNICODE));
  494. app('LogService')->log(__METHOD__,'重新分配商品',json_encode($commodityTag,JSON_UNESCAPED_UNICODE));
  495. app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存盘点任务
  496. app('InventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
  497. app('InventoryDailyLogService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存每日记录
  498. app('ProcessesContentService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新二次加工内容单
  499. app('StoreCheckingReceiveItemService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新入库盘收一体
  500. app('OrderPackageCommoditiesService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新订单商品
  501. app('LogService')->log(__METHOD__,'删除商品与对应条码',json_encode($commodityDel,JSON_UNESCAPED_UNICODE));
  502. CommodityBarcode::query()->whereIn('commodity_id',$commodityDel)->delete();
  503. Commodity::destroy($commodityDel);
  504. }
  505. }
  506. private function cleanBarcode(){
  507. $logCommodityBarcodes = CommodityBarcode::query()->where('code', "")->get();
  508. if (count($logCommodityBarcodes) > 0) app('LogService')->log(__METHOD__, "纠正商品-删除空条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
  509. CommodityBarcode::query()->where('code', "")->delete();
  510. $barcodes = DB::select(DB::raw('select * from commodity_barcodes c
  511. where (c.code,c.commodity_id) in (select code,commodity_id from commodity_barcodes group by code,commodity_id having count(*) > 1) order by commodity_id'));
  512. $barcodeMap = [];
  513. $barcodeDelete = [];
  514. foreach ($barcodes as $barcode) {
  515. if (isset($barcodeMap[$barcode->code . '_' . $barcode->commodity_id])) $barcodeDelete[] = $barcode->id;
  516. else $barcodeMap[$barcode->code . '_' . $barcode->commodity_id] = $barcode->id;
  517. }
  518. $logCommodityBarcodes = CommodityBarcode::query()->whereIn('id', $barcodeDelete)->get();
  519. if (count($logCommodityBarcodes) > 0) app('LogService')->log(__METHOD__, "纠正商品-删除重复条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
  520. CommodityBarcode::destroy($barcodeDelete);
  521. }
  522. public function correctCommodity()
  523. {
  524. ini_set('max_execution_time', 2500);
  525. ini_set('memory_limit', '1526M');
  526. //清理冗余条码
  527. //$this->cleanBarcode();
  528. //获取重复条码
  529. $commodities = DB::select(DB::raw('select commodities.name,commodities.sku,commodities.owner_id,commodity_barcodes.id as barcode_id,commodity_barcodes.code as barcode_code,commodity_barcodes.commodity_id from commodities LEFT JOIN commodity_barcodes on commodities.id = commodity_barcodes.commodity_id
  530. where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owner_id,commodity_barcodes.code from commodities LEFT JOIN commodity_barcodes on commodities.id = commodity_barcodes.commodity_id group by commodities.owner_id,commodity_barcodes.code having count(*) > 1) order by commodities.owner_id,commodity_barcodes.code'));
  531. //对比map池
  532. $commodityMap = [];
  533. //需要删除项
  534. $commodityDelete = [];
  535. foreach ($commodities as $index => $commodity) {
  536. $commodity->barcode_code = strtolower(trim($commodity->barcode_code));
  537. //货主+条码 为唯一key值 设想正常数据下同货主不应该有同条码
  538. $key = $commodity->owner_id . '_' . $commodity->barcode_code;
  539. //使用map池对比为重复数据
  540. if (isset($commodityMap[$key])) {
  541. //获取下标指针指向的源数据
  542. $c = $commodities[$commodityMap[$key]];
  543. //源数据不符合规范,当前数据替换掉它
  544. if (($c->sku == null || $c->sku == "") && ($commodity->sku != null && $commodity->sku != "")) {
  545. $commodityDelete[] = $commodityMap[$key];
  546. $commodityMap[$key] = $index;
  547. } else {
  548. //当前数据比源数据更符合预期,替换掉
  549. if (($c->sku == $commodity->sku) && (strlen($c->name) < strlen($commodity->name))) {
  550. $commodityDelete[] = $commodityMap[$key];
  551. $commodityMap[$key] = $index;
  552. } else {
  553. //扔进处理池
  554. $commodityDelete[] = $index;
  555. }
  556. }
  557. //第一次出现的新数据,val为下标,当作指针指向源数据
  558. } else $commodityMap[$key] = $index;
  559. }
  560. $createBarcodes = []; //批量生成条码
  561. $deleteCommodities = []; //批量删除商品及商品条码
  562. $updateCommodities = [];
  563. foreach ($commodityDelete as $index) {
  564. //获取到被处理数据 与 目标数据
  565. $del = $commodities[$index];
  566. $target = $commodities[$commodityMap[$del->owner_id . '_' . $del->barcode_code]];
  567. //记录ID删除商品与条码
  568. $deleteCommodities[] = $del->commodity_id;
  569. //有效条码合并
  570. $barcodes = DB::select(DB::raw("select * from
  571. (select * from commodity_barcodes where commodity_id = " . $del->commodity_id . ")a
  572. where (select count(1) as num from commodity_barcodes b
  573. where commodity_id = " . $target->commodity_id . " and b.code = a.code) = 0"));
  574. if (count($barcodes) > 0) {
  575. foreach ($barcodes as $barcode) {
  576. $createBarcodes[] = ['code' => $barcode->code, 'commodity_id' => $target->commodity_id];
  577. }
  578. }
  579. $updateCommodities[$del->commodity_id] = $target->commodity_id;
  580. }
  581. if (count($updateCommodities) > 0){
  582. app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存盘点任务
  583. app('InventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
  584. app('InventoryDailyLogService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存每日记录
  585. app('ProcessesContentService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新二次加工内容单
  586. app('StoreCheckingReceiveItemService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新入库盘收一体
  587. app('OrderPackageCommoditiesService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新订单商品
  588. }
  589. if (count($createBarcodes) > 0) app('LogService')->log(__METHOD__, "纠正商品-录入合并条码", json_encode(data_get($createBarcodes, '*.id'), JSON_UNESCAPED_UNICODE));
  590. CommodityBarcode::query()->insert($createBarcodes);
  591. $logCommodityBarcodes = CommodityBarcode::query()->whereIn('commodity_id', $deleteCommodities)->get();
  592. if (count($logCommodityBarcodes) > 0) app('LogService')->log(__METHOD__, "纠正商品-删除无用商品条码", json_encode(data_get($logCommodityBarcodes, '*.id'), JSON_UNESCAPED_UNICODE));
  593. CommodityBarcode::query()->whereIn('commodity_id', $deleteCommodities)->delete();
  594. // $logCommodities = Commodity::query()->whereIn('id',$deleteCommodities)->get();
  595. if (count($deleteCommodities) > 0) app('LogService')->log(__METHOD__, "纠正商品-删除无用商品", json_encode($deleteCommodities, JSON_UNESCAPED_UNICODE));
  596. Commodity::destroy($deleteCommodities);
  597. }
  598. /*1*/
  599. function socket(Request $request)
  600. {/**/
  601. $a = microtime(true);
  602. error_reporting(E_ALL);
  603. set_time_limit(0);
  604. echo "<h2>TCP/IP Connection</h2>\n";
  605. $port = 8091;
  606. $ip = "127.0.0.1";
  607. /*
  608. +-------------------------------
  609. * @socket连接整个过程
  610. +-------------------------------
  611. * @socket_create
  612. * @socket_connect
  613. * @socket_write
  614. * @socket_read
  615. * @socket_close
  616. +--------------------------------
  617. */
  618. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  619. if ($socket < 0) {
  620. echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
  621. } else {
  622. echo "OK.\n";
  623. }
  624. echo "试图连接 '$ip' 端口 '$port'...\n";
  625. $result = socket_connect($socket, $ip, $port);
  626. if ($result < 0) {
  627. echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
  628. } else {
  629. echo "连接OK\n";
  630. }
  631. $b = microtime(true);
  632. echo "连接耗时:" . ($b - $a) . "\n";
  633. $content = Commodity::query()->limit(200)->get();
  634. $c = microtime(true);
  635. echo "查询数据耗时:" . ($c - $b) . "\n";
  636. $content->toArray();
  637. /*$chunks=$content->chunk(100);
  638. foreach ($chunks as $chunk){
  639. $chunk->toJson();
  640. var_dump(mb_strlen($chunk->toJson()));
  641. //socket_write($socket, $chunk->toJson(), mb_strlen($chunk->toJson()));
  642. }*/
  643. $d = microtime(true);
  644. echo "发送数据耗时:" . ($d - $c) . "\n";
  645. socket_close($socket);
  646. $e = microtime(true);
  647. echo "共耗时:" . ($e - $a) . "\n";
  648. }
  649. public function test3()
  650. {
  651. /** @var OrderTrackingService $orderTrackingService */
  652. $orderTrackingService = app('OrderTrackingService');
  653. /** @var OrderService $orderService */
  654. $orderService = app(OrderService::class);
  655. $owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
  656. $startDate = \Illuminate\Support\Carbon::parse('2020-10-28 00:00:00')->toDateTimeString();
  657. $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
  658. ->where('addTime', '>=', $startDate)
  659. ->whereIn('customerID', data_get($owners, '*.code'))
  660. ->get();
  661. $orderService->updateByWmsOrders($orderHeaders);
  662. $orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
  663. }
  664. public function test11()
  665. {
  666. $rejectedBills = RejectedBill::query()
  667. ->where('created_at','>=','2020-11-10 18:00:22')
  668. ->where('created_at','<=','2020-11-11 00:00:00')
  669. ->get();
  670. $update = [['id','logistic_number']];
  671. $rejectedBills->each(function ($rejectedBill)use(&$update){
  672. if($rejectedBill->logistic_number == '原单退回'){
  673. $details = OracleActAllocationDetails::query()->with('oracleDocOrderHeader')->whereHas('oracleDocOrderHeader',function($query)use($rejectedBill){
  674. $query->where('SOReference1',$rejectedBill->order_number);
  675. })->get()->groupBy('picktotraceid');
  676. if($details->count() == 1){
  677. $update[] = ['id'=> $rejectedBill->id ,'logistic_number'=>$rejectedBill->logistic_number_return];
  678. }
  679. }
  680. });
  681. app('RejectedBillService')->batchUpdate($update);
  682. }
  683. public function output()
  684. {
  685. /** @var CacheService $cacheService */
  686. $cacheService = app('CacheService');
  687. $authorities=$cacheService->getOrExecute('userxx',function (){
  688. return Authority::with('roles')->get();
  689. });
  690. dd($authorities);
  691. }
  692. public function output2()
  693. {
  694. dump(Cache::get('aa'));
  695. Cache::put('aa', '2223', 5);
  696. }
  697. public function usage()
  698. {
  699. dd(Request::all());
  700. }
  701. public function relating()
  702. {
  703. dd(OrderIssue::query()->where('id',182)->paginate()->total());
  704. }
  705. public function updateOrdersWarehouse()
  706. {
  707. /**
  708. * @var DataHandlerService $dataHandlerService
  709. * @var OrderService $orderService
  710. */
  711. $dataHandlerService = app(DataHandlerService::class);
  712. $orderService = app(OrderService::class);
  713. $page = 500;
  714. $count = Order::query()->count();
  715. $warehouse = Warehouse::query()->get();
  716. $warehouse_map = $dataHandlerService->dataHeader(['code'], $warehouse);
  717. for ($i = 0; $i < $count; $i += $page) {
  718. $min = $i;$max = $i + $page;
  719. $orders = Order::query()->where('id', '>=', $min)->where('id', '<=', $max)->get();
  720. $orderNos = array_diff(array_unique(data_get($orders, '*.code')), ['', ' ', '*', null]);
  721. if (count($orderNos)==0) continue;
  722. /** @var Collection $orderHeaders */
  723. $orderHeaders = OracleDOCOrderHeader::query()->whereIn('orderno', $orderNos)->get();
  724. if ($orderHeaders->count() == 0) continue;
  725. $orderHeader_map = $dataHandlerService->dataHeader(['orderno'], $orderHeaders);
  726. $update_params = [];
  727. $update_params[] = ['id', 'warehouse_id'];
  728. foreach ($orders as $order) {
  729. $orderHeader = $dataHandlerService->getKeyValue(['orderno' => $order->code], $orderHeader_map);
  730. if ($orderHeader == null) continue;
  731. $warehouse = $dataHandlerService->getKeyValue(['code' => $orderHeader->warehouseid], $warehouse_map);
  732. if ($warehouse == null) continue;
  733. $update_params[] = [
  734. 'id' => $order->id,
  735. 'warehouse_id' => $warehouse->id
  736. ];
  737. }
  738. $orderService->batchUpdate($update_params);
  739. unset($orders, $orderHeaders, $update_params);
  740. }
  741. unset($warehouse);
  742. }
  743. public function syncSendOrder()
  744. {
  745. $order_issues = OrderIssue::query()->whereNotNull('second_client_no')->get();
  746. $client_nos = data_get($order_issues,'*.second_client_no');
  747. $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
  748. ->whereIn('SOReference1',$client_nos)
  749. ->with(['oracleBASCustomer'=>function($query){
  750. $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
  751. },'oracleDOCOrderDetails'=>function($query){
  752. $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
  753. }, 'actAllocationDetails'=>function($query){
  754. $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID');
  755. },'oracleBASCode'=>function($query){
  756. $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
  757. }])
  758. ->get();
  759. $service = app('OrderIssueService');
  760. $service->updateByWmsOrders($orderHeaders);
  761. }
  762. public function changeOrderIssue()
  763. {
  764. // $ids = [5419,5404,5402,5401,5400,5398,5397,5395,5388,5387,5383,5382,5379,5373,5370,5353,5329,5327];
  765. // OrderIssue::query()->whereIn('id',$ids)->update(['is_new_rejecting'=>'无','rejecting_status'=>'未退回']);
  766. }
  767. }