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

安卓提供盘点任务接口

haozi 4 лет назад
Родитель
Сommit
82cb01f2c1

+ 200 - 16
app/Http/ApiControllers/InventoryController.php

@@ -7,6 +7,8 @@ namespace App\Http\ApiControllers;
 use App\Components\ApiResponse;
 use App\Http\Requests\AndroidGateRequest;
 use App\InventoryAccount;
+use App\Services\AndroidInventoryService;
+use Illuminate\Support\Facades\Auth;
 
 class InventoryController
 {
@@ -17,8 +19,7 @@ class InventoryController
      * @apiName inventoryTasks
      * @apiGroup inventory
      *
-     * @apiParam {int} page 页数
-     * @apiParam {int} paginate 每页多少
+     * @apiParam {int} taskId 盘点任务号
      *
      * @apiSuccess {string} message 响应描述
      * @apiSuccess {int} status_code HTTP响应码
@@ -30,29 +31,212 @@ class InventoryController
      *       "message": "请求成功",
      *       "status_code": "200"
      *       "data":[
-     *          {
-     *              "id"=>"宝时单号",
+     *          inventoryTask => {
+     *              "id" =>"盘点任务号",
      *              "created_at"   =>"任务创建时间",
      *              "end_at"     =>"库位最后操作时间",
-     *              "owner_name"=>"货主名",
      *              "type"=>"任务类型",
      *              "total"=>"盘点任务数",
      *              "processed"=>"盘点数",
      *          }
+     *          inventoryTaskDetails=> [
+     *            {
+     *              "id" =>"盘点任务明细号",
+     *              "location"   =>"库位",
+     *              "commodity_id"     =>"商品id",
+     *              "produced_at"=>"生产日期",
+     *              "valid_at"=>"失效日期",
+     *              "stored_at"=>"入库日期",
+     *              "batch_number"=>"批号",
+     *              "erp_type_position"=>"属性仓",
+     *              "quality"=>"质量状态",
+     *              "stored_amount"=>"库存数量",
+     *              "verified_amount"=>"盘点数量",
+     *             }
+     *           ]
      *        ]
      *     }
      */
-    public function inventoryTasks(AndroidGateRequest $request)
+    public function getInventoryTask(AndroidGateRequest $request)
     {
-        $page       = $request->input("page",1);
-        $paginate   = $request->input("paginate",20);
-        $ownerIds=app('OwnerService')->getSelection();
-        $inventories=InventoryAccount::query()->with('owner')
-            ->orderBy('id','desc')
-            ->whereIn('status',['待盘点','盘点中','复盘中'])
-            ->whereIn('owner_id',$ownerIds)
-            ->paginate($paginate,'*', 'page',$page)
-            ->append(["owner_name"]);
-        $this->response(['inventories'=>$inventories]);
+        $taskId = $request->input("taskId");
+        /** @var AndroidInventoryService $service */
+        $service=app('AndroidInventoryService');
+        $inventoryTask = InventoryAccount::query()->find($taskId);
+        $inventoryTaskDetails=$service->getUnInventoryTaskList($taskId);
+        $staffName = Auth::user()['name'];
+        $sameDayInventoryCount=$service->getStaffSameDayInvCount();
+        $this->response(['inventoryTask' => $inventoryTask,
+            'inventoryTaskDetails' => $inventoryTaskDetails,
+            'staffName'=>$staffName,'sameDayInventoryCount'=>$sameDayInventoryCount
+        ]);
+    }
+
+
+    /**
+     * @api {post} /inventory/locationInvPro 当前库位下盘点比例
+     * @apiName locationInvPro
+     * @apiGroup inventory
+     *
+     * @apiParam {int} taskId 盘点任务号
+     * @apiParam {string} location 库位
+     *
+     * @apiSuccess {string} message 响应描述
+     * @apiSuccess {int} status_code HTTP响应码
+     * @apiSuccess {object} data
+     *
+     * @apiSuccessExample {json} Success-Response:
+     *     HTTP/1.1 200 OK
+     *     {
+     *       "message": "请求成功",
+     *       "status_code": "200"
+     *       "data":{
+     *              "total" =>"库位盘点任务总条数",
+     *              "invCount"   =>"已盘条数"
+     *           }
+     *     }
+     */
+    public function locationInvPro(AndroidGateRequest $request)
+    {
+        $taskId = $request->input("taskId");
+        $location = $request->input("location");
+        $res=app('AndroidInventoryService')->getLocInvPro($taskId,$location);
+        $this->response($res);
+    }
+
+    /**
+     * @api {post} /inventory/getInventoryDetail 根据盘点任务号,库位,条码 获取盘点明细
+     * @apiName getInventoryDetail
+     * @apiGroup inventory
+     *
+     * @apiParam {int} taskId 盘点任务号
+     * @apiParam {string} location 库位
+     * @apiParam {string} barcode 条码
+     *
+     * @apiSuccess {string} message 响应描述
+     * @apiSuccess {int} status_code HTTP响应码
+     * @apiSuccess {object} data
+     *
+     * @apiSuccessExample {json} Success-Response:
+     *     HTTP/1.1 200 OK
+     *     {
+     *       "message": "请求成功",
+     *       "status_code": "200"
+     *       "data":{
+     *              "id" =>"盘点任务明细号",
+     *              "location"   =>"库位",
+     *              "commodity_id"     =>"商品id",
+     *              "produced_at"=>"生产日期",
+     *              "valid_at"=>"失效日期",
+     *              "stored_at"=>"入库日期",
+     *              "batch_number"=>"批号",
+     *              "erp_type_position"=>"属性仓",
+     *              "quality"=>"质量状态",
+     *              "stored_amount"=>"库存数量",
+     *              "verified_amount"=>"盘点数量",
+     *           }
+     *     }
+     */
+    public function getInventoryDetail(AndroidGateRequest $request)
+    {
+        $taskId = $request->input("taskId");
+        $location = $request->input("location");
+        $barcode = $request->input("barcode");
+        $inventoryDetail=app('AndroidInventoryService')->getInventoryDetail($taskId,$location,$barcode);
+        if ($inventoryDetail) {
+            $this->response($inventoryDetail);
+        }else{
+            $this->response(null,200,'未检测到指定盘点任务');
+        }
+    }
+    /**
+     * @api {post} /inventory/stockInventory 盘点
+     * @apiName stockInventory
+     * @apiGroup inventory
+     *
+     * @apiParam {int} taskId 盘点任务号
+     * @apiParam {string} location 库位
+     * @apiParam {string} barcode 条码
+     * @apiParam {int} amount 盘点数量
+     *
+     * @apiSuccess {string} message 响应描述
+     * @apiSuccess {int} status_code HTTP响应码
+     * @apiSuccess {array} data 数据列表
+     *
+     * @apiSuccessExample {json} Success-Response:
+     *     HTTP/1.1 200 OK
+     *     {
+     *       "message": "请求成功",
+     *       "status_code": "200"
+     *       "data":[
+     *          inventoryTaskDetails=>[
+     *                  {
+     *                        "id"=>"盘点任务明细号",
+     *                        "location"=>"库位",
+     *                  }
+     *              ]
+     *          sameDayInventoryCount=>“当日盘点行数”
+     *        ]
+     *     }
+     */
+    public function stockInventory(AndroidGateRequest $request)
+    {
+        $taskId = $request->input("taskId");
+        $location = $request->input("location");
+        $barcode = $request->input("barcode");
+        $amount = $request->input("amount");
+        /** @var AndroidInventoryService $service */
+        $service=app('AndroidInventoryService');
+        $service->stockInventory($taskId,$location,$barcode,$amount);
+        $inventoryTaskDetails=$service->getUnInventoryTaskList($taskId);
+        $sameDayInventoryCount=$service->getStaffSameDayInvCount();
+        $this->response([
+            'inventoryTaskDetails' => $inventoryTaskDetails, 'sameDayInventoryCount'=>$sameDayInventoryCount
+        ]);
+    }
+
+    /**
+     * @api {post} /inventory/skipInventory 跳过盘点
+     * @apiName skipInventory
+     * @apiGroup inventory
+     *
+     * @apiParam {int} inventoryDetailId 盘点任务明细id
+     *
+     * @apiSuccess {string} message 响应描述
+     * @apiSuccess {int} status_code HTTP响应码
+     * @apiSuccess {array} data 数据列表
+     *
+     * @apiSuccessExample {json} Success-Response:
+     *     HTTP/1.1 200 OK
+     *     {
+     *       "message": "请求成功",
+     *       "status_code": "200"
+     *       "data":[
+     *          inventoryTaskDetails=>[
+     *                  {
+     *                        "id"=>"盘点任务明细号",
+     *                        "location"=>"库位",
+     *                  }
+     *              ]
+     *          sameDayInventoryCount=>“当日盘点行数”
+     *        ]
+     *     }
+     */
+    public function skipInventory(AndroidGateRequest $request)
+    {
+        $inventoryDetailId = $request->input("inventoryDetailId");
+        /** @var AndroidInventoryService $service */
+        $service=app('AndroidInventoryService');
+        $inv=$service->skipInventory($inventoryDetailId);
+        if ($inv){
+            $inventoryTaskDetails=$service->getUnInventoryTaskList($inv->inventory_account_id);
+            $sameDayInventoryCount=$service->getStaffSameDayInvCount();
+            $this->response([
+                'inventoryTaskDetails' => $inventoryTaskDetails, 'sameDayInventoryCount'=>$sameDayInventoryCount
+            ]);
+        }else{
+            $this->response(null,403,'跳过失败!');
+        }
+
     }
 }

