TestController.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\Commodity;
  6. use App\CommodityBarcode;
  7. use App\CommodityMaterialBoxModel;
  8. use App\Components\AsyncResponse;
  9. use App\Components\Database;
  10. use App\Components\ErrorPush;
  11. use App\DeliveryAppointmentCar;
  12. use App\ErrorTemp;
  13. use App\Feature;
  14. use App\Http\ApiControllers\LoginController;
  15. use App\Http\Controllers\api\thirdPart\haochuang\SortingController;
  16. use App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeCell;
  17. use App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeRelation;
  18. use App\Http\Controllers\api\thirdPart\syrius\beans\Task;
  19. use App\Http\Controllers\api\thirdPart\syrius\beans\TaskItem;
  20. use App\Http\Controllers\api\thirdPart\syrius\producer\StorageTypeController;
  21. use App\Http\Controllers\api\thirdPart\syrius\units\Signature;
  22. use App\Http\Controllers\api\thirdPart\syrius\units\StorageTypeAttribute;
  23. use App\Http\Requests\AndroidGateRequest;
  24. use App\Http\Requests\OrderDelivering;
  25. use App\InventoryAccount;
  26. use App\InventoryAccountMission;
  27. use App\Jobs\BatchTaskJob;
  28. use App\Jobs\BroadcastBatchToZhengCangJob;
  29. use App\Jobs\CacheShelfTaskJob;
  30. use App\Jobs\OrderCreateInstantBill;
  31. use App\Jobs\OrderCreateWaybill;
  32. use App\Jobs\SettlementBillReportJob;
  33. use App\Jobs\StoreCreateInstantBill;
  34. use App\Jobs\TestJob;
  35. use App\Jobs\WeightUpdateInstantBill;
  36. use App\LaborCompanyDispatch;
  37. use App\LaborReport;
  38. use App\LaborReportStatus;
  39. use App\Logistic;
  40. use App\MaterialBox;
  41. use App\MaterialBoxModel;
  42. use App\Notifications\RoutineNotification;
  43. use App\Observers\WaybillObserver;
  44. use App\OracleDOCASNDetail;
  45. use App\OracleDOCASNHeader;
  46. use App\OracleDOCOrderHeader;
  47. use App\OracleDocOrderPackingSummary;
  48. use App\OracleDOCWaveDetails;
  49. use App\Order;
  50. use App\OrderBin;
  51. use App\OrderCommodity;
  52. use App\OrderIssue;
  53. use App\OrderIssueProcessLog;
  54. use App\OrderIssueType;
  55. use App\OrderPackage;
  56. use App\Owner;
  57. use App\OwnerAreaReport;
  58. use App\OwnerBillReport;
  59. use App\OwnerFeeDetail;
  60. use App\OwnerFeeDetailLogistic;
  61. use App\OwnerFeeExpress;
  62. use App\OwnerFeeLogistic;
  63. use App\OwnerFeeOperation;
  64. use App\OwnerFeeOperationDetail;
  65. use App\OwnerFeeStorage;
  66. use App\OwnerPriceExpress;
  67. use App\OwnerPriceOperation;
  68. use App\OrderPackageCountingRecord;
  69. use App\OwnerReport;
  70. use App\ProcurementCheckSheet;
  71. use App\ProcurementDeliverie;
  72. use App\ReceiveRecord;
  73. use App\RejectedBill;
  74. use App\SeeLog;
  75. use App\Services\AndroidInventoryService;
  76. use App\Services\AuthorityService;
  77. use App\Services\BatchService;
  78. use App\Services\CacheShelfService;
  79. use App\Services\common\BatchUpdateService;
  80. use App\Services\ForeignHaiRoboticsService;
  81. use App\Services\ForeignZhenCangService;
  82. use App\Services\LogisticService;
  83. use App\Services\LogService;
  84. use App\Services\MenuService;
  85. use App\Services\NotificationService;
  86. use App\Services\OracleDOCOrderHeaderService;
  87. use App\Services\OrderPackageCommoditiesService;
  88. use App\Services\OrderPackageReceivedSyncService;
  89. use App\Services\OrderPackageService;
  90. use App\Services\OrderService;
  91. use App\Services\OrderTrackingService;
  92. use App\Services\OwnerFeeTotalService;
  93. use App\Services\OwnerLogisticFeeReportService;
  94. use App\Services\OwnerPriceOperationService;
  95. use App\Services\OwnerService;
  96. use App\Services\OwnerStoreFeeReportService;
  97. use App\Services\OwnerStoreOutFeeReportService;
  98. use App\Services\ReceivingTaskService;
  99. use App\Services\ReplenishmentService;
  100. use App\Services\ReviewService;
  101. use App\Services\StationService;
  102. use App\Services\StorageService;
  103. use App\Services\StoreItemService;
  104. use App\Services\StoreService;
  105. use App\Services\SyriusTaskService;
  106. use App\Services\UserService;
  107. use App\Services\WorkOrderService;
  108. use App\SortingStation;
  109. use App\Station;
  110. use App\StationTask;
  111. use App\StationTaskMaterialBox;
  112. use App\Store;
  113. use App\StoreItem;
  114. use App\TaskTransaction;
  115. use App\Unit;
  116. use App\User;
  117. use App\UserDetail;
  118. use App\UserDutyCheck;
  119. use App\ValueStore;
  120. use App\Waybill;
  121. use App\WorkOrder;
  122. use App\WorkOrderCommodities;
  123. use App\WorkOrderDetail;
  124. use App\WorkOrderImage;
  125. use App\WorkOrderLog;
  126. use Carbon\Carbon;
  127. use Carbon\CarbonPeriod;
  128. use Decimal\Decimal;
  129. use Doctrine\DBAL\Driver\AbstractDB2Driver;
  130. use Doctrine\DBAL\Exception;
  131. use Firebase\JWT\ExpiredException;
  132. use Firebase\JWT\JWT;
  133. use Illuminate\Database\Eloquent\Builder;
  134. use Illuminate\Database\Eloquent\Collection;
  135. use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
  136. use Illuminate\Database\QueryException;
  137. use Illuminate\Foundation\Http\FormRequest;
  138. use Illuminate\Http\Request;
  139. use Illuminate\Support\Facades\Broadcast;
  140. use Illuminate\Support\Facades\Cache;
  141. use Illuminate\Support\Facades\Auth;
  142. use Illuminate\Support\Facades\Cookie;
  143. use Illuminate\Support\Facades\DB;
  144. use Illuminate\Support\Facades\Hash;
  145. use Illuminate\Support\Facades\Http;
  146. use Illuminate\Support\Facades\Log;
  147. use Illuminate\Support\Facades\Notification;
  148. use Illuminate\Support\Facades\URL;
  149. use Illuminate\Support\Facades\Validator;
  150. use Illuminate\Support\Str;
  151. use Laravel\Horizon\Events\JobFailed;
  152. use Monolog\Handler\IFTTTHandler;
  153. use phpDocumentor\Reflection\Types\Resource_;
  154. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  155. use PhpParser\Node\Stmt\DeclareDeclare;
  156. use Ramsey\Uuid\Uuid;
  157. use Symfony\Component\ErrorHandler\Error\FatalError;
  158. class TestController extends Controller
  159. {
  160. use AsyncResponse, ErrorPush, Database;
  161. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  162. public function __construct()
  163. {
  164. $this->data["active_test"] = "active";
  165. }
  166. public function method(Request $request, $method)
  167. {
  168. try {
  169. return call_user_func([$this, $method], $request);
  170. }catch (\BadMethodCallException $e){
  171. dd("方法不存在");
  172. }
  173. }
  174. public function test1(\Closure $c,string $a){
  175. dd($c($a));
  176. }
  177. public function test(Request $request)
  178. {
  179. foreach (Batch::query()->where("created_at",">=","2021-12-18 00:00:00")->get() as $bat){
  180. $this->assignBatch($bat->code);
  181. }
  182. dd("OK");
  183. $user = User::query()->where("name","yanyuanmin")->first();
  184. dd($user->id);
  185. dd($codes = app('OwnerService')->getQuery($user->id)->select("code")->pluck("code"));
  186. $ownerIds=app('UserService')->getPermittingOwnerIds($user);
  187. $owners = Owner::query()->select("id","name","code")->whereIn('id', $ownerIds)->whereNull('deleted_at')->get();
  188. $codes = array_column($owners->toArray(), 'code');
  189. dd($codes);
  190. dd(Order::class);
  191. $c = "test";
  192. $a = function ($b)use($c){
  193. return $b.$c;
  194. };
  195. $this->test1($a,"a");
  196. dd(2);
  197. $w = Waybill::query()->get();
  198. foreach ($w->chunk(50) as $a){
  199. dd($a);
  200. }
  201. $path = '';
  202. $id = 252;
  203. $file = fopen($path, "r");
  204. $user=array();
  205. $i=0;
  206. //输出文本中所有的行,直到文件结束为止。
  207. while(! feof($file)){
  208. $user[$i]= trim(fgets($file));//fgets()函数从文件指针中读取一行
  209. $i++;
  210. }
  211. fclose($file);
  212. foreach ($user as $item){
  213. $arr = explode(",",$item);
  214. if (count($arr)!=2){
  215. dump($item);
  216. continue;
  217. }
  218. DB::table("details")->insert([
  219. "name" => $arr[0],
  220. "size" => $arr[1],
  221. "created_at" => date("Y-m-d H:i:s"),
  222. "updated_at" => date("Y-m-d H:i:s"),
  223. "header_id" => $id
  224. ]);
  225. }
  226. }
  227. public function test123(){
  228. $rejected_bill = RejectedBill::query()->find(2);
  229. $service = new WorkOrderService();
  230. $service->syncWorkOrder($rejected_bill);
  231. }
  232. public function changeWorkOrder(){
  233. $type = OrderIssueType::query()->where('name' ,'拦截')->first();
  234. WorkOrder::query()->where('order_issue_type_id',$type->id)
  235. ->where('status',[4,5])
  236. ->where('process_progress','拦截成功')
  237. ->update(['process_progress' => '成功已退回,不赔偿']);
  238. WorkOrder::query()->where('order_issue_type_id',$type->id)
  239. ->whereIn('status',[4,5])
  240. ->where('process_progress','拦截失败')
  241. ->update(['process_progress' => '无法拦截']);
  242. WorkOrderDetail::query()->where('order_issue_type_id',$type->id)
  243. ->where('status',[4,5])
  244. ->where('process_progress','拦截成功')
  245. ->update(['process_progress' => '成功已退回,不赔偿']);
  246. WorkOrderDetail::query()->where('order_issue_type_id',$type->id)
  247. ->whereIn('status',[4,5])
  248. ->where('process_progress','拦截失败')
  249. ->update(['process_progress' => '无法拦截']);
  250. }
  251. public function assignBatch($code)
  252. {
  253. $batches = Batch::query()->where("code",$code)->get();
  254. if (!$batches->count()){
  255. $wave = DB::connection("oracle")->selectOne(DB::raw("select * from DOC_WAVE_HEADER where WAVENO = ?"),[$code]);
  256. if (!$wave){
  257. dd("FLUX无波次");
  258. }
  259. $owner = app("OwnerService")->codeGetOwner($wave->customerid);
  260. $obj = [
  261. "wms_status" => $this->wms_status($wave),
  262. "wms_type"=>$wave->descr,
  263. "created_at"=>date("Y-m-d H:i:s"),
  264. "wms_created_at"=>$wave->addtime,
  265. "updated_at"=>$wave->edittime,
  266. "owner_id"=>$owner->id,
  267. ];
  268. $wave = Batch::query()->where("code",$code)->first();
  269. if (!$wave){
  270. $obj["code"] = $code;
  271. $wave = Batch::query()->create($obj);
  272. }else{
  273. Batch::query()->where("code",$code)->update($obj);
  274. }
  275. $ordernos = array_column(DB::connection("oracle")->select(DB::raw("select orderno from DOC_WAVE_DETAILS where WAVENO = ?"),[$code]),"orderno");
  276. Order::query()->whereIn("code",$ordernos)->update([
  277. "batch_id"=>$wave->id
  278. ]);
  279. Order::query()->with(["batch","bin"])->whereIn("code",$ordernos)->get()->each(function ($order){
  280. if (!$order->bin){
  281. $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"),[$order->batch->code,$order->code]);
  282. if ($bin){
  283. OrderBin::query()->create([
  284. 'order_id' => $order->id,
  285. 'number' => $bin->seqno,
  286. ]);
  287. }
  288. }
  289. });
  290. $batches = Batch::query()->where("code",$code)->get();
  291. }
  292. app("BatchService")->assignTasks($batches);
  293. }
  294. public function inventory()
  295. {
  296. $location='H05-35-04';
  297. $inventoryAccountId=792;
  298. $barcode='6973244250033';
  299. $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])
  300. ->whereHas('commodity',function($query)use($barcode){
  301. $query->whereHas('barcodes',function($sql)use($barcode){
  302. $sql->where('code','=',$barcode);
  303. });
  304. })->where('location',$location)->where('inventory_account_id',$inventoryAccountId)->toSql();
  305. dd($inventoryAccountMission);
  306. }
  307. public function testOrder(){
  308. $controller = new ReceivingTaskController();
  309. return $controller->index();
  310. }
  311. public function testZC()
  312. {
  313. // $batches=Batch::query()->where('id',1)->get();
  314. // BroadcastBatchToZhengCangJob::dispatch($batches); //在这里为波次注册队列任务!
  315. $taskId=792;
  316. $location='H05-35-04';
  317. $barcode='6931481255587';
  318. /** @var AndroidInventoryService $service */
  319. $service=app('AndroidInventoryService');
  320. $inventoryAccountMission=$service->getInventoryDetail($taskId,$location,$barcode);
  321. dd($inventoryAccountMission->stockInventoryPersons);
  322. }
  323. public function testTable(){
  324. return view('httpTest');
  325. }
  326. public function testForm(){
  327. $date = \Illuminate\Support\Carbon::now();
  328. // 'Y-m-d H:i:s'
  329. $item = $date->format(Carbon::DEFAULT_TO_STRING_FORMAT);
  330. $item = $date->format("Ymd");
  331. dd($item);
  332. }
  333. public function testCount(){
  334. dd(DeliveryAppointmentCar::query()->where('appointment_number','admin123546')->first());
  335. }
  336. }