InventoryController.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. namespace App\Http\ApiControllers;
  3. use App\Components\ApiResponse;
  4. use App\InventoryAccount;
  5. use App\Services\AndroidInventoryService;
  6. use Illuminate\Http\Request;
  7. class InventoryController
  8. {
  9. use ApiResponse;
  10. /**
  11. * @api {get} /inventory/inventoryTask 获取盘点任务数据
  12. * @apiName inventoryTasks
  13. * @apiGroup inventory
  14. *
  15. * @apiParam {int} taskId 盘点任务号
  16. *
  17. * @apiSuccess {string} message 响应描述
  18. * @apiSuccess {int} status_code HTTP响应码
  19. * @apiSuccess {array} data 数据列表
  20. * @apiSuccess {int} data.sameDayInventoryCount 员工当日盘点数
  21. * @apiSuccess {int} data.stocktakingTask 当前盘点任务信息
  22. * @apiSuccess {int} data.notStocktakingList 未盘任务列表
  23. *
  24. * @apiSuccessExample {json} Success-Response:
  25. * HTTP/1.1 200 OK
  26. * {
  27. * "message": "请求成功",
  28. * "status_code": "200"
  29. * "data":[
  30. * "sameDayInventoryCount" => 0,
  31. * "inventoryTask" => {
  32. * "id" =>"盘点任务号",
  33. * "created_at" =>"任务创建时间",
  34. * "end_at" =>"库位最后操作时间",
  35. * "type"=>"任务类型",
  36. * "total"=>"盘点任务数",
  37. * "processed"=>"盘点数",
  38. * },
  39. * "notStocktakingList"=> [
  40. * {
  41. * "location" =>"库位",
  42. * "count" =>"未盘商品数",
  43. * }
  44. * ]
  45. * ]
  46. * }
  47. */
  48. public function getInventoryTask(Request $request)
  49. {
  50. $taskId = $request->input("taskId");
  51. /** @var AndroidInventoryService $service */
  52. $service=app('AndroidInventoryService');
  53. $stocktakingTask = InventoryAccount::query()->find($taskId);
  54. $notStocktakingList=$service->getUnInventoryTaskList($taskId);
  55. $sameDayInventoryCount=$service->getStaffSameDayInvCount();
  56. $this->response(['stocktakingTask' => $stocktakingTask,
  57. 'notStocktakingList' => $notStocktakingList,
  58. 'sameDayInventoryCount'=>$sameDayInventoryCount
  59. ]);
  60. }
  61. /**
  62. * @api {post} /inventory/locationInvPro 当前库位下盘点比例
  63. * @apiName locationInvPro
  64. * @apiGroup inventory
  65. *
  66. * @apiParam {int} taskId 盘点任务号
  67. * @apiParam {string} location 库位
  68. *
  69. * @apiSuccess {string} message 响应描述
  70. * @apiSuccess {int} status_code HTTP响应码
  71. * @apiSuccess {object} data
  72. *
  73. * @apiSuccessExample {json} Success-Response:
  74. * HTTP/1.1 200 OK
  75. * {
  76. * "message": "请求成功",
  77. * "status_code": "200"
  78. * "data":{
  79. * "total" =>"库位盘点任务总条数",
  80. * "invCount" =>"已盘条数"
  81. * }
  82. * }
  83. */
  84. public function locationInvPro(Request $request)
  85. {
  86. $taskId = $request->input("taskId");
  87. $location = $request->input("location");
  88. $res=app('AndroidInventoryService')->getLocInvPro($taskId,$location);
  89. $this->response($res);
  90. }
  91. /**
  92. * @api {post} /inventory/getInventoryDetail 根据盘点任务号,库位,条码 获取盘点明细
  93. * @apiName getInventoryDetail
  94. * @apiGroup inventory
  95. *
  96. * @apiParam {int} taskId 盘点任务号
  97. * @apiParam {string} location 库位
  98. * @apiParam {string} barcode 条码
  99. *
  100. * @apiSuccess {string} message 响应描述
  101. * @apiSuccess {int} status_code HTTP响应码
  102. * @apiSuccess {object} data
  103. *
  104. * @apiSuccessExample {json} Success-Response:
  105. * HTTP/1.1 200 OK
  106. * {
  107. * "message": "请求成功",
  108. * "status_code": "200"
  109. * "data":{
  110. * "id" =>"盘点任务明细号",
  111. * "location" =>"库位",
  112. * "produced_at"=>"生产日期",
  113. * "valid_at"=>"失效日期",
  114. * "stored_at"=>"入库日期",
  115. * "batch_number"=>"批号",
  116. * "erp_type_position"=>"属性仓",
  117. * "quality"=>"质量状态",
  118. * }
  119. * }
  120. */
  121. public function getInventoryDetail(Request $request)
  122. {
  123. $taskId = $request->input("taskId");
  124. $location = $request->input("location");
  125. $barcode = $request->input("barcode");
  126. $inventoryDetail=app('AndroidInventoryService')->getInventoryDetail($taskId,$location,$barcode);
  127. if ($inventoryDetail) {
  128. $this->response($inventoryDetail);
  129. }else{
  130. $this->response(null,403,'未检测到指定盘点任务');
  131. }
  132. }
  133. /**
  134. * @api {post} /inventory/stockInventory 盘点
  135. * @apiName stockInventory
  136. * @apiGroup inventory
  137. *
  138. * @apiParam {int} taskId 盘点任务号
  139. * @apiParam {string} location 库位
  140. * @apiParam {string} barcode 条码
  141. * @apiParam {int} amount 盘点数量
  142. *
  143. * @apiSuccess {string} message 响应描述
  144. * @apiSuccess {int} status_code HTTP响应码
  145. * @apiSuccess {array} data 数据列表
  146. *
  147. * @apiSuccessExample {json} Success-Response:
  148. * HTTP/1.1 200 OK
  149. * {
  150. * "message": "请求成功",
  151. * "status_code": "200"
  152. * "data":[
  153. * "notStocktakingList"=>[
  154. * {
  155. * "id"=>"盘点任务明细号",
  156. * "location"=>"库位",
  157. * }
  158. * ]
  159. * ]
  160. * }
  161. */
  162. public function stockInventory(Request $request)
  163. {
  164. $taskId = $request->input("taskId");
  165. $location = $request->input("location");
  166. $barcode = $request->input("barcode");
  167. $amount = $request->input("amount");
  168. /** @var AndroidInventoryService $service */
  169. $service=app('AndroidInventoryService');
  170. $service->stockInventory($taskId,$location,$barcode,$amount);
  171. $notStocktakingList=$service->getUnInventoryTaskList($taskId);
  172. $this->response([
  173. "notStocktakingList" => $notStocktakingList,
  174. ]);
  175. }
  176. /**
  177. * @api {post} /inventory/skipInventory 跳过盘点
  178. * @apiName skipInventory
  179. * @apiGroup inventory
  180. *
  181. * @apiParam {int} inventoryDetailId 盘点任务明细id
  182. *
  183. * @apiSuccess {string} message 响应描述
  184. * @apiSuccess {int} status_code HTTP响应码
  185. * @apiSuccess {array} data 数据列表
  186. *
  187. * @apiSuccessExample {json} Success-Response:
  188. * HTTP/1.1 200 OK
  189. * {
  190. * "message": "请求成功",
  191. * "status_code": "200"
  192. * "data":[
  193. * inventoryTaskDetails=>[
  194. * {
  195. * "id"=>"盘点任务明细号",
  196. * "location"=>"库位",
  197. * }
  198. * ]
  199. * sameDayInventoryCount=>“当日盘点行数”
  200. * ]
  201. * }
  202. */
  203. public function skipInventory(Request $request)
  204. {
  205. $inventoryDetailId = $request->input("inventoryDetailId");
  206. /** @var AndroidInventoryService $service */
  207. $service=app('AndroidInventoryService');
  208. $inv=$service->skipInventory($inventoryDetailId);
  209. if ($inv){
  210. $inventoryTaskDetails=$service->getUnInventoryTaskList($inv->inventory_account_id);
  211. $sameDayInventoryCount=$service->getStaffSameDayInvCount();
  212. $this->response([
  213. 'inventoryTaskDetails' => $inventoryTaskDetails, 'sameDayInventoryCount'=>$sameDayInventoryCount
  214. ]);
  215. }else{
  216. $this->response(null,403,'跳过失败!');
  217. }
  218. }
  219. }