| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- <?php
- namespace App\Http\Controllers;
- use App\Authority;
- use App\Batch;
- use App\Commodity;
- use App\CommodityMaterialBoxModel;
- use App\Components\AsyncResponse;
- use App\Components\Database;
- use App\Components\ErrorPush;
- use App\ErrorTemp;
- use App\Feature;
- use App\Http\ApiControllers\LoginController;
- use App\Http\Requests\AndroidGateRequest;
- use App\Http\Requests\OrderDelivering;
- use App\Jobs\BatchTaskJob;
- use App\Jobs\CacheShelfTaskJob;
- use App\Jobs\OrderCreateInstantBill;
- use App\Jobs\OrderCreateWaybill;
- use App\Jobs\SettlementBillReportJob;
- use App\Jobs\StoreCreateInstantBill;
- use App\Jobs\TestJob;
- use App\Jobs\WeightUpdateInstantBill;
- use App\LaborCompanyDispatch;
- use App\LaborReport;
- use App\LaborReportStatus;
- use App\MaterialBox;
- use App\MaterialBoxModel;
- use App\Notifications\RoutineNotification;
- use App\OracleDOCASNHeader;
- use App\OracleDOCOrderHeader;
- use App\OracleDocOrderPackingSummary;
- use App\Order;
- use App\OrderBin;
- use App\OrderIssue;
- use App\OrderIssueProcessLog;
- use App\OrderPackage;
- use App\Owner;
- use App\OwnerAreaReport;
- use App\OwnerFeeDetail;
- use App\OwnerFeeDetailLogistic;
- use App\OwnerFeeExpress;
- use App\OwnerFeeLogistic;
- use App\OwnerFeeOperation;
- use App\OwnerFeeOperationDetail;
- use App\OwnerFeeStorage;
- use App\OwnerPriceOperation;
- use App\OrderPackageCountingRecord;
- use App\ProcurementCheckSheet;
- use App\RejectedBill;
- use App\SeeLog;
- use App\Services\AuthorityService;
- use App\Services\BatchService;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Services\NotificationService;
- use App\Services\OrderPackageReceivedSyncService;
- use App\Services\OrderPackageService;
- use App\Services\OrderService;
- use App\Services\OwnerFeeTotalService;
- use App\Services\OwnerLogisticFeeReportService;
- use App\Services\OwnerPriceOperationService;
- use App\Services\OwnerStoreFeeReportService;
- use App\Services\OwnerStoreOutFeeReportService;
- use App\Services\ReviewService;
- use App\Services\StationService;
- use App\Services\StorageService;
- use App\Services\StoreService;
- use App\Station;
- use App\StationTask;
- use App\StationTaskMaterialBox;
- use App\Store;
- use App\StoreItem;
- use App\TaskTransaction;
- use App\Unit;
- use App\User;
- use App\UserDetail;
- use App\UserDutyCheck;
- use App\ValueStore;
- use App\Waybill;
- use App\WorkOrder;
- use Carbon\Carbon;
- use Carbon\CarbonPeriod;
- use Decimal\Decimal;
- use Doctrine\DBAL\Exception;
- use Firebase\JWT\JWT;
- use Illuminate\Database\Eloquent\Collection;
- use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Broadcast;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Cookie;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Http;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Notification;
- use Illuminate\Support\Facades\URL;
- use Illuminate\Support\Facades\Validator;
- use Illuminate\Support\Str;
- use Laravel\Horizon\Events\JobFailed;
- use Monolog\Handler\IFTTTHandler;
- use phpDocumentor\Reflection\Types\Resource_;
- use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
- use Ramsey\Uuid\Uuid;
- use Symfony\Component\ErrorHandler\Error\FatalError;
- class TestController extends Controller
- {
- use AsyncResponse, ErrorPush, Database;
- const ASNREFERENCE_2 = 'ASNREFERENCE2';
- public function __construct()
- {
- $this->data["active_test"] = "active";
- }
- public function method(Request $request, $method)
- {
- try {
- return call_user_func([$this, $method], $request);
- }catch (\BadMethodCallException $e){
- dd("方法不存在");
- }
- }
- /**
- * @param $wave
- * @return string
- */
- private function wms_status($wave): string
- {
- switch ($wave->wavestatus) {
- case 00:
- $wms_status = '创建';
- break;
- case 40:
- $wms_status = '部分收货';
- break;
- case 90:
- $wms_status = '取消';
- break;
- case 99:
- $wms_status = '完成';
- break;
- case 62:
- $wms_status = '部分装箱';
- break;
- default:
- $wms_status = (string)$wave->wavestatus;
- }
- return $wms_status;
- }
- public function assignBatch()
- {
- $code = \request("code");
- $batches = Batch::query()->where("code",$code)->get();
- if (!$batches->count()){
- $wave = DB::connection("oracle")->selectOne(DB::raw("select * from DOC_WAVE_HEADER where WAVENO = ?"),[$code]);
- if (!$wave){
- dd("FLUX无波次");
- }
- $owner = app("OwnerService")->codeGetOwner($wave->customerid);
- $obj = [
- "wms_status" => $this->wms_status($wave),
- "wms_type"=>$wave->descr,
- "created_at"=>date("Y-m-d H:i:s"),
- "wms_created_at"=>$wave->addtime,
- "updated_at"=>$wave->edittime,
- "owner_id"=>$owner->id,
- ];
- $wave = Batch::query()->where("code",$code)->first();
- if (!$wave){
- $obj["code"] = $code;
- $wave = Batch::query()->create($obj);
- }else{
- Batch::query()->where("code",$code)->update($obj);
- }
- $ordernos = array_column(DB::connection("oracle")->select(DB::raw("select orderno from DOC_WAVE_DETAILS where WAVENO = ?"),[$code]),"orderno");
- Order::query()->whereIn("code",$ordernos)->update([
- "batch_id"=>$wave->id
- ]);
- Order::query()->with(["batch","bin"])->whereIn("code",$ordernos)->get()->each(function ($order){
- if (!$order->bin){
- $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"),[$order->batch->code,$order->code]);
- if ($bin){
- OrderBin::query()->create([
- 'order_id' => $order->id,
- 'number' => $bin->seqno,
- ]);
- }
- }
- });
- $batches = Batch::query()->where("code",$code)->get();
- }
- app("BatchService")->assignTasks($batches);
- }
- public function test()
- {
- $ids = [];
- $sql = <<<sql
- select id from orders where owner_id = 396
- and wms_status = '订单完成'
- and wms_edittime>='2021-09-01 00:00:00' and wms_edittime<'2021-10-01 00:00:00' and id not in
- (select outer_id from owner_fee_details where owner_id = 396 and created_at>='2021-09-01 00:00:00' and created_at<'2021-10-01 00:00:00'
- and outer_table_name = 'orders')
- sql;
- foreach (DB::select(DB::raw($sql)) as $order){
- $ids[] = $order->id;
- }
- $orders = Order::query()->whereIn("id",$ids)->get();
- dispatch(new OrderCreateInstantBill($orders));
- return;
- //中通接口请求body
- $collectUploadDTOS = [[
- 'billCode' => "75811463670235",
- 'weight' => 0,
- 'appId' => $appId,
- 'importDate' => now()->toDateTimeString(),
- ]];
- $body = json_encode([
- 'collectUploadDTOS' => $collectUploadDTOS,
- ], JSON_UNESCAPED_UNICODE);
- $data_digest = base64_encode(md5($body . $appSecret, TRUE));
- $headers = [
- 'Content-Type' => 'application/json; charset=UTF-8',
- 'x-companyid' => $xAppKey,
- 'x-datadigest' => $data_digest,
- ];
- dd(Http::withHeaders($headers)->withBody($body, 'application/json')->post($url)->body());
- $stores = Store::query()->whereIn("id",[490692,492252,492405,493259,491290,491758,492252,492989,493522,
- 496079,490702,491173,491780,493522,488622,490891,491020,491173,493308,489448,491020,491184,493573,493977,
- 496105,492086,493714,493977,496118,492593,492592,492591,492590,493011,493979,490721,492192,493429,493978,
- 496106,490721,491460,493165,496114,489319,489436,490703,491190,493957,496115,496114,489436,491147,
- 491695,492395,490711,491461,491695,492079,494533,496099,496096,490711,491458,491797,492244,
- 492422,496098,496097,496100,491458,491798,493572,493752,490443,491457,492394,493531,493572,491687,
- 492394,492968,493782,490431,490994,493782,488570,489103,490616,490994,493966,489862,490616,
- 490629,495645,490629,491455,488793])->get();
- $this->dispatch(new StoreCreateInstantBill($stores));
- dd(1);
- /** @var StationTaskMaterialBox $stationTaskMaterialBox */
- $stationTaskMaterialBox = app("StorageService")->createWarehousingTask($stationService->getStation_byType('立库')["id"],$station->materialBox->id);
- app("CacheShelfService")->lightUp($station->code,'3','0',['title'=>"等待机器人拿走,请勿操作"]);
- Cache::forever("CACHE_SHELF_OCCUPANCY_{$station->id}",true);
- dd($ForeignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox, $station));
- $user = Auth::user();
- $remark = "zengjunlj";
- $ownerName = 'zengjunlj' ?? '';
- $clientCode = 'zengjunljljlj' ?? '';
- $msg = $user["name"]."建立了新工单<br/>".$ownerName.":".$clientCode."<br/>".$remark;
- NotificationService::SingleRegister($msg,$clientCode,"订单管理-问题件");
- dd(1);
- $seeLog = SeeLog::query()->find(9);
- Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
- dd(1);
- Broadcast::channel('notification', function ($user, $id) {
- return (int) $user->id === (int) $id;
- });
- dd(1);
- Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
- dd(1);
- $username = config('database.connections.oracle.username');
- $password = config('database.connections.oracle.password');
- $host = config('database.connections.oracle.host');
- $service_name = config('database.connections.oracle.service_name');
- $conn = oci_connect($username, $password, $host . '/' . $service_name,"utf8");
- $sql = <<<sql
- BEGIN
- SPSO_HardAllocation_Process('WH01','Allocation','By OrderNO',
- null,'SO21090100007','0',null,
- 'zhouzhendong',:CODE);
- END;
- sql;
- $stmt = oci_parse($conn, $sql);
- $code = "";
- oci_bind_by_name($stmt, ':CODE', $code,300);
- oci_execute($stmt);
- oci_close($conn);
- dd($code);
- //
- $no = "SO21090900001";
- $db = DB::connection("oracle");
- //$order = $db->selectOne(DB::raw("select * from DOC_ORDER_HEADER where orderno = ?"),[$no]);
- dd($db->select($sql,[
- ]));
- $db->select("CALL SPSO_HardAllocation_Process(?,'Allocation','By OrderNO',null,?,'0',null,'zhouzhendong',@code)",[
- $order->warehouseid,$no
- ]);
- //SPSO_HardAllocation_Process
- dd($db->selectOne("select @code"));
- $date = "2021-09-14 15:47:00";
- dispatch(new TestJob("1"))->delay(Carbon::parse($date));
- dispatch(new TestJob("2"))->delay(Carbon::parse($date));
- dispatch(new TestJob("3"))->delay(Carbon::parse($date));
- dispatch(new TestJob("4"))->delay(Carbon::parse($date));
- dispatch(new TestJob("5"))->delay(Carbon::parse($date));
- dispatch(new TestJob("6"))->delay(Carbon::parse($date));
- dispatch(new TestJob("7"))->delay(Carbon::parse($date));
- dispatch(new TestJob("8"))->delay(Carbon::parse($date));
- dispatch(new TestJob("9"))->delay(Carbon::parse($date));
- dispatch(new TestJob("10"))->delay(Carbon::parse($date));
- dd(1);
- Station::query()->where("station_type_id", 5)->update(["status" => 1]);
- Cache::forget("CACHE_SHELF_AVAILABLE");
- $station = ["HAIB1-01-01", "HAIB1-02-01"];
- $material = ["IDE0001824", "IDE0001740", "IDE0002710"];
- Station::query()->whereIn("code", $station)->update(["status" => 0]);
- $stations = Station::query()->whereIn("code", $station)->get();
- $materials = MaterialBox::query()->whereIn("code", $material)->get();
- $dateTime = date("Y-m-d H:i:s");
- $task1 = StationTaskMaterialBox::query()->create([
- 'station_id' => $stations[0]->id,
- 'material_box_id' => $materials[0]->id,
- 'station_task_batch_id' => 1,
- 'status' => '待处理'
- ]);
- $task2 = StationTaskMaterialBox::query()->create([
- 'station_id' => $stations[1]->id,
- 'material_box_id' => $materials[1]->id,
- 'station_task_batch_id' => 1,
- 'status' => '待处理'
- ]);
- $task3 = StationTaskMaterialBox::query()->create([
- 'station_id' => 6,
- 'material_box_id' => $materials[2]->id,
- 'station_task_batch_id' => 1,
- 'status' => '待处理'
- ]);
- TaskTransaction::query()->insert([[
- "doc_code" => "test",
- "bar_code" => "test",
- "to_station_id" => $stations[0]->id,
- "material_box_id" => $materials[0]->id,
- "task_id" => $task1->id,
- "commodity_id" => 505012,//XUNI03
- "amount" => 1,
- "type" => "出库",
- "status" => 0,
- "mark" => 2,
- "bin_number" => 1,
- "created_at" => $dateTime,
- "updated_at" => $dateTime,
- ], [
- "doc_code" => "test",
- "bar_code" => "test",
- "to_station_id" => $stations[1]->id,
- "material_box_id" => $materials[1]->id,
- "task_id" => $task2->id,
- "commodity_id" => 505012,//XUNI03
- "amount" => 1,
- "type" => "出库",
- "status" => 0,
- "mark" => 2,
- "bin_number" => 1,
- "created_at" => $dateTime,
- "updated_at" => $dateTime,
- ], [
- "doc_code" => "test",
- "bar_code" => "test",
- "to_station_id" => 6,
- "material_box_id" => $materials[2]->id,
- "task_id" => $task3->id,
- "commodity_id" => 505012,//XUNI03
- "amount" => 1,
- "type" => "出库",
- "status" => 3,
- "mark" => 2,
- "bin_number" => 1,
- "created_at" => $dateTime,
- "updated_at" => $dateTime,
- ]]);
- $foreignHaiRoboticsService = new ForeignHaiRoboticsService();
- $toLocation = collect($station);
- $taskMaterialBoxes = collect([$task1, $task2]);
- $foreignHaiRoboticsService->
- fetchGroup_multiLocation($toLocation, $taskMaterialBoxes, '', '立架出至缓存架', 20, false);
- foreach ($toLocation as $index => $value) {
- app("CacheShelfService")->lightUp($value, '3', '0', ["title" => "机器人取箱中,禁止操作"]);
- Cache::forever("CACHE_SHELF_OCCUPANCY_{$stations[$index]->id}", true);
- }
- app("StationService")->locationOccupyMulti($toLocation->toArray());
- }
- public function update_order_packages_is_manual_update()
- {
- $descriptions = Log::query()
- ->select('description')
- ->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
- ->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
- foreach ($descriptions as $description) {
- $description = substr($description, 9);
- $description = \Illuminate\Support\Str::before($description, "}");
- $obj = json_decode($description . '}', true);
- OrderPackage::query()
- ->whereIn('logistic_number', $obj['logistic_numbers'])
- ->update([
- 'status' => '无',
- 'is_manual_update' => false,
- ]);
- }
- }
- public function testUpdateInv()
- {
- ini_set('max_execution_time', 0);
- ini_set('memory_limit', '4096M');
- $sql = <<<sql
- select FMLOTNUM,FMLOCATION,PLANTOLOCATION,CREATE_TRANSACTIONID,SKU,CUSTOMERID from TSK_TASKLISTS
- where CUSTOMERID=?
- AND FMLOCATION= ?
- AND OPENWHO = ?
- AND TASKPROCESS = ?
- AND DOCTYPE = ?
- AND TASKTYPE = ?
- AND LOTATT05=?
- AND LOTATT08=?
- AND PLANTOID = ?
- and OPENTIME>=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
- and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
- sql;
- $CUSTOMERID = 'JIANSHANG';
- $FMLOCATION = 'STAGEWH02';
- $OPENWHO = 'WCS';
- $TASKPROCESS = '00';
- $DOCTYPE = 'ASN';
- $TASKTYPE = 'PA';
- $LOTATT05 = 'MJ-CP';
- $LOTATT08 = 'ZP';
- $PLANTOID = '*';
- $traceid = 'JIANSHANG03';
- $start = '2021-09-02 23:59:59';
- $end = '2021-09-03 11:10:00';
- $res = DB::connection("oracle")->select(DB::raw($sql),
- [$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
- $resItems = array_chunk($res, 200);
- foreach ($resItems as $res) {
- DB::connection("oracle")->beginTransaction();
- try {
- foreach ($res as $re) {
- DB::connection("oracle")->table('INV_LOT_LOC_ID')
- ->where([
- 'LOTNUM' => $re->fmlotnum,
- 'LOCATIONID' => $re->fmlocation,
- 'CUSTOMERID' => $re->customerid,
- 'sku' => $re->sku,
- 'TRACEID' => '*',
- ])
- ->update([
- 'TRACEID' => $traceid,
- 'EDITWHO' => 'WCS_',
- ]);
- if ($re->fmlocation != $re->plantolocation) {
- DB::connection("oracle")->table('INV_LOT_LOC_ID')
- ->where([
- 'LOTNUM' => $re->fmlotnum,
- 'LOCATIONID' => $re->plantolocation,
- 'CUSTOMERID' => $re->customerid,
- 'sku' => $re->sku,
- 'TRACEID' => '*',
- ])
- ->update([
- 'TRACEID' => $traceid,
- 'EDITWHO' => 'WCS_',
- ]);
- }
- DB::connection("oracle")->commit();
- }
- dd(true);
- } catch (\Exception $e) {
- DB::connection("oracle")->rollBack();
- dd($e->getMessage());
- }
- }
- }
- /**
- * 重置15天内的数据
- */
- public function order_packages_init()
- {
- OrderPackage::query()
- ->whereBetween('created_at', [now()->subDays(15), now()])
- ->update([
- 'is_delay_deliver' => 0,
- 'sync_routes_flag' => 0,
- 'status' => 1,
- 'exception_status' => 0,
- ]);
- OrderPackage::query()
- ->whereBetween('created_at', [now()->subDays(15), now()])
- ->whereNotNull('received_at')
- ->update([
- 'status' => 7,
- ]);
- }
- public function syncOrderPackage(){
- ini_set('memory_limit','500M');
- ini_set('max_execution_time', 0);
- $orderPackingSummary = OracleDocOrderPackingSummary::query()
- ->where('editTime','>=','2021-09-11 12:00:00')
- ->where('editTime','<=','2021-09-12 12:40:00')
- ->get();
- $orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
- foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
- foreach ($orderPackingSummarys as $orderPackingSummary) {
- $orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
- $orderPackage->update([
- 'uploaded_to_wms'=> true,
- 'weight'=>$orderPackingSummary->grossweight,
- 'length'=>$orderPackingSummary->length,
- 'width'=>$orderPackingSummary->width,
- 'height'=>$orderPackingSummary->height,
- 'weighed_at'=>$orderPackingSummary->edittime
- ]);
- dispatch(new WeightUpdateInstantBill($orderPackage));
- }
- }
- return ['success' => true];
- }
- public function collectUpload()
- {
- /** @var OrderPackageService $service */
- $service = app('OrderPackageService');
- return $service->collectUpload([
- '75601803541125'
- ]);
- }
- public function init_在途异常()
- {
- $logistic_numbers = OrderPackage::query()
- ->select('logistic_number')
- ->where('exception_status', 5)
- ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
- ->pluck('logistic_number');
- /** @var OrderPackageReceivedSyncService $service */
- $service = app('OrderPackageReceivedSyncService');
- $service->syncLogisticRoute(false, $logistic_numbers);
- // $logistic_numbers = OrderPackage::query()
- // ->select(['logistic_number', 'order_id', 'id'])
- // ->whereIn('order_id', function ($query) {
- // $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
- // $builder->from('logistics')->selectRaw('id')->where('type', '=', '快递')->whereNotIn('belong_company', ['顺丰', '中通', '韵达', '圆通', '京东']);
- // });
- // })
- // ->where('exception_status', 5)
- // ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
- // ->pluck('logistic_number');
- // $service->syncLogisticRouteByAliJiSu($logistic_numbers);
- }
- public function store()
- {
- ini_set('max_execution_time', 0);
- ini_set('memory_limit', '1024M');
- // $now = Carbon::now();
- // $startDate = $this->getDate();
- $startDate = '2021-09-25 13:23:14';
- $diffDay = 1; // 天数
- for($i = 0;$i<=$diffDay;$i++){
- $endDate = Carbon::parse($startDate)->addDays(1)->toDateTimeString();
- $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
- // if (count($doc_asn_headers)>0){
- // $this->syncStores($doc_asn_headers);
- // $this->syncDate($endDate);
- // }
- dump($startDate,$endDate);
- $startDate = $endDate;
- }
- $this->clearCache();
- // ValueStore::query()->updateOrCreate([
- // 'name' => 'last_asn_sync_task_end_at',
- // ], [
- // 'name' => 'last_asn_sync_task_end_at',
- // 'value' => $now,
- // ]);
- }
- public function getDocAsnHeader($startDate,$endDate)
- {
- return OracleDOCASNHeader::query()
- ->with(['asnType', 'asnStatus'])
- ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3','asnreference2')
- ->where('EditTime', '>=', $startDate)
- ->where('EditTime', '<=', $endDate)
- ->whereColumn('EditTime', '<>', 'addTime')
- ->orderByDesc('EditTime')
- ->get();
- }
- public function getDate(){
- return ValueStore::query()->where('name','asn_last_updated_sync_at')->value('value');
- }
- public function syncStores($doc_asn_headers){
- $service = new StoreService();
- $service->createStore($doc_asn_headers,"update");
- $service->updateStore($doc_asn_headers);
- $service->createStoreRejected($doc_asn_headers);
- unset($doc_asn_headers);
- }
- public function syncDate($date)
- {
- // 同步更新时间
- ValueStore::query()->updateOrCreate([
- 'name' => 'asn_last_updated_sync_at',
- ], [
- 'name' => 'asn_last_updated_sync_at',
- 'value' => $date,
- ]);
- }
- public function clearCache()
- {
- $service = new StoreService();
- $update_set = config('sync.asn_sync.cache_prefix.update_set');
- $update_keys = config('sync.asn_sync.cache_prefix.update_keys');
- $service->deleteCacheKey($update_set, $update_keys);
- // 清空保存 ans 号的栈
- // 清除 更新时间 开始 结束
- }
- public function updateStoreItem()
- {
- ini_set('max_execution_time', 0);
- ini_set('memory_limit', '1024M');
- $storeIds = Store::query()
- ->where('updated_at', '>=', '2021-09-25 13:21:26')
- ->whereColumn('updated_at', '<>', 'created_at')
- ->pluck('id');
- $storeItemMaxIds = StoreItem::query()
- ->selectRaw('max(id) as max_id')
- ->whereIn('store_id', $storeIds)
- ->groupBy(['store_id', 'asn_line_code'])
- ->get();
- // dd($storeItemMaxIds->count());
- $storeItems = StoreItem::query()
- ->whereIn('store_id', $storeIds)
- ->whereNotIn('id', $storeItemMaxIds)
- ->delete();
- }
- public function init_SettlementBillReportTask()
- {
- $this->dispatch(new SettlementBillReportJob('2021-08-01',[]));
- }
- public function test2(){
- $source_file ="E:\OneDrive\桌面\工作目录\文件库\\5.jpg";
- $img = ImageCreateFromJpeg($source_file);
- imagecolortransparent($img);//将某个颜色设置成透明色
- imagecolorstotal($img);
- header('Content-type:image/jpeg');
- imagejpeg($img);
- //dd($this->run('E:\OneDrive\桌面\工作目录\文件库\5.jpg', 'E:\OneDrive\桌面\工作目录\文件库\6.jpg'));
- }
- const FILE_NOT_FOUND = '-1';
- const FILE_EXTNAME_ILLEGAL = '-2';
- public function run($src1, $src2) {
- if(!is_file($src1) || !is_file($src2)) exit(self::FILE_NOT_FOUND);
- $hash1 = $this->getHashValue($src1);
- $hash2 = $this->getHashValue($src2);
- if(strlen($hash1) !== strlen($hash2)) return false;
- $count = 0;
- $len = strlen($hash1);
- for($i = 0; $i < $len; $i++) if($hash1[$i] !== $hash2[$i]){
- $count++;
- }
- dd($count);
- return $count <= 10 ? true : false;
- }
- public function getImage($file) {
- $extname = pathinfo($file, PATHINFO_EXTENSION);
- if(!in_array($extname, ['jpg','jpeg','png','gif'])) exit(self::FILE_EXTNAME_ILLEGAL);
- $img = call_user_func('imagecreatefrom'. ( $extname == 'jpg' ? 'jpeg' : $extname ) , $file);
- return $img;
- }
- public function getHashValue($file) {
- $w = 32;
- $h = 32;
- $img = imagecreatetruecolor($w, $h);
- list($src_w, $src_h) = getimagesize($file);
- $src = $this->getImage($file);
- imagecopyresampled($img, $src, 0, 0, 0, 0, $w, $h, $src_w, $src_h);
- imagedestroy($src);
- $total = 0;
- $array = array();
- for( $y = 0; $y < $h; $y++) {
- for ($x = 0; $x < $w; $x++) {
- $rgb = imagecolorat($img, $x, $y);
- $gray = $rgb & 0xFF;
- /*dump([
- ($rgb >> 8) & 0xFF,
- ($rgb >> 16) & 0xFF,
- $rgb & 0xFF,
- ]);*/
- if(!isset($array[$y])) $array[$y] = array();
- $array[$y][$x] = $gray;
- $total += $gray;
- }
- }
- imagedestroy($img);
- $average = intval($total / ($w * $h * 2));
- $hash = '';
- for($y = 0; $y < $h; $y++) {
- for($x = 0; $x < $w; $x++) {
- $hash .= ($array[$y][$x] >= $average) ? '1' : '0';
- }
- }
- dump($hash);
- return $hash;
- }
- public function sortTransferStatus()
- {
- $orderPackage = OrderPackage::query()->where('logistic_number','75601831068018')->first();
- app('OrderPackageService')->sortOrderPackageTransferStatus($orderPackage);
- dd($orderPackage);
- }
- public function clear_work_space()
- {
- \App\LaborApply::query()->truncate();
- LaborCompanyDispatch::query()->truncate();
- \App\LaborCompanyDispatchDetail::query()->truncate();
- }
- }
|