+ 30 - 0
app/Http/Controllers/TestController.php

@@ -24,6 +24,7 @@ use App\Http\Controllers\api\thirdPart\syrius\units\StorageTypeAttribute;
 use App\Http\Requests\AndroidGateRequest;
 use App\Http\Requests\OrderDelivering;
 use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\Jobs\BatchTaskJob;
 use App\Jobs\BroadcastBatchToZhengCangJob;
 use App\Jobs\CacheShelfTaskJob;
@@ -67,9 +68,11 @@ use App\OwnerPriceOperation;
 use App\OrderPackageCountingRecord;
 use App\OwnerReport;
 use App\ProcurementCheckSheet;
+use App\ProcurementDeliverie;
 use App\ReceiveRecord;
 use App\RejectedBill;
 use App\SeeLog;
+use App\Services\AndroidInventoryService;
 use App\Services\AuthorityService;
 use App\Services\BatchService;
 use App\Services\CacheShelfService;
@@ -269,6 +272,33 @@ class TestController extends Controller
         app("BatchService")->assignTasks($batches);
     }
 
+    public function inventory()
+    {
+        $location='H05-35-04';
+        $inventoryAccountId=792;
+        $barcode='6973244250033';
+        $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',$inventoryAccountId)->toSql();
+        dd($inventoryAccountMission);
+
+    }
+
+    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);
+    }
 
 
 

