Browse Source

Merge branch 'master' into zengjun

# Conflicts:
#	app/Http/Controllers/TestController.php
ajun 5 years ago
parent
commit
e8a6357d8e

+ 17 - 3
app/Console/Commands/InventoryDailyLoggingOwner.php

@@ -49,9 +49,11 @@ class InventoryDailyLoggingOwner extends Command
         if ($let == 0)return;
         //拼接SQL,SELECT仅取指定字段
         $sql = "SELECT INV_LOT.customerid,INV_LOT.sku,INV_LOT.qty,BAS_SKU.skulength,
-                BAS_SKU.skuwidth,BAS_SKU.skuhigh,BAS_SKU.cube,BAS_SKU.descr_c,BAS_SKU.alternate_sku1,BAS_SKU.grossweight
+                BAS_SKU.skuwidth,BAS_SKU.skuhigh,BAS_SKU.cube,BAS_SKU.descr_c,BAS_SKU.alternate_sku1,BAS_SKU.grossweight,
+                INV_LOT_ATT.lotatt05
                 FROM INV_LOT
                 LEFT JOIN BAS_SKU ON INV_LOT.sku = BAS_SKU.sku AND INV_LOT.customerid = BAS_SKU.customerid
+                LEFT JOIN INV_LOT_ATT ON INV_LOT.lotnum = INV_LOT_ATT.lotnum
                 WHERE INV_LOT.customerid IN (";
         $index = 1;
         foreach ($owners as $code => $id){
@@ -85,6 +87,7 @@ class InventoryDailyLoggingOwner extends Command
                     'amount' => $invLot->qty,
                     'volumn_occupied' => 0,
                     'gross_weight' => 0,
+                    'depository_code' => $invLot->lotatt05,
                 ];
             }
         }
@@ -110,20 +113,31 @@ class InventoryDailyLoggingOwner extends Command
             ];
             $result = $commodityService->updateOrCreate($param,$column);
             LogService::log(__METHOD__,"同步库存每日记录时修改或生成商品",json_encode($column));
+
             $commodity_id = $result->id;
             //寻找对应barcode是否存在,不存在录入
             if ($commodity['code']) CommodityBarcode::query()->firstOrCreate(['commodity_id'=>$commodity_id,'code'=>$commodity['code']]);
             //计算总体积,商品体积×该单数量
             $volumn_occupied = $commodity['volumn']*$inventoryDailyLog["amount"];
             $gross_weight = $commodity['weight']*$inventoryDailyLog["amount"];
-            array_push($data,[
+
+            $depository = null;
+            if ($inventoryDailyLog['depository_code']){
+                $depository = app('depositoryService')->firstOrCreate(["code"=>$inventoryDailyLog['depository_code']],[
+                    "name"=>$inventoryDailyLog['depository_code'],
+                    "code"=>$inventoryDailyLog['depository_code'],
+                ]);
+            }
+
+            $data[]  = [
                 "owner_id"=>$commodity['owner_id'],
                 "created_at"=>date('Y-m-d H:i:s'),
                 "commodity_id"=>$commodity_id,
                 "amount"=>$inventoryDailyLog['amount'],
                 "volumn_occupied"=>$volumn_occupied,
                 "gross_weight"=>$gross_weight,
-            ]);
+                "depository_id"=>$depository ? $depository->id : null,
+            ];
         }
         DB::table('inventory_daily_logs')->insert($data);
         LogService::log(__METHOD__,"同步库存每日记录",json_encode($data));

+ 4 - 3
app/Http/Controllers/InventoryController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\OracleBasCustomer;
 use App\Services\AllInventoryService;
+use App\Services\InventoryDailyLogService;
 use App\Services\InventoryService;
 use App\Services\OwnerService;
 use Exception;
@@ -81,7 +82,7 @@ class InventoryController extends Controller
      */
     function dailyLog(Request $request,OwnerService $ownerService){
         if (!Gate::allows('库存管理-库存体积')){return redirect(url('/')); }
-        /** @var InventoryService*/
+        /** @var InventoryDailyLogService*/
         $inventoryDailyLogs = app('inventoryDailyLogService')->paginate($request->input());
         $owners = $ownerService->getSelection();
         $param = $request->input();
@@ -112,8 +113,8 @@ class InventoryController extends Controller
 
         }else $sql=app('inventoryDailyLogService')->getSql(['id'=>$request->data]);
 
