TestController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. Log::info("揽收成功",["id"=>1,"number"=>2]);
  208. dd(1);
  209. $b = new StorageTypeController();
  210. $name = "test";
  211. $tag = "tag_name";
  212. $attributes = new \App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeAttribute();
  213. $attributes->icon = "http:///was.baoshi56.com/test.jpg";
  214. $attributes->quantity = 5;
  215. $attributes->length = 10.1;
  216. $attributes->weight = 10.1;
  217. $attributes->width = 10.1;
  218. $attributes->high = 10.1;
  219. $attributes->toolType = 0;
  220. $attributes->maxLoad = 55.6;
  221. $attributes->layers = 2;
  222. $attributes->numOfLayerCell = 20;
  223. $cell = new StorageTypeCell();
  224. $cell->name = "cell";
  225. $cell->color = "red";
  226. $cell->disassemble = false;
  227. $cell->capacity = 50;
  228. $cell->length = 30;
  229. $cell->width = 30;
  230. $cell->high = 30;
  231. $relation = new StorageTypeRelation();
  232. $relation->storageTypeId = 1;
  233. $relation->require = true;
  234. $relation->num = 500;
  235. //dd($b->getStorageType(1)->body());
  236. $c = $b->createStorageType($name,$tag,$attributes->get(),[(array)$cell->get()],[(array)$relation->get()]);
  237. dd($c->body());
  238. $sql = <<<SQL
  239. SELECT ORDERNO,WAVENO,WAREHOUSEID,CUSTOMERID FROM DOC_ORDER_HEADER WHERE ORDERNO = ?
  240. SQL;
  241. $sql1 = <<<SQL
  242. SELECT ORDERNO,ORDERLINENO,SKULINENO,a.SKU,LOTNUM,LOCATION,QTY_EACH,PICKTOTRACEID,DESCR_C,ALTERNATE_SKU1
  243. FROM ACT_ALLOCATION_DETAILS a LEFT JOIN BAS_SKU ON a.CUSTOMERID = BAS_SKU.CUSTOMERID
  244. AND a.SKU = BAS_SKU.SKU WHERE ORDERNO IN
  245. SQL;
  246. $db = DB::connection("oracle");
  247. $taskList = [];
  248. $map = [];
  249. $codes = "";
  250. foreach ($db->select($sql,["SO211015008847"]) as $index=>$item){
  251. $task = new Task();
  252. $task->id = $item->orderno;
  253. $task->batchId = $item->waveno;
  254. $task->warehouseId = $item->warehouseid;
  255. $task->attributes = [
  256. "customer" => $item->customerid,
  257. ];
  258. $task->items = [];
  259. $task->storages = [["type"=>"test"]];
  260. $taskList[] = $task;
  261. $map[$item->orderno] = $index;
  262. $codes .= "'".$item->orderno."',";
  263. }
  264. if (count($taskList)<0)dd(1);
  265. foreach ($db->select($sql1."(".rtrim($codes,",").")") as $item){
  266. $taskItem = new TaskItem();
  267. $taskItem->name = $item->descr_c;
  268. $taskItem->barcode = $item->alternate_sku1;
  269. $taskItem->quantity = $item->qty_each;
  270. $taskItem->binLocations = [
  271. $item->location,
  272. ];
  273. $taskItem->attributes = [
  274. "orderLineNo" => $item->orderlineno,
  275. "skuLineNo" => $item->skulineno,
  276. "sku" => $item->sku,
  277. "lotNum" => $item->lotnum,
  278. "logisticNumber"=>$item->picktotraceid,
  279. ];
  280. $taskList[$map[$item->orderno]]->items[] = (array)$taskItem->get();
  281. }
  282. $a = new \App\Http\Controllers\api\thirdPart\syrius\producer\OrderController();
  283. $a->createOrder($taskList[0]->get());
  284. }
  285. public function update_order_packages_is_manual_update()
  286. {
  287. $descriptions = Log::query()
  288. ->select('description')
  289. ->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
  290. ->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
  291. foreach ($descriptions as $description) {
  292. $description = substr($description, 9);
  293. $description = \Illuminate\Support\Str::before($description, "}");
  294. $obj = json_decode($description . '}', true);
  295. OrderPackage::query()
  296. ->whereIn('logistic_number', $obj['logistic_numbers'])
  297. ->update([
  298. 'status' => '无',
  299. 'is_manual_update' => false,
  300. ]);
  301. }
  302. }
  303. public function testUpdateInv()
  304. {
  305. ini_set('max_execution_time', 0);
  306. ini_set('memory_limit', '4096M');
  307. $sql = <<<sql
  308. select FMLOTNUM,FMLOCATION,PLANTOLOCATION,CREATE_TRANSACTIONID,SKU,CUSTOMERID from TSK_TASKLISTS
  309. where CUSTOMERID=?
  310. AND FMLOCATION= ?
  311. AND OPENWHO = ?
  312. AND TASKPROCESS = ?
  313. AND DOCTYPE = ?
  314. AND TASKTYPE = ?
  315. AND LOTATT05=?
  316. AND LOTATT08=?
  317. AND PLANTOID = ?
  318. and OPENTIME>=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  319. and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
  320. sql;
  321. $CUSTOMERID = 'JIANSHANG';
  322. $FMLOCATION = 'STAGEWH02';
  323. $OPENWHO = 'WCS';
  324. $TASKPROCESS = '00';
  325. $DOCTYPE = 'ASN';
  326. $TASKTYPE = 'PA';
  327. $LOTATT05 = 'MJ-CP';
  328. $LOTATT08 = 'ZP';
  329. $PLANTOID = '*';
  330. $traceid = 'JIANSHANG03';
  331. $start = '2021-09-02 23:59:59';
  332. $end = '2021-09-03 11:10:00';
  333. $res = DB::connection("oracle")->select(DB::raw($sql),
  334. [$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
  335. $resItems = array_chunk($res, 200);
  336. foreach ($resItems as $res) {
  337. DB::connection("oracle")->beginTransaction();
  338. try {
  339. foreach ($res as $re) {
  340. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  341. ->where([
  342. 'LOTNUM' => $re->fmlotnum,
  343. 'LOCATIONID' => $re->fmlocation,
  344. 'CUSTOMERID' => $re->customerid,
  345. 'sku' => $re->sku,
  346. 'TRACEID' => '*',
  347. ])
  348. ->update([
  349. 'TRACEID' => $traceid,
  350. 'EDITWHO' => 'WCS_',
  351. ]);
  352. if ($re->fmlocation != $re->plantolocation) {
  353. DB::connection("oracle")->table('INV_LOT_LOC_ID')
  354. ->where([
  355. 'LOTNUM' => $re->fmlotnum,
  356. 'LOCATIONID' => $re->plantolocation,
  357. 'CUSTOMERID' => $re->customerid,
  358. 'sku' => $re->sku,
  359. 'TRACEID' => '*',
  360. ])
  361. ->update([
  362. 'TRACEID' => $traceid,
  363. 'EDITWHO' => 'WCS_',
  364. ]);
  365. }
  366. DB::connection("oracle")->commit();
  367. }
  368. dd(true);
  369. } catch (\Exception $e) {
  370. DB::connection("oracle")->rollBack();
  371. dd($e->getMessage());
  372. }
  373. }
  374. }
  375. /**
  376. * 重置15天内的数据
  377. */
  378. public function order_packages_init()
  379. {
  380. OrderPackage::query()
  381. ->whereBetween('created_at', [now()->subDays(15), now()])
  382. ->update([
  383. 'is_delay_deliver' => 0,
  384. 'sync_routes_flag' => 0,
  385. 'status' => 1,
  386. 'exception_status' => 0,
  387. ]);
  388. OrderPackage::query()
  389. ->whereBetween('created_at', [now()->subDays(15), now()])
  390. ->whereNotNull('received_at')
  391. ->update([
  392. 'status' => 7,
  393. ]);
  394. }
  395. public function syncOrderPackage(){
  396. ini_set('memory_limit','500M');
  397. ini_set('max_execution_time', 0);
  398. $orderPackingSummary = OracleDocOrderPackingSummary::query()
  399. ->where('editTime','>=','2021-09-11 12:00:00')
  400. ->where('editTime','<=','2021-09-12 12:40:00')
  401. ->get();
  402. $orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
  403. foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
  404. foreach ($orderPackingSummarys as $orderPackingSummary) {
  405. $orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
  406. $orderPackage->update([
  407. 'uploaded_to_wms'=> true,
  408. 'weight'=>$orderPackingSummary->grossweight,
  409. 'length'=>$orderPackingSummary->length,
  410. 'width'=>$orderPackingSummary->width,
  411. 'height'=>$orderPackingSummary->height,
  412. 'weighed_at'=>$orderPackingSummary->edittime
  413. ]);
  414. dispatch(new WeightUpdateInstantBill($orderPackage));
  415. }
  416. }
  417. return ['success' => true];
  418. }
  419. public function collectUpload()
  420. {
  421. /** @var OrderPackageService $service */
  422. $service = app('OrderPackageService');
  423. return $service->collectUpload([
  424. '75601803541125'
  425. ]);
  426. }
  427. public function init_在途异常()
  428. {
  429. $logistic_numbers = OrderPackage::query()
  430. ->select('logistic_number')
  431. ->where('exception_status', 5)
  432. ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
  433. ->pluck('logistic_number');
  434. /** @var OrderPackageReceivedSyncService $service */
  435. $service = app('OrderPackageReceivedSyncService');
  436. $service->syncLogisticRoute(false, $logistic_numbers);
  437. // $logistic_numbers = OrderPackage::query()
  438. // ->select(['logistic_number', 'order_id', 'id'])
  439. // ->whereIn('order_id', function ($query) {
  440. // $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
  441. // $builder->from('logistics')->selectRaw('id')->where('type', '=', '快递')->whereNotIn('belong_company', ['顺丰', '中通', '韵达', '圆通', '京东']);
  442. // });
  443. // })
  444. // ->where('exception_status', 5)
  445. // ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
  446. // ->pluck('logistic_number');
  447. // $service->syncLogisticRouteByAliJiSu($logistic_numbers);
  448. }
  449. public function store()
  450. {
  451. ini_set('max_execution_time', 0);
  452. ini_set('memory_limit', '1024M');
  453. // $now = Carbon::now();
  454. // $startDate = $this->getDate();
  455. $startDate = '2021-09-25 13:23:14';
  456. $diffDay = 1; // 天数
  457. for($i = 0;$i<=$diffDay;$i++){
  458. $endDate = Carbon::parse($startDate)->addDays(1)->toDateTimeString();
  459. $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
  460. // if (count($doc_asn_headers)>0){
  461. // $this->syncStores($doc_asn_headers);
  462. // $this->syncDate($endDate);
  463. // }
  464. dump($startDate,$endDate);
  465. $startDate = $endDate;
  466. }
  467. $this->clearCache();
  468. // ValueStore::query()->updateOrCreate([
  469. // 'name' => 'last_asn_sync_task_end_at',
  470. // ], [
  471. // 'name' => 'last_asn_sync_task_end_at',
  472. // 'value' => $now,
  473. // ]);
  474. }
  475. public function getDocAsnHeader($startDate,$endDate)
  476. {
  477. return OracleDOCASNHeader::query()
  478. ->with(['asnType', 'asnStatus'])
  479. ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3','asnreference2')
  480. ->where('EditTime', '>=', $startDate)
  481. ->where('EditTime', '<=', $endDate)
  482. ->whereColumn('EditTime', '<>', 'addTime')
  483. ->orderByDesc('EditTime')
  484. ->get();
  485. }
  486. public function getDate(){
  487. return ValueStore::query()->where('name','asn_last_updated_sync_at')->value('value');
  488. }
  489. public function syncStores($doc_asn_headers){
  490. $service = new StoreService();
  491. $service->createStore($doc_asn_headers,"update");
  492. $service->updateStore($doc_asn_headers);
  493. $service->createStoreRejected($doc_asn_headers);
  494. unset($doc_asn_headers);
  495. }
  496. public function syncDate($date)
  497. {
  498. // 同步更新时间
  499. ValueStore::query()->updateOrCreate([
  500. 'name' => 'asn_last_updated_sync_at',
  501. ], [
  502. 'name' => 'asn_last_updated_sync_at',
  503. 'value' => $date,
  504. ]);
  505. }
  506. public function clearCache()
  507. {
  508. $service = new StoreService();
  509. $update_set = config('sync.asn_sync.cache_prefix.update_set');
  510. $update_keys = config('sync.asn_sync.cache_prefix.update_keys');
  511. $service->deleteCacheKey($update_set, $update_keys);
  512. // 清空保存 ans 号的栈
  513. // 清除 更新时间 开始 结束
  514. }
  515. public function updateStoreItem()
  516. {
  517. ini_set('max_execution_time', 0);
  518. ini_set('memory_limit', '1024M');
  519. $storeIds = Store::query()
  520. ->where('updated_at', '>=', '2021-09-25 13:21:26')
  521. ->whereColumn('updated_at', '<>', 'created_at')
  522. ->pluck('id');
  523. $storeItemMaxIds = StoreItem::query()
  524. ->selectRaw('max(id) as max_id')
  525. ->whereIn('store_id', $storeIds)
  526. ->groupBy(['store_id', 'asn_line_code'])
  527. ->get();
  528. // dd($storeItemMaxIds->count());
  529. $storeItems = StoreItem::query()
  530. ->whereIn('store_id', $storeIds)
  531. ->whereNotIn('id', $storeItemMaxIds)
  532. ->delete();
  533. }
  534. public function init_SettlementBillReportTask()
  535. {
  536. $this->dispatch(new SettlementBillReportJob('2021-09-01',[]));
  537. }
  538. public function test2(){
  539. $source_file ="E:\OneDrive\桌面\工作目录\文件库\\5.jpg";
  540. $img = ImageCreateFromJpeg($source_file);
  541. imagecolortransparent($img);//将某个颜色设置成透明色
  542. imagecolorstotal($img);
  543. header('Content-type:image/jpeg');
  544. imagejpeg($img);
  545. //dd($this->run('E:\OneDrive\桌面\工作目录\文件库\5.jpg', 'E:\OneDrive\桌面\工作目录\文件库\6.jpg'));
  546. }
  547. const FILE_NOT_FOUND = '-1';
  548. const FILE_EXTNAME_ILLEGAL = '-2';
  549. public function run($src1, $src2) {
  550. if(!is_file($src1) || !is_file($src2)) exit(self::FILE_NOT_FOUND);
  551. $hash1 = $this->getHashValue($src1);
  552. $hash2 = $this->getHashValue($src2);
  553. if(strlen($hash1) !== strlen($hash2)) return false;
  554. $count = 0;
  555. $len = strlen($hash1);
  556. for($i = 0; $i < $len; $i++) if($hash1[$i] !== $hash2[$i]){
  557. $count++;
  558. }
  559. dd($count);
  560. return $count <= 10 ? true : false;
  561. }
  562. public function getImage($file) {
  563. $extname = pathinfo($file, PATHINFO_EXTENSION);
  564. if(!in_array($extname, ['jpg','jpeg','png','gif'])) exit(self::FILE_EXTNAME_ILLEGAL);
  565. $img = call_user_func('imagecreatefrom'. ( $extname == 'jpg' ? 'jpeg' : $extname ) , $file);
  566. return $img;
  567. }
  568. public function getHashValue($file) {
  569. $w = 32;
  570. $h = 32;
  571. $img = imagecreatetruecolor($w, $h);
  572. list($src_w, $src_h) = getimagesize($file);
  573. $src = $this->getImage($file);
  574. imagecopyresampled($img, $src, 0, 0, 0, 0, $w, $h, $src_w, $src_h);
  575. imagedestroy($src);
  576. $total = 0;
  577. $array = array();
  578. for( $y = 0; $y < $h; $y++) {
  579. for ($x = 0; $x < $w; $x++) {
  580. $rgb = imagecolorat($img, $x, $y);
  581. $gray = $rgb & 0xFF;
  582. /*dump([
  583. ($rgb >> 8) & 0xFF,
  584. ($rgb >> 16) & 0xFF,
  585. $rgb & 0xFF,
  586. ]);*/
  587. if(!isset($array[$y])) $array[$y] = array();
  588. $array[$y][$x] = $gray;
  589. $total += $gray;
  590. }
  591. }
  592. imagedestroy($img);
  593. $average = intval($total / ($w * $h * 2));
  594. $hash = '';
  595. for($y = 0; $y < $h; $y++) {
  596. for($x = 0; $x < $w; $x++) {
  597. $hash .= ($array[$y][$x] >= $average) ? '1' : '0';
  598. }
  599. }
  600. dump($hash);
  601. return $hash;
  602. }
  603. public function sortTransferStatus()
  604. {
  605. $orderPackage = OrderPackage::query()->where('logistic_number','75601831068018')->first();
  606. app('OrderPackageService')->sortOrderPackageTransferStatus($orderPackage);
  607. dd($orderPackage);
  608. }
  609. public function clear_work_space()
  610. {
  611. \App\LaborApply::query()->truncate();
  612. LaborCompanyDispatch::query()->truncate();
  613. \App\LaborCompanyDispatchDetail::query()->truncate();
  614. }
  615. public function testChange()
  616. {
  617. $last_start_key = config('sync.order_sync.cache_prefix.last_start_at');
  618. $last_end_key = config('sync.order_sync.cache_prefix.last_end_at');
  619. Cache::put($last_start_key,Carbon::make('2021-10-12 06:23:37'));
  620. Cache::put($last_end_key,Carbon::make('2021-10-12 06:23:38'));
  621. ValueStore::query()->where('name','order_last_created_sync_at')->update(['value' => '2021-10-12 06:23:37']);
  622. ValueStore::query()->where('name','order_last_updated_sync_at')->update(['value' => '2021-10-12 06:23:37']);
  623. ValueStore::query()->where('name','last_order_sync_task_start_at')->update(['value' => '2021-10-12 06:23:37']);
  624. ValueStore::query()->where('name','last_order_sync_task_end_at')->update(['value' => '2021-10-12 06:23:38']);
  625. }
  626. public function syncOrder()
  627. {
  628. $code = \request("code");
  629. $service = new OracleDOCOrderHeaderService();
  630. $orderService = new OrderService();
  631. $orderHeaders = $service->getQuery()->where('DOC_Order_Header.WaveNo',$code)->get();
  632. $orderService->syncOrderByWMSOrderHeaders($orderHeaders);
  633. app("OrderCommodityService")->syncOrderCommodity($orderHeaders);
  634. dd('同步完成');
  635. }
  636. public function test_sddgdfg()
  637. {
  638. /** @var OwnerStoreOutFeeReportService $service */
  639. $service = app('OwnerStoreOutFeeReportService');
  640. $service->recordReport(null, [2]);
  641. }
  642. }