|
|
@@ -6,7 +6,9 @@ namespace App\Http\ApiControllers;
|
|
|
|
|
|
use App\Components\ApiResponse;
|
|
|
use App\InventoryAccount;
|
|
|
+use App\InventoryAccountMission;
|
|
|
use App\Services\AndroidInventoryService;
|
|
|
+use App\Services\InventoryAccountService;
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
class InventoryController
|
|
|
@@ -56,7 +58,12 @@ class InventoryController
|
|
|
$taskId = $request->input("taskId");
|
|
|
/** @var AndroidInventoryService $service */
|
|
|
$service=app('AndroidInventoryService');
|
|
|
- $stocktakingTask = InventoryAccount::query()->find($taskId);
|
|
|
+ if (!$taskId) $this->response(null,410,"未获取到任务号");
|
|
|
+ $stocktakingTask = InventoryAccount::query()
|
|
|
+ ->whereIn('status',['待盘点','盘点中','复盘中'])
|
|
|
+ ->where('id',$taskId)
|
|
|
+ ->first();
|
|
|
+ if (!$stocktakingTask) $this->response(null,410,"未查询到盘点任务");
|
|
|
$notStocktakingList=$service->getUnInventoryTaskList($taskId);
|
|
|
$sameDayInventoryCount=$service->getStaffSameDayInvCount();
|
|
|
$this->response(['stocktakingTask' => $stocktakingTask,
|
|
|
@@ -135,7 +142,7 @@ class InventoryController
|
|
|
if ($inventoryDetail) {
|
|
|
$this->response($inventoryDetail);
|
|
|
}else{
|
|
|
- $this->response(null,403,'未检测到指定盘点任务');
|
|
|
+ $this->response(null,410,'未检测到指定盘点任务');
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
@@ -169,14 +176,26 @@ class InventoryController
|
|
|
*/
|
|
|
public function stockInventory(Request $request)
|
|
|
{
|
|
|
- $taskId = $request->input("taskId");
|
|
|
- $location = $request->input("location");
|
|
|
- $barcode = $request->input("barcode");
|
|
|
- $amount = $request->input("amount");
|
|
|
- /** @var AndroidInventoryService $service */
|
|
|
+ $task_item_id = $request->input("task_item_id");
|
|
|
+ $verified_amount = $request->input("verified_amount");
|
|
|
+ /**
|
|
|
+ * @var AndroidInventoryService $service
|
|
|
+ *@var InventoryAccountService $stockService
|
|
|
+ */
|
|
|
$service=app('AndroidInventoryService');
|
|
|
- $service->stockInventory($taskId,$location,$barcode,$amount);
|
|
|
- $notStocktakingList=$service->getUnInventoryTaskList($taskId);
|
|
|
+ $stockService=app('InventoryAccountService');
|
|
|
+ $inventoryAccountMission=InventoryAccountMission::query()->find($task_item_id);
|
|
|
+ if (!$inventoryAccountMission)$this->response(null,410,'未查询到盘点明细');
|
|
|
+ $task_id=$inventoryAccountMission->inventory_account_id;
|
|
|
+ if (!$request->has('produced_at')&&!$request->has('valid_at')&&!$request->has('batch_number')){
|
|
|
+ $stockService->盘点($task_id,$verified_amount,$inventoryAccountMission);
|
|
|
+ }else{
|
|
|
+ $stockService->盘点生产日期_失效日期_批号有改动任务($task_item_id, $verified_amount, $task_id,
|
|
|
+ $request->input('produced_at')??'', $request->input('valid_at')??'',
|
|
|
+ $request->input('batch_number')??'');
|
|
|
+ $stockService->updateInventory($task_id);
|
|
|
+ }
|
|
|
+ $notStocktakingList=$service->getUnInventoryTaskList($task_id);
|
|
|
$this->response([
|
|
|
"notStocktakingList" => $notStocktakingList,
|
|
|
]);
|
|
|
@@ -222,7 +241,7 @@ class InventoryController
|
|
|
'inventoryTaskDetails' => $inventoryTaskDetails, 'sameDayInventoryCount'=>$sameDayInventoryCount
|
|
|
]);
|
|
|
}else{
|
|
|
- $this->response(null,403,'跳过失败!');
|
|
|
+ $this->response(null,410,'跳过失败!');
|
|
|
}
|
|
|
|
|
|
}
|