TestController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\Commodity;
  6. use App\CommodityMaterialBoxModel;
  7. use App\Components\AsyncResponse;
  8. use App\Components\ErrorPush;
  9. use App\ErrorTemp;
  10. use App\Feature;
  11. use App\Http\ApiControllers\LoginController;
  12. use App\Http\Requests\OrderDelivering;
  13. use App\Jobs\BatchTaskJob;
  14. use App\Jobs\CacheShelfTaskJob;
  15. use App\Jobs\OrderCreateInstantBill;
  16. use App\Jobs\OrderCreateWaybill;
  17. use App\Jobs\SettlementBillReportTask;
  18. use App\Jobs\StoreCreateInstantBill;
  19. use App\Jobs\TestJob;
  20. use App\Jobs\WeightUpdateInstantBill;
  21. use App\LaborReport;
  22. use App\LaborReportStatus;
  23. use App\MaterialBox;
  24. use App\MaterialBoxModel;
  25. use App\Notifications\RoutineNotification;
  26. use App\OracleDOCASNHeader;
  27. use App\OracleDOCOrderHeader;
  28. use App\OracleDocOrderPackingSummary;
  29. use App\Order;
  30. use App\OrderIssue;
  31. use App\OrderIssueProcessLog;
  32. use App\OrderPackage;
  33. use App\Owner;
  34. use App\OwnerFeeDetail;
  35. use App\OwnerFeeDetailLogistic;
  36. use App\OwnerFeeExpress;
  37. use App\OwnerFeeLogistic;
  38. use App\OwnerFeeOperation;
  39. use App\OwnerFeeOperationDetail;
  40. use App\OwnerFeeStorage;
  41. use App\OwnerPriceOperation;
  42. use App\OrderPackageCountingRecord;
  43. use App\ProcurementCheckSheet;
  44. use App\RejectedBill;
  45. use App\SeeLog;
  46. use App\Services\BatchService;
  47. use App\Services\CacheShelfService;
  48. use App\Services\ForeignHaiRoboticsService;
  49. use App\Services\NotificationService;
  50. use App\Services\OrderPackageReceivedSyncService;
  51. use App\Services\OrderPackageService;
  52. use App\Services\OrderService;
  53. use App\Services\OwnerFeeTotalService;
  54. use App\Services\OwnerLogisticFeeReportService;
  55. use App\Services\OwnerPriceOperationService;
  56. use App\Services\OwnerStoreFeeReportService;
  57. use App\Services\OwnerStoreOutFeeReportService;
  58. use App\Services\ReviewService;
  59. use App\Services\StationService;
  60. use App\Services\StorageService;
  61. use App\Services\StoreService;
  62. use App\Station;
  63. use App\StationTask;
  64. use App\StationTaskMaterialBox;
  65. use App\Store;
  66. use App\TaskTransaction;
  67. use App\Unit;
  68. use App\User;
  69. use App\UserDetail;
  70. use App\UserDutyCheck;
  71. use App\ValueStore;
  72. use App\Waybill;
  73. use App\WorkOrder;
  74. use Carbon\Carbon;
  75. use Carbon\CarbonPeriod;
  76. use Decimal\Decimal;
  77. use Doctrine\DBAL\Exception;
  78. use Firebase\JWT\JWT;
  79. use Illuminate\Database\Eloquent\Collection;
  80. use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
  81. use Illuminate\Foundation\Http\FormRequest;
  82. use Illuminate\Http\Request;
  83. use Illuminate\Support\Facades\Broadcast;
  84. use Illuminate\Support\Facades\Cache;
  85. use Illuminate\Support\Facades\Auth;
  86. use Illuminate\Support\Facades\Cookie;
  87. use Illuminate\Support\Facades\DB;
  88. use Illuminate\Support\Facades\Http;
  89. use Illuminate\Support\Facades\Log;
  90. use Illuminate\Support\Facades\Notification;
  91. use Illuminate\Support\Facades\URL;
  92. use Illuminate\Support\Facades\Validator;
  93. use Illuminate\Support\Str;
  94. use Laravel\Horizon\Events\JobFailed;
  95. use Monolog\Handler\IFTTTHandler;
  96. use phpDocumentor\Reflection\Types\Resource_;
  97. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  98. class TestController extends Controller
  99. {
  100. use AsyncResponse, ErrorPush;
  101. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  102. public function __construct()
  103. {
  104. $this->data["active_test"] = "active";
  105. }
  106. public function method(Request $request, $method)
  107. {
  108. return call_user_func([$this, $method], $request);
  109. }
  110. public function test()
  111. {
  112. dd(Notification::send(User::query()->where("name","zhouzhendong")->get(),new RoutineNotification(SeeLog::query()->first()->toArray())));
  113. $user = Auth::user();
  114. $remark = "zengjunlj";
  115. $ownerName = 'zengjunlj' ?? '';
  116. $clientCode = 'zengjunljljlj' ?? '';
  117. $msg = $user["name"]."建立了新工单<br/>".$ownerName.":".$clientCode."<br/>".$remark;
  118. NotificationService::SingleRegister($msg,$clientCode,"订单管理-问题件");
  119. dd(1);
  120. $seeLog = SeeLog::query()->find(9);
  121. Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
  122. dd(1);
  123. Broadcast::channel('notification', function ($user, $id) {
  124. return (int) $user->id === (int) $id;
  125. });
  126. dd(1);
  127. Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
  128. dd(1);
  129. $username = config('database.connections.oracle.username');
  130. $password = config('database.connections.oracle.password');
  131. $host = config('database.connections.oracle.host');
  132. $service_name = config('database.connections.oracle.service_name');
  133. $conn = oci_connect($username, $password, $host . '/' . $service_name,"utf8");
  134. $sql = <<<sql
  135. BEGIN
  136. SPSO_HardAllocation_Process('WH01','Allocation','By OrderNO',
  137. null,'SO21090100007','0',null,
  138. 'zhouzhendong',:CODE);
  139. END;
  140. sql;
  141. $stmt = oci_parse($conn, $sql);
  142. $code = "";
  143. oci_bind_by_name($stmt, ':CODE', $code,300);
  144. oci_execute($stmt);
  145. oci_close($conn);
  146. dd($code);
  147. //
  148. $no = "SO21090900001";
  149. $db = DB::connection("oracle");
  150. //$order = $db->selectOne(DB::raw("select * from DOC_ORDER_HEADER where orderno = ?"),[$no]);
  151. dd($db->select($sql,[
  152. ]));
  153. $db->select("CALL SPSO_HardAllocation_Process(?,'Allocation','By OrderNO',null,?,'0',null,'zhouzhendong',@code)",[
  154. $order->warehouseid,$no
  155. ]);
  156. //SPSO_HardAllocation_Process
  157. dd($db->selectOne("select @code"));
  158. $date = "2021-09-14 15:47:00";
  159. dispatch(new TestJob("1"))->delay(Carbon::parse($date));
  160. dispatch(new TestJob("2"))->delay(Carbon::parse($date));
  161. dispatch(new TestJob("3"))->delay(Carbon::parse($date));
  162. dispatch(new TestJob("4"))->delay(Carbon::parse($date));
  163. dispatch(new TestJob("5"))->delay(Carbon::parse($date));
  164. dispatch(new TestJob("6"))->delay(Carbon::parse($date));
  165. dispatch(new TestJob("7"))->delay(Carbon::parse($date));
  166. dispatch(new TestJob("8"))->delay(Carbon::parse($date));
  167. dispatch(new TestJob("9"))->delay(Carbon::parse($date));
  168. dispatch(new TestJob("10"))->delay(Carbon::parse($date));
  169. dd(1);
  170. Station::query()->where("station_type_id", 5)->update(["status" => 1]);
  171. Cache::forget("CACHE_SHELF_AVAILABLE");
  172. $station = ["HAIB1-01-01", "HAIB1-02-01"];
  173. $material = ["IDE0001824", "IDE0001740", "IDE0002710"];
  174. Station::query()->whereIn("code", $station)->update(["status" => 0]);
  175. $stations = Station::query()->whereIn("code", $station)->get();
  176. $materials = MaterialBox::query()->whereIn("code", $material)->get();
  177. $dateTime = date("Y-m-d H:i:s");
  178. $task1 = StationTaskMaterialBox::query()->create([
  179. 'station_id' => $stations[0]->id,
  180. 'material_box_id' => $materials[0]->id,
  181. 'station_task_batch_id' => 1,
  182. 'status' => '待处理'
  183. ]);
  184. $task2 = StationTaskMaterialBox::query()->create([
  185. 'station_id' => $stations[1]->id,
  186. 'material_box_id' => $materials[1]->id,
  187. 'station_task_batch_id' => 1,
  188. 'status' => '待处理'
  189. ]);
  190. $task3 = StationTaskMaterialBox::query()->create([
  191. 'station_id' => 6,
  192. 'material_box_id' => $materials[2]->id,
  193. 'station_task_batch_id' => 1,
  194. 'status' => '待处理'
  195. ]);
  196. TaskTransaction::query()->insert([[
  197. "doc_code" => "test",
  198. "bar_code" => "test",
  199. "to_station_id" => $stations[0]->id,
  200. "material_box_id" => $materials[0]->id,
  201. "task_id" => $task1->id,
  202. "commodity_id" => 505012,//XUNI03
  203. "amount" => 1,
  204. "type" => "出库",
  205. "status" => 0,
  206. "mark" => 2,
  207. "bin_number" => 1,
  208. "created_at" => $dateTime,
  209. "updated_at" => $dateTime,
  210. ], [
  211. "doc_code" => "test",
  212. "bar_code" => "test",
  213. "to_station_id" => $stations[1]->id,
  214. "material_box_id" => $materials[1]->id,
  215. "task_id" => $task2->id,
  216. "commodity_id" => 505012,//XUNI03
  217. "amount" => 1,
  218. "type" => "出库",
  219. "status" => 0,
  220. "mark" => 2,
  221. "bin_number" => 1,
  222. "created_at" => $dateTime,
  223. "updated_at" => $dateTime,
  224. ], [
  225. "doc_code" => "test",
  226. "bar_code" => "test",
  227. "to_station_id" => 6,
  228. "material_box_id" => $materials[2]->id,
  229. "task_id" => $task3->id,
  230. "commodity_id" => 505012,//XUNI03
  231. "amount" => 1,
  232. "type" => "出库",
  233. "status" => 3,
  234. "mark" => 2,
  235. "bin_number" => 1,
  236. "created_at" => $dateTime,
  237. "updated_at" => $dateTime,
  238. ]]);
  239. $foreignHaiRoboticsService = new ForeignHaiRoboticsService();
  240. $toLocation = collect($station);
  241. $taskMaterialBoxes = collect([$task1, $task2]);
  242. $foreignHaiRoboticsService->
  243. fetchGroup_multiLocation($toLocation, $taskMaterialBoxes, '', '立架出至缓存架', 20, false);
  244. foreach ($toLocation as $index => $value) {
  245. app("CacheShelfService")->lightUp($value, '3', '0', ["title" => "机器人取箱中,禁止操作"]);
  246. Cache::forever("CACHE_SHELF_OCCUPANCY_{$stations[$index]->id}", true);
  247. }
  248. app("StationService")->locationOccupyMulti($toLocation->toArray());
  249. }
  250. public function update_order_packages_is_manual_update()
  251. {
  252. $descriptions = Log::query()
  253. ->select('description')
  254. ->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
  255. ->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
  256. foreach ($descriptions as $description) {
  257. $description = substr($description, 9);
  258. $description = \Illuminate\Support\Str::before($description, "}");
  259. $obj = json_decode($description . '}', true);
  260. OrderPackage::query()
  261. ->whereIn('logistic_number', $obj['logistic_numbers'])
  262. ->update([
  263. 'status' => '无',
  264. 'is_manual_update' => false,
  265. ]);
  266. }
  267. }
  268. public function testUpdateInv()
  269. {
  270. ini_set('max_execution_time', 0);
  271. ini_set('memory_limit', '4096M');
  272. $sql = <<<sql
  273. select FMLOTNUM,FMLOCATION,PLANTOLOCATION,CREATE_TRANSACTIONID,SKU,CUSTOMERID from TSK_TASKLISTS
  274. where CUSTOMERID=?
  275. AND FMLOCATION= ?
  276. AND OPENWHO = ?
  277. AND TASKPROCESS = ?
  278. AND DOCTYPE = ?
  279. AND TASKTYPE = ?
  280. AND LOTATT05=?
  281. AND LOTATT08=?
  282. AND PLANTOID = ?
  283. and OPENTIME>=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  284. and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  285. sql;
  286. $CUSTOMERID = 'JIANSHANG';
  287. $FMLOCATION = 'STAGEWH02';
  288. $OPENWHO = 'WCS';
  289. $TASKPROCESS = '00';
  290. $DOCTYPE = 'ASN';
  291. $TASKTYPE = 'PA';
  292. $LOTATT05 = 'MJ-CP';
  293. $LOTATT08 = 'ZP';
  294. $PLANTOID = '*';
  295. $traceid = 'JIANSHANG03';
  296. $start = '2021-09-02 23:59:59';
  297. $end = '2021-09-03 11:10:00';
  298. $res = DB::connection("oracle")->select(DB::raw($sql),
  299. [$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
  300. $resItems = array_chunk($res, 200);
  301. foreach ($resItems as $res) {
  302. DB::connection("oracle")->beginTransaction();
  303. try {
  304. foreach ($res as $re) {
  305. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  306. ->where([
  307. 'LOTNUM' => $re->fmlotnum,
  308. 'LOCATIONID' => $re->fmlocation,
  309. 'CUSTOMERID' => $re->customerid,
  310. 'sku' => $re->sku,
  311. 'TRACEID' => '*',
  312. ])
  313. ->update([
  314. 'TRACEID' => $traceid,
  315. 'EDITWHO' => 'WCS_',
  316. ]);
  317. if ($re->fmlocation != $re->plantolocation) {
  318. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  319. ->where([
  320. 'LOTNUM' => $re->fmlotnum,
  321. 'LOCATIONID' => $re->plantolocation,
  322. 'CUSTOMERID' => $re->customerid,
  323. 'sku' => $re->sku,
  324. 'TRACEID' => '*',
  325. ])
  326. ->update([
  327. 'TRACEID' => $traceid,
  328. 'EDITWHO' => 'WCS_',
  329. ]);
  330. }
  331. DB::connection("oracle")->commit();
  332. }
  333. dd(true);
  334. } catch (\Exception $e) {
  335. DB::connection("oracle")->rollBack();
  336. dd($e->getMessage());
  337. }
  338. }
  339. }
  340. /**
  341. * 重置15天内的数据
  342. */
  343. public function order_packages_init()
  344. {
  345. OrderPackage::query()
  346. ->whereBetween('created_at', [now()->subDays(15), now()])
  347. ->update([
  348. 'is_delay_deliver' => 0,
  349. 'sync_routes_flag' => 0,
  350. 'status' => 1,
  351. 'exception_status' => 0,
  352. ]);
  353. OrderPackage::query()
  354. ->whereBetween('created_at', [now()->subDays(15), now()])
  355. ->whereNotNull('received_at')
  356. ->update([
  357. 'status' => 7,
  358. ]);
  359. }
  360. public function syncOrderPackage(){
  361. ini_set('memory_limit','500M');
  362. ini_set('max_execution_time', 0);
  363. $orderPackingSummary = OracleDocOrderPackingSummary::query()
  364. ->where('editTime','>=','2021-09-11 12:00:00')
  365. ->where('editTime','<=','2021-09-12 12:40:00')
  366. ->get();
  367. $orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
  368. foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
  369. foreach ($orderPackingSummarys as $orderPackingSummary) {
  370. $orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
  371. $orderPackage->update([
  372. 'uploaded_to_wms'=> true,
  373. 'weight'=>$orderPackingSummary->grossweight,
  374. 'length'=>$orderPackingSummary->length,
  375. 'width'=>$orderPackingSummary->width,
  376. 'height'=>$orderPackingSummary->height,
  377. 'weighed_at'=>$orderPackingSummary->edittime
  378. ]);
  379. dispatch(new WeightUpdateInstantBill($orderPackage));
  380. }
  381. }
  382. return ['success' => true];
  383. }
  384. public function collectUpload()
  385. {
  386. /** @var OrderPackageService $service */
  387. $service = app('OrderPackageService');
  388. return $service->collectUpload([
  389. '75803656098638',
  390. '75803656098612'
  391. ]);
  392. }
  393. public function teset12313(){
  394. dd(route("discharge.storeApi"));
  395. }
  396. }