+ 12 - 2
app/Http/Controllers/api/thirdPart/weixin/ProcurementController.php

@@ -17,6 +17,7 @@ use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
+use Monolog\Handler\IFTTTHandler;
 
 class ProcurementController extends Controller
 {
@@ -259,9 +260,14 @@ class ProcurementController extends Controller
             'created_at'=>Carbon::now()->toDateTimeString(),
             'signed_at'=>Carbon::now()->toDateString()]
         );
-        $procurementDelivery->procurement->update(['status'=>6]);
+        $procurementDeliveryCount=ProcurementDeliverie::query()
+            ->where('procurement_id',$procurementDelivery->procurement['id'])->sum('receipt_amount');
+        if ($procurementDeliveryCount==$procurementDelivery->procurement['quantity']){
+            $procurementDelivery->procurement->update(['status'=>6]);//待确定
+        }
         if ($procurementDelivery) return $this->success($procurementDelivery);
     }
+    //供应商确认账单
     public function supplierDeliverConfirm(Request $request): \Illuminate\Http\JsonResponse
     {
         $procurementDelivery=ProcurementDeliverie::query()
@@ -272,7 +278,11 @@ class ProcurementController extends Controller
             && $procurementDelivery->procurement->type!=2
             && $procurementCheckSheet)
         $procurementCheckSheet->update(['status'=>1,'account_payable'=>($procurementDelivery->receipt_amount*$procurementDelivery->procurement->cost_price)]);
-        $procurementDelivery->procurement->update(['status'=>7]);//待出账
+        $procurementDeliveryCount=ProcurementDeliverie::query()
+            ->where('procurement_id',$procurementDelivery->procurement['id'])->sum('receipt_amount');
+        if ($procurementDeliveryCount==$procurementDelivery->procurement['quantity']){
+            $procurementDelivery->procurement->update(['status'=>7]);//待出账
+        }
         if ($procurementDelivery) return $this->success($procurementDelivery);
     }
 }

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -202,6 +202,7 @@ use App\Services\WorkOrderExpressAbnormalService;
 use App\Services\WorkOrderMistakeService;
 use App\Services\WorkOrderDamageService;
 use App\Services\WorkOrderLossService;
