AiJob.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\api\controller\ps;
  3. use app\common\controller\Api;
  4. use app\common\library\ps\FactoryContext;
  5. use think\Db;
  6. /**
  7. * 工厂端 AI 识版
  8. */
  9. class AiJob extends Api
  10. {
  11. protected $noNeedRight = '*';
  12. public function _initialize()
  13. {
  14. parent::_initialize();
  15. if (!FactoryContext::id()) {
  16. $this->error('账号未绑定工厂');
  17. }
  18. }
  19. /**
  20. * 上传后的原稿提交识版。视觉模型要 1~3 分钟,后台跑完后前端轮询 status。
  21. */
  22. public function recognize()
  23. {
  24. $this->error('模板上传和识版已改到管理后台,工厂端不再上传模板');
  25. }
  26. /**
  27. * 查询识版进度
  28. */
  29. public function status()
  30. {
  31. $id = $this->request->request('id/d');
  32. $job = Db::name('ps_ai_job')
  33. ->where('id', $id)
  34. ->where('factory_id', FactoryContext::id())
  35. ->find();
  36. if (!$job) {
  37. $this->error(__('No Results were found'));
  38. }
  39. $this->success('', [
  40. 'id' => (int)$job['id'],
  41. 'status' => (string)$job['status'],
  42. 'template_id' => (int)$job['template_id'],
  43. 'error_msg' => (string)$job['error_msg'],
  44. ]);
  45. }
  46. }