Преглед на файлове

Merge branch 'master' into zengjun

ajun преди 5 години
родител
ревизия
4ca265a475
променени са 40 файла, в които са добавени 691 реда и са изтрити 176 реда
  1. 0 41
      app/Commodity.php
  2. 24 0
      app/Events/ResetProcessStatisticStartDateEvent.php
  3. 1 1
      app/Http/Controllers/LaborReportController.php
  4. 26 4
      app/Http/Controllers/ProcessController.php
  5. 6 1
      app/Http/Controllers/RejectedBillController.php
  6. 1 0
      app/Http/Controllers/RejectedBillItemController.php
  7. 32 12
      app/Http/Controllers/TestController.php
  8. 20 8
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  9. 29 19
      app/Http/Controllers/api/thirdPart/weight/PackageController.php
  10. 6 6
      app/InventoryAccount.php
  11. 22 8
      app/LaborReport.php
  12. 60 0
      app/Listeners/ResetProcessStatisticStartDateListener.php
  13. 4 0
      app/Order.php
  14. 3 3
      app/OrderPackage.php
  15. 4 0
      app/Process.php
  16. 2 0
      app/Providers/AppServiceProvider.php
  17. 3 0
      app/Providers/EventServiceProvider.php
  18. 29 0
      app/Services/CommodityBarcodeService.php
  19. 53 1
      app/Services/CommodityService.php
  20. 20 15
      app/Services/InventoryAccountService.php
  21. 1 0
      app/Services/OracleActAllocationDetailService.php
  22. 1 1
      app/Services/OrderService.php
  23. 5 3
      app/Services/OwnerService.php
  24. 2 1
      app/Services/UserService.php
  25. 32 0
      database/migrations/2020_11_11_130723_add_ignored_to_inventory__accounts.php
  26. 2 2
      public/js/app.js
  27. 2 5
      public/t.php
  28. 9 4
      resources/js/queryForm/queryForm.js
  29. 1 1
      resources/views/inventory/stockInventory/mission.blade.php
  30. 4 2
      resources/views/personnel/laborReport/index.blade.php
  31. 0 21
      tests/Inventory/ExampleTest.php
  32. 44 0
      tests/Inventory/UpdateInventoryAccount.php
  33. 0 0
      tests/Services/CacheService/GetOrExecuteTest.php
  34. 60 0
      tests/Services/CommodityBarcodeService/DestroyTest.php
  35. 65 0
      tests/Services/CommodityBarcodeService/InsertMany_onCommoditiesTest.php
  36. 98 0
      tests/Services/CommodityService/SyncBarcodesTest.php
  37. 0 2
      tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnstartDateCreateTest.php
  38. 16 13
      tests/Services/StoreService/AsnSyncTest.php
  39. 0 1
      tests/sortingFluxNewBatch.http
  40. 4 1
      文档/WAS项目规范.md

+ 0 - 41
app/Commodity.php

@@ -36,48 +36,7 @@ class Commodity extends Model
         return $this->owner['code']??'';
     }
 
-    static function newCommodityBy_BarcodeOwnerIdNameSku($barcode,$ownerId,$name,$sku){
-        $barcodes=rtrim($barcode,',');
-        $barcodes=explode(',',$barcodes);
-        foreach ($barcodes as $k=>$barcode){
-            if(!trim($barcode)) unset($barcodes[$k]);
-        }
-
-        $commodities=[];
-        foreach ($barcodes as $barcode){
-            if(!trim($barcode))continue;
-            $commodity=Commodity::whereHas('barcodes', function (Builder $query)use($barcode){
-                $query->where('code',$barcode);
-            })->where('name',$name)->where('owner_id',$ownerId)->first();
-            if($commodity)$commodities[]=$commodity;
-        }
-
-        if(count($barcodes)==count($commodities)&&count($commodities)>0){//筛选掉仅有一个条码相等的。
-            $commodity=$commodities[0];
-        }else{
-            $commodity=null;
-        }
 
-        if(!$commodity){
-            $commodity=new Commodity(['name'=>$name,'sku'=>$sku,'owner_id'=>$ownerId]);
-            $commodity->save();
-        }else{
-            if(!isset($commodity['name'])||(!isset($commodity['sku'])||$sku)){
-                $commodity['name']=$name;
-                $commodity['sku']=$sku;
-                $commodity->save();
-            }
-        }
-        foreach ($barcodes as $barcode){
-            if(!trim($barcode))continue;
-            $commodityBarcode=CommodityBarcode::where('code',$barcode)->where('commodity_id',$commodity['id'])->first();
-            if(!$commodityBarcode){
-                $commodityBarcode=new CommodityBarcode(['code'=>$barcode,'commodity_id'=>$commodity['id']]);
-                $commodityBarcode->save();
-            }
-        }
-        return $commodity;
-    }
 
     public function newBarcode($barcode){
         $barcodeModel = $this->barcodes()->where('code', $barcode)->first();

+ 24 - 0
app/Events/ResetProcessStatisticStartDateEvent.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Events;
+
+use App\Process;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class ResetProcessStatisticStartDateEvent
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+
+    public $process;
+    /**
+     * Create a new event instance.
+     * @param Process $process
+     * @return void
+     */
+    public function __construct(Process $process)
+    {
+        $this->process = $process;
+    }
+}

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

@@ -71,7 +71,7 @@ class LaborReportController extends Controller
         $totalLaborReports=app('laborReportService')->get($param);
         $totalWorkingHours=0;
         foreach ($totalLaborReports as $totalLaborReport){
-            $totalWorkingHours=$totalWorkingHours+$totalLaborReport->thisRecordWorkingTime;
+            $totalWorkingHours=$totalWorkingHours+$totalLaborReport->thisRoundRecordWorkingTime;
         }
         return $totalWorkingHours;
     }

+ 26 - 4
app/Http/Controllers/ProcessController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Commodity;
 use App\CommodityBarcode;
+use App\Events\ResetProcessStatisticStartDateEvent;
 use App\LaborReport;
 use App\Owner;
 use App\Process;
@@ -20,6 +21,7 @@ use App\UserDutyCheck;
 use App\UserLabor;
 use Carbon\Carbon;
 use Exception;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
@@ -319,6 +321,8 @@ class ProcessController extends Controller
         }
         return $process_id;
     }
