Ver código fonte

WMS货主建立缓存
inventoryCompareService service注册名首字大写化

LD 5 anos atrás
pai
commit
8faef17153

+ 3 - 3
app/Http/Controllers/InventoryCompareController.php

@@ -93,7 +93,7 @@ class InventoryCompareController extends Controller
     function inventoryCompare(Request $request,OwnerService $ownerService){
         if (!Gate::allows('库存管理-库存-库存对比')){return redirect(url('/')); }
         $owners = $ownerService->getSelection();
-        $inventoryCompares=app('inventoryCompareService')->getInventoryCompare($request->all());
+        $inventoryCompares=app('InventoryCompareService')->getInventoryCompare($request->all());
         $param = $request->input();
         return view('inventory.statement.inventoryCompare',compact('owners','inventoryCompares','param'));
     }
@@ -134,10 +134,10 @@ class InventoryCompareController extends Controller
         if ($request->checkAllSign){
             $params = $request->input();
             unset($params['checkAllSign']);
-            $sql=app('inventoryCompareService')->getSql($params);
+            $sql=app('InventoryCompareService')->getSql($params);
 //            dd($sql);
         }else{
-            $sql=app('inventoryCompareService')->getSql(['id'=>$request->data]);
+            $sql=app('InventoryCompareService')->getSql(['id'=>$request->data]);
         }
         $post = Http::post(config('go.export.url'),['type'=>'inventoryCompare','sql'=>$sql]);
         if ($post->status() == 500){

+ 1 - 5
app/Http/Controllers/OrderController.php

@@ -40,11 +40,7 @@ class OrderController extends Controller
         $orders = $result['orders'];
         $orderIssueNos =  $orderService->返回有问题件的订单号($orders);
         $commodities = $result['commodities'];
-        $customers=OracleBasCustomer::query()->select('customerid','descr_c')
-            ->where('customer_type','OW')
-            ->where('active_flag','Y')
-            ->whereIn('customerid',$codes)
-            ->get();
+        $customers=app('OracleBasCustomerService')->getCustomers($codes);
         $page = $request["page"] ?? 1;
         $codes=DB::connection('oracle')->table('BAS_CODES')->select('code','codename_c')->where('codeid','SO_STS')->orderBy('code','asc')->get();
         $orderIssueType = OrderIssueType::all();

+ 2 - 2
app/Http/Controllers/TestController.php

@@ -538,7 +538,7 @@ class TestController extends Controller
             LogService::log(__METHOD__,'重新分配商品',json_encode($commodityTag,JSON_UNESCAPED_UNICODE));
 
             app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存盘点任务
-            app('inventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
+            app('InventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
             app('InventoryDailyLogService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存每日记录
             app('ProcessesContentService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新二次加工内容单
             app('StoreCheckingReceiveItemService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新入库盘收一体
@@ -637,7 +637,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         }
         if (count($updateCommodities) > 0){
             app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存盘点任务
-            app('inventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
+            app('InventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
             app('InventoryDailyLogService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存每日记录
             app('ProcessesContentService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新二次加工内容单
             app('StoreCheckingReceiveItemService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新入库盘收一体

+ 2 - 2
app/Imports/InventoryCompareImport.php

@@ -25,7 +25,7 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
     public function __construct()
     {
 //            $this->owner_id=$owner_id;
-            app()->singleton('inventoryCompareService',InventoryCompareService::class);
+            app()->singleton('InventoryCompareService',InventoryCompareService::class);
     }
 
     public function Collection(Collection $collection)
@@ -160,7 +160,7 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
             }
 //            if(empty($exception)){
                 /** @var InventoryCompareService $service */
-                $service = app('inventoryCompareService');
+                $service = app('InventoryCompareService');
                 $inventoryCompare= $service->createInventoryCompares($inventoryCompares);
                 if (!$inventoryCompare) array_push($exception, ['创建库存对比失败!']);
 //            }

+ 3 - 1
app/Providers/AppServiceProvider.php

@@ -12,6 +12,7 @@ use App\Services\common\DataHandlerService;
 use App\Services\DepositoryService;
 use App\Services\InventoryAccountMissionService;
 use App\Services\InventoryCompareService;
+use App\Services\OracleBasCustomerService;
 use App\Services\OracleBasSkuService;
 use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDOCOrderHeaderService;
@@ -64,7 +65,7 @@ class AppServiceProvider extends ServiceProvider
     {
         //
         app()->singleton('OrderIssuePerformanceService',OrderIssuePerformanceService::class);
-        app()->singleton('inventoryCompareService',InventoryCompareService::class);
+        app()->singleton('InventoryCompareService',InventoryCompareService::class);
     }
 
     /**
@@ -122,6 +123,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('StoreCheckingReceiveService',StoreCheckingReceiveService::class);
         app()->singleton('StoreCheckingReceiveItemService',StoreCheckingReceiveItemService::class);
         app()->singleton('CommodityBarcodeService',CommodityBarcodeService::class);
+        app()->singleton('OracleBasCustomerService',OracleBasCustomerService::class);
         app()->singleton('OracleBasSkuService',OracleBasSkuService::class);
         app()->singleton('OracleDocAsnDetailService',OracleDocAsnDetailService::class);
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);

+ 15 - 0
app/Services/OracleBasCustomerService.php

@@ -6,6 +6,11 @@ use App\OracleBasCustomer;
 
 Class OracleBasCustomerService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
     public function getWareHouse($customerIDs = null)
     {
         if(!$customerIDs){
@@ -13,5 +18,15 @@ Class OracleBasCustomerService
         }
         return  OracleBasCustomer::query()->where('Customer_Type','WH')->get();
     }
+    public function getCustomers($codes)
+    {
+        return $this->cacheService->getOrExecute('OwnersAll_Id',function()use($codes){
+            return OracleBasCustomer::query()->select('customerid','descr_c')
+                ->where('customer_type','OW')
+                ->where('active_flag','Y')
+                ->whereIn('customerid',$codes)
+                ->get();
+        },config('cache.expirations.owners'));
+    }
 
 }