<?php

namespace App\Providers;

use App\Http\Controllers\Controller;
use App\Services\AuthorityService;
use App\Services\BatchService;
use App\Services\CacheService;
use App\Services\CacheShelfService;
use App\Services\CommodityService;
use App\Services\common\BatchUpdateService;
use App\Services\CommodityBarcodeService;
use App\Services\common\DataHandlerService;
use App\Services\ConfigurationService;
use App\Services\CustomerLogService;
use App\Services\CustomerLogStatusService;
use App\Services\CustomerService;
use App\Services\DepositoryService;
use App\Services\FacilitatorService;
use App\Services\DemandService;
use App\Services\DemandProcessService;
use App\Services\FeatureService;
use App\Services\ForeignHaiRoboticsService;
use App\Services\InventoryAccountMissionService;
use App\Services\InventoryCompareService;
use App\Services\LaborReportsCountingRecordService;
use App\Services\LogisticSFService;
use App\Services\LogisticYTOService;
use App\Services\LogService;
use App\Services\MaterialBoxService;
use App\Services\OracleBasCustomerService;
use App\Services\OracleBasSkuService;
use App\Services\OracleDocAsnDetailService;
use App\Services\OracleDOCOrderHeaderService;
use App\Services\OracleDocWaveDetailService;
use App\Services\OrderCommodityService;
use App\Services\OrderCommodityAssignService;
use App\Services\OrderIssuePerformanceService;
use App\Services\AllInventoryService;
use App\Services\InventoryDailyLogService;
use App\Services\LogisticService;
use App\Services\OracleActAllocationDetailService;
use App\Services\OrderIssueProcessLogService;
use App\Services\OrderIssueRejectedBillService;
use App\Services\OrderIssueService;
use App\Services\OrderPackageReceivedSyncService;
use App\Services\OrderPackageService;
use App\Services\OrderService;
use App\Services\OrderIssueWorkLoadService;
use App\Services\OrderPackageCommoditiesService;
use App\Services\OrderTrackingService;
use App\Services\OwnerAreaReportService;
use App\Services\OwnerBillReportService;
use App\Services\OwnerFeeDetailService;
use App\Services\OwnerMaterialService;
use App\Services\OwnerPriceDirectLogisticService;
use App\Services\OwnerPriceExpressService;
use App\Services\OwnerPriceLogisticService;
use App\Services\OwnerPriceOperationItemService;
use App\Services\OwnerPriceOperationService;
use App\Services\OwnerReportService;
use App\Services\OwnerService;
use App\Services\OwnerStoragePriceModelService;
use App\Services\PackageService;
use App\Services\PackageStatisticsService;
use App\Services\ProcessesContentService;
use App\Services\ProcessMethodService;
use App\Services\ProcessService;
use App\Services\ProcessStatisticService;
use App\Services\ProcurementService;
use App\Services\ProcurementTotalBillService;
use App\Services\ProcurementWeiXinSendMessageService;
use App\Services\ProvinceService;
use App\Services\RealtimePendingOrdersService;
use App\Services\RejectedBillItemService;
use App\Services\RejectedBillService;
use App\Services\ShopService;
use App\Services\RejectedService;
use App\Services\StationRuleBatchService;
use App\Services\StationTaskBatchService;
use App\Services\StationTaskBatchTypeService;
use App\Services\StationService;
use App\Services\StationTaskChildService;
use App\Services\StationTaskCommodityService;
use App\Services\StationTaskMaterialBoxService;
use App\Services\StationTaskService;
use App\Services\StationTaskTypeService;
use App\Services\StationTypeBinMonitorService;
use App\Services\StationTypeService;
use App\Services\StoreCheckingReceiveItemService;
use App\Services\StoreCheckingReceiveService;
use App\Services\StoreItemService;
use App\Services\StoreService;
use App\Services\CheckActiveMenuService;
use App\Services\UnitService;
use App\Services\UserOwnerGroupService;
use App\Services\UserService;
use App\Services\WarehouseService;
use App\Services\WaybillFinancialService;
use App\Services\WeighExceptedService;
use App\Services\OrderFreezeService;
use App\Services\RegionService;
use App\Services\UserWorkgroupService;
use App\Services\DischargeTaskService;
use App\Services\DeliveryAppointmentService;
use App\Services\StationCacheShelfGridService;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Facades\Validator;
use App\Services\SupplierService;
use App\Services\OrderPackageCommoditySerialNumberService;
use App\Services\OrderPackageExceptionTypeCountingRecordService;
use App\Services\LogisticYDService;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->loadingService();
        //
        Schema::defaultStringLength(191);
        Queue::failing(function (JobFailed $event) {
            (new Controller())->log(__METHOD__,'EventError_',json_encode($event));
        });
        //扩展身份证验证规则
        Validator::extend('identity_cards', function($attribute, $value, $parameters) {
            return preg_match('/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', $value);
        });
        View::share('pageUuid',Uuid::uuid4());

        \Illuminate\Database\Query\Builder::macro('sql', function () {
            $bindings = $this->getBindings();
            $sql = str_replace('?',"'%s'",$this->toSql());
            return vsprintf($sql, $bindings);
        });

        \Illuminate\Database\Eloquent\Builder::macro('sql', function(){
            return ($this->getQuery()->sql());
        });
    }

    private function loadingService(){
        app()->singleton('AllInventoryService',AllInventoryService::class);
        app()->singleton('AuthorityService',AuthorityService::class);
        app()->singleton('BatchService',BatchService::class);
        app()->singleton('BatchUpdateService', BatchUpdateService::class);
        app()->singleton('CacheService',CacheService::class);
        app()->singleton('CacheShelfService',CacheShelfService::class);
        app()->singleton('CheckActiveMenuService',CheckActiveMenuService::class);
        app()->singleton('CommodityBarcodeService',CommodityBarcodeService::class);
        app()->singleton('CommodityService', CommodityService::class);
        app()->singleton('ConfigurationService',ConfigurationService::class);
        app()->singleton('CustomerLogService',CustomerLogService::class);
        app()->singleton('CustomerLogService',CustomerLogService::class);
        app()->singleton('CustomerLogStatusService',CustomerLogStatusService::class);
        app()->singleton('CustomerLogStatusService',CustomerLogStatusService::class);
        app()->singleton('CustomerService',CustomerService::class);
        app()->singleton('DataHandlerService',DataHandlerService::class);
        app()->singleton('DeliveryAppointmentService',DeliveryAppointmentService::class);
        app()->singleton('DemandProcessService',DemandProcessService::class);
        app()->singleton('DemandService',DemandService::class);
        app()->singleton('DepositoryService',DepositoryService::class);
        app()->singleton('DischargeTaskService',DischargeTaskService::class);
        app()->singleton('FacilitatorService',FacilitatorService::class);
        app()->singleton('FeatureService',FeatureService::class);
        app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
        app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
        app()->singleton('InventoryCompareService',InventoryCompareService::class);
        app()->singleton('InventoryDailyLogService',InventoryDailyLogService::class);
        app()->singleton('LaborReportsCountingRecordService',LaborReportsCountingRecordService::class);
        app()->singleton('LogService',LogService::class);
        app()->singleton('LogisticSFService',LogisticSFService::class);
        app()->singleton('LogisticService',LogisticService::class);
        app()->singleton('LogisticYDService',LogisticYDService::class);
        app()->singleton('LogisticYTOService',LogisticYTOService::class);
        app()->singleton('MaterialBoxService',MaterialBoxService::class);
        app()->singleton('OracleActAllocationDetailService',OracleActAllocationDetailService::class);
        app()->singleton('OracleBasCustomerService',OracleBasCustomerService::class);
        app()->singleton('OracleBasSkuService',OracleBasSkuService::class);
        app()->singleton('OracleDocAsnDetailService',OracleDocAsnDetailService::class);
        app()->singleton('OracleDocOrderHeaderService',OracleDOCOrderHeaderService::class);
        app()->singleton('OracleDocWaveDetailService',OracleDocWaveDetailService::class);
        app()->singleton('OrderCommodityAssignService',OrderCommodityAssignService::class);
        app()->singleton('OrderCommodityService',OrderCommodityService::class);
        app()->singleton('OrderFreezeService',OrderFreezeService::class);
        app()->singleton('OrderIssuePerformanceService',OrderIssuePerformanceService::class);
        app()->singleton('OrderIssueProcessLogService',OrderIssueProcessLogService::class);
        app()->singleton('OrderIssueRejectedBillService',OrderIssueRejectedBillService::class);
        app()->singleton('OrderIssueService',OrderIssueService::class);
        app()->singleton('OrderIssueWorkLoadService',OrderIssueWorkLoadService::class);
        app()->singleton('OrderPackageCommoditiesService',OrderPackageCommoditiesService::class);
        app()->singleton('OrderPackageCommoditySerialNumberService',OrderPackageCommoditySerialNumberService::class);
        app()->singleton('OrderPackageExceptionTypeCountingRecordService',OrderPackageExceptionTypeCountingRecordService::class);
        app()->singleton('OrderPackageReceivedSyncService',OrderPackageReceivedSyncService::class);
        app()->singleton('OrderPackageService',OrderPackageService::class);
        app()->singleton('OrderService',OrderService::class);
        app()->singleton('OrderTrackingService',OrderTrackingService::class);
        app()->singleton('OwnerAreaReportService',OwnerAreaReportService::class);
        app()->singleton('OwnerBillReportService',OwnerBillReportService::class);
        app()->singleton('OwnerFeeDetailService',OwnerFeeDetailService::class);
        app()->singleton('OwnerMaterialService',OwnerMaterialService::class);
        app()->singleton('OwnerMaterialService',OwnerMaterialService::class);
        app()->singleton('OwnerPriceDirectLogisticService',OwnerPriceDirectLogisticService::class);
        app()->singleton('OwnerPriceExpressService',OwnerPriceExpressService::class);
        app()->singleton('OwnerPriceLogisticService',OwnerPriceLogisticService::class);
        app()->singleton('OwnerPriceOperationItemService',OwnerPriceOperationItemService::class);
        app()->singleton('OwnerPriceOperationService',OwnerPriceOperationService::class);
        app()->singleton('OwnerReportService',OwnerReportService::class);
        app()->singleton('OwnerService',OwnerService::class);
        app()->singleton('OwnerStoragePriceModelService',OwnerStoragePriceModelService::class);
        app()->singleton('PackageService',PackageService::class);
        app()->singleton('PackageStatisticsService',PackageStatisticsService::class);
        app()->singleton('ProcessMethodService',ProcessMethodService::class);
        app()->singleton('ProcessService',ProcessService::class);
        app()->singleton('ProcessStatisticService',ProcessStatisticService::class);
        app()->singleton('ProcessesContentService',ProcessesContentService::class);
        app()->singleton('ProcurementService',ProcurementService::class);
        app()->singleton('ProcurementTotalBillService',ProcurementTotalBillService::class);
        app()->singleton('ProcurementWeiXinSendMessageService',ProcurementWeiXinSendMessageService::class);
        app()->singleton('ProvinceService',ProvinceService::class);
        app()->singleton('RealtimePendingOrdersService',RealtimePendingOrdersService::class);
        app()->singleton('RegionService',RegionService::class);
        app()->singleton('RejectedBillItemService',RejectedBillItemService::class);
        app()->singleton('RejectedBillService',RejectedBillService::class);
        app()->singleton('RejectedService',RejectedService::class);
        app()->singleton('ShopService',ShopService::class);
        app()->singleton('StationCacheShelfGridService',StationCacheShelfGridService::class);
        app()->singleton('StationRuleBatchService',StationRuleBatchService::class);
        app()->singleton('StationService',StationService::class);
        app()->singleton('StationTaskBatchService',StationTaskBatchService::class);
        app()->singleton('StationTaskBatchTypeService',StationTaskBatchTypeService::class);
        app()->singleton('StationTaskChildService',StationTaskChildService::class);
        app()->singleton('StationTaskCommodityService',StationTaskCommodityService::class);
        app()->singleton('StationTaskMaterialBoxService',StationTaskMaterialBoxService::class);
        app()->singleton('StationTaskService',StationTaskService::class);
        app()->singleton('StationTaskTypeService',StationTaskTypeService::class);
        app()->singleton('StationTypeBinMonitorService',StationTypeBinMonitorService::class);
        app()->singleton('StationTypeService',StationTypeService::class);
        app()->singleton('StoreCheckingReceiveItemService',StoreCheckingReceiveItemService::class);
        app()->singleton('StoreCheckingReceiveService',StoreCheckingReceiveService::class);
        app()->singleton('StoreItemService',StoreItemService::class);
        app()->singleton('StoreService',StoreService::class);
        app()->singleton('SupplierService',SupplierService::class);
        app()->singleton('UnitService',UnitService::class);
        app()->singleton('UserOwnerGroupService',UserOwnerGroupService::class);
        app()->singleton('UserService',UserService::class);
        app()->singleton('UserWorkgroupService',UserWorkgroupService::class);
        app()->singleton('WarehouseService',WarehouseService::class);
        app()->singleton('WaybillFinancialService',WaybillFinancialService::class);
        app()->singleton('WeighExceptedService',WeighExceptedService::class);
    }


}