+use App\Services\AndroidInventoryService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -230,6 +231,7 @@ class AppServiceProvider extends ServiceProvider
 
     private function loadingService(){
         app()->singleton('AllInventoryService',AllInventoryService::class);
+        app()->singleton('AndroidInventoryService',AndroidInventoryService::class);
         app()->singleton('AuthorityService',AuthorityService::class);
         app()->singleton('BatchService',BatchService::class);
         app()->singleton('BatchUpdateService', BatchUpdateService::class);

+ 85 - 0
app/Services/AndroidInventoryService.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Services;
+
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Sign;
+use App\Traits\ServiceAppAop;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
+
+class AndroidInventoryService
+{
+    use ServiceAppAop;
+
+    //未盘任务列表
+    public function getUnInventoryTaskList($taskId)
+    {
+        return  InventoryAccountMission::query()
+            ->select('id','location')
+            ->where('inventory_account_id', $taskId)
+            ->where('checked', '否')
+            ->get();
+    }
+    //根据员工姓名获取当日盘点行数
+    public function getStaffSameDayInvCount(): int
+    {
+         return Sign::query()
+            ->where('signable_type', 'inventory_account_missions')
+            ->where('field', '盘点人')
+            ->where('created_at', 'like', Carbon::now()->toDateString() . '%')
+            ->where('mark', Auth::user()['name'])->count();
+    }
+    public function getLocInvPro($taskId,$location): array
+    {
+        $ins=InventoryAccountMission::query()
+            ->where('inventory_account_id',$taskId)
+            ->where('location',$location)->get();
+        //库位盘点任务总条数
+        $total=$ins->count();
+        //已盘数
+        $invCount=$ins->where('checked','<>','否')->count();
+        return ['total'=>$total,'invCount'=>$invCount];
+    }
+    //根据盘点任务号,库位,条码 查询指定盘点任务
+    public function getInventoryDetail($taskId,$location,$barcode)
+    {
+        return Cache::remember($taskId.'_'.$location.'_'.$barcode, 60, function ()use($taskId,$location,$barcode) {
+            return 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();
+        });
+    }
+
+    public function stockInventory($taskId,$location,$barcode,$amount)
+    {
+        $inventoryAccountMission=$this->getInventoryDetail($taskId,$location,$barcode);
+        /** @var InventoryAccountService $service */
+        $service=app('InventoryAccountService');
+        return $service->盘点($taskId,$amount,$inventoryAccountMission);
+    }
+
+    public function skipInventory($inventoryDetailId)
+    {
+        $inventoryAccountMission=InventoryAccountMission::query()->find($inventoryDetailId);
+        if (!$inventoryAccountMission)return null;
+        $inventoryAccountMission->checked='跳过';
+        $inventoryAccountMission->update();
+        if ($inventoryAccountMission->checked=='跳过'){
+            $inventoryAccount=InventoryAccount::query()->find($inventoryAccountMission->inventory_account_id);
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
+            $inventoryAccount->update();
+        }
+        return $inventoryAccountMission;
+    }
+
+
+}

+ 1 - 25
app/Services/ForeignZhenCangService.php

@@ -13,28 +13,6 @@ class ForeignZhenCangService
 
     public function broadcastBatch($batches)
     {
-//        $body=[];
-//        $body['id']=$batches->code;
-//        $body['orders'] = [];
-//        foreach ($batches->orders as $order){
-//            $orderArr = [];
-//            $orderArr['id']=$order->code??'';
-//            $orderArr['createdAt']=Carbon::parse($order->created_at)->toDateTimeString()??'';
-//            $orderArr['barcodes'] = [];
-//            foreach ($order->orderCommodities as $orderCommodity){
-//                $barcode=[];
-//                $barcode['id']=$orderCommodity->id;
-//                $barcode['barcode']=$orderCommodity->commodity ? ($orderCommodity->commodity->barcodes?$orderCommodity->commodity->barcodes->first()['code']:'') : '';
-//                $barcode['name']=$orderCommodity->commodity->name??'';
-//                $barcode['sku']=$orderCommodity->commodity->sku??'';
-//                $barcode['amount']=$orderCommodity->amount??'';
-//                $barcode['location']=$orderCommodity->location??'';
-//                $orderArr['barcodes'][]=$barcode;
-//            }
-//            $body['orders'][] = $orderArr;
-//        }
-
-        //12.13
         $body=[];
         $body['id']=$batches->code;
         $body['slots'] = [];
@@ -61,8 +39,6 @@ class ForeignZhenCangService
         }
         $body['slots']=array_values($result);
         dd($body);
-        $response = Http::withHeaders([
-            'Host' => 'zc-it.com',
-        ])->post('http://1.116.164.201:8080/api/createBatch',$body);
+        $response = Http::post('http://zc-it.cn/api/createBatch',$body);
     }
 }

