123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- namespace app\controller;
- use app\BaseController;
- use app\validate\EditProduct;
- use app\validate\Id;
- use app\validate\Page;
- use app\service\ProductBatchService;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\exception\ValidateException;
- use think\response\Json;
- use think\annotation\Route;
- use think\annotation\route\Middleware;
- use hg\apidoc\annotation as Apidoc;
- /**
- * @Apidoc\Title("建档出证")
- * @Apidoc\Group("产品建档出征")
- * @Apidoc\Sort (17)
- */
- class ProductBatch extends BaseController
- {
- protected $middleware = [
- 'jwt',
- ];
- use ResponseJson;
- /**
- * @Apidoc\Title("建档出证列表信息")
- * @Apidoc\Tag("列表信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getProductBatchList",method="GET")
- * @Middleware({"jwt"})
- */
- public function getProductBatchList(): Json
- {
- $page = $this->request->get();
- try {
- validate(Page::class)->check($page);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(ProductBatchService::getProductBatchList($page,getQydm()));
- }
- /**
- * @Apidoc\Title("获取所有批次信息")
- * @Apidoc\Tag("列表信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getProductBatchAllInfo",method="GET")
- * @Middleware({"jwt"})
- */
- public function getProductBatchAllInfo(): Json
- {
- $page = $this->request->get();
- try {
- return $this->JsonSucess(ProductBatchService::getProductBatchAll(getQydm()));
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- }
- /**
- * @Apidoc\Title("建档出证列表信息")
- * @Apidoc\Tag("列表信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("selectProductBatchList",method="GET")
- * @Middleware({"jwt"})
- */
- public function selectProductBatchList(): Json
- {
- $page = $this->request->get();
- try {
- validate(Page::class)->check($page);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(ProductBatchService::getProductList($page,getQydm()));
- }
- /**
- * @Apidoc\Title("建档出证企业基础信息获取")
- * @Apidoc\Tag("基础信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getEnterprisesBaseInfo",method="GET")
- * @Middleware({"jwt"})
- */
- public function getEnterprisesBaseInfo(): Json
- {
- $result = ProductBatchService::findEnterprisesBaseInfo(getQydm());
- return $this->JsonSucess($result);
- }
- /**
- * @Apidoc\Title("建档出证产品信息获取")
- * @Apidoc\Tag("基础信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getProductBaseInfo",method="GET")
- * @Middleware({"jwt"})
- */
- public function getProductBaseInfo(): Json
- {
- $result = ProductBatchService::selectProductBaseInfo(getQydm());
- return $this->JsonSucess($result);
- }
- /**
- * @Apidoc\Title("建档出证产品产地信息获取")
- * @Apidoc\Tag("基础信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getChandiBaseInfo",method="GET")
- * @Middleware({"jwt"})
- */
- public function getchandiBaseInfo(): Json
- {
- $result = ProductBatchService::selectChandiBaseInfo(getQydm());
- return $this->JsonSucess($result);
- }
- /**
- * @Apidoc\Title("添加产品批次信息")
- * @Apidoc\Tag("产品批次")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("yang")
- * @Route("addProductBatch",method="POST")
- * @Middleware({"jwt"})
- */
- public function addProductBatch(): Json
- {
- $info = $this->request->post();
- try {
- validate(\app\validate\ProductBatch::class)->check($info);
- } catch (ValidateException $e) {
- $this->JsonError($e->getError());
- }
- $info['batch_id'] = date('mdhis', time());
- $info['creation_time'] = date('Y-m-d h:i:s', time());
- return $this->JsonSucess(ProductBatchService::addProductBatch($info));
- }
- /**
- * @Apidoc\Title("产品批次信息ByID")
- * @Apidoc\Tag("产品批次信息")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("yang")
- * @Route("getProductBatchInfo",method="GET")
- * @Middleware({"jwt"})
- */
- public function getProductBatchInfo(): Json
- {
- $id = $this->request->get();
- try {
- validate(Id::class)->check($id);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(ProductBatchService::getProductBatchInfoById($id["id"]));
- }
- /**
- * @Apidoc\Title("更新产品批次信息")
- * @Apidoc\Tag("产品批次信息")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("yang")
- * @Route("editProductBatch",method="POST")
- * @Middleware({"jwt"})
- */
- public function editProductBatch(): Json
- {
- $info = $this->request->post();
- try {
- validate(\app\validate\ProductBatch::class)->check($info);
- } catch (ValidateException $e) {
- $this->JsonError($e->getError());
- }
- return $this->JsonSucess(ProductBatchService::editProductBatch($info,$info["id"]));
- }
- /**
- * @Apidoc\Author("ihavoc")
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- * @Apidoc\Title("根据产品id获取批次号信息")
- * @Apidoc\Tag("批次号")
- * @Apidoc\Method ("POST")
- * @Route("/getPchByProductId",method="POST")
- * @Middleware({"jwt"})
- */
- public function getPchByProductId(){
- $id = $this->request->get();
- try {
- validate(Id::class)->check($id);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(ProductBatchService::getPchByProId($id["id"]));
- }
- }
|