InventoryController.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. * "verified_amount" =>"已盘数量",
  112. * "produced_at"=>"生产日期",
  113. * "valid_at"=>"失效日期",
  114. * "batch_number"=>"批号",
  115. * "erp_type_position"=>"属性仓",
  116. * "quality"=>"质量状态",
  117. * }
  118. * }
  119. */
  120. public function getInventoryDetail(Request $request)
  121. {
  122. $taskId = $request->input("taskId");
  123. $location = $request->input("location");
  124. $barcode = $request->input("barcode");
  125. $inventoryDetail=app('AndroidInventoryService')->getInventoryDetail($taskId,$location,$barcode);
  126. if ($inventoryDetail) {
  127. $this->response($inventoryDetail);
  128. }else{
  129. $this->response(null,403,'未检测到指定盘点任务');
  130. }
  131. }
  132. /**
  133. * @api {post} /inventory/stockInventory 盘点
  134. * @apiName stockInventory
  135. * @apiGroup inventory
  136. *
  137. * @apiParam {int} taskId 盘点任务号
  138. * @apiParam {string} location 库位
  139. * @apiParam {string} barcode 条码
  140. * @apiParam {int} amount 盘点数量
  141. *
  142. * @apiSuccess {string} message 响应描述
  143. * @apiSuccess {int} status_code HTTP响应码
  144. * @apiSuccess {array} data 数据列表
  145. *
  146. * @apiSuccessExample {json} Success-Response:
  147. * HTTP/1.1 200 OK
  148. * {
  149. * "message": "请求成功",
  150. * "status_code": "200"
  151. * "data":[
  152. * "notStocktakingList"=>[
  153. * {
  154. * "id"=>"盘点任务明细号",
  155. * "location"=>"库位",
  156. * }
  157. * ]
  158. * ]
  159. * }
  160. */
  161. public function stockInventory(Request $request)
  162. {
  163. $taskId = $request->input("taskId");
  164. $location = $request->input("location");
  165. $barcode = $request->input("barcode");
  166. $amount = $request->input("amount");
  167. /** @var AndroidInventoryService $service */
  168. $service=app('AndroidInventoryService');
  169. $service->stockInventory($taskId,$location,$barcode,$amount);
  170. $notStocktakingList=$service->getUnInventoryTaskList($taskId);
  171. $this->response([
  172. "notStocktakingList" => $notStocktakingList,
  173. ]);
  174. }
  175. /**
  176. * @api {post} /inventory/skipInventory 跳过盘点
  177. * @apiName skipInventory
  178. * @apiGroup inventory
  179. *
  180. * @apiParam {int} inventoryDetailId 盘点任务明细id
  181. *
  182. * @apiSuccess {string} message 响应描述
  183. * @apiSuccess {int} status_code HTTP响应码
  184. * @apiSuccess {array} data 数据列表
  185. *
  186. * @apiSuccessExample {json} Success-Response:
  187. * HTTP/1.1 200 OK
  188. * {
  189. * "message": "请求成功",
  190. * "status_code": "200"
  191. * "data":[
  192. * inventoryTaskDetails=>[
  193. * {
  194. * "id"=>"盘点任务明细号",
  195. * "location"=>"库位",
  196. * }
  197. * ]
  198. * sameDayInventoryCount=>“当日盘点行数”
  199. * ]
  200. * }
  201. */
  202. public function skipInventory(Request $request)
  203. {
  204. $inventoryDetailId = $request->input("inventoryDetailId");
  205. /** @var AndroidInventoryService $service */
  206. $service=app('AndroidInventoryService');
  207. $inv=$service->skipInventory($inventoryDetailId);
  208. if ($inv){
  209. $inventoryTaskDetails=$service->getUnInventoryTaskList($inv->inventory_account_id);
  210. $sameDayInventoryCount=$service->getStaffSameDayInvCount();
  211. $this->response([
  212. 'inventoryTaskDetails' => $inventoryTaskDetails, 'sameDayInventoryCount'=>$sameDayInventoryCount
  213. ]);
  214. }else{
  215. $this->response(null,403,'跳过失败!');
  216. }
  217. }
  218. }