+ 61 - 20
app/Services/ObligationService.php

@@ -42,12 +42,21 @@ class ObligationService
             if ($kc){
                 $kc->update(['department_id'=>$param['kc']]);
             }else{
-                DepartmentObligationOwner::query()
-                    ->orderByDesc('id')
+                $kcHis=DepartmentObligationOwner::query()
                     ->where('obligation_id',$obligation['kc'])
                     ->where('owner_id',$param['id'])
-                    ->update(['failure_time'=>$time]);
-                DepartmentObligationOwner::query()->insert(['department_id'=>$param['kc'],'obligation_id'=>$obligation['kc'],'obligation_code'=>'kc','owner_id'=>$param['id'],'valid_time'=>$time]);
+                    ->where('department_id',$param['kc'])
+                    ->whereNull('failure_time')
+                    ->first();
+                if (!$kcHis){
+                    DepartmentObligationOwner::query()
+                        ->orderByDesc('id')
+                        ->where('obligation_id',$obligation['kc'])
+                        ->where('owner_id',$param['id'])
+                        ->update(['failure_time'=>$time]);
+                    DepartmentObligationOwner::query()->insert(['department_id'=>$param['kc'],'obligation_id'=>$obligation['kc'],'obligation_code'=>'kc','owner_id'=>$param['id'],'valid_time'=>$time]);
+                }
+
             }
             $jg=DepartmentObligationOwner::query()
                 ->where('obligation_id',$obligation['jg'])
@@ -56,12 +65,20 @@ class ObligationService
             if ($jg){
                 $jg->update(['department_id'=>$param['jg']]);
             }else{
-                DepartmentObligationOwner::query()
-                    ->orderByDesc('id')
+                $jgHis=DepartmentObligationOwner::query()
                     ->where('obligation_id',$obligation['jg'])
                     ->where('owner_id',$param['id'])
-                    ->update(['failure_time'=>$time]);
-                DepartmentObligationOwner::query()->insert(['department_id'=>$param['jg'],'obligation_id'=>$obligation['jg'],'obligation_code'=>'jg','owner_id'=>$param['id'],'valid_time'=>$time]);
+                    ->where('department_id',$param['jg'])
+                    ->whereNull('failure_time')
+                    ->first();
+                if (!$jgHis){
+                    DepartmentObligationOwner::query()
+                        ->orderByDesc('id')
+                        ->where('obligation_id',$obligation['jg'])
+                        ->where('owner_id',$param['id'])
+                        ->update(['failure_time'=>$time]);
+                    DepartmentObligationOwner::query()->insert(['department_id'=>$param['jg'],'obligation_id'=>$obligation['jg'],'obligation_code'=>'jg','owner_id'=>$param['id'],'valid_time'=>$time]);
+                }
             }
 
             $th=DepartmentObligationOwner::query()
@@ -71,12 +88,20 @@ class ObligationService
             if ($th){
                 $th->update(['department_id'=>$param['th']]);
             }else{
-                DepartmentObligationOwner::query()
-                    ->orderByDesc('id')
+                $thHis=DepartmentObligationOwner::query()
                     ->where('obligation_id',$obligation['th'])
                     ->where('owner_id',$param['id'])
-                    ->update(['failure_time'=>$time]);
-                DepartmentObligationOwner::query()->insert(['department_id'=>$param['th'],'obligation_id'=>$obligation['th'],'obligation_code'=>'th','owner_id'=>$param['id'],'valid_time'=>$time]);
+                    ->where('department_id',$param['th'])
+                    ->whereNull('failure_time')
+                    ->first();
+                if (!$thHis){
+                    DepartmentObligationOwner::query()
+                        ->orderByDesc('id')
+                        ->where('obligation_id',$obligation['th'])
+                        ->where('owner_id',$param['id'])
+                        ->update(['failure_time'=>$time]);
+                    DepartmentObligationOwner::query()->insert(['department_id'=>$param['th'],'obligation_id'=>$obligation['th'],'obligation_code'=>'th','owner_id'=>$param['id'],'valid_time'=>$time]);
+                }
             }
 
             $sh=DepartmentObligationOwner::query()