+
+    //新增参与人
     public function storeProcessDailyParticipant(Request $request){
         if(!Gate::allows('二次加工管理-登记工时')){ return redirect(url('/'));  }
         $errors=$this->validatorProcessDailyParticipant($request)->errors();
@@ -355,6 +359,11 @@ class ProcessController extends Controller
         $processDailyParticipant->load(['processDaily'=>function($query){
             $query->with('process');
         }]);
+
+        // 重置统计开始时间
+        event(new ResetProcessStatisticStartDateEvent($processDailyParticipant->processDaily->process));
+
+
         if ($processDailyParticipant->processDaily && $processDailyParticipant->processDaily->process &&
             $processDailyParticipant->processDaily->process->status=='交接完成'){
             $this->statistic($processDailyParticipant->processDaily->process);
@@ -908,9 +917,13 @@ class ProcessController extends Controller
                 unset($processDaily);
             }
         }
-        ProcessDaily::destroy($processDailiesId);
-        ProcessDailyParticipant::whereIn('process_daily_id',$processDailiesId)->delete();
+
         $process=Process::find($process_id);
+        if (count($processDailiesId) > 0){
+            ProcessDaily::destroy($processDailiesId);
+            ProcessDailyParticipant::whereIn('process_daily_id',$processDailiesId)->delete();
+            event(new ResetProcessStatisticStartDateEvent($process));
+        }
         if (!$is_process_daily && $process){
             $ProcessDailyNow=ProcessDaily::create([
                 'process_id'=>$process_id,
@@ -920,7 +933,7 @@ class ProcessController extends Controller
             ]);
             $processDailies->push($ProcessDailyNow);
         }
-        $today=Carbon::now()->format('Y-m-d');
+        $today=Carbon::parse($start_date)->format('Y-m-d');
         $this->createDeficiencyData($processDailies,$today);
         $processDailies=ProcessDaily::with('processDailyParticipants')->where('process_id',$process_id)
             ->orderBy('date','DESC')->get();
@@ -963,7 +976,16 @@ class ProcessController extends Controller
 
     //删除临时工工作记录
     public function destroyDailyParticipant($id){
-        if (ProcessDailyParticipant::destroy($id)) return ['success'=>true];
+        $pro = ProcessDailyParticipant::query()->with(["processDaily"=>function($query){
+            /** @var Builder $query */
+            $query->with("process");
+        }])->find($id);
+        if ($pro->delete()) {
+
+            event(new ResetProcessStatisticStartDateEvent($pro->processDaily->process));
+
+            return ['success'=>true];
+        }
         return ['success'=>false , 'data'=>'记录不存在!'];
     }
     //导入商品数据

+ 6 - 1
app/Http/Controllers/RejectedBillController.php