-        $row = ["货主","日期","商品名称","商品编码","商品条码","在库数量","长","宽","高","体积","总占用体积","总毛重"];
-        $column = ["owner_name", "created_at", "commodity_name", "commodity_sku", "commodity_barcode_code",
+        $row = ["货主","日期","商品名称","商品编码","商品条码","属性仓","在库数量","长","宽","高","体积","总占用体积","总毛重"];
+        $column = ["owner_name", "created_at", "commodity_name", "commodity_sku", "commodity_barcode_code","depository_name",
             "amount", "commodity_length", "commodity_width", "commodity_height", "commodity_volumn", "volumn_occupied", "gross_weight"];
         $rule = ["created_at"=> "mysqlDate"];
         $post = Http::post(config('go.export.url'),['type'=>'unify','sql'=>$sql, 'connection'=>'mysql',

+ 1 - 2
app/Http/Controllers/LaborReportController.php

@@ -95,7 +95,7 @@ class LaborReportController extends Controller
                 "working_duration" => $laborReport->working_duration,
                 "remark" => $laborReport->remark,
             ];
-            array_push($data,$row);
+            $data[] = $row;
         }
         $post = Http::post(config('go.export.url'),['type'=>'laborReport','data'=>json_encode($data,JSON_UNESCAPED_UNICODE)]);
         if ($post->status() == 500){
@@ -119,7 +119,6 @@ class LaborReportController extends Controller
         $laborReportStatus->save();
         $this->log(__METHOD__,"门卫打卡审核创建当前临时工报表状态".__FUNCTION__,json_encode($laborReportStatus),Auth::user()['id']);
         $userDutyCheck=UserDutyCheck::find($userDutyCheckId);
-        $delme=Auth::user();
         $userDutyCheck->verify_user_id=Auth::user()['id'];
         $userDutyCheck->update();
         event(new GuardAuditEvent($userDutyCheck));

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

@@ -24,11 +24,26 @@ class OrderController extends Controller
         /** @var OrderService $orderService */
         $orderService = app('orderService');
         $request = $request->input();
+        $owners = app('ownerService')->getSelection(['id','code']);
+        $codes = array_column($owners->toArray(),'code');
+        if ($request['customerid'] ?? false){
+            $arr = explode(',',$request['customerid']);
+            $request['customerid'] = [];
+            foreach ($arr as $value){
+                if (in_array($value,$codes))$request['customerid'][] = $value;
+            }
+            if (count($request['customerid']) < 1)$request['customerid'] = [''];
+        }else $request['customerid'] = $codes;
+
         $result = $orderService->paginate($request);
         $picktotraceids = $result['picktotraceids'];
         $orders = $result['orders'];
         $commodities = $result['commodities'];
-        $customers=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+        $customers=OracleBasCustomer::query()->select('customerid','descr_c')
+            ->where('customer_type','OW')
+            ->where('active_flag','Y')
+            ->whereIn('customerid',$codes)
+            ->get();
         $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();

+ 45 - 27
app/Http/Controllers/TestController.php

@@ -20,7 +20,6 @@ use App\OracleDOCWaveDetails;
 use App\Order;
 use App\OrderIssue;
 use App\OrderPackage;
-use App\OrderPackageCommodities;
 use App\OrderTracking;
 use App\OrderTrackingOwner;
 use App\Owner;
@@ -30,20 +29,15 @@ use App\ProcessDaily;
 use App\ProcessStatistic;
 use App\RejectedBill;
 use App\RejectedBillItem;
-use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
 use App\Services\InventoryCompareService;
-use App\Services\LogisticService;
 use App\Services\LogService;
 use App\Services\OracleDOCOrderHeaderService;
 use App\Services\OrderIssueService;
-use App\Services\OrderPackageCommoditiesService;
 use App\Services\OrderPackageService;
 use App\Services\OrderService;
-use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
-use App\Services\OwnerService;
 use App\Unit;
 use App\User;
 use App\Waybill;
@@ -255,7 +249,7 @@ class TestController extends Controller
                         'measuring_machine_id'=>$package->measuring_machine_id,
                         'weighed_at'=>$package->weighed_at,
                         'status'=>$package->status]);
