TestController.php 25 KB

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