TestController.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Commodity;
  5. use App\CommodityMaterialBoxModel;
  6. use App\Components\AsyncResponse;
  7. use App\Components\ErrorPush;
  8. use App\ErrorTemp;
  9. use App\Feature;
  10. use App\Http\ApiControllers\LoginController;
  11. use App\Http\Requests\OrderDelivering;
  12. use App\Jobs\CacheShelfTaskJob;
  13. use App\Jobs\OrderCreateInstantBill;
  14. use App\Jobs\OrderCreateWaybill;
  15. use App\Jobs\SettlementBillReportTask;
  16. use App\Jobs\StoreCreateInstantBill;
  17. use App\Jobs\WeightUpdateInstantBill;
  18. use App\Log;
  19. use App\MaterialBox;
  20. use App\MaterialBoxModel;
  21. use App\Order;
  22. use App\OrderPackage;
  23. use App\Owner;
  24. use App\OwnerFeeDetail;
  25. use App\OwnerFeeDetailLogistic;
  26. use App\OwnerFeeExpress;
  27. use App\OwnerFeeLogistic;
  28. use App\OwnerFeeOperation;
  29. use App\OwnerFeeOperationDetail;
  30. use App\OwnerFeeStorage;
  31. use App\OwnerPriceOperation;
  32. use App\OrderPackageCountingRecord;
  33. use App\ProcurementCheckSheet;
  34. use App\RejectedBill;
  35. use App\Services\CacheShelfService;
  36. use App\Services\ForeignHaiRoboticsService;
  37. use App\Services\OrderPackageReceivedSyncService;
  38. use App\Services\OrderService;
  39. use App\Services\OwnerFeeTotalService;
  40. use App\Services\OwnerLogisticFeeReportService;
  41. use App\Services\OwnerPriceOperationService;
  42. use App\Services\OwnerStoreFeeReportService;
  43. use App\Services\OwnerStoreOutFeeReportService;
  44. use App\Services\StationService;
  45. use App\Services\StorageService;
  46. use App\Station;
  47. use App\StationTask;
  48. use App\StationTaskMaterialBox;
  49. use App\Store;
  50. use App\TaskTransaction;
  51. use App\Unit;
  52. use App\User;
  53. use App\UserDetail;
  54. use App\UserDutyCheck;
  55. use App\ValueStore;
  56. use App\Waybill;
  57. use Carbon\Carbon;
  58. use Carbon\CarbonPeriod;
  59. use Decimal\Decimal;
  60. use Doctrine\DBAL\Exception;
  61. use Firebase\JWT\JWT;
  62. use Illuminate\Database\Eloquent\Collection;
  63. use Illuminate\Foundation\Http\FormRequest;
  64. use Illuminate\Http\Request;
  65. use Illuminate\Support\Facades\Cache;
  66. use Illuminate\Support\Facades\Auth;
  67. use Illuminate\Support\Facades\Cookie;
  68. use Illuminate\Support\Facades\DB;
  69. use Illuminate\Support\Facades\Http;
  70. use Illuminate\Support\Facades\URL;
  71. use Illuminate\Support\Facades\Validator;
  72. use Laravel\Horizon\Events\JobFailed;
  73. use Monolog\Handler\IFTTTHandler;
  74. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  75. class TestController extends Controller
  76. {
  77. use AsyncResponse, ErrorPush;
  78. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  79. public function __construct()
  80. {
  81. $this->data["active_test"] = "active";
  82. }
  83. public function method(Request $request, $method)
  84. {
  85. return call_user_func([$this, $method], $request);
  86. }
  87. public function test()
  88. {
  89. $a = 1;
  90. if ($a > 2) dd(1);
  91. else if ($a == 0) dd(2);
  92. dd(3);
  93. }
  94. public function update_order_packages_is_manual_update()
  95. {
  96. $descriptions = Log::query()
  97. ->select('description')
  98. ->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
  99. ->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
  100. foreach ($descriptions as $description) {
  101. $description = substr($description, 9);
  102. $description = \Illuminate\Support\Str::before($description, "}");
  103. $obj = json_decode($description . '}', true);
  104. OrderPackage::query()
  105. ->whereIn('logistic_number', $obj['logistic_numbers'])
  106. ->update([
  107. 'status' => '无',
  108. 'is_manual_update' => false,
  109. ]);
  110. }
  111. }
  112. public function testUpdateInv()
  113. {
  114. ini_set('max_execution_time', 0);
  115. ini_set('memory_limit', '4096M');
  116. $sql = <<<sql
  117. select FMLOTNUM,FMLOCATION,PLANTOLOCATION,CREATE_TRANSACTIONID,SKU,CUSTOMERID from TSK_TASKLISTS
  118. where CUSTOMERID=?
  119. AND FMLOCATION= ?
  120. AND OPENWHO = ?
  121. AND TASKPROCESS = ?
  122. AND DOCTYPE = ?
  123. AND TASKTYPE = ?
  124. AND LOTATT05=?
  125. AND LOTATT08=?
  126. AND PLANTOID = ?
  127. and OPENTIME>=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  128. and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  129. sql;
  130. $CUSTOMERID = 'JIANSHANG';
  131. $FMLOCATION = 'STAGEWH02';
  132. $OPENWHO = 'WCS';
  133. $TASKPROCESS = '00';
  134. $DOCTYPE = 'ASN';
  135. $TASKTYPE = 'PA';
  136. $LOTATT05 = 'MJ-CP';
  137. $LOTATT08 = 'ZP';
  138. $PLANTOID = '*';
  139. $traceid = 'JIANSHANG03';
  140. $start = '2021-09-02 23:59:59';
  141. $end = '2021-09-03 11:10:00';
  142. $res = DB::connection("oracle")->select(DB::raw($sql),
  143. [$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
  144. $resItems = array_chunk($res, 200);
  145. foreach ($resItems as $res) {
  146. DB::connection("oracle")->beginTransaction();
  147. try {
  148. foreach ($res as $re) {
  149. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  150. ->where([
  151. 'LOTNUM' => $re->fmlotnum,
  152. 'LOCATIONID' => $re->fmlocation,
  153. 'CUSTOMERID' => $re->customerid,
  154. 'sku' => $re->sku,
  155. 'TRACEID' => '*',
  156. ])
  157. ->update([
  158. 'TRACEID' => $traceid,
  159. 'EDITWHO' => 'WCS_',
  160. ]);
  161. if ($re->fmlocation != $re->plantolocation) {
  162. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  163. ->where([
  164. 'LOTNUM' => $re->fmlotnum,
  165. 'LOCATIONID' => $re->plantolocation,
  166. 'CUSTOMERID' => $re->customerid,
  167. 'sku' => $re->sku,
  168. 'TRACEID' => '*',
  169. ])
  170. ->update([
  171. 'TRACEID' => $traceid,
  172. 'EDITWHO' => 'WCS_',
  173. ]);
  174. }
  175. DB::connection("oracle")->commit();
  176. }
  177. dd(true);
  178. } catch (\Exception $e) {
  179. DB::connection("oracle")->rollBack();
  180. dd($e->getMessage());
  181. }
  182. }
  183. }
  184. }