ProductBatch.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\validate\EditProduct;
  5. use app\validate\Id;
  6. use app\validate\Page;
  7. use app\service\ProductBatchService;
  8. use think\db\exception\DataNotFoundException;
  9. use think\db\exception\DbException;
  10. use think\db\exception\ModelNotFoundException;
  11. use think\exception\ValidateException;
  12. use think\response\Json;
  13. use think\annotation\Route;
  14. use think\annotation\route\Middleware;
  15. use hg\apidoc\annotation as Apidoc;
  16. /**
  17. * @Apidoc\Title("建档出证")
  18. * @Apidoc\Group("产品建档出征")
  19. * @Apidoc\Sort (17)
  20. */
  21. class ProductBatch extends BaseController
  22. {
  23. protected $middleware = [
  24. 'jwt',
  25. ];
  26. use ResponseJson;
  27. /**
  28. * @Apidoc\Title("建档出证列表信息")
  29. * @Apidoc\Tag("列表信息")
  30. * @Apidoc\Method ("GET")
  31. * @Apidoc\Author ("yang")
  32. * @Route("getProductBatchList",method="GET")
  33. * @Middleware({"jwt"})
  34. */
  35. public function getProductBatchList(): Json
  36. {
  37. $page = $this->request->get();
  38. try {
  39. validate(Page::class)->check($page);
  40. }catch (ValidateException $e){
  41. return $this->JsonError($e->getError());
  42. }
  43. return $this->JsonSucess(ProductBatchService::getProductBatchList($page,getQydm()));
  44. }
  45. /**
  46. * @Apidoc\Title("获取所有批次信息")
  47. * @Apidoc\Tag("列表信息")
  48. * @Apidoc\Method ("GET")
  49. * @Apidoc\Author ("yang")
  50. * @Route("getProductBatchAllInfo",method="GET")
  51. * @Middleware({"jwt"})
  52. */
  53. public function getProductBatchAllInfo(): Json
  54. {
  55. $page = $this->request->get();
  56. try {
  57. return $this->JsonSucess(ProductBatchService::getProductBatchAll(getQydm()));
  58. }catch (ValidateException $e){
  59. return $this->JsonError($e->getError());
  60. }
  61. }
  62. /**
  63. * @Apidoc\Title("建档出证列表信息")
  64. * @Apidoc\Tag("列表信息")
  65. * @Apidoc\Method ("GET")
  66. * @Apidoc\Author ("yang")
  67. * @Route("selectProductBatchList",method="GET")
  68. * @Middleware({"jwt"})
  69. */
  70. public function selectProductBatchList(): Json
  71. {
  72. $page = $this->request->get();
  73. try {
  74. validate(Page::class)->check($page);
  75. }catch (ValidateException $e){
  76. return $this->JsonError($e->getError());
  77. }
  78. return $this->JsonSucess(ProductBatchService::getProductList($page,getQydm()));
  79. }
  80. /**
  81. * @Apidoc\Title("建档出证企业基础信息获取")
  82. * @Apidoc\Tag("基础信息")
  83. * @Apidoc\Method ("GET")
  84. * @Apidoc\Author ("yang")
  85. * @Route("getEnterprisesBaseInfo",method="GET")
  86. * @Middleware({"jwt"})
  87. */
  88. public function getEnterprisesBaseInfo(): Json
  89. {
  90. $result = ProductBatchService::findEnterprisesBaseInfo(getQydm());
  91. return $this->JsonSucess($result);
  92. }
  93. /**
  94. * @Apidoc\Title("建档出证产品信息获取")
  95. * @Apidoc\Tag("基础信息")
  96. * @Apidoc\Method ("GET")
  97. * @Apidoc\Author ("yang")
  98. * @Route("getProductBaseInfo",method="GET")
  99. * @Middleware({"jwt"})
  100. */
  101. public function getProductBaseInfo(): Json
  102. {
  103. $result = ProductBatchService::selectProductBaseInfo(getQydm());
  104. return $this->JsonSucess($result);
  105. }
  106. /**
  107. * @Apidoc\Title("建档出证产品产地信息获取")
  108. * @Apidoc\Tag("基础信息")
  109. * @Apidoc\Method ("GET")
  110. * @Apidoc\Author ("yang")
  111. * @Route("getChandiBaseInfo",method="GET")
  112. * @Middleware({"jwt"})
  113. */
  114. public function getchandiBaseInfo(): Json
  115. {
  116. $result = ProductBatchService::selectChandiBaseInfo(getQydm());
  117. return $this->JsonSucess($result);
  118. }
  119. /**
  120. * @Apidoc\Title("添加产品批次信息")
  121. * @Apidoc\Tag("产品批次")
  122. * @Apidoc\Method ("POST")
  123. * @Apidoc\Author ("yang")
  124. * @Route("addProductBatch",method="POST")
  125. * @Middleware({"jwt"})
  126. */
  127. public function addProductBatch(): Json
  128. {
  129. $info = $this->request->post();
  130. try {
  131. validate(\app\validate\ProductBatch::class)->check($info);
  132. } catch (ValidateException $e) {
  133. $this->JsonError($e->getError());
  134. }
  135. $info['batch_id'] = date('mdhis', time());
  136. $info['creation_time'] = date('Y-m-d h:i:s', time());
  137. return $this->JsonSucess(ProductBatchService::addProductBatch($info));
  138. }
  139. /**
  140. * @Apidoc\Title("产品批次信息ByID")
  141. * @Apidoc\Tag("产品批次信息")
  142. * @Apidoc\Method ("GET")
  143. * @Apidoc\Author ("yang")
  144. * @Route("getProductBatchInfo",method="GET")
  145. * @Middleware({"jwt"})
  146. */
  147. public function getProductBatchInfo(): Json
  148. {
  149. $id = $this->request->get();
  150. try {
  151. validate(Id::class)->check($id);
  152. }catch (ValidateException $e){
  153. return $this->JsonError($e->getError());
  154. }
  155. return $this->JsonSucess(ProductBatchService::getProductBatchInfoById($id["id"]));
  156. }
  157. /**
  158. * @Apidoc\Title("更新产品批次信息")
  159. * @Apidoc\Tag("产品批次信息")
  160. * @Apidoc\Method ("POST")
  161. * @Apidoc\Author ("yang")
  162. * @Route("editProductBatch",method="POST")
  163. * @Middleware({"jwt"})
  164. */
  165. public function editProductBatch(): Json
  166. {
  167. $info = $this->request->post();
  168. try {
  169. validate(\app\validate\ProductBatch::class)->check($info);
  170. } catch (ValidateException $e) {
  171. $this->JsonError($e->getError());
  172. }
  173. return $this->JsonSucess(ProductBatchService::editProductBatch($info,$info["id"]));
  174. }
  175. /**
  176. * @Apidoc\Author("ihavoc")
  177. * @throws ModelNotFoundException
  178. * @throws DataNotFoundException
  179. * @throws DbException
  180. * @Apidoc\Title("根据产品id获取批次号信息")
  181. * @Apidoc\Tag("批次号")
  182. * @Apidoc\Method ("POST")
  183. * @Route("/getPchByProductId",method="POST")
  184. * @Middleware({"jwt"})
  185. */
  186. public function getPchByProductId(){
  187. $id = $this->request->get();
  188. try {
  189. validate(Id::class)->check($id);
  190. }catch (ValidateException $e){
  191. return $this->JsonError($e->getError());
  192. }
  193. return $this->JsonSucess(ProductBatchService::getPchByProId($id["id"]));
  194. }
  195. }