|
|
@@ -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,'跳过失败!');
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|