@@ -150,9 +150,14 @@ class RejectedBillController extends Controller
     {
         $mobileShouldBeRequired = 'required';
         $logistic=Logistic::find($data['id_logistic_return']);
-        if($logistic){if(strstr($logistic['name'],'顺丰')){
+        if($logistic){if(
+            strstr($logistic['name'],'顺丰')
+        ){
             $mobileShouldBeRequired = 'nullable';
         }}
+        if($data['id_owner']=='4'){
+            $mobileShouldBeRequired = 'nullable';
+        }
         $mobileDigits = '';
         if($data['mobile_sender']&&$data['mobile_sender'][0]=='1'){
             $mobileDigits = 'digits:11';

+ 1 - 0
app/Http/Controllers/RejectedBillItemController.php

@@ -363,6 +363,7 @@ class RejectedBillItemController extends Controller
         }
         $rejectedBillItem = RejectedBillItem::find($request->input('id'));
         $rejectedBillItem->forceDelete();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($rejectedBillItem),Auth::user()['id']);
         return ['success'=>'true','id'=>$request->input('id')];
     }
 

Файловите разлики са ограничени, защото са твърде много
+ 32 - 12
app/Http/Controllers/TestController.php


+ 20 - 8
app/Http/Controllers/api/thirdPart/flux/SortingController.php

@@ -10,6 +10,8 @@ use App\Order;
 use App\OrderBin;
 use App\OrderCommodity;
 use App\Owner;
+//use App\Services\OrderService;
+use App\Services\CommodityService;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Validator;
@@ -18,6 +20,12 @@ use Zttp\Zttp;
 class SortingController extends Controller
 {
 
+//    /** @var OrderService orderService */
+//    private $orderService;
+//    public function __construct(){
+//        $this->orderService=app('OrderService');
+//    }
+
     /**
      * 新增被通知的波次列表(一个以上的波次),并且保存在本地数据库,供get波次使用
      * 接收:request[(下边newBatch的字段)]
@@ -37,12 +45,14 @@ class SortingController extends Controller
         $requestBatches = $requestArr['request']?? '';
         foreach ($requestBatches as $requestBatch){
             $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
-            $batch=new Batch([
-                'code' => $requestBatch['waveno'],
-                'wms_type' => $requestBatch['batch_type']??'',
-                'wms_status' => $requestBatch['docstatus']??'',
-                'status' => '未处理',
-                'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
+            $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
+            if(!$batch)$batch=new Batch();
+            $batch->fill([
+                    'code' => $requestBatch['waveno'],
+                    'wms_type' => $requestBatch['batch_type']??'',
+                    'wms_status' => $requestBatch['docstatus']??'',
+                    'status' => '未处理',
+                    'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
             ]);
             $batch->save();
             $oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
@@ -73,7 +83,9 @@ class SortingController extends Controller
                     $orderCommodity=OrderCommodity::query()
                         ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
                     if(!$orderCommodity){
-                        $commodity=Commodity::newCommodityBy_BarcodeOwnerIdNameSku($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['descr_c'],$requestBarcode['sku']);
+                        /** @var CommodityService $commodityService */
+                        $commodityService=app('CommodityService');
+                        $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
                         $orderCommodity = new OrderCommodity([
                             'order_id' => $order['id'],
                             'commodity_id' => $commodity['id'],
@@ -96,7 +108,7 @@ class SortingController extends Controller
     {
         return Validator::make($data, [
             'request' => ['required', 'array', 'min:1'],
-            'request.*.waveno' => ['required', 'string', 'max:191','unique:batches,code'],
+            'request.*.waveno' => ['required', 'string', 'max:191'],
             'request.*.taskprocess' => ['nullable', 'string', 'max:191'],
             'request.*.edittime' => ['nullable', 'string', 'max:191'],
             'request.*.batch_type' => ['nullable', 'string', 'max:191'],

+ 29 - 19
app/Http/Controllers/api/thirdPart/weight/PackageController.php

@@ -226,9 +226,14 @@ class PackageController extends Controller
                 $logisticNumberController = new LogisticNumberFeatureController();
                 if (!$package->order){
                     $package->order = new Order();
-                }
-                if (!$package->order->logistic){
-                    $package->order->logistic = $logisticNumberController->getLogisticByFeatures($package->logistic_number);
+                    $logistic=$logisticNumberController->getLogisticByFeatures($package->logistic_number);
+                    $package->order->logistic = $logistic;
+                }else{
+                    if(!$package->order->logistic){
+                        $logistic=$logisticNumberController->getLogisticByFeatures($package->logistic_number);
+                        $package->order->logistic_id = $logistic['id'];
+                        $package->order->save();
+                    }
                 }
             }catch (\Exception $e){
                 $response=["msg"=>"称重下发修改时发生错误!".json_encode($e),"code"=>500,"data"=>null];
@@ -260,17 +265,22 @@ class PackageController extends Controller
             $package->fetchAllFromOracle();
             $package->fetchPaperBox();
             try{
+                $package->save();
                 $package->load(['order'=>function($query){
                     $query->with('owner','logistic');
                 },'paperBox','measuringMachine']);
                 $logisticNumberController = new LogisticNumberFeatureController();
                 if (!$package->order){
                     $package->order = new Order();
+                    $logistic=$logisticNumberController->getLogisticByFeatures($package->logistic_number);
+                    $package->order->logistic = $logistic;
+                }else{
+                    if(!$package->order->logistic){
+                        $logistic=$logisticNumberController->getLogisticByFeatures($package->logistic_number);
+                        $package->order->logistic_id = $logistic['id'];
+                        $package->order->save();
+                    }
                 }
-                if (!$package->order->logistic){
-                    $package->order->logistic = $logisticNumberController->getLogisticByFeatures($package->logistic_number);
-                }
-                $package->save();
             }catch (\Exception $e){
                 $response=["msg"=>$e->getMessage(),"code"=>500,"data"=>$e->getTraceAsString()];
                 app('LogService')->log(__METHOD__,'weightApi(ERROR)'.__FUNCTION__,json_encode($request).'||'.json_encode($response).'||'.$e->getTraceAsString(),null);
@@ -287,18 +297,18 @@ class PackageController extends Controller
         }
         if(!empty($package->order))
             Waybill::setWeightByOrderCode($package->order->code,$package->weight);
-            event(new WeighedEvent($package));
-            $response=["msg"=>"保存成功",
-                "code"=>200,
-                "data"=>true,
-                "serverMsg"=>null,
-                "requestor"=>[
-                    "requestor"=>"1",
-                    "eventCode"=>"0",
-                    "reqDate"=>$reqDate,
-                    "resDate"=>Carbon::now()]
-            ];
-            app('LogService')->log(__METHOD__,__FUNCTION__,"下发写入包裹成功:".json_encode($request).'|'.json_encode($response),null);
+        event(new WeighedEvent($package));
+        $response=["msg"=>"保存成功",
+            "code"=>200,
+            "data"=>true,
+            "serverMsg"=>null,
+            "requestor"=>[
+                "requestor"=>"1",
+                "eventCode"=>"0",
+                "reqDate"=>$reqDate,
+                "resDate"=>Carbon::now()]
+        ];
+        app('LogService')->log(__METHOD__,__FUNCTION__,"下发写入包裹成功:".json_encode($request).'|'.json_encode($response),null);
         return json_encode($response,JSON_UNESCAPED_UNICODE);
     }
 

+ 6 - 6
app/InventoryAccount.php

@@ -12,10 +12,10 @@ class InventoryAccount extends Model
     use ModelTimeFormat;
     use SoftDeletes;
     protected $fillable=[
-        'id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at','status','remark','auditor'
+        'id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at','status','remark','auditor','ignored'
     ];
     protected $appends = [
-            'surplus','check_surplus','ignored'
+            'surplus','check_surplus'
     ];
     public function creator(){
         return $this->hasOne('App\Sign','signable_id','id')
@@ -35,10 +35,10 @@ class InventoryAccount extends Model
     {
         return $this['total'] ? $this['total']-($this['processed']+$this['ignored']):0;
     }
-    public function getProcessedAttribute(){
+    public function getProcessedAmount(){
         return $this->inventoryMissions()->whereIn('checked',['是','确认差异','已复核'])->where('inventory_account_id',$this['id'])->count();
     }
-    public function getIgnoredAttribute(){
+    public function getIgnoredAmount(){
         return $this->inventoryMissions()->where('checked','跳过')->where('inventory_account_id',$this['id'])->count();
     }
     //复盘剩余数
@@ -47,11 +47,11 @@ class InventoryAccount extends Model
         $re_checked_amount=$this->inventoryMissions()->where('inventory_account_id',$this['id'])->whereNotNull('re_checked_amount')->count();
         return $this['total'] ? $this['total']-$re_checked_amount:null;
     }
-    public function getDifferenceAttribute(){
+    public function getDifferenceAmount(){
         return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('difference_amount','!=',0)->count();
     }
     //复盘归位
-    public function getReturnedAttribute(){
+    public function getReturnedAmount(){
         return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('returned','是')->count();
 
     }

+ 22 - 8
app/LaborReport.php

@@ -20,7 +20,7 @@ class LaborReport extends Model
         'user_duty_check_id','relax_time'
     ];
     protected $appends = [
-        'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime',
+        'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime','thisRoundRecordWorkingTime',
         'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId','isAdult','round_check_in_at','round_check_out_at','has_group_verify_right'
     ];
     protected $tempFields = [
@@ -115,11 +115,7 @@ class LaborReport extends Model
     //本轮工作结束时间
     public function getThisRoundOnlineEndTimeAttribute(){
         $laborReports=LaborReport::where('enter_number',$this['enter_number'])->get();
-//        $maxId=$laborReports->max('id');
         foreach ($laborReports as $laborReport){
-//            if ($laborReport['id']==$maxId&&!$laborReport['exit_at']&&$laborReport['check_out_at']){
-//                return $laborReport['check_out_at'];
-//            }
             if ($laborReport['exit_at']&&$laborReport['check_out_at'])
                 return $laborReport['check_out_at'];
         }
@@ -160,12 +156,30 @@ class LaborReport extends Model
             return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime)-$this['relax_time']/60;
         }
     }
+    //本次取整工作时长
+    public function getThisRoundRecordWorkingTimeAttribute(){
+        if ($this['round_check_in_at']&&!$this['round_check_out_at']&&!$this['relax_time']){
+            $workingTime=round(Carbon::parse(Carbon::now())->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse(Carbon::now())->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime);
+        }
+        if ($this['round_check_in_at']&&$this['round_check_out_at']&&!$this['relax_time']){
+            $workingTime=round(Carbon::parse($this['round_check_out_at'])->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse($this['round_check_out_at'])->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime);
+        }
+        if ($this['round_check_in_at']&&$this['round_check_out_at']&&$this['relax_time']){
+            $workingTime=round(Carbon::parse($this['round_check_out_at'])->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse($this['round_check_out_at'])->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime)-$this['relax_time']/60;
+        }
+    }
 
     //工作时长减午饭休息时间
     public function minusLunchTime($checkInTime,$checkOutTime,$hour){
-//        if ((int)$checkInTime<=12&&(int)$checkOutTime>=13){
-//            $hour=$hour-1;
-//        }
         if ($checkInTime->lessThanOrEqualTo($checkInTime->clone()->setHours(11)->setMinutes(30))&&(int)$checkOutTime>=13){
             $hour=$hour-1;
         }

+ 60 - 0
app/Listeners/ResetProcessStatisticStartDateListener.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Listeners;
+
+use App\Events\ResetProcessStatisticStartDateEvent;
+use App\Process;
+use App\ProcessStatistic;
+use Carbon\Carbon;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Queue\InteractsWithQueue;
+
+class ResetProcessStatisticStartDateListener
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param  ResetProcessStatisticStartDateEvent  $event
+     * @return void
+     */
+    public function handle(ResetProcessStatisticStartDateEvent $event)
+    {
+        $process = $event->process;
+        $process->load(["processDailies"=>function($query){
+            /** @var Builder $query */
+            $query->orderBy("date")->withCount(["processDailyParticipants"]);
+        },"processStatistic"=>function($query){
+            /** @var Builder $query */
+            $query->select("process_id","started_at");
+        }]);
+
+        $dailies = $process->processDailies ?? false;
+        if ($dailies){
+            foreach ($dailies as $daily){
+                if ($daily->process_daily_participants_count > 0){
+                    $this->comparisonReplace($process->processStatistic,$daily->date." 09:00:00");
+                    return;
+                }
+            }
+        }
+        $this->comparisonReplace($process->processStatistic,null);
+    }
+
+    private function comparisonReplace($statistic, $date)
+    {
+        if ($statistic->started_at != $date){
+            ProcessStatistic::query()->where("process_id",$statistic->process_id)->update(["started_at"=>$date]);
+        }
+    }
+}

+ 4 - 0
app/Order.php

@@ -28,6 +28,10 @@ class Order extends Model
         'amount',
         'commodityPackages'
     ];
+    public function cancel(){
+        $this['status'] = '取消';
+        $this->update();
+    }
 
     public function logistic()
     {

+ 3 - 3
app/OrderPackage.php

@@ -106,15 +106,15 @@ class OrderPackage extends Model
         $now = Carbon::now();
         foreach($resultOracleObjs_grouped as $resultOracleObj_grouped){
             $resultOracleObj = $resultOracleObj_grouped[0];
-            /** @var OrderService */
-            $order = app('OrderService')->logisticNumberFirstOrCreateOrder($resultOracleObj['soreference5']);
+            /** @var OrderService $orderService*/
+            $orderService = app('OrderService');
+            $order = $orderService->logisticNumberFirstOrCreateOrder($resultOracleObj['soreference5']);
             if (!$order){
                 app('LogService')->log(__METHOD__,"此包裹在WMS未找到order",json_encode($resultOracleObj),Auth::user()['id']);
                 continue;
             }
             array_push($packages,[
                 'batch_number'=>$batchCode??'',
-                /** @var OrderPackageService */
                 'order_id' => $order->id,
                 'logistic_number'=>$resultOracleObj['soreference5']??'',
                 'weight'=>$weight,

+ 4 - 0
app/Process.php

@@ -50,6 +50,10 @@ class Process extends Model
         return $this->hasMany('App\Sign','signable_id','id')
             ->where('signable_type','processes')->where('field','unit_price');
     }
+    public function processStatistic()
+    {
+        return $this->hasOne(ProcessStatistic::class,"process_id","id");
+    }
 
     public function automaticSupplementSign(){
         return $this->hasOne('App\Sign','signable_id','id')

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -32,6 +32,7 @@ use App\Services\OrderService;
 use App\Services\OrderIssueWorkLoadService;
 use App\Services\OrderPackageCommoditiesService;
 use App\Services\OrderTrackingService;
+use App\Services\OwnerReportService;
 use App\Services\OwnerService;
 use App\Services\PackageService;
 use App\Services\PackageStatisticsService;
@@ -125,6 +126,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OrderIssueService',OrderIssueService::class);
         app()->singleton('OrderService',OrderService::class);
         app()->singleton('OracleDocOrderHeaderService',OracleDOCOrderHeaderService::class);
+        app()->singleton('OwnerReportService',OwnerReportService::class);
         app()->singleton('RejectedBillService',RejectedBillService::class);
         app()->singleton('RejectedBillItemService',RejectedBillItemService::class);
         app()->singleton('StoreCheckingReceiveService',StoreCheckingReceiveService::class);

+ 3 - 0
app/Providers/EventServiceProvider.php

@@ -27,6 +27,9 @@ class EventServiceProvider extends ServiceProvider
         'App\Events\CustomerStored' =>[
             'App\Listeners\FulfillPackageCustomer'
         ],
+        'App\Events\ResetProcessStatisticStartDateEvent' =>[
+            'App\Listeners\ResetProcessStatisticStartDateListener'
+        ],
     ];
 
     /**

+ 29 - 0
app/Services/CommodityBarcodeService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 
 use App\CommodityBarcode;
+use Illuminate\Support\Collection;
 
 Class CommodityBarcodeService
 {
@@ -44,4 +45,32 @@ Class CommodityBarcodeService
     {
         return CommodityBarcode::query()->create($params);
     }
+
+    /**
+     * @param array $commoditiesAndBarcodesPacks 格式:[['commodity_id'=>id, barcodes=[str,str,str]], [......]]
+     * @return bool
+     */
+    public function insertMany_onCommodities(array $commoditiesAndBarcodesPacks)
+    {
+        $commodityBarcodes=[];
+        foreach ($commoditiesAndBarcodesPacks as $commoditiesAndBarcodesPack){
+            $commodity_id=$commoditiesAndBarcodesPack['commodity_id'];
+            $barcodes=$commoditiesAndBarcodesPack['barcodes'];
+            foreach ($barcodes as $barcode){
+                $commodityBarcodes[]=[
+                    'commodity_id'=>$commodity_id,
+                    'code'=>$barcode,
+                ];
+            }
+        }
+        if(empty($commodityBarcodes))return false;
+        return CommodityBarcode::query()->insert($commodityBarcodes);
+    }
+    public function destroyCollections(Collection $commodityBarcodes)
+    {
+        $ids=$commodityBarcodes->map(function($commodityBarcode){
+            return $commodityBarcode['id'];
+        });
+        return CommodityBarcode::destroy($ids);
+    }
 }

+ 53 - 1
app/Services/CommodityService.php

@@ -3,15 +3,17 @@
 namespace App\Services;
 
 use App\Commodity;
+use App\CommodityBarcode;
 use App\OracleBasSKU;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Collection;
 
 Class CommodityService
 {
-    public function firstOrCreate($param,$column = null){
+    public function firstOrCreate($param,$column = null):Commodity{
         if ($column) return Commodity::query()->firstOrCreate($param,$column);
         return Commodity::query()->firstOrCreate($param);
     }
@@ -214,4 +216,54 @@ Class CommodityService
         $params["type"] = "临时";
         return Commodity::query()->create($params);
     }
+
+
+
+    public function syncBarcodes($barcodesStr,$ownerId,$sku):Commodity
+    {
+        $barcodes=(function()use($barcodesStr){
+            $barcodes=rtrim($barcodesStr,',');
+            $barcodes=explode(',',$barcodes);
+            foreach ($barcodes as $k=>$barcode){
+                if(!trim($barcode)) unset($barcodes[$k]);
+            }
+            return $barcodes;
+        })();
+        $commodity=$this->firstOrCreate(['owner_id'=>$ownerId,'sku'=>$sku]);
+        $commodityBarcodes=$commodity['barcodes']??new Collection();
+
+
+        /** @var CommodityBarcodeService $commodityBarcodeService */
+        $commodityBarcodeService=app('CommodityBarcodeService');
+        $redundantCommodityBarcodes=new Collection();
+        foreach($commodityBarcodes as $commodityBarcode){//清除数组中 已经在商品有的条码,清除商品条码中,不在数组中的条码
+            $hasMatch=false;
+            foreach($barcodes as $key=>$barcode){
+                if($barcodes[$key]==$commodityBarcode['code']){
+                    $hasMatch=true;
+                    unset($barcodes[$key]);
+                    break;
+                }
+            }
+            if(!$hasMatch){
+                $redundantCommodityBarcodes->push($commodityBarcode);
+            }
+        }
+        if(!empty($redundantCommodityBarcodes)){
+            $commodityBarcodeService->destroyCollections($redundantCommodityBarcodes);
+        }
+        if(!empty($barcodes)){
+            $commodityBarcodeService->insertMany_onCommodities([['commodity_id'=>$commodity['id'],'barcodes'=>$barcodes]]);
+        }
+        return $commodity;
+    }
+    public function destroyWithOffspring(Commodity $commodity)
+    {
+        $barcodesIds=$commodity->barcodes->map(function ($barcode){
+            return $barcode['id'];
+        });
+        CommodityBarcode::destroy($barcodesIds);
+        $commodity->delete();
+    }
+
 }

+ 20 - 15
app/Services/InventoryAccountService.php

@@ -346,9 +346,10 @@ class InventoryAccountService
     //盘点修改盘点任务数据
     public function updateInventory($inventoryAccountId){
         $inventoryAccount=InventoryAccount::find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+        $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount(); //跳过数
         if($inventoryAccount->status=='待盘点')
             $inventoryAccount->status='盘点中';
         $inventoryAccount->update();
@@ -430,9 +431,10 @@ class InventoryAccountService
             Controller::logS(__METHOD__,"增加盘点人".__FUNCTION__,json_encode($inventoryId));
             $inventoryAccount=InventoryAccount::query()->find($inventoryId);
             $inventoryAccount->total=$inventoryAccount->total+1;
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
             $inventoryAccount->update();
             Controller::logS(__METHOD__,"修改盘点任务记录".__FUNCTION__,json_encode($inventoryId));
             $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->where('id',$inventoryAccountMission->id)->first();
@@ -539,9 +541,10 @@ class InventoryAccountService
         if ($inventoryAccountMission>0){
             $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
             $inventoryAccount->total=$inventoryAccount->total-1;
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
             $inventoryAccount->update();
             Controller::logS(__METHOD__,'删除盘点记录时修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         }
@@ -554,9 +557,10 @@ class InventoryAccountService
         app('LogService')->log(__METHOD__,"跳过盘点记录修改checked状态",json_encode($inventoryAccountMissionId));
         if ($inventoryAccountMission->checked=='跳过'){
             $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
             $inventoryAccount->update();
             Controller::logS(__METHOD__,'跳过盘点记录时修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         }
@@ -582,9 +586,10 @@ class InventoryAccountService
         }
         app('LogService')->log(__METHOD__,"批量跳过或确认差异",json_encode($checkData));
         $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+        $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
         $inventoryAccount->update();
         Controller::logS(__METHOD__,'批量跳过或确认差异修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         return $inventoryAccountMissions;

+ 1 - 0
app/Services/OracleActAllocationDetailService.php

@@ -40,6 +40,7 @@ Class OracleActAllocationDetailService
         if (($params['page'] ?? false) && ($params['paginate'] ?? false))$allocations = $this->paginate($params);
         else $allocations = $this->get($params);
         $count = count($allocations);
+        if (!$count)return null;
         $str = "(";
         foreach ($allocations as $index => $allocation){
             if ($index < $count-1){

+ 1 - 1
app/Services/OrderService.php

@@ -203,7 +203,7 @@ class OrderService
             $ordernos = app('OracleActAllocationDetailService')
                 ->getOrderno(['checktime_start'=>$checktime_start,'checktime_end'=>$checktime_end,
                     'paginate'=>$paginate,'page'=>$page]);
-            $params['ordernos'] = $ordernos;
+            if ($ordernos)$params['ordernos'] = $ordernos;
         }
         $sql="select ACT_ALLOCATION_DETAILS.CHECKTIME,DOC_ORDER_HEADER.addtime,DOC_ORDER_HEADER.C_PROVINCE,DOC_ORDER_HEADER.C_CITY,DOC_ORDER_HEADER.C_DISTRICT,DOC_ORDER_HEADER.C_CONTACT,DOC_ORDER_HEADER.OrderNo,DOC_ORDER_HEADER.SOStatus,DOC_ORDER_HEADER.WAREHOUSEID,DOC_ORDER_HEADER.CustomerID
         ,DOC_ORDER_HEADER.C_Tel2,DOC_ORDER_HEADER.C_Tel1,DOC_ORDER_HEADER.CarrierName,DOC_ORDER_HEADER.IssuePartyName,DOC_ORDER_HEADER.EDIREMARKS2,

+ 5 - 3
app/Services/OwnerService.php

@@ -7,6 +7,7 @@ use App\Owner;
 use App\User;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
 
 Class OwnerService
@@ -22,10 +23,11 @@ Class OwnerService
      */
     public function getSelection(array $column = ['id', 'name'])
     {
-        return $this->cacheService->getOrExecute('OwnersAll_IdName',function()use($column){
-            return Owner::filterAuthorities()->select($column)->get();
+        $ownerIds=app('UserService')->getPermittingOwnerIds(Auth::user());
+        return $this->cacheService->getOrExecute('OwnersAll_IdName'.md5(json_encode($column).json_encode($ownerIds)),function()use($column,$ownerIds){
+            if(empty($ownerIds))return new Collection();
+            return Owner::query()->select($column)->whereIn('id', $ownerIds)->get();
         },config('cache.expirations.owners'));
-
     }
     public function getSelectionId($column = ['id'])
     {

+ 2 - 1
app/Services/UserService.php

@@ -24,7 +24,8 @@ class UserService
         });
         return !!$roles->intersect($thisRoles)->count();
     }
-    function getPermittingOwnerIds($user){
+    function getPermittingOwnerIds($user=null){
+        if(!$user)return [];
         return $this->cacheService->getOrExecute("user{$user['id']}->getPermittingOwnerIds",function()use($user){
             return $user->getPermittingOwnerIdsAttribute() ?? [];
         });

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

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddIgnoredToInventoryAccounts extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('inventory_accounts', function (Blueprint $table) {
+            $table->integer('ignored')->nullable()->comment('跳过数');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('inventory_accounts', function (Blueprint $table) {
+            $table->dropColumn('ignored');
+        });
+    }
+}

+ 2 - 2
public/js/app.js

@@ -86472,8 +86472,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\wamp64\www\bswas\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\Demo\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\Demo\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),

+ 2 - 5
public/t.php

@@ -1,7 +1,4 @@
 <?php
 
-
-$str = '货号:yw2020110877入正品仓';
-$result=[];
-preg_match("/[a-zA-Z]{0,5}\d{6,20}/", $str, $result);
-var_dump($result);
+$ar=[5,3,22];
+echo array_key_last($ar);

+ 9 - 4
resources/js/queryForm/queryForm.js

@@ -558,7 +558,7 @@ const query = function getQueryForm(data) {
 
         let ul_div = $("<div class='pl-0 tooltipTarget' style='position: absolute;left: 100px;top:25px; max-height: 150px; overflow-y: scroll; border: 1px solid rgb(221, 221, 221); border-radius: 5px; text-align: center; transform: scale(0.9);z-index:1' tabindex='1'></div>");
         let ul = $("<ul name='" + condition.name + "' class='list-group pl-0 m-0 p-0 bg-white' style='list-style-type: none;width: 150px;top:35px; z-index: 100' ></ul>");
-        let check = $("<input type = 'checkbox' style='z-index:101;position:fixed;top:0;right: 0;border:1px green' >");
+        let check = $("<input id='multipleCheckBox' type = 'checkbox' style='z-index:101;position:fixed;top:0;right: 0;border:1px green' >");
         let isMouseenterCheckBox = false;
 
         select_div.append(input).append(ul_div.append(ul).append(check));
@@ -656,8 +656,10 @@ const query = function getQueryForm(data) {
         ul_div.mouseenter(function () {
             if(_data[condition.name].value.length>0){
                 setTimeout(()=> {
-                    ul_div.attr("title","移出多选区域即可自动提交");
-                    ul_div.tooltip('show');
+                    if (ul_div.is(':visible')){
+                        ul_div.attr("title","移出多选区域即可自动提交");
+                        ul_div.tooltip('show');
+                    }
                 },1000);
             }
         });
@@ -1042,7 +1044,10 @@ const query = function getQueryForm(data) {
                     dom.style.backgroundColor = "#FFFFFF";
                     $(dom).removeClass('active');
                 }
-            })
+            });
+            if (lis.length === select.length) {
+                $("#multipleCheckBox").prop("checked", true);
+            }
             isMultiple(ul.attr('name'));
         }
     }

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

@@ -77,7 +77,7 @@
                     <td >@{{ inventory.total }}</td>
                     <td >@{{ inventory.processed }}</td>
                     <td >@{{ inventory.surplus }}</td>
-                    <td >@{{ inventory.ignored }}</td>
+                    <td >@{{ inventory.ignored?inventory.ignored:0 }}</td>
                     <td>@{{ inventory.difference }}</td>
                     <td>@{{ inventory.returned }}</td>
                     <td v-if="inventory.processed">@{{ inventory.processed }}/@{{ inventory.total }}</td>

+ 4 - 2
resources/views/personnel/laborReport/index.blade.php

@@ -83,7 +83,7 @@
                 <td class="text-muted"><span v-if="laborReport.relax_time">@{{laborReport.relax_time}}</span></td>
                 {{--                        <td class="text-muted"><span v-if="laborReport.onlineDuration">@{{laborReport.onlineDuration}}</span></td>--}}
                 <td class="text-muted"><span v-if="laborReport.thisRecordOnlineTime">@{{laborReport.thisRecordOnlineTime}}</span></td>
-                <td><span v-if="laborReport.thisRecordWorkingTime">@{{laborReport.thisRecordWorkingTime}}</span></td>
+                <td><span v-if="laborReport.thisRoundRecordWorkingTime">@{{laborReport.thisRoundRecordWorkingTime}}</span></td>
                 {{--                        <td><span v-if="laborReport.workingDuration">@{{laborReport.workingDuration}}</span></td>--}}
                 <td>
                     @can('人事管理-临时工报表-编辑备注')
@@ -296,7 +296,9 @@
                             workingDuration:'{{$laborReport->working_duration}}', created_at:'{{$laborReport->created_at}}',
                             enter_at:'{{$laborReport->enter_at}}',exit_at:'{{$laborReport->exit_at}}',
                             thisRecordOnlineTime:'{{$laborReport->thisRecordOnlineTime}}',
-                            thisRecordWorkingTime:'{{$laborReport->thisRecordWorkingTime}}',isAdult:'{{$laborReport->isAdult}}',has_group_verify_right:'{{$laborReport->has_group_verify_right}}',
+                            thisRecordWorkingTime:'{{$laborReport->thisRecordWorkingTime}}',
+                            thisRoundRecordWorkingTime:'{{$laborReport->thisRoundRecordWorkingTime}}',
+                            isAdult:'{{$laborReport->isAdult}}',has_group_verify_right:'{{$laborReport->has_group_verify_right}}',
                             sequence:'{{$laborReport->sequence}}',amountOfJoined:'{{$laborReport->amountOfJoined}}',remark:'{{$laborReport->remark}}',
                             @if($laborReport->userDutyCheck)user_duty_check_id:'{{$laborReport->userDutyCheck->id}}', userDutyCheckVerifyUserId:'{{$laborReport->userDutyCheck->verify_user_id}}'
                             ,userDutyCheckType:'{{$laborReport->userDutyCheck->type}}',userDutyCheckAt:'{{$laborReport->userDutyCheck->checked_at}}',@endif},

+ 0 - 21
tests/Inventory/ExampleTest.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace Tests\Unit;
-
-use App\Authority;
-use App\Carrier;
-use App\Role;
-use App\User;
-use Illuminate\Support\Facades\DB;
-use Tests\TestCase;
-use Illuminate\Foundation\Testing\WithFaker;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-
-class ExampleTest extends TestCase
-{
-
-    public function testExample(){
-        $this->assertEquals(2,1+1);
-    }
-
-}

+ 44 - 0
tests/Inventory/UpdateInventoryAccount.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace Tests\Inventory;
+
+
+use App\InventoryAccount;
+use App\Services\common\BatchUpdateService;
+use Carbon\Carbon;
+use Tests\TestCase;
+
+class UpdateInventoryAccount extends TestCase
+{
+    public $inventoryAccounts;
+    public function setUp(): void
+    {
+        parent::setUp(); // TODO: Change the autogenerated stub
+        $this->inventoryAccounts=InventoryAccount::query()->get();
+    }
+
+    public function testUpdateInventoryAccount(){
+        $updateParams = [[
+            'id','processed','ignored','updated_at'
+        ]];
+        $updated_at=Carbon::now()->toDateTimeString();
+        foreach ($this->inventoryAccounts as $inventoryAccount){
+            if ($inventoryAccount->getIgnoredAmount()>0){
+                $updateParams[] = [
+                    'id'=>$inventoryAccount->id,
+                    'processed'=>$inventoryAccount->getProcessedAmount(),
+                    'ignored' => $inventoryAccount->getIgnoredAmount(),
+                    'updated_at'=>$updated_at,
+                ];
+            }
+        }
+        if(count($updateParams) > 1){
+            $this->batchUpdate($updateParams);
+        }
+    }
+    public function batchUpdate($params){
+        return app(BatchUpdateService::class)->batchUpdate('inventory_accounts',$params);
+    }
+
+}

+ 0 - 0
tests/Services/CacheService/GetOrExecuteTest/GetOrExecuteTest.php → tests/Services/CacheService/GetOrExecuteTest.php


+ 60 - 0
tests/Services/CommodityBarcodeService/DestroyTest.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Tests\Services\CacheService\GetOrExecuteTest;
+
+use App\Commodity;
+use App\CommodityBarcode;
+use App\Services\CacheService;
+use App\Services\CommodityBarcodeService;
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\Cache;
+use Tests\TestCase;
+
+class InsertMany_onCommoditiesTest extends TestCase
+{
+
+    /** @var CommodityBarcodeService $service */
+    public $service;
+    public $data=[];
+    public function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app('CommodityBarcodeService');
+        ($this->data['commodity']=(new Commodity()))->save();
+        $this->data['barcodes']=['A1','B1','C2'];
+        $inserts=(function(){
+            $targets=[];
+            foreach ($this->data['barcodes'] as $barcode) {
+                $targets[]=['commodity_id'=>$this->data['commodity']['id'],'code'=>$barcode];
+            }
+            return $targets;
+        })();
+        CommodityBarcode::query()->insert($inserts);
+        $this->data['commodityBarcodes']=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->whereIn('code',$this->data['barcodes'])
+            ->get();
+    }
+
+    public function testDeleted(){
+        $this->assertGreaterThan(0,$this->data['commodityBarcodes']->count());
+        $destroyIds = $this->data['commodityBarcodes']->map(function ($commodityBarcode) {
+            return $commodityBarcode['id'];
+        });
+        $commodityBarcodes = CommodityBarcode::query()->whereIn('id', $destroyIds)->get();
+        $this->service->destroyCollections($commodityBarcodes);
+
+        $commodityBarcodesResult = CommodityBarcode::query()->whereIn('id', $destroyIds)->get();
+        $this->assertEquals(0, $commodityBarcodesResult->count());
+    }
+
+
+    public function tearDown(): void
+    {
+        $this->data['commodity']->delete();
+        CommodityBarcode::destroy($this->data['commodityBarcodes']->map(function ($commodityBarcode){
+            return $commodityBarcode['id'];
+        }));
+        parent::tearDown();
+    }
+}

+ 65 - 0
tests/Services/CommodityBarcodeService/InsertMany_onCommoditiesTest.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace Tests\Services\CacheService\GetOrExecuteTest;
+
+use App\Commodity;
+use App\CommodityBarcode;
+use App\Services\CacheService;
+use App\Services\CommodityBarcodeService;
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\Cache;
+use Tests\TestCase;
+
+class InsertMany_onCommoditiesTest extends TestCase
+{
+
+    /** @var CommodityBarcodeService $service */
+    public $service;
+    public $data=[];
+    public function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app('CommodityBarcodeService');
+        ($this->data['commodity']=(new Commodity()))->save();
+        $this->data['barcodes']=['A1','B1','C2'];
+        $this->data['commodityBarcodes']=new Collection();
+    }
+
+    public function testInsert(){
+        $inputs=[
+            'commodity_id'=>$this->data['commodity']['id'],
+            'barcodes'=>$this->data['barcodes']
+        ];
+        $this->service->insertMany_onCommodities([$inputs]);
+        $this->data['commodityBarcodes']=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->whereIn('code',$this->data['barcodes'])
+            ->get();
+        $resultArr=$this->data['commodityBarcodes']->map(function ($commodityBarcode){
+            return [$commodityBarcode['commodity_id'],$commodityBarcode['code']];
+        });
+        $expectArr = (function () {
+            $arr=[];
+            foreach ($this->data['barcodes'] as $barcode) {
+                $arr[]=[
+                    $this->data['commodity']['id'],$barcode
+                ];
+            }
+            return $arr;
+        })();
+        $this->assertEquals(json_encode($expectArr),json_encode($resultArr));
+
+        $result=$this->service->insertMany_onCommodities([]);
+        $this->assertEquals(false,$result);
+    }
+
+
+    public function tearDown(): void
+    {
+        $this->data['commodity']->delete();
+        CommodityBarcode::destroy($this->data['commodityBarcodes']->map(function ($commodityBarcode){
+            return $commodityBarcode['id'];
+        }));
+        parent::tearDown();
+    }
+}

+ 98 - 0
tests/Services/CommodityService/SyncBarcodesTest.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace Tests\Services\CacheService\GetOrExecuteTest;
+
+use App\Commodity;
+use App\CommodityBarcode;
+use App\Services\CacheService;
+use App\Services\CommodityBarcodeService;
+use App\Services\CommodityService;
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\Cache;
+use Tests\TestCase;
+
+class InsertMany_onCommoditiesTest extends TestCase
+{
+
+    /** @var CommodityService $service */
+    public $service;
+    /** @var CommodityBarcodeService $commodityBarcodeService */
+    public $commodityBarcodeService;
+    public $data=[];
+    public function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app('CommodityService');
+        $this->commodityBarcodeService = app('CommodityBarcodeService');
+        ($this->data['commodity']=(new Commodity(['owner_id'=>1,'sku'=>md5(microtime(true))])))->save();
+        $this->data['barcodes']=['A1','B1','C2'];
+        $this->data['commodityBarcodes']=new Collection();
+        $inputs=[
+            'commodity_id'=>$this->data['commodity']['id'],
+            'barcodes'=>$this->data['barcodes']
+        ];
+        $this->commodityBarcodeService->insertMany_onCommodities([$inputs]);
+    }
+
+    public function testLessBarcodesCommodity(){
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $lastCode=array_pop($this->data['barcodes']);
+        $this->data['barcodesStr']=implode(',',$this->data['barcodes']);
+        $this->service->syncBarcodes($this->data['barcodesStr'], $this->data['commodity']->owner_id, $this->data['commodity']->sku);
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $nullCommodityBarcode=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->where('code',$lastCode)
+            ->first();
+        $this->assertEquals(null,$nullCommodityBarcode);
+
+    }
+    public function testMoreBarcodesCommodity(){
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $this->data['barcodes'][] = $newCode='FF';
+        $this->data['barcodesStr']=implode(',',$this->data['barcodes']);
+        $this->service->syncBarcodes($this->data['barcodesStr'], $this->data['commodity']->owner_id, $this->data['commodity']->sku);
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $additionalCommodityBarcode=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->where('code',$newCode)
+            ->get();
+        $this->assertEquals(1,$additionalCommodityBarcode->count());
+
+    }
+    public function testDiffMoreBarcodesCommodity(){
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $this->data['barcodes'][] = $newCode='FF';
+        $firstCode=array_shift($this->data['barcodes']);
+        $this->data['barcodesStr']=implode(',',$this->data['barcodes']);
+        $this->service->syncBarcodes($this->data['barcodesStr'], $this->data['commodity']->owner_id, $this->data['commodity']->sku);
+        $commodityBarcodes = $this->data['commodity']->load('barcodes')->barcodes;
+        $this->assertEquals(count($this->data['barcodes']),$commodityBarcodes->count());
+        $additionalCommodityBarcode=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->where('code',$newCode)
+            ->get();
+        $nullCommodityBarcode=CommodityBarcode::query()
+            ->where('commodity_id',$this->data['commodity']['id'])
+            ->where('code',$firstCode)
+            ->first();
+        $this->assertEquals(1,$additionalCommodityBarcode->count());
+        $this->assertEquals(null,$nullCommodityBarcode);
+
+    }
+
+
+    public function tearDown(): void
+    {
+        $this->service->destroyWithOffspring($this->data['commodity']);
+        CommodityBarcode::destroy($this->data['commodityBarcodes']->map(function ($commodityBarcode){
+            return $commodityBarcode['id'];
+        }));
+        parent::tearDown();
+    }
+}

+ 0 - 2
tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnstartDateCreateTest.php

@@ -23,9 +23,7 @@ class GetWmsOrderOnstartDateCreateTest extends TestCase
     public function testGetWmsOrderOnstartDateCreate()
     {
         $carbon =Carbon::now()->subHours(10);
-        var_dump(Carbon::now());
         $orderHeaders = $this->service->getWmsOrderOnStartDateCreate($carbon);
-        var_dump(Carbon::now());
         $this->assertNotNull($orderHeaders);
         $orderHeader = $orderHeaders->first();
         if($orderHeaders->count() == 0){

+ 16 - 13
tests/Services/StoreService/AsnSyncTest.php

@@ -8,6 +8,7 @@ use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDocAsnHerderService;
 use App\Services\StoreService;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Auth;
 use Tests\TestCase;
 
 class AsnSyncTest extends TestCase
@@ -22,20 +23,22 @@ class AsnSyncTest extends TestCase
 
 
     public function testAsnSync(){
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
-
-        $syncStartDate = data_get(config('sync'), 'asn_sync.start_at');
-
-        if($syncStartDate ?? false){
-            $syncStartDate = Carbon::parse($syncStartDate);
-            if ($startDate->lt($syncStartDate)) {
-                $startDate = $syncStartDate;
-            }
-        }
-//        $startDate=Carbon::parse('2020-10-22 00:00:00')->subDays(1)->format('Y-m-d H:i:s');
+//        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
+//
+//        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+//
+//        $syncStartDate = data_get(config('sync'), 'asn_sync.start_at');
+//
+//        if($syncStartDate ?? false){
+//            $syncStartDate = Carbon::parse($syncStartDate);
+//            if ($startDate->lt($syncStartDate)) {
+//                $startDate = $syncStartDate;
+//            }
+//        }
+        //$startDate=Carbon::parse('2020-10-22 00:00:00')->subDays(1)->format('Y-m-d H:i:s');
+//        app('LogService')->log(__METHOD__,"start".__FUNCTION__,Carbon::now());
         //app(StoreService::class)->syncWmsAsnData($startDate);
+//        app('LogService')->log(__METHOD__,"end".__FUNCTION__,Carbon::now());
         //$asnHeaders=app(OracleDocAsnHerderService::class)->getWmsAsnOnStartDateCreate($startDate);
         //dd($asnHeaders);
 

Файловите разлики са ограничени, защото са твърде много
+ 0 - 1
tests/sortingFluxNewBatch.http


+ 4 - 1
文档/WAS项目规范.md

@@ -27,6 +27,7 @@
 	
 
 ##服务
+    服务不能传入Request,不能返回Builder。以可以明确测试,以及明确缓存
 	注册
 		必须在AppServiceProvicder中用app()->singleton绑定为单例;在控制器使用时可以在参数处依赖注入,也可以用app()实例化,使用app()实例化的,在其上用/**@var 类型 参数名 **/   进行注释以使其可以关联提示;服务中调用其他服务的,也用app()进行实例化并且用@var注释
 		注册字符串名称大写开头
@@ -78,7 +79,9 @@
 	每个需求修改提交一个commit
 ##测试
     每个Service方法均需写一个对应的测试
-    每个Service在Tests,Services文夹下,建立对应对名文件夹,一个方法对应一个测试文件
+    每个Service在Tests,Services文夹下,建立对应名文件夹,一个方法对应一个测试文件
+    每个方法可以超过一个文件,如果N个是在基镜中需要配置相同假数据的,可以放在一个文件,不需要或其他假数据的,可以再做一个文件
+    同方法的多文件,在后缀Test之前用下划线_标注区分
     windwos下调用测试,在命令行运行phpunit.bat ,空格后跟要测试的目标包(包可以phpunit.xml定义)
 ##缓存
     缓存在service层以上使用,模型层内不使用

Някои файлове не бяха показани, защото твърде много файлове са промени