TestController.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\Events\CancelOrder;
  6. use App\Events\WmsReceiveNewEvent;
  7. use App\Http\Controllers\Api\thirdPart\flux\WaybillController;
  8. use App\Logistic;
  9. use App\OracleActTransactionLog;
  10. use App\Order;
  11. use App\Package;
  12. use App\Rejected;
  13. use App\RejectedBill;
  14. use App\RejectedBillItem;
  15. use App\Unit;
  16. use App\User;
  17. use App\UserToken;
  18. use App\UserWorkgroup;
  19. use App\Waybill;
  20. use App\OraccleBasCustomer;
  21. use App\WMSReflectReceive;
  22. use Carbon\Carbon;
  23. use Endroid\QrCode\QrCode;
  24. use Endroid\QrCode\Response\QrCodeResponse;
  25. use Illuminate\Database\Query\JoinClause;
  26. use Illuminate\Http\Request;
  27. use Illuminate\Support\Facades\DB;
  28. use function PHPSTORM_META\map;
  29. use Zttp\Zttp;
  30. class TestController extends Controller
  31. {
  32. private $data=[];
  33. public function __construct()
  34. {
  35. $this->data["active_test"]="active";
  36. }
  37. public function method(Request $request,$method)
  38. {
  39. return call_user_func([$this, $method],$request);
  40. }
  41. function t1(Request $request){ //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  42. $waybills=Waybill::all();
  43. $controller=(new WaybillController());
  44. $waybills->each(function ($waybill)use($controller){
  45. $controller->accomplishToWMS($waybill);
  46. });
  47. }
  48. function tj(Request $request){
  49. $a=11;
  50. try{
  51. $b=22;
  52. }catch (\Exception $exception){
  53. $this->log(__METHOD__,'Exception_'.__FUNCTION__,'请求异常:'.$exception->getMessage(),null);
  54. return ['result'=>'false'];
  55. }
  56. echo $a+$b;
  57. }
  58. function injectJS(Request $request){
  59. $items=RejectedBillItem::whereHas('rejectedBill',function($query){
  60. return $query->where('id_owner',2);
  61. })->where('created_at','>','2019-12-23 18:11:00')->where('created_at','<','2019-12-24 11:25:00')->get();
  62. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  63. }
  64. public function tj2(Request $request)
  65. {
  66. $rejected = Rejected::find(10);
  67. $rejectedJianshang=new \App\Http\Controllers\api\jianshang\RejectedController();
  68. dd( $rejectedJianshang->sendRejected($rejected));
  69. }
  70. public function excelIt()
  71. {
  72. $excel=new ExcelController();
  73. return $excel->makeExcel();
  74. }
  75. public function featureIt()
  76. {
  77. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5,2500);
  78. }
  79. public function newSku()
  80. {
  81. $url='http://bswcs/api/sorting/flux/newSku';
  82. $response = Zttp::post($url, [
  83. 'request'=>[
  84. [
  85. "SKU"=> "1234567890",
  86. "NAME"=> "瑞士莲**巧克力",
  87. "Alternate_SKU1"=> "1122334455",
  88. "GrossWeight"=> "1.2",
  89. "Cube"=> "0.75",
  90. "SKULength"=> "0.25",
  91. "SKUWidth"=> "0.15",
  92. "SKUHigh"=> "0.05"
  93. ],
  94. [
  95. "SKU"=> "1234567892",
  96. "NAME"=> "跳跳饼",
  97. "Alternate_SKU1"=> "",
  98. "GrossWeight"=> "1.3",
  99. "Cube"=> "0.75",
  100. "SKULength"=> "0.25",
  101. "SKUWidth"=> "0.15",
  102. "SKUHigh"=> "0.25"
  103. ],
  104. ]
  105. ]);
  106. return $response->json();
  107. }
  108. public function changePackage(){
  109. $packages=Package::where('delivery_number','<>',null)->where('logistic_id',null)->get();
  110. dd($packages);
  111. $packages=Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  112. $logistics=Logistic::get();
  113. $packages->each(function ($package)use($logistics){
  114. $logistics->each(function ($logistic)use($package){
  115. if ($package->WMSReflectPackage->CarrierID==$logistic->code){
  116. $package->logistic_id=$logistic->id;
  117. return;
  118. }
  119. });
  120. });
  121. return "OK";
  122. }
  123. public function tNull(){
  124. }
  125. public function deletePackageAuthority()
  126. {
  127. $authorities=Authority::where('name','like','%包裹信息%')->get();
  128. $authorities->each(function ($authority){
  129. $authority->delete();
  130. });
  131. }
  132. public function test3()
  133. {
  134. $strs=["auibh","aopk","bikon"];
  135. if (!$strs[0])return "";
  136. $len=strlen($strs[0]);
  137. for ($i=1;$i<count($strs);$i++){
  138. if ($len<1)break;
  139. for ($j=0;$j<$len;$j++){
  140. if ($strs[$i][$j]!=$strs[0][$j]){
  141. if ($j==0)return "";
  142. break;
  143. }
  144. $sum=$j+1;
  145. }
  146. $len=isset($sum)?$sum:0;
  147. }
  148. return substr($strs[0],0,$len);
  149. }
  150. public function test4(){
  151. $s="{([{()()[]{}}])[{()()[}]{}}](){[]}";
  152. $map = [
  153. ")" => "(",
  154. "}" => "{",
  155. "]" => "[",
  156. ];
  157. $len = strlen($s);
  158. $stack = [];
  159. if ($len%2!=0)dd(false);
  160. //s中出现map的key则弹出,没有出现则入栈
  161. for ($i =0; $i<$len; $i++) {
  162. var_dump("data:".$s[$i]);
  163. if (isset($map[$s[$i]])){
  164. //s中出现map的key:如果能找到对应的map的值 (,{,[ 则说明有配对,则弹出
  165. if (isset($stack) && $stack[0] == $map[$s[$i]]) {
  166. array_shift($stack);
  167. } else { //仅找到后面的一部分,说明是不匹配的
  168. dd(false);
  169. }
  170. var_dump("value1:".$map[$s[$i]]);
  171. var_dump($stack);
  172. } else {
  173. array_unshift($stack, $s[$i]);
  174. var_dump("value2:".$s[$i]);
  175. var_dump($stack);
  176. }
  177. }
  178. if (count($stack) > 0) {
  179. dd(false);
  180. }
  181. dd(true);
  182. //利用栈的先进后出 一个正确的括号组对应都为1对1或N对N
  183. // 先进后出“([{”入栈,")]}"出栈,轮询到出栈元素去映射栈顶,符合出栈,不符合直接返回
  184. //依次轮询 如果映射正确那么最后栈为空栈 否则返回false
  185. }
  186. function test5(Request $request){
  187. $page=$request->input('page')??1;
  188. $date_start=$request->input('date_start');
  189. $date_end=$request->input('date_end');
  190. $sql='select * from (select result.*,rownum rn from (';
  191. $sql.=' select customer.Descr_C 货主, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
  192. $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
  193. $sql.=' lot.LotAtt04 批号 ';
  194. $sql.=' , sum(移出数量)移出数量, sum(移入数量)移入数量 ';
  195. $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
  196. $sql.=' (select FMLotNum,FMSKU,TOCustomerID,0 as 移出数量, sum(TOQty_Each) as 移入数量, TOLocation as 库位 ';
  197. $sql.=" from ACT_Transaction_Log where TransactionType='PA' ";
  198. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  199. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  200. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  201. $sql.=' group by TOCustomerID, TOLocation, TOCustomerID,FMSKU,FMLotNum union all ';
  202. $sql.=' select FMLotNum,FMSKU,TOCustomerID,sum(FMQty_Each) as 移出数量, 0 as 移入数量, FMLOCATION as 库位 ';
  203. $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
  204. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  205. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  206. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  207. $sql.=' group by FMCustomerID, FMLocation, TOCustomerID,FMSKU,FMLotNum union all ';
  208. $sql.=' select FMLotNum,FMSKU,TOCustomerID,sum(FMQty_Each) as 移出数量,0 as 移入数量, FMLocation as 库位 ';
  209. $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
  210. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  211. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  212. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  213. $sql.=' group by FMLocation,TOCustomerID,FMSKU,FMLotNum union all ';
  214. $sql.=' select FMLotNum,FMSKU,TOCustomerID,0 as 移出数量,sum(TOQty_Each)as 移入数量, TOLocation as 库位 ';
  215. $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
  216. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  217. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  218. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  219. $sql.=' group by TOLocation,TOCustomerID,FMSKU,FMLotNum)stockLog ';
  220. $sql.=' left join BAS_Customer customer on customer.CustomerID=stockLog.TOCUSTOMERID ';
  221. $sql.=' left join BAS_SKU sku on sku.SKU=stockLog.FMSKU ';
  222. $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM=stockLog.FMLOTNUM ';
  223. $sql.=' left join INV_LOT_LOC_ID storeStatus on storeStatus.LOTNUM=stockLog.FMLOTNUM ';;
  224. $sql.=' and storeStatus.LocationID=stockLog.库位 where ROWNUM<=50 ';
  225. $sql.=' group by 库位,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
  226. $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
  227. $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated ';
  228. $sql.=' )result) where rn>0';
  229. $oracleActTransactingLogs1=DB::connection('oracle')->select($sql);
  230. unset($sql);
  231. $sql='select * from (select result.*,rownum rn from (';
  232. $sql.=' select customer.Descr_C 货主, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
  233. $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
  234. $sql.=' lot.LotAtt04 批号 ';
  235. $sql.=' , sum(移出数量)移出数量, sum(移入数量)移入数量 ';
  236. $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
  237. $sql.=' (select FMLotNum,FMSKU,TOCustomerID,0 as 移出数量, sum(TOQty_Each) as 移入数量, TOLocation as 库位 ';
  238. $sql.=" from ACT_Transaction_Log where TransactionType='PA' ";
  239. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  240. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  241. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  242. $sql.=' group by TOCustomerID, TOLocation, TOCustomerID,FMSKU,FMLotNum union all ';
  243. $sql.=' select FMLotNum,FMSKU,TOCustomerID,sum(FMQty_Each) as 移出数量, 0 as 移入数量, FMLOCATION as 库位 ';
  244. $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
  245. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  246. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  247. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  248. $sql.=' group by FMCustomerID, FMLocation, TOCustomerID,FMSKU,FMLotNum union all ';
  249. $sql.=' select FMLotNum,FMSKU,TOCustomerID,sum(FMQty_Each) as 移出数量,0 as 移入数量, FMLocation as 库位 ';
  250. $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
  251. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  252. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  253. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  254. $sql.=' group by FMLocation,TOCustomerID,FMSKU,FMLotNum union all ';
  255. $sql.=' select FMLotNum,FMSKU,TOCustomerID,0 as 移出数量,sum(TOQty_Each)as 移入数量, TOLocation as 库位 ';
  256. $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
  257. if ($date_start) $sql.=" and addtime > '".$date_start." 00:00:00' ";
  258. if ($date_end) $sql.=" and addtime < '".$date_end." 23:59:59' ";
  259. if (!$date_start && !$date_end)$sql .= " and addtime >'".date('Y-m-d H:i:s',strtotime("-1 day"))."' ";
  260. $sql.=' group by TOLocation,TOCustomerID,FMSKU,FMLotNum)stockLog ';
  261. $sql.=' left join BAS_Customer customer on customer.CustomerID=stockLog.TOCUSTOMERID ';
  262. $sql.=' left join BAS_SKU sku on sku.SKU=stockLog.FMSKU ';
  263. $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM=stockLog.FMLOTNUM ';
  264. $sql.=' left join INV_LOT_LOC_ID storeStatus on storeStatus.LOTNUM=stockLog.FMLOTNUM ';;
  265. $sql.=' and storeStatus.LocationID=stockLog.库位 where ROWNUM<=500 ';
  266. $sql.=' group by 库位,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
  267. $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
  268. $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated ';
  269. $sql.=' )result) where rn>50';
  270. $oracleActTransactingLogs2=DB::connection('oracle')->select($sql);
  271. $oracleActTransactingLogs1=json_encode($oracleActTransactingLogs1);
  272. $oracleActTransactingLogs2=json_encode($oracleActTransactingLogs2);
  273. $oracleActTransactingLogs1=json_decode($oracleActTransactingLogs1,true);
  274. $oracleActTransactingLogs2=json_decode($oracleActTransactingLogs2,true);
  275. foreach ($oracleActTransactingLogs1 as $oracleActTransactingLog1){
  276. foreach ($oracleActTransactingLogs2 as $oracleActTransactingLog2){
  277. if ($oracleActTransactingLog1['产品编码']==$oracleActTransactingLog2['产品编码']){
  278. /*if ($oracleActTransactingLog1['产品编码']=='6206100971005')*/var_dump(['oracleActTransactingLog1'=>$oracleActTransactingLog1,'oracleActTransactingLog2'=>$oracleActTransactingLog2]);
  279. }
  280. }
  281. }
  282. }
  283. }