@@ -86,12 +111,20 @@ class ObligationService
             if ($sh){
                 $sh->update(['department_id'=>$param['sh']]);
             }else{
-                DepartmentObligationOwner::query()
-                    ->orderByDesc('id')
+                $shHis=DepartmentObligationOwner::query()
                     ->where('obligation_id',$obligation['sh'])
                     ->where('owner_id',$param['id'])
-                    ->update(['failure_time'=>$time]);
-                DepartmentObligationOwner::query()->insert(['department_id'=>$param['sh'],'obligation_id'=>$obligation['sh'],'obligation_code'=>'sh','owner_id'=>$param['id'],'valid_time'=>$time]);
+                    ->where('department_id',$param['sh'])
+                    ->whereNull('failure_time')
+                    ->first();
+                if (!$shHis){
+                    DepartmentObligationOwner::query()
+                        ->orderByDesc('id')
+                        ->where('obligation_id',$obligation['sh'])
+                        ->where('owner_id',$param['id'])
+                        ->update(['failure_time'=>$time]);
+                    DepartmentObligationOwner::query()->insert(['department_id'=>$param['sh'],'obligation_id'=>$obligation['sh'],'obligation_code'=>'sh','owner_id'=>$param['id'],'valid_time'=>$time]);
+                }
             }
 
             $fh=DepartmentObligationOwner::query()
@@ -101,12 +134,20 @@ class ObligationService
             if ($fh){
                 $fh->update(['department_id'=>$param['fh']]);
             }else{
-                DepartmentObligationOwner::query()
-                    ->orderByDesc('id')
+                $fhHis=DepartmentObligationOwner::query()
                     ->where('obligation_id',$obligation['fh'])
                     ->where('owner_id',$param['id'])
-                    ->update(['failure_time'=>$time]);
-                DepartmentObligationOwner::query()->insert(['department_id'=>$param['fh'],'obligation_id'=>$obligation['fh'],'obligation_code'=>'fh','owner_id'=>$param['id'],'valid_time'=>$time]);
+                    ->where('department_id',$param['fh'])
+                    ->whereNull('failure_time')
+                    ->first();
+                if (!$fhHis){
+                    DepartmentObligationOwner::query()
+                        ->orderByDesc('id')
+                        ->where('obligation_id',$obligation['fh'])
+                        ->where('owner_id',$param['id'])
+                        ->update(['failure_time'=>$time]);
+                    DepartmentObligationOwner::query()->insert(['department_id'=>$param['fh'],'obligation_id'=>$obligation['fh'],'obligation_code'=>'fh','owner_id'=>$param['id'],'valid_time'=>$time]);
+                }
             }
         }
         return Owner::query()->with('departmentObligationOwner')->find($param['id']);

+ 1 - 0
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -268,6 +268,7 @@
                     let error = {};
                     if (!this.info.sku)error.sku = ["条码必填"];
                     if (!this.info.amount)error.amount = ["实收数量必填"];
+                    if (this.info.amount==0)error.amount = ["实收数量不可为零"];
                     if (!this.info.trackNumber)error.trackNumber = ["容器号必填"];
                     if (this.info.amount && ((Number(this.info.amount)+Number(this.info.receivedqty))>Number(this.info.expectedqty)))error.amount = ["总数不能超过预期数"];
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey01==='Y' && !this.info.lotatt01) error.lotatt01=["生产日期为选"];

+ 5 - 1
routes/api.php

@@ -33,7 +33,11 @@ Route::prefix("v1")->group(function (){
                 Route::GET('batchRecover', 'OrderController@recoverBatch');
             });
             Route::prefix("inventory")->group(function () {
-                Route::GET('inventoryTasks', 'OrderController@getInventoryTasks');
+                Route::POST('inventoryTask', 'InventoryController@getInventoryTask');
+                Route::POST('locationInvPro', 'InventoryController@locationInvPro');
+                Route::POST('getInventoryDetail', 'InventoryController@getInventoryDetail');
+                Route::POST('stockInventory', 'InventoryController@stockInventory');
+                Route::POST('skipInventory', 'InventoryController@skipInventory');
             });
         });
 });