TestController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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\Database;
  9. use App\Components\ErrorPush;
  10. use App\ErrorTemp;
  11. use App\Feature;
  12. use App\Http\ApiControllers\LoginController;
  13. use App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeCell;
  14. use App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeRelation;
  15. use App\Http\Controllers\api\thirdPart\syrius\beans\Task;
  16. use App\Http\Controllers\api\thirdPart\syrius\beans\TaskItem;
  17. use App\Http\Controllers\api\thirdPart\syrius\producer\StorageTypeController;
  18. use App\Http\Controllers\api\thirdPart\syrius\units\StorageTypeAttribute;
  19. use App\Http\Requests\AndroidGateRequest;
  20. use App\Http\Requests\OrderDelivering;
  21. use App\Jobs\BatchTaskJob;
  22. use App\Jobs\CacheShelfTaskJob;
  23. use App\Jobs\OrderCreateInstantBill;
  24. use App\Jobs\OrderCreateWaybill;
  25. use App\Jobs\SettlementBillReportJob;
  26. use App\Jobs\StoreCreateInstantBill;
  27. use App\Jobs\TestJob;
  28. use App\Jobs\WeightUpdateInstantBill;
  29. use App\LaborCompanyDispatch;
  30. use App\LaborReport;
  31. use App\LaborReportStatus;
  32. use App\Logistic;
  33. use App\MaterialBox;
  34. use App\MaterialBoxModel;
  35. use App\Notifications\RoutineNotification;
  36. use App\OracleDOCASNHeader;
  37. use App\OracleDOCOrderHeader;
  38. use App\OracleDocOrderPackingSummary;
  39. use App\Order;
  40. use App\OrderBin;
  41. use App\OrderIssue;
  42. use App\OrderIssueProcessLog;
  43. use App\OrderPackage;
  44. use App\Owner;
  45. use App\OwnerAreaReport;
  46. use App\OwnerFeeDetail;
  47. use App\OwnerFeeDetailLogistic;
  48. use App\OwnerFeeExpress;
  49. use App\OwnerFeeLogistic;
  50. use App\OwnerFeeOperation;
  51. use App\OwnerFeeOperationDetail;
  52. use App\OwnerFeeStorage;
  53. use App\OwnerPriceExpress;
  54. use App\OwnerPriceOperation;
  55. use App\OrderPackageCountingRecord;
  56. use App\ProcurementCheckSheet;
  57. use App\RejectedBill;
  58. use App\SeeLog;
  59. use App\Services\AuthorityService;
  60. use App\Services\BatchService;
  61. use App\Services\CacheShelfService;
  62. use App\Services\ForeignHaiRoboticsService;
  63. use App\Services\NotificationService;
  64. use App\Services\OracleDOCOrderHeaderService;
  65. use App\Services\OrderPackageCommoditiesService;
  66. use App\Services\OrderPackageReceivedSyncService;
  67. use App\Services\OrderPackageService;
  68. use App\Services\OrderService;
  69. use App\Services\OwnerFeeTotalService;
  70. use App\Services\OwnerLogisticFeeReportService;
  71. use App\Services\OwnerPriceOperationService;
  72. use App\Services\OwnerStoreFeeReportService;
  73. use App\Services\OwnerStoreOutFeeReportService;
  74. use App\Services\ReviewService;
  75. use App\Services\StationService;
  76. use App\Services\StorageService;
  77. use App\Services\StoreService;
  78. use App\Station;
  79. use App\StationTask;
  80. use App\StationTaskMaterialBox;
  81. use App\Store;
  82. use App\StoreItem;
  83. use App\TaskTransaction;
  84. use App\Unit;
  85. use App\User;
  86. use App\UserDetail;
  87. use App\UserDutyCheck;
  88. use App\ValueStore;
  89. use App\Waybill;
  90. use App\WorkOrder;
  91. use Carbon\Carbon;
  92. use Carbon\CarbonPeriod;
  93. use Decimal\Decimal;
  94. use Doctrine\DBAL\Exception;
  95. use Firebase\JWT\JWT;
  96. use Illuminate\Database\Eloquent\Builder;
  97. use Illuminate\Database\Eloquent\Collection;
  98. use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
  99. use Illuminate\Foundation\Http\FormRequest;
  100. use Illuminate\Http\Request;
  101. use Illuminate\Support\Facades\Broadcast;
  102. use Illuminate\Support\Facades\Cache;
  103. use Illuminate\Support\Facades\Auth;
  104. use Illuminate\Support\Facades\Cookie;
  105. use Illuminate\Support\Facades\DB;
  106. use Illuminate\Support\Facades\Http;
  107. use Illuminate\Support\Facades\Log;
  108. use Illuminate\Support\Facades\Notification;
  109. use Illuminate\Support\Facades\URL;
  110. use Illuminate\Support\Facades\Validator;
  111. use Illuminate\Support\Str;
  112. use Laravel\Horizon\Events\JobFailed;
  113. use Monolog\Handler\IFTTTHandler;
  114. use phpDocumentor\Reflection\Types\Resource_;
  115. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  116. use Ramsey\Uuid\Uuid;
  117. use Symfony\Component\ErrorHandler\Error\FatalError;
  118. class TestController extends Controller
  119. {
  120. use AsyncResponse, ErrorPush, Database;
  121. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  122. public function __construct()
  123. {
  124. $this->data["active_test"] = "active";
  125. }
  126. public function method(Request $request, $method)
  127. {
  128. try {
  129. return call_user_func([$this, $method], $request);
  130. }catch (\BadMethodCallException $e){
  131. dd("方法不存在");
  132. }
  133. }
  134. /**
  135. * @param $wave
  136. * @return string
  137. */
  138. private function wms_status($wave): string
  139. {
  140. switch ($wave->wavestatus) {
  141. case 00:
  142. $wms_status = '创建';
  143. break;
  144. case 40:
  145. $wms_status = '部分收货';
  146. break;
  147. case 90:
  148. $wms_status = '取消';
  149. break;
  150. case 99:
  151. $wms_status = '完成';
  152. break;
  153. case 62:
  154. $wms_status = '部分装箱';
  155. break;
  156. default:
  157. $wms_status = (string)$wave->wavestatus;
  158. }
  159. return $wms_status;
  160. }
  161. public function assignBatch()
  162. {
  163. $code = \request("code");
  164. $batches = Batch::query()->where("code",$code)->get();
  165. if (!$batches->count()){
  166. $wave = DB::connection("oracle")->selectOne(DB::raw("select * from DOC_WAVE_HEADER where WAVENO = ?"),[$code]);
  167. if (!$wave){
  168. dd("FLUX无波次");
  169. }
  170. $owner = app("OwnerService")->codeGetOwner($wave->customerid);
  171. $obj = [
  172. "wms_status" => $this->wms_status($wave),
  173. "wms_type"=>$wave->descr,
  174. "created_at"=>date("Y-m-d H:i:s"),
  175. "wms_created_at"=>$wave->addtime,
  176. "updated_at"=>$wave->edittime,
  177. "owner_id"=>$owner->id,
  178. ];
  179. $wave = Batch::query()->where("code",$code)->first();
  180. if (!$wave){
  181. $obj["code"] = $code;
  182. $wave = Batch::query()->create($obj);
  183. }else{
  184. Batch::query()->where("code",$code)->update($obj);
  185. }
  186. $ordernos = array_column(DB::connection("oracle")->select(DB::raw("select orderno from DOC_WAVE_DETAILS where WAVENO = ?"),[$code]),"orderno");
  187. Order::query()->whereIn("code",$ordernos)->update([
  188. "batch_id"=>$wave->id
  189. ]);
  190. Order::query()->with(["batch","bin"])->whereIn("code",$ordernos)->get()->each(function ($order){
  191. if (!$order->bin){
  192. $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"),[$order->batch->code,$order->code]);
  193. if ($bin){
  194. OrderBin::query()->create([
  195. 'order_id' => $order->id,
  196. 'number' => $bin->seqno,
  197. ]);
  198. }
  199. }
  200. });
  201. $batches = Batch::query()->where("code",$code)->get();
  202. }
  203. app("BatchService")->assignTasks($batches);
  204. }
  205. public function test(Request $request)
  206. {
  207. $b = new StorageTypeController();
  208. $name = "test";
  209. $tag = "tag_name";
  210. $attributes = new \App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeAttribute();
  211. $attributes->icon = "http:///was.baoshi56.com/test.jpg";
  212. $attributes->quantity = 5;
  213. $attributes->length = 10.1;
  214. $attributes->weight = 10.1;
  215. $attributes->width = 10.1;
  216. $attributes->high = 10.1;
  217. $attributes->toolType = 0;
  218. $attributes->maxLoad = 55.6;
  219. $attributes->layers = 2;
  220. $attributes->numOfLayerCell = 20;
  221. $cell = new StorageTypeCell();
  222. $cell->name = "cell";
  223. $cell->color = "red";
  224. $cell->disassemble = false;
  225. $cell->capacity = 50;
  226. $cell->length = 30;
  227. $cell->width = 30;
  228. $cell->high = 30;
  229. $relation = new StorageTypeRelation();
  230. $relation->storageTypeId = 1;
  231. $relation->require = true;
  232. $relation->num = 500;
  233. //dd($b->getStorageType(1)->body());
  234. $c = $b->createStorageType($name,$tag,$attributes->get(),[(array)$cell->get()],[(array)$relation->get()]);
  235. dd($c->body());
  236. $sql = <<<SQL
  237. SELECT ORDERNO,WAVENO,WAREHOUSEID,CUSTOMERID FROM DOC_ORDER_HEADER WHERE ORDERNO = ?
  238. SQL;
  239. $sql1 = <<<SQL
  240. SELECT ORDERNO,ORDERLINENO,SKULINENO,a.SKU,LOTNUM,LOCATION,QTY_EACH,PICKTOTRACEID,DESCR_C,ALTERNATE_SKU1
  241. FROM ACT_ALLOCATION_DETAILS a LEFT JOIN BAS_SKU ON a.CUSTOMERID = BAS_SKU.CUSTOMERID
  242. AND a.SKU = BAS_SKU.SKU WHERE ORDERNO IN
  243. SQL;
  244. $db = DB::connection("oracle");
  245. $taskList = [];
  246. $map = [];
  247. $codes = "";
  248. foreach ($db->select($sql,["SO211015008847"]) as $index=>$item){
  249. $task = new Task();
  250. $task->id = $item->orderno;
  251. $task->batchId = $item->waveno;
  252. $task->warehouseId = $item->warehouseid;
  253. $task->attributes = [
  254. "customer" => $item->customerid,
  255. ];
  256. $task->items = [];
  257. $task->storages = [["type"=>"test"]];
  258. $taskList[] = $task;
  259. $map[$item->orderno] = $index;
  260. $codes .= "'".$item->orderno."',";
  261. }
  262. if (count($taskList)<0)dd(1);
  263. foreach ($db->select($sql1."(".rtrim($codes,",").")") as $item){
  264. $taskItem = new TaskItem();
  265. $taskItem->name = $item->descr_c;
  266. $taskItem->barcode = $item->alternate_sku1;
  267. $taskItem->quantity = $item->qty_each;
  268. $taskItem->binLocations = [
  269. $item->location,
  270. ];
  271. $taskItem->attributes = [
  272. "orderLineNo" => $item->orderlineno,
  273. "skuLineNo" => $item->skulineno,
  274. "sku" => $item->sku,
  275. "lotNum" => $item->lotnum,
  276. "logisticNumber"=>$item->picktotraceid,
  277. ];
  278. $taskList[$map[$item->orderno]]->items[] = (array)$taskItem->get();
  279. }
  280. $a = new \App\Http\Controllers\api\thirdPart\syrius\producer\OrderController();
  281. $a->createOrder($taskList[0]->get());
  282. }
  283. public function update_order_packages_is_manual_update()
  284. {
  285. $descriptions = Log::query()
  286. ->select('description')
  287. ->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
  288. ->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
  289. foreach ($descriptions as $description) {
  290. $description = substr($description, 9);
  291. $description = \Illuminate\Support\Str::before($description, "}");
  292. $obj = json_decode($description . '}', true);
  293. OrderPackage::query()
  294. ->whereIn('logistic_number', $obj['logistic_numbers'])
  295. ->update([
  296. 'status' => '无',
  297. 'is_manual_update' => false,
  298. ]);
  299. }
  300. }
  301. public function testUpdateInv()
  302. {
  303. ini_set('max_execution_time', 0);
  304. ini_set('memory_limit', '4096M');
  305. $sql = <<<sql
  306. select FMLOTNUM,FMLOCATION,PLANTOLOCATION,CREATE_TRANSACTIONID,SKU,CUSTOMERID from TSK_TASKLISTS
  307. where CUSTOMERID=?
  308. AND FMLOCATION= ?
  309. AND OPENWHO = ?
  310. AND TASKPROCESS = ?
  311. AND DOCTYPE = ?
  312. AND TASKTYPE = ?
  313. AND LOTATT05=?
  314. AND LOTATT08=?
  315. AND PLANTOID = ?
  316. and OPENTIME>=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  317. and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  318. sql;
  319. $CUSTOMERID = 'JIANSHANG';
  320. $FMLOCATION = 'STAGEWH02';
  321. $OPENWHO = 'WCS';
  322. $TASKPROCESS = '00';
  323. $DOCTYPE = 'ASN';
  324. $TASKTYPE = 'PA';
  325. $LOTATT05 = 'MJ-CP';
  326. $LOTATT08 = 'ZP';
  327. $PLANTOID = '*';
  328. $traceid = 'JIANSHANG03';
  329. $start = '2021-09-02 23:59:59';
  330. $end = '2021-09-03 11:10:00';
  331. $res = DB::connection("oracle")->select(DB::raw($sql),
  332. [$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
  333. $resItems = array_chunk($res, 200);
  334. foreach ($resItems as $res) {
  335. DB::connection("oracle")->beginTransaction();
  336. try {
  337. foreach ($res as $re) {
  338. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  339. ->where([
  340. 'LOTNUM' => $re->fmlotnum,
  341. 'LOCATIONID' => $re->fmlocation,
  342. 'CUSTOMERID' => $re->customerid,
  343. 'sku' => $re->sku,
  344. 'TRACEID' => '*',
  345. ])
  346. ->update([
  347. 'TRACEID' => $traceid,
  348. 'EDITWHO' => 'WCS_',
  349. ]);
  350. if ($re->fmlocation != $re->plantolocation) {
  351. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  352. ->where([
  353. 'LOTNUM' => $re->fmlotnum,
  354. 'LOCATIONID' => $re->plantolocation,
  355. 'CUSTOMERID' => $re->customerid,
  356. 'sku' => $re->sku,
  357. 'TRACEID' => '*',
  358. ])
  359. ->update([
  360. 'TRACEID' => $traceid,
  361. 'EDITWHO' => 'WCS_',
  362. ]);
  363. }
  364. DB::connection("oracle")->commit();
  365. }
  366. dd(true);
  367. } catch (\Exception $e) {
  368. DB::connection("oracle")->rollBack();
  369. dd($e->getMessage());
  370. }
  371. }
  372. }
  373. /**
  374. * 重置15天内的数据
  375. */
  376. public function order_packages_init()
  377. {
  378. OrderPackage::query()
  379. ->whereBetween('created_at', [now()->subDays(15), now()])
  380. ->update([
  381. 'is_delay_deliver' => 0,
  382. 'sync_routes_flag' => 0,
  383. 'status' => 1,
  384. 'exception_status' => 0,
  385. ]);
  386. OrderPackage::query()
  387. ->whereBetween('created_at', [now()->subDays(15), now()])
  388. ->whereNotNull('received_at')
  389. ->update([
  390. 'status' => 7,
  391. ]);
  392. }
  393. public function syncOrderPackage(){
  394. ini_set('memory_limit','500M');
  395. ini_set('max_execution_time', 0);
  396. $orderPackingSummary = OracleDocOrderPackingSummary::query()
  397. ->where('editTime','>=','2021-09-11 12:00:00')
  398. ->where('editTime','<=','2021-09-12 12:40:00')
  399. ->get();
  400. $orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
  401. foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
  402. foreach ($orderPackingSummarys as $orderPackingSummary) {
  403. $orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
  404. $orderPackage->update([
  405. 'uploaded_to_wms'=> true,
  406. 'weight'=>$orderPackingSummary->grossweight,
  407. 'length'=>$orderPackingSummary->length,
  408. 'width'=>$orderPackingSummary->width,
  409. 'height'=>$orderPackingSummary->height,
  410. 'weighed_at'=>$orderPackingSummary->edittime
  411. ]);
  412. dispatch(new WeightUpdateInstantBill($orderPackage));
  413. }
  414. }
  415. return ['success' => true];
  416. }
  417. public function collectUpload()
  418. {
  419. /** @var OrderPackageService $service */
  420. $service = app('OrderPackageService');
  421. return $service->collectUpload([
  422. '75601803541125'
  423. ]);
  424. }
  425. public function init_在途异常()
  426. {
  427. $logistic_numbers = OrderPackage::query()
  428. ->select('logistic_number')
  429. ->where('exception_status', 5)
  430. ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
  431. ->pluck('logistic_number');
  432. /** @var OrderPackageReceivedSyncService $service */
  433. $service = app('OrderPackageReceivedSyncService');
  434. $service->syncLogisticRoute(false, $logistic_numbers);
  435. // $logistic_numbers = OrderPackage::query()
  436. // ->select(['logistic_number', 'order_id', 'id'])
  437. // ->whereIn('order_id', function ($query) {
  438. // $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
  439. // $builder->from('logistics')->selectRaw('id')->where('type', '=', '快递')->whereNotIn('belong_company', ['顺丰', '中通', '韵达', '圆通', '京东']);
  440. // });
  441. // })
  442. // ->where('exception_status', 5)
  443. // ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
  444. // ->pluck('logistic_number');
  445. // $service->syncLogisticRouteByAliJiSu($logistic_numbers);
  446. }
  447. public function store()
  448. {
  449. ini_set('max_execution_time', 0);
  450. ini_set('memory_limit', '1024M');
  451. // $now = Carbon::now();
  452. // $startDate = $this->getDate();
  453. $startDate = '2021-09-25 13:23:14';
  454. $diffDay = 1; // 天数
  455. for($i = 0;$i<=$diffDay;$i++){
  456. $endDate = Carbon::parse($startDate)->addDays(1)->toDateTimeString();
  457. $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
  458. // if (count($doc_asn_headers)>0){
  459. // $this->syncStores($doc_asn_headers);
  460. // $this->syncDate($endDate);
  461. // }
  462. dump($startDate,$endDate);
  463. $startDate = $endDate;
  464. }
  465. $this->clearCache();
  466. // ValueStore::query()->updateOrCreate([
  467. // 'name' => 'last_asn_sync_task_end_at',
  468. // ], [
  469. // 'name' => 'last_asn_sync_task_end_at',
  470. // 'value' => $now,
  471. // ]);
  472. }
  473. public function getDocAsnHeader($startDate,$endDate)
  474. {
  475. return OracleDOCASNHeader::query()
  476. ->with(['asnType', 'asnStatus'])
  477. ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3','asnreference2')
  478. ->where('EditTime', '>=', $startDate)
  479. ->where('EditTime', '<=', $endDate)
  480. ->whereColumn('EditTime', '<>', 'addTime')
  481. ->orderByDesc('EditTime')
  482. ->get();
  483. }
  484. public function getDate(){
  485. return ValueStore::query()->where('name','asn_last_updated_sync_at')->value('value');
  486. }
  487. public function syncStores($doc_asn_headers){
  488. $service = new StoreService();
  489. $service->createStore($doc_asn_headers,"update");
  490. $service->updateStore($doc_asn_headers);
  491. $service->createStoreRejected($doc_asn_headers);
  492. unset($doc_asn_headers);
  493. }
  494. public function syncDate($date)
  495. {
  496. // 同步更新时间
  497. ValueStore::query()->updateOrCreate([
  498. 'name' => 'asn_last_updated_sync_at',
  499. ], [
  500. 'name' => 'asn_last_updated_sync_at',
  501. 'value' => $date,
  502. ]);
  503. }
  504. public function clearCache()
  505. {
  506. $service = new StoreService();
  507. $update_set = config('sync.asn_sync.cache_prefix.update_set');
  508. $update_keys = config('sync.asn_sync.cache_prefix.update_keys');
  509. $service->deleteCacheKey($update_set, $update_keys);
  510. // 清空保存 ans 号的栈
  511. // 清除 更新时间 开始 结束
  512. }
  513. public function updateStoreItem()
  514. {
  515. ini_set('max_execution_time', 0);
  516. ini_set('memory_limit', '1024M');
  517. $storeIds = Store::query()
  518. ->where('updated_at', '>=', '2021-09-25 13:21:26')
  519. ->whereColumn('updated_at', '<>', 'created_at')
  520. ->pluck('id');
  521. $storeItemMaxIds = StoreItem::query()
  522. ->selectRaw('max(id) as max_id')
  523. ->whereIn('store_id', $storeIds)
  524. ->groupBy(['store_id', 'asn_line_code'])
  525. ->get();
  526. // dd($storeItemMaxIds->count());
  527. $storeItems = StoreItem::query()
  528. ->whereIn('store_id', $storeIds)
  529. ->whereNotIn('id', $storeItemMaxIds)
  530. ->delete();
  531. }
  532. public function init_SettlementBillReportTask()
  533. {
  534. $this->dispatch(new SettlementBillReportJob('2021-09-01',[]));
  535. }
  536. public function test2(){
  537. $source_file ="E:\OneDrive\桌面\工作目录\文件库\\5.jpg";
  538. $img = ImageCreateFromJpeg($source_file);
  539. imagecolortransparent($img);//将某个颜色设置成透明色
  540. imagecolorstotal($img);
  541. header('Content-type:image/jpeg');
  542. imagejpeg($img);
  543. //dd($this->run('E:\OneDrive\桌面\工作目录\文件库\5.jpg', 'E:\OneDrive\桌面\工作目录\文件库\6.jpg'));
  544. }
  545. const FILE_NOT_FOUND = '-1';
  546. const FILE_EXTNAME_ILLEGAL = '-2';
  547. public function run($src1, $src2) {
  548. if(!is_file($src1) || !is_file($src2)) exit(self::FILE_NOT_FOUND);
  549. $hash1 = $this->getHashValue($src1);
  550. $hash2 = $this->getHashValue($src2);
  551. if(strlen($hash1) !== strlen($hash2)) return false;
  552. $count = 0;
  553. $len = strlen($hash1);
  554. for($i = 0; $i < $len; $i++) if($hash1[$i] !== $hash2[$i]){
  555. $count++;
  556. }
  557. dd($count);
  558. return $count <= 10 ? true : false;
  559. }
  560. public function getImage($file) {
  561. $extname = pathinfo($file, PATHINFO_EXTENSION);
  562. if(!in_array($extname, ['jpg','jpeg','png','gif'])) exit(self::FILE_EXTNAME_ILLEGAL);
  563. $img = call_user_func('imagecreatefrom'. ( $extname == 'jpg' ? 'jpeg' : $extname ) , $file);
  564. return $img;
  565. }
  566. public function getHashValue($file) {
  567. $w = 32;
  568. $h = 32;
  569. $img = imagecreatetruecolor($w, $h);
  570. list($src_w, $src_h) = getimagesize($file);
  571. $src = $this->getImage($file);
  572. imagecopyresampled($img, $src, 0, 0, 0, 0, $w, $h, $src_w, $src_h);
  573. imagedestroy($src);
  574. $total = 0;
  575. $array = array();
  576. for( $y = 0; $y < $h; $y++) {
  577. for ($x = 0; $x < $w; $x++) {
  578. $rgb = imagecolorat($img, $x, $y);
  579. $gray = $rgb & 0xFF;
  580. /*dump([
  581. ($rgb >> 8) & 0xFF,
  582. ($rgb >> 16) & 0xFF,
  583. $rgb & 0xFF,
  584. ]);*/
  585. if(!isset($array[$y])) $array[$y] = array();
  586. $array[$y][$x] = $gray;
  587. $total += $gray;
  588. }
  589. }
  590. imagedestroy($img);
  591. $average = intval($total / ($w * $h * 2));
  592. $hash = '';
  593. for($y = 0; $y < $h; $y++) {
  594. for($x = 0; $x < $w; $x++) {
  595. $hash .= ($array[$y][$x] >= $average) ? '1' : '0';
  596. }
  597. }
  598. dump($hash);
  599. return $hash;
  600. }
  601. public function sortTransferStatus()
  602. {
  603. $orderPackage = OrderPackage::query()->where('logistic_number','75601831068018')->first();
  604. app('OrderPackageService')->sortOrderPackageTransferStatus($orderPackage);
  605. dd($orderPackage);
  606. }
  607. public function clear_work_space()
  608. {
  609. \App\LaborApply::query()->truncate();
  610. LaborCompanyDispatch::query()->truncate();
  611. \App\LaborCompanyDispatchDetail::query()->truncate();
  612. }
  613. public function testChange()
  614. {
  615. $last_start_key = config('sync.order_sync.cache_prefix.last_start_at');
  616. $last_end_key = config('sync.order_sync.cache_prefix.last_end_at');
  617. Cache::put($last_start_key,Carbon::make('2021-10-12 06:23:37'));
  618. Cache::put($last_end_key,Carbon::make('2021-10-12 06:23:38'));
  619. ValueStore::query()->where('name','order_last_created_sync_at')->update(['value' => '2021-10-12 06:23:37']);
  620. ValueStore::query()->where('name','order_last_updated_sync_at')->update(['value' => '2021-10-12 06:23:37']);
  621. ValueStore::query()->where('name','last_order_sync_task_start_at')->update(['value' => '2021-10-12 06:23:37']);
  622. ValueStore::query()->where('name','last_order_sync_task_end_at')->update(['value' => '2021-10-12 06:23:38']);
  623. }
  624. public function syncOrder()
  625. {
  626. $code = \request("code");
  627. $service = new OracleDOCOrderHeaderService();
  628. $orderService = new OrderService();
  629. $orderHeaders = $service->getQuery()->where('DOC_Order_Header.WaveNo',$code)->get();
  630. $orderService->syncOrderByWMSOrderHeaders($orderHeaders);
  631. app("OrderCommodityService")->syncOrderCommodity($orderHeaders);
  632. dd('同步完成');
  633. }
  634. public function test_sddgdfg()
  635. {
  636. /** @var OwnerStoreOutFeeReportService $service */
  637. $service = app('OwnerStoreOutFeeReportService');
  638. $service->recordReport(null, [2]);
  639. }
  640. }