InventoryController.php 7.8 KB

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