| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?php
- 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;
- use Illuminate\Support\Facades\Log;
- use phpDocumentor\Reflection\Types\Object_;
- 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');
- 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,
- '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);
- if ($res===0){
- $this->response(null,410,"库位不存在!");
- }else{
- $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,410,'未检测到指定盘点任务');
- }
- }
- /**
- * @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 数据列表
- * @apiSuccess {bool} isDiff 是否差异
- *
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- * {
- * "message": "请求成功",
- * "status_code": "200"
- * "data":[
- * “isDiff”=>“是否差异",
- * "notStocktakingList"=>[
- * {
- * "location"=>"库位",
- * "count"=>"待盘数量",
- * }
- * ]
- * ]
- * }
- */
- public function stockInventory(Request $request)
- {
- $task_item_id = $request->input("task_item_id");
- $verified_amount = $request->input("verified_amount");
- /**
- * @var AndroidInventoryService $service
- *@var InventoryAccountService $stockService
- */
- $service=app('AndroidInventoryService');
- $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')){
- $stockDetail=$stockService->盘点($task_id,$verified_amount,$inventoryAccountMission);
- }else{
- $stockDetail=$stockService->盘点生产日期_失效日期_批号有改动任务($task_item_id, $verified_amount, $task_id,
- $request->input('produced_at')??'', $request->input('valid_at')??'',
- $request->input('batch_number')??'');
- $stockService->updateInventory($task_id);
- }
- if ($stockDetail->difference_amount==0){
- $isDiff=false;
- }else{
- $isDiff=true;
- }
- $notStocktakingList=$service->getUnInventoryTaskList($task_id);
- $this->response(['isDiff'=>$isDiff,'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,410,'跳过失败!');
- }
- }
- }
|