| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?php
- namespace App\Http\ApiControllers;
- use App\Components\ApiResponse;
- use App\InventoryAccount;
- use App\Services\AndroidInventoryService;
- use Illuminate\Http\Request;
- class InventoryController
- {
- use ApiResponse;
- /**
- * @api {get} /inventory/inventoryTask 获取盘点任务数据
- * @apiName inventoryTasks
- * @apiGroup inventory
- *
- * @apiParam {int} taskId 盘点任务号
- *
- * @apiSuccess {string} message 响应描述
- * @apiSuccess {int} status_code HTTP响应码
- * @apiSuccess {array} data 数据列表
- * @apiSuccess {int} data.sameDayInventoryCount 员工当日盘点数
- * @apiSuccess {int} data.stocktakingTask 当前盘点任务信息
- * @apiSuccess {int} data.notStocktakingList 未盘任务列表
- *
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- * {
- * "message": "请求成功",
- * "status_code": "200"
- * "data":[
- * "sameDayInventoryCount" => 0,
- * "inventoryTask" => {
- * "id" =>"盘点任务号",
- * "created_at" =>"任务创建时间",
- * "end_at" =>"库位最后操作时间",
- * "type"=>"任务类型",
- * "total"=>"盘点任务数",
- * "processed"=>"盘点数",
- * },
- * "notStocktakingList"=> [
- * {
- * "location" =>"库位",
- * "count" =>"未盘商品数",
- * }
- * ]
- * ]
- * }
- */
- public function getInventoryTask(Request $request)
- {
- $taskId = $request->input("taskId");
- /** @var AndroidInventoryService $service */
- $service=app('AndroidInventoryService');
- $stocktakingTask = InventoryAccount::query()->find($taskId);
- $notStocktakingList=$service->getUnInventoryTaskList($taskId);
- $sameDayInventoryCount=$service->getStaffSameDayInvCount();
- $this->response(['stocktakingTask' => $stocktakingTask,
- 'notStocktakingList' => $notStocktakingList,
- '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(Request $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" =>"盘点任务明细号",
- * "verified_amount" =>"已盘数量",
- * "produced_at"=>"生产日期",
- * "valid_at"=>"失效日期",
- * "batch_number"=>"批号",
- * "erp_type_position"=>"属性仓",
- * "quality"=>"质量状态",
- * }
- * }
- */
- public function getInventoryDetail(Request $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,403,'未检测到指定盘点任务');
- }
- }
- /**
- * @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":[
- * "notStocktakingList"=>[
- * {
- * "id"=>"盘点任务明细号",
- * "location"=>"库位",
- * }
- * ]
- * ]
- * }
- */
- public function stockInventory(Request $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);
- $notStocktakingList=$service->getUnInventoryTaskList($taskId);
- $this->response([
- "notStocktakingList" => $notStocktakingList,
- ]);
- }
- /**
- * @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(Request $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,'跳过失败!');
- }
- }
- }
|