Просмотр исходного кода

Merge branch 'master' into zengjun

loustwo 4 лет назад
Родитель
Сommit
98ad4ce9ae

+ 0 - 3
app/Console/Commands/SyncWMSOrderTask.php

@@ -9,7 +9,6 @@ use App\ValueStore;
 use Carbon\Carbon;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\Log;
 
 class SyncWMSOrderTask extends Command
 {
@@ -62,13 +61,11 @@ class SyncWMSOrderTask extends Command
         $start = (string)$start;
         Cache::put($this->last_start_key,$start);
         ValueStore::query()->where('name',$this->last_start_key)->update(['value'=>$start]);
-        Log::info("订单同步开始时间",['date' => $start]);
         $this->syncCreatedOrder();
         $this->syncUpdatedOrder();
         $end = (string)Carbon::now();
         Cache::put($this->last_end_key,$end);
         ValueStore::query()->where('name',$this->last_end_key)->update(['value'=>$end]);
-        Log::info("订单同步结束时间",['date' => $end]);
     }
 
     public function syncCreatedOrder()

+ 4 - 4
app/Filters/OrderPackageFilters.php

@@ -57,12 +57,12 @@ class OrderPackageFilters
     public function apply($builder)
     {
         $this->queryBuilder = $builder;
-        $filters = array_filter($this->request->only($this->filters),function($item){
+        $filters = array_filter($this->request->only($this->filters), function ($item) {
             return $item !== null;
         });
         $this->queryBuilder
-            ->whereIn('status', [0,1,2,3,4,5,6,7,8,9,null])
-            ->whereIn('exception_status', [0,1,2,3,4,5,6,7,null]);
+            ->whereIn('status', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, null])
+            ->whereIn('exception_status', [0, 1, 2, 3, 4, 5, 6, 7, null]);
         foreach ($filters as $filter => $value) {
             if (method_exists($this, $filter)) {
                 $this->$filter($value, $this->queryBuilder);
@@ -104,7 +104,7 @@ class OrderPackageFilters
 
     private function status($status)
     {
-        $statuses = array_filter(preg_split('/[,, ]+/is', $status),function($item){
+        $statuses = array_filter(preg_split('/[,, ]+/is', $status), function ($item) {
             return $item !== null;
         });
         $this->queryBuilder->whereIn('status', $statuses);

+ 8 - 0
app/Http/Controllers/PackageLogisticController.php

@@ -28,7 +28,11 @@ class PackageLogisticController extends Controller
     {
         /** @var UserService $userService */
         $userService = app('UserService');
+        /** @var array $owner_ids */
         $owner_ids = $userService->getPermittingOwnerIds(auth()->user());
+        $owner_ids = array_map(function ($item) {
+            return $item = (int)$item;
+        }, $owner_ids);
         $paginateParams = $request->input();
         $orderPackages = OrderPackage::query()
             ->filter($filters)
@@ -68,7 +72,11 @@ class PackageLogisticController extends Controller
 
         /** @var UserService $userService */
         $userService = app('UserService');
+        /** @var array $owner_ids */
         $owner_ids = $userService->getPermittingOwnerIds(auth()->user());
+        $owner_ids = array_map(function ($item) {
+            return $item = (int)$item;
+        }, $owner_ids);
         $total = OrderPackage::query()
             ->selectRaw("count(*) as total")
             ->filter($filters)

+ 13 - 0
app/Http/Controllers/ScanDeviceMonitorController.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ScanDeviceMonitorController extends Controller
+{
+    public function index()
+    {
+        return view('maintenance.scanDevice.index');
+    }
+}

+ 1 - 1
app/Http/Controllers/StorageController.php

@@ -287,7 +287,7 @@ SQL;
                     $modelMap[$model->id] = $model->commodity->maximum;
                 }
                 $orderBy.= " END";
-                $boxes = MaterialBox::query()->whereIn("code",$codes)->orderByRaw($orderBy)->lockForUpdate()->get();
+                $boxes = MaterialBox::query()->whereIn("code",$codes)->orderByRaw($orderBy)->get();
                 //筛选下海柔可用箱
                 list($codes,$notCodes) = app("MaterialBoxService")->checkHaiQ(array_column($boxes->toArray(),"code"));
                 if (!$codes)$boxes = new \Illuminate\Database\Eloquent\Collection();

+ 33 - 78
app/Http/Controllers/TestController.php

@@ -179,22 +179,41 @@ class TestController extends Controller
     public function test1(\Closure $c,string $a){
         dd($c($a));
     }
-    public function test(Request $request)
+    private function paramDefault(&$waybill):array
     {
-        foreach (Batch::query()->where("created_at",">=","2021-12-18 00:00:00")->get() as $bat){
-            $this->assignBatch($bat->code);
+        $update = [];
+        if (!$waybill->order_type){
+            $update["order_type"] = $waybill->order_type = Waybill::ORDER_TYPE_DEFAULT;
         }
-        dd("OK");
-        $user = User::query()->where("name","yanyuanmin")->first();
-        dd($user->id);
-        dd($codes = app('OwnerService')->getQuery($user->id)->select("code")->pluck("code"));
-
-
-        $ownerIds=app('UserService')->getPermittingOwnerIds($user);
-        $owners =  Owner::query()->select("id","name","code")->whereIn('id', $ownerIds)->whereNull('deleted_at')->get();
-        $codes = array_column($owners->toArray(), 'code');
-        dd($codes);
-        dd(Order::class);
+        if (!$waybill->transport_type){
+            $update["transport_type"] = $waybill->transport_type = "JZKH";
+        }
+        if (!$waybill->cargo_name){
+            $update["cargo_name"] = $waybill->cargo_name = "补货";
+        }
+        if (!$waybill->total_number){
+            $update["total_number"] = $waybill->total_number = 1;
+        }
+        if (!$waybill->total_weight){
+            $update["total_weight"] = $waybill->total_weight = 1;
+        }
+        if (!$waybill->package_service){
+            $update["package_service"] = $waybill->package_service = '托膜';
+        }
+        if (!$waybill->deliveryType){
+            $update["deliveryType_id"] = $waybill->deliveryType_id = 3;
+        }
+        if (!$waybill->pay_type){
+            $update["pay_type"] = $waybill->pay_type = Waybill::PAY_TYPE_DEFAULT;
+        }
+        if (!$waybill->back_sign_bill){
+            $update["back_sign_bill"] = $waybill->back_sign_bill = Waybill::BACK_SIGN_BILL_DEFAULT;
+        }
+        return $update;
+    }
+    public function test(Request $request)
+    {
+        dd(1);
         $c = "test";
         $a = function ($b)use($c){
             return $b.$c;
@@ -239,31 +258,6 @@ class TestController extends Controller
         $service->syncWorkOrder($rejected_bill);
     }
 
-    public function changeWorkOrder(){
-        $type = OrderIssueType::query()->where('name' ,'拦截')->first();
-
-        WorkOrder::query()->where('order_issue_type_id',$type->id)
-            ->where('status',[4,5])
-            ->where('process_progress','拦截成功')
-            ->update(['process_progress' => '成功已退回,不赔偿']);
-
-        WorkOrder::query()->where('order_issue_type_id',$type->id)
-            ->whereIn('status',[4,5])
-            ->where('process_progress','拦截失败')
-            ->update(['process_progress' => '无法拦截']);
-
-
-        WorkOrderDetail::query()->where('order_issue_type_id',$type->id)
-            ->where('status',[4,5])
-            ->where('process_progress','拦截成功')
-            ->update(['process_progress' => '成功已退回,不赔偿']);
-
-        WorkOrderDetail::query()->where('order_issue_type_id',$type->id)
-            ->whereIn('status',[4,5])
-            ->where('process_progress','拦截失败')
-            ->update(['process_progress' => '无法拦截']);
-    }
-
 
     public function assignBatch($code)
     {
@@ -309,45 +303,6 @@ class TestController extends Controller
         app("BatchService")->assignTasks($batches);
     }
 
-    public function inventory()
-    {
-        $location='B15-01-01';
-        $taskId=950;
-        $barcode='Fxdsc';
-        $start=microtime(true);
-//        $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])
-//            ->whereHas('commodity',function($query)use($barcode){
-//            $query->whereHas('barcodes',function($sql)use($barcode){
-//                $sql->where('code','=',$barcode);
-//            });
-//        })->where('location',$location)->where('inventory_account_id',$taskId)->first();
-//
-
-//        $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])
-//            ->whereIn('commodity_id',function($query)use($barcode){
-//                $query->from('commodity_barcodes')->select('commodity_id')->where('code',$barcode);
-//            })->where('location',$location)
-//            ->where('inventory_account_id',$taskId)
-//            ->where('checked','否')
-//            ->first();
-        $stock_status=InventoryAccount::query()->where('id',$taskId)->value('status');
-        $end=microtime(true);
-        dump(round($end-$start,3),$stock_status);
-    }
-
-    public function testZC()
-    {
-//        $batches=Batch::query()->where('id',1)->get();
-//        BroadcastBatchToZhengCangJob::dispatch($batches);    //在这里为波次注册队列任务!
-        $taskId=792;
-        $location='H05-35-04';
-        $barcode='6931481255587';
-        /** @var AndroidInventoryService $service */
-        $service=app('AndroidInventoryService');
-        $inventoryAccountMission=$service->getInventoryDetail($taskId,$location,$barcode);
-        dd($inventoryAccountMission->stockInventoryPersons);
-    }
-
 
 
 }

+ 0 - 1
app/Jobs/LaborApplyRecordJob.php

@@ -38,7 +38,6 @@ class LaborApplyRecordJob implements ShouldQueue
      */
     public function handle()
     {
-        Log::debug("LaborApplyRecordJob isAppend = " . ($this->isAppend + 1) . "");
         $response = $this->service->allocationLaborToLaborCompany($this->isAppend);
         if (!$response['success']) throw new WarningException($response['error_message']);
     }

+ 9 - 7
app/Observers/WaybillObserver.php

@@ -24,17 +24,19 @@ class WaybillObserver
                 return;
             }
             $update = $this->paramDefault($waybill);
+            $waybill->update($update);
             $bill = app('DbOpenService')->getDbOrderNo($waybill);
             if (!$bill || $bill["result"]=="false"){
-                Log::error("德邦单号获取失败",["no"=>$waybill->waybill_number,"info"=>$bill]);
+                Log::error("德邦单号获取失败",["no"=>$waybill->toArray(),"info"=>$bill]);
                 return;
             }
-            $update["carrier_bill"] = $bill['mailNo'];
-            $update["waybill_number"] = $bill['mailNo'];
-            $update["station_no"] = $bill['stationNo'];
-            $update["arrived_org_simple_name"] = $bill['arrivedOrgSimpleName'];
-            $update["much_higher_delivery"] = $bill['muchHigherDelivery'];
-            $waybill->update($update);
+            $waybill->update([
+                "carrier_bill"=>$bill['mailNo'],
+                "waybill_number"=>$bill['mailNo'],
+                "station_no"=>$bill['stationNo'],
+                "arrived_org_simple_name"=>$bill['arrivedOrgSimpleName'],
+                "much_higher_delivery"=>$bill['muchHigherDelivery'],
+            ]);
             if (!app("WaybillService")->notifyFlux($waybill)){
                 Log::error("德邦单号回传FLUX失败",["no"=>$waybill->waybill_number,"info"=>$bill]);
                 return;

+ 0 - 1
app/Services/DbOpenService.php

@@ -5,7 +5,6 @@ namespace App\Services;
 use App\Components\ErrorPush;
 use App\Traits\ServiceAppAop;
 use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Facades\Log;
 
 
 class DbOpenService

+ 1 - 1
app/Services/OwnerAreaReportService.php

@@ -60,7 +60,7 @@ class OwnerAreaReportService
         $area = $this->query(OwnerAreaReport::query(),$params)->with("ownerStoragePriceModel")->lockForUpdate()->first();
         try{
             if ($values["accounting_area"] ?? null && $area->accounting_area != $values["accounting_area"]){
-                $report = OwnerBillReport::query()->lockForUpdate()->where("owner_id",$area->owner_id)
+                $report = OwnerBillReport::query()->where("owner_id",$area->owner_id)
                     ->where("counting_month",'like',$area->counting_month."%")->first();
                 if ($report){
                     if (!$area->ownerStoragePriceModel)return false;

+ 1 - 1
app/Services/OwnerPriceOperationService.php

@@ -259,7 +259,7 @@ class OwnerPriceOperationService
             DB::beginTransaction();
             //此处暂时未使用cache的互斥锁 使用sql行锁代替下 防止缓存击穿
             $pivot = app(CacheService::class)->getOrExecute($key,function ()use($key,$targetValue,&$sign,$rule,$owner){
-                return DB::selectOne(DB::raw("SELECT * FROM owner_price_operation_owner WHERE owner_price_operation_id = ? AND owner_id = ? for update"),[$rule->id,$owner]);
+                return DB::selectOne(DB::raw("SELECT * FROM owner_price_operation_owner WHERE owner_price_operation_id = ? AND owner_id = ? "),[$rule->id,$owner]);
             },1000);
             if ($pivot && (!$pivot->discount_date || substr($pivot->discount_date,0,7)!=$month || $pivot->target_value < $targetValue)){
                 //未被标记过处理时间或处理时间不为本月,或上次处理值过期,处理历史即时账单

+ 78 - 0
resources/views/maintenance/scanDevice/index.blade.php

@@ -0,0 +1,78 @@
+@extends('layouts.app')
+@section('title')扫描设备监视器@endsection
+@section('content')
+    <div class="d-none" id="list">
+        <!--            表格-->
+        <table class="table table-striped table-bordered table-hover text-nowrap waybill-table td-min-width-80"
+               style="background: #fff;" id="table">
+            <tr v-for="(item,i) in details.data" :key="i">
+                <td class="td-warm text-muted"><span>@{{ i+1 }}</span></td>
+                <td class="td-warm text-muted"><span>@{{ item.name }}</span></td>
+                <td class="td-warm text-muted">
+                    <span
+                        :class="item.active?'badge badge-pill badge-success':'badge badge-pill badge-danger'">
+                        @{{ item.active ? '正常':'掉线' }}
+                    </span>
+                </td>
+                <td class="td-warm text-muted"><span>@{{ item.macAddress }}</span></td>
+                <td class="td-warm text-muted"><span>@{{ item.receiveTime }}</span></td>
+            </tr>
+        </table>
+    </div>
+
+
+@endsection
+
+@section('lastScript')
+    <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
+    <script>
+        let vue = new Vue({
+            el: "#list",
+            data: {
+                selectTr: '',
+                details: [],
+            },
+            created() {
+                let url = this.getBaseUrl();
+                url += '/api/report/scanDeviceMonitor/list';
+                axios.get(url, this.search).then(res => {
+                    this.details = res.data;
+                });
+            },
+            mounted: function () {
+                $('#list').removeClass('d-none');
+                this.rendingHeader();
+            },
+            methods: {
+                //根据环境获取不同的url
+                getBaseUrl() {
+                    let url = '';
+                    let env = "{{ config('app.env') }}";
+                    if (env === 'local') {
+                        url = 'http://127.0.0.1:8111'
+                    } else if (env === 'production') {
+                        url = 'https://stat.baoshi56.com'
+                    }
+                    return url;
+                },
+                rendingHeader() {
+                    let column = [
+                        {name: 'name', value: '名称', neglect: true, class: "td-cool"},
+                        {name: 'active', value: '状态', neglect: true, class: "td-warm"},
+                        {name: 'macAddress', value: 'macAddress', neglect: true, class: "td-warm"},
+                        {name: 'receiveTime', value: '最近一次上传时间', neglect: true, class: "td-warm"},
+                    ];
+                    new Header({
+                        el: "table",
+                        name: "details",
+                        column: column,
+                        data: this.details,
+                        restorationColumn: 'id',
+                        fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 2,
+                    }).init();
+                },
+            },
+        });
+    </script>
+@endsection
+

+ 2 - 0
routes/web.php

@@ -390,6 +390,8 @@ Route::group(['middleware' => 'auth'], function ($route) {
         Route::post('mail/updateTemplate', 'SendEmailsController@updateTemplate')->name('mail.updateTemplate');
         Route::post('mail/updateRemark', 'SendEmailsController@updateRemark')->name('mail.updateRemark');
         Route::post('mail/active', 'SendEmailsController@active')->name('mail.active');
+
+        Route::get("scanDevice/monitor", 'ScanDeviceMonitorController@index');
     });
     $route->get('maintenance', function () {
         return view('maintenance.index');