-               if (!$orderPackage)array_push($error,$package->id);
+                if (!$orderPackage)array_push($error,$package->id);
             }
             LogService::log(__METHOD__,"同步时WMS中未找到这些订单",json_encode($error));
             $id = $packages[count($packages)-1]->id;
@@ -419,8 +413,11 @@ class TestController extends Controller
     }
 
     public function test2(){
-        $c = Commodity::find(325434);
-        dd($c['name']);
+        $depository = app('depositoryService')->firstOrCreate(["code"=>"TEST"],[
+            "name"=>"TEST",
+            "code"=>"TEST",
+        ]);
+        dd($depository);
     }
 
     /*1*/
@@ -480,23 +477,11 @@ class TestController extends Controller
     }
 
 
-    public function divide()
-    {
-        $trackings = OrderTracking::query()->with('commodities.package')->get();
-        $trackings->each(function ($tracking){
-            $package = $tracking->commodities->package;
-            $bulk = $package->bulk;
-            if($bulk>=1000000){
-                $bulk = bcdiv($bulk,1000000000,3);
-                OrderPackage::query()->where('id',$package->id)->update(['bulk'=>$bulk]);
-            }
-        });
-    }
+    public function test3(){
 
-    public function test3()
-    {
         /** @var DataHandlerService $dataHandlerService */
-        $dataHandlerService = app(DataHandlerService::class);
+        $dataHandlerService = app('dataHandlerService');
+        $startDate = \Illuminate\Support\Carbon::parse('2020-05-06 13:16:51')->toDateTimeString();
         /** @var OrderTrackingService $orderTrackingService */
         $orderTrackingService  = app('orderTrackingService');
         /** @var OrderService $orderSerivce */
@@ -524,8 +509,41 @@ class TestController extends Controller
 
     }
 
+    public function doctype(){
+
+        $a=\Doctrine\DBAL\Types\Type::getTypesMap();
+        dd($a);
+    }
+    public function orderTrckingOwnerAll(){
+        $owners = Owner::all();
+        foreach ($owners as $owner) {
+            $orderTrackingOwner =  OrderTrackingOwner::query()->where('owner_id',$owner->id)->first();
+            if($orderTrackingOwner == null){
+                OrderTrackingOwner::query()->create(['owner_id'=>$owner->id,'status'=>'启用']);
+            }else{
+                if($orderTrackingOwner->status == '禁用'){
+                    $orderTrackingOwner->status = '启用';
+                }
+            }
+        }
+    }
+
+    public function updateOrderTracking(){
+        $orderTrackings = OrderTracking::query()->with('commodities.package.order')
+            ->whereHas('commodities.package.order',function($query){
+                $query->where('client_code','O2009027827');
+            })
+            ->where('created_at','>','2020-09-28 00:07:06')->first();
+        $order = $orderTrackings->commodities->package->order;
+        $client_code = $order->client_code;
+        if(preg_match('/^O[\d]/',$client_code ?? '') > 0){
+            OrderTracking::query()->where('id',$orderTrackings->id)->update(['web_order_number'=>$client_code]);
+        }
+    }
+
     public function updateOrderTrackingGrossWeightAndBulk(){
-        $orderTrackings = OrderTracking::query()->with('commodities.package.order.owner','commodities.commodity')->get();
+        $orderTrackings = OrderTracking::query()->with('commodities.package.order.owner','commodities.commodity')
+            ->where('created_at','>','2020-09-28 00:07:06')->get();
         foreach ($orderTrackings as $orderTracking) {
             $code = $orderTracking->commodities->package->order->owner->code ?? false;
             $amount = $orderTracking->commodities->amount;
@@ -536,9 +554,9 @@ class TestController extends Controller
             $bulk = null;
             $gross_weight = round($basSku->cube * $amount,3);
             $bulk = round($basSku->grossweight * $amount,3);
-           if($orderTracking->gross_weight!= $gross_weight ||$orderTracking->bulk!= $bulk ){
+            if($orderTracking->gross_weight!= $gross_weight ||$orderTracking->bulk!= $bulk ){
                 OrderTracking::query()->where('id',$orderTracking->id)->update(['gross_weight'=>$gross_weight,'bulk'=>$bulk]);
-           }
+            }
         }
 
     }

+ 4 - 1
app/InventoryDailyLog.php

@@ -8,7 +8,7 @@ class InventoryDailyLog extends Model
 {
     public $timestamps=false;
     protected $fillable=[
-        'owner_id','created_at','commodity_id','amount','volumn_occupied','gross_weight'
+        'owner_id','created_at','commodity_id','amount','volumn_occupied','gross_weight','depository_id'
     ];
 
     public function owner(){
@@ -17,4 +17,7 @@ class InventoryDailyLog extends Model
     public function commodity(){
         return $this->hasOne('App\Commodity','id','commodity_id');
     }
+    public function depository(){
+        return $this->hasOne('App\Depository','id','depository_id');
+    }
 }

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -8,6 +8,7 @@ use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
 use App\Services\CommodityBarcodeService;
 use App\Services\common\DataHandlerService;
+use App\Services\DepositoryService;
 use App\Services\InventoryCompareService;
 use App\Services\OracleBasSkuService;
 use App\Services\OracleDocAsnDetailService;
@@ -140,6 +141,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('commodityService' , CommodityService::class);
         app()->singleton('batchUpdateService' , BatchUpdateService::class);
         app()->singleton('dataHandlerService',DataHandlerService::class);
+        app()->singleton('depositoryService',DepositoryService::class);
     }
 
     private function loadingRejectedModuleService(){

+ 13 - 0
app/Services/DepositoryService.php

@@ -0,0 +1,13 @@
+<?php 
+
+namespace App\Services; 
+
+use App\Depository;
+
+Class DepositoryService
+{ 
+    public function firstOrCreate(array $params, array $values = null){
+        if (!$values) $values = $params;
+        return Depository::query()->firstOrCreate($params, $values);
+    }
+}

+ 3 - 1
app/Services/InventoryDailyLogService.php

@@ -10,7 +10,7 @@ Class InventoryDailyLogService
 {
     //库存体积条件
     function conditionQuery(array $param){
-        $inventoryDailyLogs = InventoryDailyLog::query()->with(['owner','commodity'=>function($query){
+        $inventoryDailyLogs = InventoryDailyLog::query()->with(['depository','owner','commodity'=>function($query){
             $query->with('barcodes');
         }])->orderByDesc('inventory_daily_logs.id');
         $columnQueryRules=[
@@ -28,6 +28,8 @@ Class InventoryDailyLogService
         return $this->conditionQuery($params)->selectRaw("inventory_daily_logs.created_at,inventory_daily_logs.amount,inventory_daily_logs.volumn_occupied,inventory_daily_logs.gross_weight")
             ->leftJoin('owners','inventory_daily_logs.owner_id','owners.id')
                 ->selectRaw('owners.name owner_name')
+            ->leftJoin('depositories','inventory_daily_logs.depository_id','depositories.id')
+                ->selectRaw('depositories.name depository_name')
             ->leftJoin('commodities','inventory_daily_logs.commodity_id','commodities.id')
                 ->selectRaw('commodities.name commodity_name,commodities.sku commodity_sku,commodities.length commodity_length,commodities.width commodity_width,commodities.height commodity_height,commodities.volumn commodity_volumn')
             ->leftJoin('commodity_barcodes','commodity_barcodes.commodity_id','commodities.id')

+ 7 - 1
app/Services/OrderService.php

@@ -105,7 +105,8 @@ class OrderService
             $sql.=" and addtime<=to_date('".$orderdate_end.":59','yyyy-mm-dd hh24:mi:ss')";
         }
         if ($customerid){
-            $arr = explode(',',$customerid);
+            if (!is_array($customerid))$arr = explode(',',$customerid);
+            else $arr = $customerid;
             if (count($arr)>0) {
                 $sql.=" and customerid in (";
                 foreach ($arr as $index=>$str){
@@ -265,6 +266,11 @@ class OrderService
     }
 
     public function paginate(array $params){
+        if (($params['is_display_all'] ?? false) && !($params['codename_c'] ?? false) && !($params['codename_c_end'] ?? false)){
+            $params['codename_c'] = "00";
+            $params['codename_c_end'] = "62";
+        }
+
         $sql = $this->getSql($params,$params['page'] ?? 1, $params['paginate'] ?? 50);
         $orders=DB::connection('oracle')->select(DB::raw($sql));
         return $this->orderFormat($orders);

+ 32 - 0
database/migrations/2020_09_29_101752_change_inventory_daily_logs_add_column_depository_id.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeInventoryDailyLogsAddColumnDepositoryId extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('inventory_daily_logs', function (Blueprint $table) {
+            $table->bigInteger('depository_id')->nullable()->comment('外联属性仓');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('inventory_daily_logs', function (Blueprint $table) {
+            $table->dropColumn('depository_id');
+        });
+    }
+}

+ 3 - 0
resources/views/inventory/statement/dailyLog.blade.php

@@ -65,6 +65,7 @@
                             </span>
                         </span>
                     </td>
+                    <td>@{{ inventoryDailyLog.depository_name }}</td>
                     <td>@{{ inventoryDailyLog.amount }}</td>
                     <td>@{{ inventoryDailyLog.commodity_length }}</td>
                     <td>@{{ inventoryDailyLog.commodity_width }}</td>
@@ -102,6 +103,7 @@
                         commodity_height:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->height : ''}}',
                         commodity_volumn:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->volumn : ''}}',
                         volumn_occupied:'{{$inventoryDailyLog->volumn_occupied}}',
+                        depository_name:'{{$inventoryDailyLog->depository ? $inventoryDailyLog->depository->name : ''}}',
                         gross_weight:'{{$inventoryDailyLog->gross_weight}}'},
                     @endforeach
                 ],
@@ -159,6 +161,7 @@
                     {name: 'commodity_name', value: '商品名称'},
                     {name:'commodity_sku',value: '商品编码'},
                     {name: 'commodity_barcodes', value: '商品条码', neglect: true},
+                    {name: 'depository_name', value: '属性仓'},
                     {name: 'amount', value: '在库数量', neglect: true},
                     {name: 'commodity_length', value: '长', neglect: true},
                     {name: 'commodity_width',value: '宽', neglect: true},

+ 1 - 1
resources/views/inventory/stockInventory/mission.blade.php

@@ -20,7 +20,7 @@
             <span class="form-inline">
                 <input type="date" @change="hasDateStart" class="form-control form-control-sm ml-5 tooltipTarget" name="date_start" id="date_start"  title="选择创建日期的开始时间" style="width: 150px">
                 <input type="date" @change="hasDateEnd" class="form-control form-control-sm ml-5 tooltipTarget" name="date_end" id="date_end"  title="选择创建日期的结束时间" style="width: 150px">
-                <input type="text" @change="hasLocation" class="form-control form-control-sm ml-5 tooltipTarget" name="location" id="location"  title="选择创建盘点任务库位的前缀字母" placeholder="库位前缀字母" style="width: 150px" autocomplete="off">
+                <input type="text" @change="hasLocation" class="form-control form-control-sm ml-5 tooltipTarget" name="location" id="location"  title="选择创建盘点任务库位的前缀字母,支持多个,以空格或逗号分隔" placeholder="库位前缀字母,多个空格分隔" style="width: 150px" autocomplete="off">
                 <input type="text" @change="hasBarcode" class="form-control form-control-sm ml-5 tooltipTarget" name="barcode" id="barcode"  title="商品条码,糊模查找需要在左边打上%符号" placeholder="条码" style="width: 200px" autocomplete="off">
             </span>
             <span class="ml-5">

+ 1 - 0
resources/views/order/index/delivering.blade.php

@@ -300,6 +300,7 @@
                         {name:'releasestatus',type:'select',tip:'是否冻结冻结',placeholder:'是否冻结',data:[{name:'H',value:'是'},{name:'',value:'否'}]},
                         {name:'checktime_start',type:'dateTime',tip:'选择显示复核时间的起始日期'},
                         {name:'checktime_end',type:'dateTime',tip:'选择显示复核时间的结束日期'},
+                        {name: 'is_display_all', type: 'checkbox', tip: '是否隐藏装箱完成以后的状态', data: [{name: 'ture', value: '隐藏完成状态'}]},
                     ],
                 ];
                 this.form = new query({

+ 1 - 1
tests/webApi/test.http

@@ -8,7 +8,7 @@
 POST http://bswas/api/thirdPart/weight/new
 Content-Type: application/json
 
-{"id": "abc6","barcode": "233170028951","weight": "13","length": 3,"width": 1,"height": 2}
+{"id": "TESTgpios","barcode": "test200928-c","weight": "697","length": 1010,"width": 1009,"height": 1000}
 
 ###
 POST http://bswas/api/thirdPart/weight/new