ggsong 3 years ago
commit
eb4dfaec03
100 changed files with 6719 additions and 0 deletions
  1. 1 0
      .example.env
  2. 5 0
      .gitignore
  3. 0 0
      .htaccess
  4. 42 0
      .travis.yml
  5. 32 0
      LICENSE.txt
  6. 56 0
      README.md
  7. 1 0
      app/.htaccess
  8. 22 0
      app/AppService.php
  9. 94 0
      app/BaseController.php
  10. 74 0
      app/ExceptionHandle.php
  11. 8 0
      app/Request.php
  12. 78 0
      app/api/business/LoginBus.php
  13. 175 0
      app/api/business/ModelBus.php
  14. 26 0
      app/api/business/PesticidesBus.php
  15. 30 0
      app/api/business/ProductBus.php
  16. 56 0
      app/api/business/SampleBus.php
  17. 113 0
      app/api/business/SuperviserTaskBus.php
  18. 106 0
      app/api/business/TaskBusOrganizer.php
  19. 98 0
      app/api/business/TaskBusUndertaker.php
  20. 23 0
      app/api/business/TaskCommonBus.php
  21. 59 0
      app/api/business/TestUnitBus.php
  22. 217 0
      app/api/controller/v1/Chandi.php
  23. 896 0
      app/api/controller/v1/Index.php
  24. 34 0
      app/api/controller/v1/Login.php
  25. 123 0
      app/api/controller/v1/Model.php
  26. 48 0
      app/api/controller/v1/Organizer.php
  27. 45 0
      app/api/controller/v1/Pesticides.php
  28. 189 0
      app/api/controller/v1/Product.old.php
  29. 21 0
      app/api/controller/v1/Product.php
  30. 140 0
      app/api/controller/v1/Production.php
  31. 30 0
      app/api/controller/v1/ResponseJson.php
  32. 130 0
      app/api/controller/v1/Sample.old.php
  33. 54 0
      app/api/controller/v1/Sample.php
  34. 83 0
      app/api/controller/v1/Superviser.php
  35. 37 0
      app/api/controller/v1/TaskCommon.php
  36. 252 0
      app/api/controller/v1/Traceability.php
  37. 54 0
      app/api/controller/v1/Undertaker.php
  38. 23 0
      app/api/controller/v1/Upload.php
  39. 24 0
      app/api/exception/ApiException.php
  40. 49 0
      app/api/middleware/CheckAllow.php
  41. 42 0
      app/api/middleware/Ip.php
  42. 80 0
      app/api/middleware/Rsa.php
  43. 47 0
      app/api/middleware/WxMiddleware.php
  44. 15 0
      app/api/middleware/rsa_private_key.pem
  45. 6 0
      app/api/middleware/rsa_public_key.pem
  46. 123 0
      app/api/model/Ccjc.php
  47. 37 0
      app/api/model/Cyd.php
  48. 46 0
      app/api/model/Jcdw.php
  49. 21 0
      app/api/model/Jgry.php
  50. 54 0
      app/api/model/Orgs.php
  51. 28 0
      app/api/model/Pesticides.php
  52. 21 0
      app/api/model/ProductClass.php
  53. 15 0
      app/api/model/Production.php
  54. 26 0
      app/api/model/Ry.php
  55. 97 0
      app/api/model/TestModel.php
  56. 26 0
      app/api/model/TestPesticides.php
  57. 31 0
      app/api/model/TestProduct.php
  58. 63 0
      app/api/model/Undertake.php
  59. 15 0
      app/api/model/UnitsTest.php
  60. 47 0
      app/api/model/User.php
  61. 96 0
      app/api/route/app.php
  62. 39 0
      app/common.php
  63. 105 0
      app/common/lib/Arr.php
  64. 202 0
      app/common/lib/auth/JwtAuth.php
  65. 94 0
      app/common/lib/upload/AliyunOss.php
  66. 34 0
      app/common/middleware/JwtAuth.php
  67. 27 0
      app/common/model/mysql/Ry.php
  68. 17 0
      app/event.php
  69. 10 0
      app/middleware.php
  70. 9 0
      app/provider.php
  71. 9 0
      app/service.php
  72. 51 0
      composer.json
  73. 1118 0
      composer.lock
  74. 32 0
      config/app.php
  75. 39 0
      config/cache.php
  76. 9 0
      config/console.php
  77. 20 0
      config/cookie.php
  78. 60 0
      config/database.php
  79. 24 0
      config/filesystem.php
  80. 12 0
      config/jwt.php
  81. 27 0
      config/lang.php
  82. 45 0
      config/log.php
  83. 8 0
      config/middleware.php
  84. 45 0
      config/route.php
  85. 19 0
      config/session.php
  86. 47 0
      config/status.php
  87. 10 0
      config/trace.php
  88. 19 0
      config/upload.php
  89. 25 0
      config/view.php
  90. 2 0
      extend/.gitignore
  91. 0 0
      nginx.htaccess
  92. 0 0
      public/.htaccess
  93. BIN
      public/favicon.ico
  94. 24 0
      public/index.php
  95. 6 0
      public/nginx.htaccess
  96. 2 0
      public/robots.txt
  97. 19 0
      public/router.php
  98. 2 0
      public/static/.gitignore
  99. 22 0
      route/app.php
  100. 2 0
      runtime/.gitignore

+ 1 - 0
.example.env

@@ -0,0 +1 @@
+APP_DEBUG = true

[APP]
DEFAULT_TIMEZONE = Asia/Shanghai

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true

[LANG]
default_lang = zh-cn

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+/.idea
+/.vscode
+/vendor
+*.log
+.env

+ 0 - 0
.htaccess


+ 42 - 0
.travis.yml

@@ -0,0 +1,42 @@
+sudo: false
+
+language: php
+
+branches:
+  only:
+    - stable
+
+cache:
+  directories:
+    - $HOME/.composer/cache
+
+before_install:
+  - composer self-update
+
+install:
+  - composer install --no-dev --no-interaction --ignore-platform-reqs
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
+  - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
+  - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
+
+script:
+  - php think unit
+
+deploy:
+  provider: releases
+  api_key:
+    secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
+  file:
+    - ThinkPHP_Core.zip
+    - ThinkPHP_Full.zip
+  skip_cleanup: true
+  on:
+    tags: true

+ 32 - 0
LICENSE.txt

@@ -0,0 +1,32 @@
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
+All rights reserved。
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
+允许代码修改,再作为开源或商业软件发布。需要满足
+的条件: 
+1. 需要给代码的用户一份Apache Licence ;
+2. 如果你修改了代码,需要在被修改的文件中说明;
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
+带有原来代码中的协议,商标,专利声明和其他原来作者规
+定需要包含的说明;
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
+件中需要带有本协议内容。你可以在Notice中增加自己的
+许可,但不可以表现为对Apache Licence构成更改。 
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.

+ 56 - 0
README.md

@@ -0,0 +1,56 @@
+ThinkPHP 6.0
+===============
+
+> 运行环境要求PHP7.1+,兼容PHP8.0。
+
+[官方应用服务市场](https://market.topthink.com) | [`ThinkAPI`——官方统一API服务](https://docs.topthink.com/think-api)
+
+ThinkPHPV6.0版本由[亿速云](https://www.yisu.com/)独家赞助发布。
+
+## 主要新特性
+
+* 采用`PHP7`强类型(严格模式)
+* 支持更多的`PSR`规范
+* 原生多应用支持
+* 更强大和易用的查询
+* 全新的事件系统
+* 模型事件和数据库事件统一纳入事件系统
+* 模板引擎分离出核心
+* 内部功能中间件化
+* SESSION/Cookie机制改进
+* 对Swoole以及协程支持改进
+* 对IDE更加友好
+* 统一和精简大量用法
+
+## 安装
+
+~~~
+composer create-project topthink/think tp 6.0.*
+~~~
+
+如果需要更新框架使用
+~~~
+composer update topthink/framework
+~~~
+
+## 文档
+
+[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
+
+## 参与开发
+
+请参阅 [ThinkPHP 核心框架包](https://github.com/top-think/framework)。
+
+## 版权信息
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+
+本项目包含的第三方源码和二进制文件之版权信息另行标注。
+
+版权所有Copyright © 2006-2020 by ThinkPHP (http://thinkphp.cn)
+
+All rights reserved。
+
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+更多细节参阅 [LICENSE.txt](LICENSE.txt)

+ 1 - 0
app/.htaccess

@@ -0,0 +1 @@
+deny from all

+ 22 - 0
app/AppService.php

@@ -0,0 +1,22 @@
+<?php
+declare (strict_types = 1);
+
+namespace app;
+
+use think\Service;
+
+/**
+ * 应用服务类
+ */
+class AppService extends Service
+{
+    public function register()
+    {
+        // 服务注册
+    }
+
+    public function boot()
+    {
+        // 服务启动
+    }
+}

+ 94 - 0
app/BaseController.php

@@ -0,0 +1,94 @@
+<?php
+declare (strict_types = 1);
+
+namespace app;
+
+use think\App;
+use think\exception\ValidateException;
+use think\Validate;
+
+/**
+ * 控制器基础类
+ */
+abstract class BaseController
+{
+    /**
+     * Request实例
+     * @var \think\Request
+     */
+    protected $request;
+
+    /**
+     * 应用实例
+     * @var \think\App
+     */
+    protected $app;
+
+    /**
+     * 是否批量验证
+     * @var bool
+     */
+    protected $batchValidate = false;
+
+    /**
+     * 控制器中间件
+     * @var array
+     */
+    protected $middleware = [];
+
+    /**
+     * 构造方法
+     * @access public
+     * @param  App  $app  应用对象
+     */
+    public function __construct(App $app)
+    {
+        $this->app     = $app;
+        $this->request = $this->app->request;
+
+        // 控制器初始化
+        $this->initialize();
+    }
+
+    // 初始化
+    protected function initialize()
+    {}
+
+    /**
+     * 验证数据
+     * @access protected
+     * @param  array        $data     数据
+     * @param  string|array $validate 验证器名或者验证规则数组
+     * @param  array        $message  提示信息
+     * @param  bool         $batch    是否批量验证
+     * @return array|string|true
+     * @throws ValidateException
+     */
+    protected function validate(array $data, $validate, array $message = [], bool $batch = false)
+    {
+        if (is_array($validate)) {
+            $v = new Validate();
+            $v->rule($validate);
+        } else {
+            if (strpos($validate, '.')) {
+                // 支持场景
+                [$validate, $scene] = explode('.', $validate);
+            }
+            $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
+            $v     = new $class();
+            if (!empty($scene)) {
+                $v->scene($scene);
+            }
+        }
+
+        $v->message($message);
+
+        // 是否批量验证
+        if ($batch || $this->batchValidate) {
+            $v->batch(true);
+        }
+
+        return $v->failException(true)->check($data);
+    }
+
+}

+ 74 - 0
app/ExceptionHandle.php

@@ -0,0 +1,74 @@
+<?php
+namespace app;
+
+use app\index\exception\ApiException;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\exception\Handle;
+use think\exception\HttpException;
+use think\exception\HttpResponseException;
+use think\exception\ValidateException;
+use think\Response;
+use Throwable;
+
+/**
+ * 应用异常处理类
+ */
+class ExceptionHandle extends Handle
+{
+    /**
+     * 不需要记录信息(日志)的异常类列表
+     * @var array
+     */
+    protected $ignoreReport = [
+        HttpException::class,
+        HttpResponseException::class,
+        ModelNotFoundException::class,
+        DataNotFoundException::class,
+        ValidateException::class,
+    ];
+
+    /**
+     * 记录异常信息(包括日志或者其它方式记录)
+     *
+     * @access public
+     * @param  Throwable $exception
+     * @return void
+     */
+    public function report(Throwable $exception): void
+    {
+        // 使用内置的方式记录异常日志
+        parent::report($exception);
+    }
+
+    /**
+     * Render an exception into an HTTP response.
+     *
+     * @access public
+     * @param \think\Request   $request
+     * @param Throwable $e
+     * @return Response
+     */
+    public function render($request, Throwable $e): Response
+    {
+        // 添加自定义异常处理机制
+
+        //apiException异常的处理
+        if ($e instanceof ApiException) {
+            $code = $e->getCode();
+            $message = $e->getMessage();
+        } else {
+            //Todo 改成三元运算符简化代码
+            $code = $e->getCode();
+            if (!$code || $code < 0) $code = config('status.err_token')[0];
+            $message = $e->getMessage();
+            if (!$message) $message=config('status.unknow_error')[1];
+        }
+
+        return show($code, $message);
+
+        // 其他错误交给系统处理
+        //return parent::render($request, $e);
+
+    }
+}

+ 8 - 0
app/Request.php

@@ -0,0 +1,8 @@
+<?php
+namespace app;
+
+// 应用请求对象类
+class Request extends \think\Request
+{
+
+}

+ 78 - 0
app/api/business/LoginBus.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/8
+ */
+
+namespace app\api\business;
+
+use app\api\model\Jcdw;
+use app\common\lib\auth\JwtAuth;
+use app\common\model\mysql\Ry;
+use app\api\exception\ApiException;
+use think\facade\Cache;
+
+class LoginBus
+{
+    public function login($username,$password)
+    {
+        //从人员表中查询数据
+        $ry_info=(new Ry())->getUserInfoByRybh($username);
+        //从检测单位表中查询数据
+        $jcdw_info=(new Jcdw())->getInfoByLoginName($username);
+        //用户名都不存在则抛出异常
+        if (!$ry_info && !$jcdw_info) {
+            throw new ApiException(config('status.err_user_not_exist'));
+        }
+
+        //在ry表中查询到数据,则验证用户名和密码
+        if (isset($ry_info['rybh']) && $ry_info['kl']==$password) {
+            $data=[
+                'id' => $ry_info['id'],
+                'groupname'=>$ry_info['groupname'],
+                'rymc'=>$ry_info['rymc'],
+                'name'=>'',
+                'rybh'=>$ry_info['rybh'],
+                'qydm'=>$ry_info['qydm'],
+            ];
+        }
+        //在jcdw表中查询到数据,则验证用户名和密码
+        if (isset($jcdw_info['login_name']) && $jcdw_info['pwd'] == $password) {
+            //return '正确2';
+            $data=[
+                'id' => $jcdw_info['id'],
+                'groupname'=>$jcdw_info['groupname'],
+                'rymc'=>$jcdw_info['login_name'],
+                'name'=>$jcdw_info['name'],
+                'rybh'=>'',
+                'qydm'=>$jcdw_info['qydm'],
+            ];
+        }
+
+
+
+        //实例化JwtAuth,生成token
+        $jwt_auth=JwtAuth::getInstance();
+        $token = $jwt_auth
+            ->setGroupname($data['groupname'])
+            ->setRymc($data['rymc'])
+            ->setName($data['name'])
+            ->setRybh($data['rybh'])
+            ->setQydm($data['qydm'])
+            ->setUid($data['id'])
+            ->encode()
+            ->getToken();
+
+        //将ip存到redis中,通过middleware验证
+        $real_ip = request()->ip();
+        Cache::store('redis')->set($real_ip,$token,1 * 24 * 3600);
+
+        //data数组添加两条数据
+        $data['token']=$token;
+        $data['re_ip']=$real_ip;
+        return $data;
+    }
+
+
+}

+ 175 - 0
app/api/business/ModelBus.php

@@ -0,0 +1,175 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\business;
+
+use app\api\exception\ApiException;
+use app\api\model\Ccjc;
+use app\api\model\TestModel;
+use app\api\model\TestPesticides;
+use app\api\model\TestProduct;
+use app\common\lib\auth\JwtAuth;
+
+class ModelBus
+{
+    private $uid;
+    public function __construct()
+    {
+        $jwtAuth = JwtAuth::getInstance();
+        $this->uid = $jwtAuth->getUid();
+    }
+
+    //获取当前用户的模型页列表
+    public function selectModelList($data)
+    {
+        $pageNum = $data['pageNum'];
+        $pageSize = $data['pageSize'];
+        $type_id = $data['type_id'];//1.种植业 2.畜牧业 3.渔业 4.其他
+
+        $where = [];
+        if (!empty($type_id)) {
+            array_push($where, ['type_id', '=', (int)$type_id]);
+        }
+        $result = (new TestModel())->getListByUserId($this->uid,$pageNum,$pageSize,$where)->toArray();
+        $count = (new TestModel())->countListByUserId($this->uid, $where);
+        return ['rows'=>$result, 'total' => $count,];
+    }
+
+    //获取模型信息
+    public function getModelInfo($model_id)
+    {
+        //todo 这里可以连表查询,可以多对多,以后再研究优化
+        $model_info=(new TestModel())->getModelInfoByModelID($model_id);//获取模型信息
+        $model_product=(new TestModel())->getProductInfo($model_id)->toArray();//检测对象
+        $model_pesticides = (new TestModel())->getPesticidesInfo($model_id)->toArray();//检测项
+        $data=[
+            'name'=>$model_info,
+            'product'=>$model_product,
+            'pesticides'=>$model_pesticides
+        ];
+        return $data;
+    }
+
+    public function updateInfoByTaskID($task_id, $data)
+    {
+        $result = (new Ccjc())->updateInfoByTaskID($task_id, $data);
+        return $result;
+    }
+
+
+
+    //修改模型信息
+    public function updateModelInfo($model_id,$model_info,$product='',$pesticides='')
+    {
+////todo ------------- foreach有问题!!! 直接复制的,要重写!!
+        if ($product != '') {
+            $product_update_data=[];
+            foreach ($product as $k=>$v){
+                $j=[];
+                $j['test_model_id']=$model_id;
+                $j['product_id']=$v['id'];
+                $j['product_name']=$v['name'];
+                $product_update_data[]=$j;
+            }
+        }
+
+        if ($pesticides != '') {
+            $pesticides_update_data=[];
+            foreach ($pesticides as $i=>$o){
+                $p=[];
+                $p['test_model_id']=$model_id;
+                $p['test_name']=$o['name'];
+                $p['test_id']=$o['id'];
+                $pesticides_update_data[]=$p;
+
+            }
+        }
+
+        //更新model_test表中的信息
+        (new TestModel())->updateModelInfoByModelID($model_id,$model_info);
+        //删除原有Product中model_id的内容
+        (new TestProduct())->deleteProductInfoByTestModelID($model_id);
+        //删除原有Pesticides中model_id的内容
+        (new TestPesticides())->deletePesticidesInfoByTestModelID($model_id);
+
+        //添加新的Product中model_id的内容
+        $updateProductInfo = (new TestProduct())->insertProductInfo($product_update_data);
+        //添加新的Pesticides中model_id的内容
+        $updatePesticidesInfo = (new TestPesticides())->insertPesticidesInfo($pesticides_update_data);
+
+        if ($updateProductInfo == 0) {
+            return showError(config('status.none_model_product'),config('status.none_model_product'));
+        }
+        if ($updatePesticidesInfo == 0) {
+            return showError(config('status.none_model_pesticides'),config('status.none_model_pesticides'));
+        }
+        return true;
+    }
+
+    //新增模型
+    public function createModelInfo($model_name,$type_id,$product_data,$pesticides_data)
+    {
+        $uid=$this->uid;
+        $model_id = (new TestModel())->createModelInfo($model_name, $type_id, $uid);
+
+        //格式化$product_data=》$product
+        $product=[];
+        //todo 需要重写foreach
+        foreach ($product_data as $k=>$v){
+            $j=[];
+            $j['test_model_id']=$model_id;
+            $j['product_id']=$v['id'];
+            $j['product_name']=$v['name'];
+            $product[]=$j;
+        }
+        //格式化$pesticides_data=》$pesticides
+        $pesticides=[];
+        foreach ($pesticides_data as $i=>$o){
+            $p=[];
+            $p['test_model_id']=$model_id;
+            $p['test_name']=$o['name'];
+            $p['test_id']=$o['id'];
+            $pesticides[]=$p;
+        }
+        //todo 写到一个model里
+        $update_test_product = (new TestProduct())->createProductInfo($product);
+        if ($update_test_product == 0) {
+            throw new ApiException(config('status.none_model_product'));
+        }
+        $update_test_pesticide =(new TestPesticides())->insertPesticidesInfo($pesticides);
+        if ($update_test_pesticide == 0) {
+            throw new ApiException(config('status.none_model_pesticides'));
+        }
+        return true;
+    }
+
+    //删除模型
+    public function deleteModelInfo($del_arr)
+    {
+        //验证模型创建者是否一致
+        foreach ($del_arr as $k => $v) {
+            //从数据库获取当前模型的user_id
+            if (empty($v['id'])) {
+                throw new ApiException(config('status.none_model_info'));
+            }
+            $user_id = (new TestModel())->getUserIdByModelID($v['id'])['user_id'];
+            if ($user_id != $this->uid) {
+                throw new ApiException(config('status.none_authority'));
+            }
+            //删除test_model信息
+            (new TestModel())->deleteModelInfoByID($v['id']);
+            //删除test_product信息
+            (new TestProduct())->deleteProductInfoByTestModelID($v['id']);
+            //删除test_pesticides信息
+            (new TestPesticides())->deletePesticidesInfoByTestModelID($v['id']);
+        }
+        return true;
+    }
+
+
+
+}

+ 26 - 0
app/api/business/PesticidesBus.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\business;
+
+use app\api\model\Pesticides;
+use app\api\model\TestPesticides;
+
+class PesticidesBus
+{
+    public function selectPesticidesList($pageNum,$pageSize,$key_word)
+    {
+        $data = (new Pesticides())->selectPesticidesList($key_word, $pageNum, $pageSize)->toArray();
+        $count = (new Pesticides())->countPesticidesList($key_word);
+        $result = [
+            'rows' => $data,
+            'total' => $count,
+        ];
+        return $result;
+    }
+
+}

+ 30 - 0
app/api/business/ProductBus.php

@@ -0,0 +1,30 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\business;
+
+use app\api\model\ProductClass;
+use app\api\model\TestProduct;
+use app\common\lib\Arr;
+
+class ProductBus
+{
+
+    public function selectProductList($type_id)
+    {
+
+        //todo cache缓存优化数据
+        $field='id,parent_id,product_code,name,alias';
+        $tmp_result = (new ProductClass())->selectProductListByTypeID($type_id,$field)->toArray();//字段调用的field过滤
+
+        //todo 树状化需要看一下,回调可以优化
+        $result = (new Arr())->Arr_tree($tmp_result,'0'.$type_id);
+        return $result;
+    }
+
+
+}

+ 56 - 0
app/api/business/SampleBus.php

@@ -0,0 +1,56 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/14
+ */
+
+namespace app\api\business;
+
+use app\api\model\Ccjc;
+use app\api\model\Cyd;
+use app\api\model\TestModel;
+use app\common\lib\Arr;
+use app\common\lib\auth\JwtAuth;
+
+class SampleBus
+{
+    private $uid;
+
+    public function __construct()
+    {
+        $JwtAuth = JwtAuth::getInstance();
+        $this->uid = $JwtAuth->getUid();
+    }
+
+    public function selectSampleList($task_id,$pageNum,$pageSize)
+    {
+        $uid = $this->uid;
+        $where=[
+            ['task_id', '=', $task_id],
+            ['sample_unit', '=', $uid]
+        ];
+        $result = (new Cyd())->selectSampleListByTaskIdAndUid($where, $pageNum, $pageSize);
+        $count = (new Cyd())->countSampleListByTaskIdAndUid($where);
+        return ['rows'=>$result,'total'=>$count];
+    }
+
+    public function getSampleObj($task_id)
+    {
+        $model_id = (new Ccjc())->getTaskInfoByTaskID($task_id)['test_model_id'];
+        $data = (new TestModel())->getProductInfo($model_id);
+        $result=(new Arr())->Arr_columns($data, 'product_name,product_id');
+        return $result;
+
+    }
+
+    public function createSample()
+    {
+        ///todo 没写呢
+        $res=Db::name('cyd')->strict(false)->insert($data);
+        $data['units_id']=Db::name('units_test')->strict(false)->insertGetId($data['units']);
+        $data['product_unit']=Db::name('production')->strict(false)->insertGetId($data['production']);
+        $data['sample_unit']=$this->request->user['unit_id']->getValue();
+    }
+
+}

+ 113 - 0
app/api/business/SuperviserTaskBus.php

@@ -0,0 +1,113 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/9
+ */
+
+namespace app\api\business;
+
+use app\api\exception\ApiException;
+use app\api\model\Ccjc;
+use app\api\model\Jcdw;
+use app\api\model\Orgs;
+use app\common\lib\Arr;
+use app\common\lib\auth\JwtAuth;
+
+class SuperviserTaskBus
+{
+    private $rymc;
+    public function __construct()
+    {
+        $jwtAuth=JwtAuth::getInstance();            //实例化jwtAuth
+        $this->rymc = $jwtAuth->getRymc();          //setRybh是在middleware/jwtAuth中完成的
+    }
+
+    //查询任务列表数据
+    public function selectTask($data)
+    {
+        //如果需要查询的字段不为空就push一个查询条件
+        $where=[];//初始化$where
+        //任务年度
+        if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
+        //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+        if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
+        //任务开始时间
+        if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
+        //任务结束时间
+        if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
+        //任务分类:例行or专项
+        if ($data['task_class'] != '') array_push($where, ['task_class', '=', $data['task_class']]);
+        //任务名称:模糊查询
+        if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
+
+        $result = (new Ccjc())->getInfoByTaskClass($where,(int)$data['pageNum'],(int)$data['pageSize'])->toArray();
+        $count = (new Ccjc())->getInfoListCount($where);
+        return ['rows'=>$result, 'total'=>$count,];
+    }
+
+    //创建任务
+    public function createTask($data,$orgs_data)
+    {
+        $data['releaser'] = $this->rymc;
+        //创建任务
+        $task_id = (new Ccjc())->createTask($data);
+
+        for($i=0;$i<count($orgs_data);$i++){
+            $orgs[$i]['task_id']=$task_id;
+            $orgs[$i]['unit_id']=$orgs_data[$i]['id'];
+            $orgs[$i]['unit_name']=$orgs_data[$i]['name'];
+        }
+
+        $result = (new Orgs())->createOrgsInfo($orgs);
+        return $result;
+    }
+
+    //删除任务
+    public function deleteTask($arr_del_task)
+    {
+        //根据ID检索创建者
+        $releaser = (new Ccjc())->getReleaserById($arr_del_task);
+        if (empty($releaser)) {
+            throw new ApiException(config('status.none_data'));
+        }
+        //将创建者releaser和token中的rymc匹配,不相等则throw无权限操作
+        foreach ($releaser as $k => $v) {
+            if (strcmp($this->rymc, $v) != 0) {
+                throw new ApiException(config('status.none_authority'));
+            }
+        }
+        //进行删除操作
+        $result = (new Ccjc())->deleteTaskByID($arr_del_task);
+        return $result;
+    }
+
+    public function updateTask($data)
+    {
+        //过滤字段,保留id,ispublic,releaser
+        $arr = (new Arr())->Arr_columns($data, 'id,ispublic,releaser');
+
+        //校验 任务状态 && 操作权限
+        foreach ($arr as $k=>$value) {
+            if ($value['ispublic'] != 1) {
+                throw new ApiException(config('status.err_public_status'));
+            }
+            if (strcmp($value['releaser'], $this->rymc) != 0) {
+                throw new ApiException(config('status.none_authority'));
+            }
+        }
+        $result = (new Ccjc())->updateTaskByArrCondition($arr);
+        return $result;
+    }
+
+
+
+
+
+
+
+
+
+
+
+}

+ 106 - 0
app/api/business/TaskBusOrganizer.php

@@ -0,0 +1,106 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/12
+ */
+
+namespace app\api\business;
+
+use app\api\exception\ApiException;
+use app\api\model\Ccjc;
+use app\api\model\Jgry;
+use app\api\model\Orgs;
+use app\api\model\TestModel;
+use app\api\model\Undertake;
+use app\common\lib\auth\JwtAuth;
+
+class TaskBusOrganizer
+{
+    private $uid;
+    public function __construct()
+    {
+        $jwtAuth=JwtAuth::getInstance();            //实例化jwtAuth
+        $this->uid = $jwtAuth->getUid();          //setRybh是在middleware/jwtAuth中完成的
+    }
+
+    //查询任务列表数据
+    public function selectTask($task_class,$pageNum,$pageSize,$data)
+    {
+        $where=[['unit_id','=',$this->uid],['task_class','=',$task_class]];
+
+        if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
+        //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+        if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
+        //任务开始时间
+        if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
+        //任务结束时间
+        if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
+        //任务名称:模糊查询
+        if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
+
+        $data = (new Orgs())->selectCcjcData($where,$pageNum,$pageSize);
+        //$data = (new Ccjc())->selectCcjcAndOrgsData($this->uid);
+        $count =(new Orgs())->countCcjcData($where);
+        return ['rows'=>$data,'total'=>$count];
+    }
+
+    //牵头单位发布任务
+    public function releaseTask($task_id)
+    {
+        $data=['ispublic' => 5];//发布任务
+        $result = (new Ccjc())->updateInfoByTaskID($task_id, $data);
+        return $result;
+    }
+
+    //获取任务基本信息
+    public function getTaskInfo($task_id,$pageNum=1,$pageSize=null)
+    {
+        $uid=$this->uid;
+        //判断 在orgs表中的当前任务的id所对应的unit_id是否等于uid
+        $unit_id = (new Orgs())->getUnitIdByTaskID($task_id)['unit_id'];
+        if ($unit_id != $uid) {
+            throw new ApiException(config('status.err_task_auth'));
+        }
+        //任务信息
+        $task_info = (new Ccjc())->getTaskInfoByTaskID($task_id);
+        $task_releaser_info = (new Jgry())->getJgryInfoByRymc($task_info['releaser']);
+        //获取uid下创建的所有模型信息
+        if (isset($task_info['test_model_id'])) {
+            $task_product_info = (new TestModel())->getProductInfo($task_info['test_model_id']);
+            $task_pesticides_info = (new TestModel())->getPesticidesInfo($task_info['test_model_id']);
+            $task_model_info=(new TestModel())->getModelInfoByModelID($task_info['test_model_id']);
+
+        }else{
+            $task_product_info ='';
+            $task_pesticides_info='';
+            $task_model_info='';
+        }
+        //牵头的任务列表的信息
+        $unitTaskList_info=(new Undertake())->selectUndertakeInfoByTaskIdAndUnitId($task_id,$uid,'','',$pageNum,$pageSize);
+        $unitTaskList_total = (new Undertake())->countUndertakeInfoByTaskIdAndUnitId($task_id, $uid);
+
+        //承担的任务列表的信息
+        $underTaskList_info=(new Undertake())->selectUndertakeInfoByTaskIdAndUnitId($task_id,'',$uid,'',$pageNum,$pageSize);
+        $underTaskList_total = (new Undertake())->countUndertakeInfoByTaskIdAndUnitId($task_id, '',$uid);
+
+        //报告上传的任务列表信息
+        $reportTaskList_info=(new Undertake())->selectUndertakeInfoByTaskIdAndUnitId($task_id,'','',$uid,$pageNum,$pageSize);
+        $reportTaskList_total = (new Undertake())->countUndertakeInfoByTaskIdAndUnitId($task_id, '','',$uid);
+
+        $data=[
+            'taskInfo'=>$task_info,
+            'releaserInfo'=>$task_releaser_info,
+            'product'=>$task_product_info,
+            'pesticides'=>$task_pesticides_info,
+            'unitTaskList'=>['rows'=>$unitTaskList_info,'total'=>$unitTaskList_total],
+            'underTaskList'=>['rows'=>$underTaskList_info,'total'=>$underTaskList_total],
+            'reportTaskList'=>['rows'=>$reportTaskList_info,'total'=>$reportTaskList_total],
+            'modelInfo'=>$task_model_info,
+        ];
+        return $data;
+    }
+
+
+
+}

+ 98 - 0
app/api/business/TaskBusUndertaker.php

@@ -0,0 +1,98 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/13
+ */
+
+namespace app\api\business;
+
+use app\api\exception\ApiException;
+use app\api\model\Ccjc;
+use app\api\model\Jcdw;
+use app\api\model\Undertake;
+use app\common\lib\auth\JwtAuth;
+
+class TaskBusUndertaker
+{
+    private $uid;
+
+    public function __construct()
+    {
+        $jwtAuth = JwtAuth::getInstance();
+        $this->uid = $jwtAuth->getUid();
+    }
+
+
+    public function deleteUnderTaker($del_arr)
+    {
+        $result=(new Undertake())->deleteInfoByID($del_arr);
+        if ($result == 0) {
+            throw new ApiException(config('status.none_data'));
+        }
+        return $result;
+    }
+
+
+
+    public function createUnderTakerInfo($data)
+    {
+        $uid = $this->uid;
+        $bear_name = (new Jcdw())->getInfoById($data['bear_id'])['name'];
+        $check_name = (new Jcdw())->getInfoById($data['check_id'])['name'];
+        $report_name = (new Jcdw())->getInfoById($data['report_id'])['name'];
+        $save_data=[
+            'task_id' => $data['task_id'],
+            'unit_id' => $uid,
+            'bear_id' => $data['bear_id'],
+            'check_id' => $data['check_id'],
+            'report_id' => $data['report_id'],
+            'bear_name' => $bear_name,
+            'check_name' => $check_name,
+            'report_name' => $report_name,
+            'sample_number' => $data['sample_number'],
+            'address' => $data['address'],
+            'uploadtime' => $data['upload_time'],
+        ];
+
+        $result = (new Undertake())->insert($save_data,true);
+        if ($result == null) {
+            throw new ApiException(config('status.err_data_upload'));
+        }
+        return true;
+    }
+
+    public function selectUnterTakerListByTaskID($task_id,$pageNum=1,$pageSize=10)
+    {
+        $bear = $this->uid;
+        $result = (new Undertake())->selectUndertakeInfoByTaskIdAndUnitId($task_id,'',$bear,'',$pageNum=1,$pageSize=null);
+        $count = (new Undertake())->countUndertakeInfoByTaskIdAndUnitId($task_id,'',$bear);
+        return ['rows'=>$result, 'total' => $count,];
+    }
+
+    //查询任务列表数据
+    public function selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data)
+    {
+        //$where=[['bear_id','=',$this->uid],['task_class','=',$task_class]];
+        $where=[['bear_id','=',$this->uid]];
+        if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
+        //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+        if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
+        //任务开始时间
+        if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
+        //任务结束时间
+        if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
+        //任务名称:模糊查询
+        if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
+
+        //$data = (new Undertake())->selectCcjcData($where,$pageNum,$pageSize);
+
+
+
+        $data = (new Ccjc())->selectUndertakeData($task_class,$where,$pageNum,$pageSize);
+        $count = (new Ccjc())->countUndertakeData($task_class,$where);
+       // $count =(new Undertake())->countCcjcData($where);
+        return ['rows'=>$data,'total'=>$count];
+    }
+
+}

+ 23 - 0
app/api/business/TaskCommonBus.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/13
+ */
+
+namespace app\api\business;
+
+use app\common\lib\auth\JwtAuth;
+
+class TaskCommonBus
+{
+    private $uid;
+    public function __construct()
+    {
+        $jwtAuth=JwtAuth::getInstance();            //实例化jwtAuth
+        $this->uid = $jwtAuth->getUid();          //setRybh是在middleware/jwtAuth中完成的
+    }
+
+
+
+}

+ 59 - 0
app/api/business/TestUnitBus.php

@@ -0,0 +1,59 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/10
+ */
+
+namespace app\api\business;
+use app\api\model\Jcdw;
+use app\common\lib\Arr;
+use app\common\lib\auth\JwtAuth;
+
+//检测单位
+class TestUnitBus
+{
+    private $rymc;
+    public function __construct()
+    {
+        $jwtAuth=JwtAuth::getInstance();            //实例化jwtAuth
+        $this->rymc = $jwtAuth->getRymc();          //setRybh是在middleware/jwtAuth中完成的
+    }
+
+    public function selectTestUnit($data,$group_type,$pageNum=1,$pageSize=10)
+    {
+        //判断where条件
+        //任务名称:模糊查询
+        $where=[
+            ['groupname','=', $group_type,]
+        ];
+        if ($data['name'] != '' ) array_push($where, ['name', 'LIKE', '%'.$data['name'].'%']);
+        //获取数据
+        $result = (new Jcdw())->getInfoList($where,$pageNum, $pageSize)->toArray();
+        //过滤字段
+        $data=(new Arr())->Arr_columns($result, 'id,name,groupname,ssqy');
+        //获取总数
+        $count=(new Jcdw())->getInfoListCount($where);
+        return ['rows'=>$data, 'total'=>$count,];
+    }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 217 - 0
app/api/controller/v1/Chandi.php

@@ -0,0 +1,217 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\model\Qy_basic;
+use app\api\model\Sym;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+use think\facade\Request as re;
+use think\Request;
+use thans\jwt\JWT;
+use app\api\model\Chandi as ChandiModel;
+use app\validate\Chandi as ChandiValidate;
+use think\exception\ValidateException;
+//use rsa\Rsa;
+
+class Chandi extends BaseController{
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' 	=> ['except' 	=> ['qycount'] ],
+        'check' => ['except' =>[]]
+//        'AddPlaceInfo','AddPlaceInfo','DoEditPlaceInfo','DelPlaceInfo','PlaceInfo'
+    ];
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    /*产地增加*/
+    public function AddPlaceInfo()
+    {
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $qydm=$data['qydm'];
+//        $chandi=$data['chandi'];
+//        $lng=$data['lng'];
+//        $lat=$data['lat'];
+//        $yt=$data['yt'];
+//        if(isset($data['jldw'])){
+//            try{
+//                validate(ChandiValidate::class)->check(
+//                    [
+//                        'qydm'=>$qydm,
+//                        'chandi'=>$chandi,
+//                        'lng' =>$lng,
+//                        'lat'=>$lat,
+//                        'yt'=>$yt ,
+//                        'tiliang'=>$data['tiliang'],
+//                        'jldw'=>$data['jldw'],
+//                    ]
+//                );
+//            }catch (ValidateException $e){
+//                return ($e->getError());
+//            }
+//        }
+
+        $qy=Qy_basic::Where('qydm','=',$qydm)->find();
+        if($qy){
+            $jd=ChandiModel::field('cdbh')->where('qydm','=',$qydm)->order('cdbh desc')->find();//按照产地查找产地表中的所有信息,
+            if(!$jd['cdbh']&&$jd['cdbh']==''){
+                $data['cdbh']='000';
+            }else{
+                $x='1'.$jd['cdbh'];
+                $y=intval($x)+1;//十进制取整
+                $data["cdbh"]=substr($y,1);//给产地编号赋值
+            }
+            //新增记录
+            $result = ChandiModel::create($data);
+//            $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+            if($result) {
+                return $this->jsonSuccessData($result);
+            }else {
+                return $this->jsonData(-1,"产地上传失败");
+            }
+        }
+        else{
+            return $this->jsonData(-2,"企业未注册");
+        }
+
+    }
+
+
+    /*执行产地信息修改*/
+    public function DoEditPlaceInfo(){
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        //从提交表单中排除关联字段cpmc字段
+        $data = $this->request->post();
+        //设置更新条件
+        $condition = ['bh'=>$data['bh']];
+        $result = ChandiModel::update($data,$condition);
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+
+        if($result) {
+            return $this->jsonSuccessData($result);
+        }else {
+            return $this->jsonData(-1,"更新失败");
+        }
+
+    }
+
+
+    /*产地删除*/
+    public function DelPlaceInfo()
+    {
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $map['bh']= $data['bh'];
+        //删除产地信息
+        $result = ChandiModel::where($map)->delete();
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+        if($result) {
+            return $this->jsonSuccessData($result);
+        }else {
+            return $this->jsonData(-1,"产地信息删除失败");
+        }
+    }
+
+
+    /*产地信息查询*/
+    public function PlaceInfo(){
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $page = $data['page']; //分页的页码
+        $query = $data['query']; //前台传过来的查询
+        $pageSize=$data['pageSize'];
+        $qydm=$data['qydm'];
+
+        if($query) {
+            $result['rows']= ChandiModel::
+            where([
+                ['chandi', 'like', '%' . $query . '%'],
+                ['t_chandi.qydm', '=', $qydm]
+            ])
+                ->field("t_chandi.*,t_qy_basic.qymc")
+                ->leftjoin('t_qy_basic','t_chandi.qydm=t_qy_basic.qydm')
+                ->page($page,$pageSize)
+                ->select();
+            $result['total']=ChandiModel::
+            where([
+                ['chandi', 'like', '%' . $query . '%'],
+                ['t_chandi.qydm', '=', $qydm]
+            ])
+                -> leftjoin('t_qy_basic','t_chandi.qydm=t_qy_basic.qydm')->count();
+
+            $result['page']=$page;
+
+        }
+        else{
+            $result['rows']= ChandiModel::
+            where(
+
+                't_chandi.qydm', '=', $qydm
+            )
+                ->field("t_chandi.*,t_qy_basic.qymc")
+                ->leftjoin('t_qy_basic','t_chandi.qydm=t_qy_basic.qydm')
+                ->page($page,$pageSize)
+                ->select();
+            $result['total']=ChandiModel::
+            where('t_chandi.qydm', '=', $qydm)
+                ->leftjoin('t_qy_basic','t_chandi.qydm=t_qy_basic.qydm')->count();
+
+            $result['page']=$page;
+        }
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+
+        if($result['rows']){
+            return $this->jsonSuccessData($result);
+        }
+        else{
+            return $this->jsonData('-1',"查询错误");
+        }
+    }
+
+
+    public function qycount()
+    {
+        $sum=0;
+        $count1 =Qy_basic::where(
+            'qylx','=','药材'
+        )->field('qydm')->select();
+//        dump(count($count1));die();
+
+//        $sym =Sym::where('date','>','2021-06-01')->count('bh');
+//
+//        return $this->jsonSuccessData(
+//            $count1
+//        );
+
+
+        for ($i = 0;$i<count($count1);$i++){
+
+            $sym =Sym::where('qydm',$count1[$i]['qydm'])->count('bh');
+            $sum=$sum+$sym;
+        }
+        return $this->jsonSuccessData(
+            $sum
+        );
+//
+    }
+
+
+
+}

+ 896 - 0
app/api/controller/v1/Index.php

@@ -0,0 +1,896 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\model\Ry;
+use app\api\model\Ryjr as RyjrModel;
+use app\api\model\Subject;
+use app\api\model\Ry as RyModel;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+use think\facade\Db;
+use OSS\Core\OssException;
+use OSS\OssClient;
+
+use think\facade\Request as re;
+use think\Request;
+use think\facade\Cache;
+use thans\jwt\JWT;
+use rsa\Rsa;
+use function Symfony\Component\VarDumper\Dumper\esc;
+
+class Index extends BaseController
+{
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' => ['except' => ['login']],
+//        'check' => ['except' => ['login']]
+
+    ];
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    public function login()
+    {
+        $data = $this->request->post();
+
+        $res = Db::name("ry")->field('rymc,qydm,rybh,groupname')->where([['rybh', '=', $data['login_name']], ['kl', '=', $data['pwd']],['groupname','<>','企业']])->findOrEmpty();
+
+        $res2 = Db::name("jcdw")->field('qydm,name,groupname,id')->where([['login_name', '=', $data['login_name']], ['pwd', '=', $data['pwd']]])->findOrEmpty();
+//        $res['qymc'] = Db::name("qyBasic")->field('qymc')->where('qydm','=',$res['qydm'])->find();
+
+        if(isset($res['qydm'])){
+
+            $res['token'] = JWTAuth::builder([
+                'qydm' => $res['qydm'],
+                'groupname' => $res['groupname'],
+            ]);
+            $res['re_ip'] = $this->request->ip();
+            Cache::store('redis')->set($res['re_ip'],$res['token'],1 * 24 * 3600);
+            $res['message'] = '登录成功';
+
+            return $this->jsonSuccessData($res);
+        } else if(isset($res2['qydm'])){
+            $res2['token'] = JWTAuth::builder([
+                'qydm' => $res2['qydm'],
+                'unit_id' => $res2['id'],
+                'groupname' => $res2['groupname'],
+            ]);
+            $res2['re_ip'] = $this->request->ip();
+            Cache::store('redis')->set($res2['re_ip'],$res2['token'],1 * 24 * 3600);
+            $res2['message'] = '登录成功';
+
+            return $this->jsonSuccessData($res2);
+
+        }else{
+            return $this->jsonData(-1, "用户名或密码错误");
+        }
+    }
+
+    /**
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * 获取任务接口:param:  pageNum  pageSize
+     */
+
+
+
+    //渲染任务列表(监管单位)
+    public function getTaskList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $map1=[];
+        $map2=[];
+        $map3=[];
+        $map4=[];
+        if(isset($data['year'])){
+            $map1=[
+                ['year','=',$data['year']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['ispublic'])){
+            $map2=[
+                ['ispublic','=',$data['ispublic']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['task_name'])){
+            $map4=[
+                ['task_name','LIKE','%'.$data['task_name'].'%'],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['starttime'])&&isset($data['endtime'])){
+            $map3=[
+                ['starttime','>=',$data['starttime']],
+                ['endtime','<=',$data['endtime']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        $sumMap=[];
+        if (count($map1)!=0){
+            $sumMap[]=$map1;
+        }
+        if (count($map2)!=0){
+            $sumMap[]=$map2;
+        }
+        if (count($map3)!=0){
+            $sumMap[]=$map3;
+        }if (count($map4)!=0){
+            $sumMap[]=$map4;
+        }else{
+            $sumMap[]=[
+                ['task_class','=',$data['task_class']]
+            ];
+
+        }
+
+        if (count($sumMap)!=0){
+            $res['rows'] = Db::name("ccjc")->where($sumMap)->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("ccjc")->where($sumMap)->count();
+        }else{
+            $res['rows'] = Db::name("ccjc")->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("ccjc")->count();
+        }
+
+        return $this->jsonSuccessData($res);
+    }
+
+    /**、
+     * @return \think\response\Json
+     * 添加任务
+     */
+
+
+    /***
+     * todo 增加没写
+     */
+    //添加任务并关联牵头单位
+    public function AddTask(){
+        $data = $this->request->post();
+        $resid=Db::name("ccjc")->strict(false)->insertGetId($data);
+        for($i=0;$i<count($data['orgs']);$i++){
+            $orgs[$i]['task_id']=$resid;
+            $orgs[$i]['unit_id']=$data['orgs'][$i]['id'];
+            $orgs[$i]['unit_name']=$data['orgs'][$i]['name'];
+        }
+        $res = Db::name('orgs')->strict(false)->insertAll($orgs);
+        return $this->jsonSuccessData($res);
+    }
+
+    public function ossUpload(Request $request){
+        $file = $request->file('file');
+        if ($file == null) {                                    //判断文件是否为空
+            return $this ->jsonResponse(-1,'未上传文件');
+        }
+
+        $data= $request -> param();
+
+
+        // 阿里云主账号AccessKey,在OSS控制台主页常用入口处有快速通道可以快速查看你的AccessKey ID($accessKeyId)以及Access Key Secret($accessKeySecret )
+        $accessKeyId = 'LTAI4G1xGunUnwkgq48jFWi9';
+        $accessKeySecret = '17PK5dY7WnLJR1ejgsopTUBUOzS05S';
+        //Endpoint(地域节点)查看位置在文章下方
+        $endpoint = 'http://oss-cn-hangzhou.aliyuncs.com';
+        //创建Bucket填写的名称
+        $bucket = 'syjcimage';
+        //设置保存的路径(前面不要加'/',否则会出错)
+        $path = 'govFile/'.time(). '/';
+        //下面这三项应该都知道
+        $name = $_FILES['file']['name'];
+        $tmp_name = $_FILES['file']['tmp_name'];
+        $error = $_FILES['file']['error'];
+        //过滤错误(临时测试时使用,代码写的比较简陋)
+        if ($error) {
+            switch ($error) {
+                case 1 :
+                    $error_message = '您上传的文件超过了PHP.INI配置文件中UPLOAD_MAX-FILESIZE的大小';
+                    break;
+                case 2 :
+                    $error_message = '您上传的文件超过了PHP.INI配置文件中的post_max_size的大小';
+                    break;
+                case 3 :
+                    $error_message = '文件只被部分上传';
+                    break;
+                case 4 :
+                    $error_message = '文件不能为空';
+                    break;
+                default :
+                    $error_message = '未知错误';
+            }
+            die($error_message);
+        }
+        //文件名生成
+        $arr_name = explode('.', $name);
+        //源文件的后缀
+        $extension = end($arr_name);
+        /**
+         * 判断上传文件是否合法
+         * 判断截取上传文件名是否为
+         * jpeg,jpg,png其中之一
+         */
+        if (!in_array($extension, array("jpeg", "jpg", "png", "PNG", "JPG", "JPEG","pdf","PDF","XLS","xls","doc","DOC","docx","xlsx"))) {
+            return $this->jsonData(-2, '上传文件不合法');
+
+        }
+
+//            try {
+//                validate(['file' => ['fileSize:2*1024*1024']])->check(['file' => $file]);
+//            } catch (ValidateException $e) {
+//                $return['msg'] = $e->getMessage();
+//
+//            }
+        //新的文件名
+        $new_name = $name;
+        //文件在OSS上的URL
+        $url=$path.$new_name;
+        //抛出异常
+
+        try{
+            //相比传统的操作,其实就多了两个步骤
+            //第一步是根据上面的参数实例化一个对象
+            $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
+            //这一步相当于之前把临时文件移入到设置的地址那步,只是以前的是自己的服务器上,现在是OSS;
+            $result =$ossClient->uploadFile($bucket,$url,$tmp_name);
+            //返回的参数
+            if (isset($result['info']['http_code']) AND $result['info']['http_code']==200) {
+                $arr=[
+                    'fileName' => $new_name,
+                    'fileUrl'  => $result['info']['url']
+                ];
+
+                return $this->jsonSuccessData($arr);
+            }else{
+                return $this->jsonData(-1,'上传失败');
+            }
+        } catch(OssException $e) {
+            $msg = $e->getMessage();
+            return $this->jsonData(-1,$msg);
+        }
+
+
+    }
+
+    /**
+     * @return \think\response\Json
+     * 删除任务  param:id
+     */
+
+    //删除任务
+    public function delTask(){
+        $data = $this->request->post();
+        halt($data);
+        $delarr = $data['delarr'];
+            for($i=0;$i<count($delarr);$i++){
+                $res=Db::name("ccjc")->where('id',$delarr[$i])->delete();
+
+            }
+        return $this->jsonSuccessData($res);
+    }
+
+    /**
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     * 发布和废止   param: id  ispublic
+     * 0:未发布 1:发布  2:废止
+     */
+
+    //更新任务发布状态
+    public function isPublicTask(){
+        $data = $this->request->post();
+        $pubarr = $data['pubarr'];
+            for($i=0;$i<count($pubarr);$i++) {
+                $res = Db::name("ccjc")->where(['id'=>$pubarr[$i]['id']])->update(["ispublic" => $pubarr[$i]["ispublic"]]);
+            }
+        return $this->jsonSuccessData($res);
+
+    }
+    /**
+     * 获取检测单位列表   param:pageNum    pageSize
+     */
+
+    //获取检测单位列表
+    public function getTestList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+
+        $res['rows'] = Db::name("jcdw")->page($pageNum,$pageSize)->select();
+        $res['total'] = Db::name("jcdw")->count();
+        return $this->jsonSuccessData($res);
+    }
+
+    /**
+     * 获取检测单位所属任务接口:param:  pageNum  pageSize
+     */
+
+
+    获取牵头单位所属任务
+    public function getTaskListTest(){
+        $data = $this->request->post();
+        $unit_id=$this->request->user['unit_id']->getValue();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $map1=[];
+        $map2=[];
+        $map3=[];
+        $map4=[];
+
+        if(isset($data['year'])){
+            $map1=[
+                ['t_ccjc.year','=',$data['year']]
+            ];
+        }
+        if(isset($data['ispublic'])){
+            $map2=[
+                ['t_ccjc.ispublic','=',$data['ispublic']]
+            ];
+        }
+        if(isset($data['task_name'])){
+            $map4=[
+                ['t_ccjc.task_name','LIKE','%'.$data['task_name'].'%']
+            ];
+        }
+        if(isset($data['starttime'])&&isset($data['endtime'])){
+            $map3=[
+                ['t_ccjc.starttime','>=',$data['starttime']],
+                ['t_ccjc.endtime','<=',$data['endtime']]
+            ];
+        }
+        $sumMap=[];
+        if (count($map1)!=0){
+            $sumMap[]=$map1;
+        }
+        if (count($map2)!=0){
+            $sumMap[]=$map2;
+        }
+        if (count($map3)!=0){
+            $sumMap[]=$map3;
+        }if (count($map4)!=0){
+            $sumMap[]=$map4;
+        }
+        $sumMap[]=['t_orgs.unit_id','=',$unit_id];
+        $sumMap[]=['t_ccjc.task_class','=',$data['task_class']];
+        $sumMap[]=['t_ccjc.ispublic','<>',0];
+
+//        $sumMap[]=['t_ccjc.ispublic','<>',0];
+        if ($map4||$map1||$map2||$map3){
+            $res['rows'] =
+                Db::name("orgs")
+                    ->Join('t_ccjc','t_orgs.task_id=t_ccjc.id')
+                    ->where($sumMap)
+                    ->page($pageNum,$pageSize)
+                    ->select();
+            $res['total'] = Db::name("orgs")
+                ->Join('t_ccjc','t_orgs.task_id=t_ccjc.id')
+                ->where($sumMap)
+                ->count();
+        }else{
+            $res['rows'] = Db::name("orgs")
+                ->Join('t_ccjc','t_orgs.task_id=t_ccjc.id')
+                ->where($sumMap)
+                ->page($pageNum,$pageSize)
+                ->select();
+            $res['total'] = Db::name("orgs")->Join('t_ccjc','t_orgs.task_id=t_ccjc.id')->where($sumMap)->count();
+        }
+
+        return $this->jsonSuccessData($res);
+    }
+
+    public function getTaskcd(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $map1=[];
+        $map2=[];
+        $map3=[];
+        $map4=[];
+        if(isset($data['year'])){
+            $map1=[
+                ['year','=',$data['year']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['ispublic'])){
+            $map2=[
+                ['ispublic','=',$data['ispublic']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['task_name'])){
+            $map4=[
+                ['task_name','LIKE','%'.$data['task_name'].'%'],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        if(isset($data['starttime'])&&isset($data['endtime'])){
+            $map3=[
+                ['starttime','>=',$data['starttime']],
+                ['endtime','<=',$data['endtime']],
+                ['task_class','=',$data['task_class']]
+            ];
+        }
+        $sumMap=[];
+        if (count($map1)!=0){
+            $sumMap[]=$map1;
+        }
+        if (count($map2)!=0){
+            $sumMap[]=$map2;
+        }
+        if (count($map3)!=0){
+            $sumMap[]=$map3;
+        }if (count($map4)!=0){
+            $sumMap[]=$map4;
+        }else{
+            $sumMap[]=[
+                ['task_class','=',$data['task_class']],
+            ];
+
+        }
+        $unit_id=$this->request->user['unit_id']->getValue();
+        $sumMap[]=['t_undertake.bear_id','=',$unit_id];
+        $sumMap[]=['t_ccjc.ispublic','<>',0];
+        $sumMap[]=['t_ccjc.ispublic','<>',1];
+
+        if (count($sumMap)!=0){
+            $res['rows'] = Db::name("undertake")
+                ->Join('t_ccjc','t_undertake.task_id=t_ccjc.id')
+                ->where($sumMap)
+                ->select();
+//            $res['rows'] = Db::name("ccjc")->where($sumMap)->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("undertake")->Join('t_ccjc','t_undertake.task_id=t_ccjc.id')->where($sumMap)->count();
+//            $res['total'] = Db::name("ccjc")->where($sumMap)->count();
+        }else{
+            $res['rows'] = Db::name("undertake")->Join('t_ccjc','t_undertake.task_id=t_ccjc.id')->where($sumMap)->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("undertake")->Join('t_ccjc','t_undertake.task_id=t_ccjc.id')->where($sumMap)->count();
+
+        }
+
+        return $this->jsonSuccessData($res);
+    }
+
+    /**
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+
+
+
+    //1.在任务里添加承担单位    2.绑定关系undertake
+    public function AddUnderTask(){
+        $data=$this->request->post();
+        $data['userid']=$this->request->user['unit_id']->getValue();
+
+        $bear_name = Db::name('jcdw')->field('name')->where('id',$data['bear_id'])->find();
+//        dump($bear_name);die;
+        $report_name = Db::name('jcdw')->field('name')->where('id',$data['report_id'])->find();
+        $check_name = Db::name('jcdw')->field('name')->where('id',$data['check_id'])->find();
+        $map =[
+            'bear_name' => $bear_name['name'],
+            'report_name' => $report_name['name'],
+            'sample_number' => $data['sample_number'],
+            'address' => $data['address'],
+            'uploadtime' => $data['uploadtime'],
+            'task_id'=> $data['task_id'],
+            'unit_id'=> $data['userid'],
+            'bear_id'=> $data['bear_id'],
+            'report_id' => $data['report_id'],
+            'check_id' => $data['check_id'],
+            'check_name' => $check_name['name']
+        ];
+
+        $res = Db::name('undertake')->strict(false)->insert($map);
+
+        return $this->jsonSuccessData($res);
+    }
+
+    //牵头单位发布任务
+    public function qtRelease(){
+        $data=$this->request->post();
+        $res = Db::name('ccjc')->where('id',$data['task_id'])->update(['ispublic' => 5]);
+
+        return $this->jsonSuccessData($res);
+    }
+
+
+    //渲染所属牵头单位下承担单位的信息
+    public function getUnderTask(){
+        $data=$this->request->post();
+        $data['userid']=$this->request->user['unit_id']->getValue();
+        $map = [['task_id','=',$data['task_id']],['unit_id','=',$data['userid']]];
+        $res['rows'] = Db::name('undertake')->where($map)->select();
+        $res['total'] = Db::name('undertake')->where($map)->count();
+
+        return $this->jsonSuccessData($res);
+    }
+
+
+    //获取模型列表
+    public function  getModelList(){
+        $data = $this->request->post();
+        $data['userid']=$this->request->user['unit_id']->getValue();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        if($data['type_id']!=''){
+            $res['rows'] = Db::name('test_model')
+                ->field('t_test_model.id,t_test_model.name,t_test_model.type_id,t_test_model.creattime,t_test_model.updatetime')
+                ->where([['t_test_model.userid','=',$data['userid']],['t_test_model.type_id','=',$data['type_id']]])
+                ->leftJoin('t_test_product','t_test_model.id=t_test_product.test_model_id')
+                ->leftjoin('t_test_pesticides','t_test_model.id=t_test_pesticides.test_model_id')
+                ->distinct(true)
+                ->page($pageNum,$pageSize)
+                ->select();
+            $res['total'] = count(Db::name('test_model')->field('t_test_model.id,t_test_model.name,t_test_model.type_id')->where([['t_test_model.userid','=',$data['userid']],['t_test_model.type_id','=',$data['type_id']]])->leftJoin('t_test_product','t_test_model.id=t_test_product.test_model_id')->leftjoin('t_test_pesticides','t_test_model.id=t_test_pesticides.test_model_id')->distinct(true)->select());
+
+        }else {
+            $res['rows'] = Db::name('test_model')
+                ->field('t_test_model.id,t_test_model.name,t_test_model.type_id,t_test_model.creattime,t_test_model.updatetime')
+                ->where('t_test_model.userid', $data['userid'])
+                ->leftJoin('t_test_product', 't_test_model.id=t_test_product.test_model_id')
+                ->leftjoin('t_test_pesticides', 't_test_model.id=t_test_pesticides.test_model_id')
+                ->distinct(true)->page($pageNum, $pageSize)
+                ->select();
+            $res['total'] = count(Db::name('test_model')->field('t_test_model.id,t_test_model.name,t_test_model.type_id')->where('t_test_model.userid', $data['userid'])->leftJoin('t_test_product', 't_test_model.id=t_test_product.test_model_id')->leftjoin('t_test_pesticides', 't_test_model.id=t_test_pesticides.test_model_id')->distinct(true)->select());
+        }
+        return $this->jsonSuccessData($res);
+    }
+
+    //查看模型详情
+    public function  getModeldetail(){
+        $data = $this->request->post();
+
+            $res['name'] = Db::name('test_model')->where([
+                ['id','=',$data['id']]
+            ])->field('id,name,type_id')
+                ->find();
+
+        $res['pesticides'] = Db::name('test_pesticides')->where([
+            ['test_model_id','=',$data['id']]
+        ])->field('test_name as name,test_id as id')
+            ->select();
+
+        $res['product'] = Db::name('test_product')->where([
+            ['test_model_id','=',$data['id']]
+        ])->field('product_name as name,product_id as id')
+            ->select();
+
+        return $this->jsonSuccessData($res);
+    }
+
+
+    /**
+     *
+     */
+    public function test()
+    {
+        $data = $this->request->post();
+        $map = [['type_id','=',$data['type_id']],['parent_id','=','0'.$data['type_id']]];
+
+        $res=Db::name('product_class')->field('id,parent_id,product_code,name,alias')->where($map)->select()->toArray();
+
+        for ($i=0;$i<count($res);$i++){
+            $res[$i]['children']=Db::name('product_class')->field('id,parent_id,product_code,name,alias')->distinct(true)->where('parent_id','=',$res[$i]['product_code'])->select()->toArray();
+            for($j=0;$j<count($res[$i]['children']);$j++){
+                $res[$i]['children'][$j]['children']=Db::name('product_class')->field('id,parent_id,product_code,name,alias')->distinct(true)->where('parent_id','=',$res[$i]['children'][$j]['product_code'])->select()->toArray();
+
+            }
+        }
+        return $this->jsonSuccessData($res);
+    }
+    function tree($res,$parent_id){
+        $arr=[];
+        foreach ($res as $k=> $v){
+
+            if($v['parent_id']==$parent_id){
+                    unset($res[$k]);
+                    $v['children']=$this->tree($res, $v['product_code']);
+                    $arr[]=$v;
+            }
+        }
+
+        return $arr;
+    }
+    public function getProductList(){
+        $data = $this->request->post();
+        $map = [['type_id','=',$data['type_id']]];
+
+        $res=Db::name('product_class')->field('id,parent_id,product_code,name,alias')->where($map)->select()->toArray();
+
+        $arr_res = $this->tree($res,'0'.$data['type_id']);
+        return $this->jsonSuccessData($arr_res);
+    }
+    public function getPesticidesList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        if(isset($data['keyword'])){
+            $res['rows'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->count();
+
+        }else{
+            $res['rows'] = Db::name("pesticides")->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("pesticides")->count();
+
+        }
+        return $this->jsonSuccessData($res);
+
+    }
+
+    /**
+     *
+     * 农药残留表格
+     */
+//    新增模型
+    public function saveModel(){
+        $data=$this->request->post();
+        $data['userid']=$this->request->user['unit_id']->getValue();
+        $res['model']=Db::name('test_model')->strict(false)->insertGetId($data);
+        $product=[];
+        foreach ($data['product'] as $k=>$v){
+            $j=[];
+            $j['test_model_id']=$res['model'];
+            $j['product_id']=$v['id'];
+            $j['product_name']=$v['name'];
+            $product[]=$j;
+        }
+        $pesticides=[];
+        foreach ($data['pesticides'] as $i=>$o){
+            $p=[];
+            $p['test_model_id']=$res['model'];
+            $p['test_name']=$o['name'];
+            $p['test_id']=$o['id'];
+            $pesticides[]=$p;
+
+        }
+        $res['product']=Db::name('test_product')->strict(false)->insertAll($product);
+        $res['pesticides']=Db::name('test_pesticides')->strict(false)->insertAll($pesticides);
+        return $this->jsonSuccessData($res);
+
+    }
+
+    //修改模型
+    public function DoEditModelInfo(){
+        $data = $this->request->post();
+        $condition = ['id'=>$data['id']];
+        Db::name('test_model')
+            ->where($condition)
+            ->data(['name' => $data['name'],'type_id' =>$data['type_id']])
+            ->update();
+
+
+        $res['id']=$data['id'];
+        $res['type_id']=$data['type_id'];
+        Db::name('test_product')
+            ->where("test_model_id",$data['id'])
+        ->delete();
+
+        Db::name('test_pesticides')
+            ->where("test_model_id",$data['id'])
+            ->delete();
+
+        $product=[];
+        foreach ($data['product'] as $k=>$v){
+            $j=[];
+            $j['test_model_id']=$res['id'];
+            $j['product_id']=$v['id'];
+            $j['product_name']=$v['name'];
+            $product[]=$j;
+        }
+
+        $pesticides=[];
+        foreach ($data['pesticides'] as $i=>$o){
+            $p=[];
+            $p['test_model_id']=$res['id'];
+            $p['test_name']=$o['name'];
+            $p['test_id']=$o['id'];
+            $pesticides[]=$p;
+
+        }
+        $res['product']=Db::name('test_product')->strict(false)->insertAll($product);
+        $res['pesticides']=Db::name('test_pesticides')->strict(false)->insertAll($pesticides);
+        return $this->jsonSuccessData($res);
+
+    }
+
+//    删除模型
+    public function delModel(){
+        $data = $this->request->post();
+        $delarr = $data['delarr'];
+
+        $id = '';
+        for($j = 0; $j<count($delarr) ; $j++){
+            if ($j == 0){
+                $id = $delarr[$j]['id'];
+            }else{
+                $id = $delarr[$j]['id'].",".$id;
+            }
+        }
+
+        $map=[];
+        $map=[['test_model_id','in',$id]];
+
+        $map1 = [['id','in',$id]];
+
+        $result1 = Db::name("test_product")->where($map)->delete();
+
+        $result2 = Db::name("test_pesticides")->where($map)->delete();
+
+        $result3 = Db::name("test_model")->where($map1)->delete();
+
+
+        if($result1 && $result2 && $result3){
+            return $this->jsonData(0,"信息删除成功");
+        }else{
+            return $this->jsonData(-1,"信息删除失败");
+        }
+        return $this->jsonSuccessData($id);
+    }
+
+
+    public function bindModel(){
+        $data = $this->request->post();
+        $res = Db::name('ccjc')->where('id',$data['id'])->update(['is_divide'=>$data['is_divide'],'test_model_id'=>$data['test_model_id'],'endtime_cydsb'=>$data['endtime_cydsb']]);
+        return $this->jsonSuccessData($res);
+    }
+    public function getTestObj(){
+        $data=$this->request->post();
+        $model = Db::name('ccjc')->where('id',$data['id'])->field('test_model_id')->find();
+        $res = Db::name('test_model')->where('t_test_model.id',$model['test_model_id'])->join('t_test_product','t_test_model.id=t_test_product.test_model_id')->field('t_test_product.product_id,t_test_product.product_name')->select();
+        return $this->jsonSuccessData($res);
+    }
+    public function saveSample(){
+        $data=$this->request->post();
+        $data['units_id']=Db::name('units_test')->strict(false)->insertGetId($data['units']);
+        $data['product_unit']=Db::name('production')->strict(false)->insertGetId($data['production']);
+        $data['sample_unit']=$this->request->user['unit_id']->getValue();
+        $res=Db::name('cyd')->strict(false)->insert($data);
+        return $this->jsonSuccessData($res);
+
+    }
+    public function getSampleList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $data['sample_unit']=$this->request->user['unit_id']->getValue();
+        $map=[['t_cyd.sample_unit','=',$data['sample_unit']],['t_cyd.task_id','=',$data['task_id']]];
+
+        $res['rows'] = Db::name('cyd')->where($map)->field('t_cyd.id,t_cyd.sample_name,t_cyd.sample_id,t_cyd.sample_date,t_production.production_name,t_cyd.place,t_cyd.status,t_units_test.units_name,t_cyd.sample_unit_name,t_cyd.test_result,t_cyd.test_status,t_cyd.jc_value_id')->leftJoin('t_production','t_cyd.product_unit=t_production.id')->leftJoin('t_units_test','t_cyd.units_id=t_units_test.id')->page($pageNum,$pageSize)->select();
+        $res['total'] = Db::name('cyd')->where($map)->leftJoin('t_production','t_cyd.product_unit=t_production.id')->leftJoin('t_units_test','t_cyd.units_id=t_units_test.id')->count();
+        return $this->jsonSuccessData($res);
+    }
+    public function getSampleId(){
+        $data=$this->request->post();
+        $task = Db::name('ccjc')->where('id',$data['id'])->field('task_class')->find();
+        $count = Db::name('cyd')->whereDay('createtime','today')->count();
+        if($task['task_class']=="例行监测"){
+                $id['id'] = 'LXJC'.date('Y').date('m').date('d').date('H').date('m').str_pad(($count+1),4,0,STR_PAD_LEFT);
+        }else{
+            $id['id'] = 'ZXJC'.date('Y').date('m').date('d').date('H').date('m').str_pad(($count+1),4,0,STR_PAD_LEFT);
+
+        }
+        return $this->jsonSuccessData($id);
+    }
+    public function setSampleStatus(){
+        $data = $this->request->post();
+        foreach ($data as $k =>$v) {
+            $res = Db::name('cyd')->where('sample_id', $v['sample_id'])->update(['status' => 1]);
+        }
+        return $this->jsonSuccessData($res);
+    }
+    public function getTaskDetail(){
+        $data=$this->request->post();
+        $data['userid']=$this->request->user['unit_id']->getValue();
+        $res = Db::name('ccjc')->where('id',$data['task_id'])->find();
+        $res['releaserInfo'] = Db::name('jgry')->where('rymc',$res['releaser'])->field('groupname,rymc')->find();
+        $res['product']=Db::name('test_model')->field('t_test_product.product_name,t_test_model.type_id')
+            ->leftJoin('t_test_product','t_test_model.id=t_test_product.test_model_id')
+            ->where('t_test_model.id',$res['test_model_id'])->select();
+        $res['pesticides']=Db::name('test_model')->field('t_test_pesticides.test_name,t_test_model.type_id')
+            ->leftJoin('t_test_pesticides','t_test_model.id=t_test_pesticides.test_model_id')
+            ->where('t_test_model.id',$res['test_model_id'])->select();
+
+        $res['name']=Db::name('undertake')->where([['task_id','=',$data['task_id']],['unit_id','=',$data['userid']]])->select();
+
+
+
+        return $this->jsonSuccessData($res);
+    }
+    public function delSample(){
+        $data = $this->request->post();
+        foreach ($data as $k =>$v){
+            $unit = Db::name('cyd')->where('sample_id',$v['sample_id'])->find();
+            $res1=Db::name('units_test')->where('id',$unit['units_id'])->delete();
+            $res2=Db::name('production')->where('id',$unit['product_unit'])->delete();
+            $res = Db::name('cyd')->where('sample_id',$v['sample_id'])->delete();
+
+        }
+
+        return $this->jsonSuccessData($res);
+    }
+    public function getSampleDetail(){
+        $data=$this->request->post();
+        $map=[['t_cyd.sample_id','=',$data['sample_id']]];
+        $res = Db::name('cyd')->where($map)->Join('t_production','t_cyd.product_unit=t_production.id')->leftJoin('t_units_test','t_cyd.units_id=t_units_test.id')->find();
+        return $this->jsonSuccessData($res);
+    }
+    public function getTestPesticides(){
+        $data=$this->request->post();
+        $sample = Db::name('cyd')->where('sample_id',$data['sample_id'])->field('task_id')->find();
+        $model = Db::name('ccjc')->where('id',$sample['task_id'])->field('test_model_id')->find();
+        $test_model = Db::name('test_pesticides')->where('test_model_id',$model['test_model_id'])->field('test_name,test_id,test_model_id')->select();
+        return $this->jsonSuccessData($test_model);
+    }
+    public function saveSamplePesticides(){
+        $data=$this->request->post();
+        $id = '';
+        $test_result=1;
+        $islog = Db::name('sample_pesticides')->where('sample_id',$data['sample_id'])->select();
+        if (count($islog)!=0){
+            return $this->jsonResponse(-1,'不要重复提交检测信息',$islog);
+        }
+        foreach ($data['pesticides'] as $k=>$v){
+            $v['sample_id']=$data['sample_id'];
+            $idv=Db::name('sample_pesticides')->insertGetId($v);
+            $id.=$idv.',';
+            if ($v['test_result']=='不合格'){
+                $test_result=0;
+            }
+        }
+        $res=Db::name('cyd')->where('sample_id',$data['sample_id'])->update(['jc_value_id'=>$id,'test_result'=>$test_result]);
+        return $this->jsonSuccessData($res);
+    }
+    public function editSamplePesticides(){
+        $data=$this->request->post();
+
+        foreach ($data as $k=>$v){
+
+            $id=Db::name('sample_pesticides')->where('id',$v['id'])->update($v);
+
+        }
+        return $this->jsonSuccessData($id);
+    }
+    public function getTestValue(){
+        $data=$this->request->post();
+        $res['result_detail']=Db::name('sample_pesticides')->where('sample_id',$data['sample_id'])->select();
+        $res['result']=Db::name('cyd')->where('sample_id',$data['sample_id'])->find();
+        return $this->jsonSuccessData($res);
+    }
+    public function saveTestFile(){
+        $data=$this->request->post();
+        $data['unit_id']=$this->request->user['unit_id']->getValue();
+        $task = Db::name('cyd')->where('sample_id')->find();
+        $data['task_id']=$task['task_id'];
+        $res = Db::name('jcbg')->strict(false)->insertGetId($data);
+        return $this->jsonSuccessData($res);
+
+    }
+    public function getUnitsFileList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $data['unit_id']=$this->request->user['unit_id']->getValue();
+        $res['rows'] = Db::name('jcbg')->where('unit_id',$data['unit_id'])->page($pageNum,$pageSize)->select();
+        $res['total'] = Db::name('jcbg')->where('unit_id',$data['unit_id'])->count();
+        return $this->jsonSuccessData($res);
+    }
+    public function getGovFileList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+//        $data['unit_id']=$this->request->user['unit_id']->getValue();
+        $res['rows'] = Db::name('jcbg')->field('t_jcbg.file_name,t_jcbg.file_url,t_ccjc.task_name,t_ccjc.year,t_cyd.sample_name,t_cyd.test_result')->join('t_ccjc','t_jcbg.task_id=t_ccjc.id')->join('t_cyd','t_jcbg.sample_id=t_cyd.id')->page($pageNum,$pageSize)->select();
+        $res['total'] = Db::name('jcbg')->count();
+        return $this->jsonSuccessData($res);
+    }
+
+
+}

+ 34 - 0
app/api/controller/v1/Login.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/8
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\LoginBus;
+use app\BaseController;
+
+class Login extends BaseController
+{
+    //登录
+    public function login()
+    {
+
+        if (!$this->request->isPost()) return showError(config('status.illegal_request'));
+        //todo validate
+
+        $username = $this->request->param('login_name', '', 'trim');
+        $password = $this->request->param('pwd', '', 'trim');
+
+        $res=(new LoginBus())->login($username,$password);
+        return showSuccess($res);
+    }
+
+    //登出
+    public function logout()
+    {
+
+    }
+}

+ 123 - 0
app/api/controller/v1/Model.php

@@ -0,0 +1,123 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\controller\v1;
+
+
+//监测模型
+use app\api\business\ModelBus;
+
+class Model
+{
+    //获取模型表
+    public function selectModelList()
+    {
+        $data = [
+            'type_id' => request()->param('type_id', '', 'int'),
+            'pageNum' => request()->param('pageNum,', 1, 'int'),
+            'pageSize' => request()->param('pageSize', 10, 'int'),
+        ];
+
+        //todo validate
+
+        $result = (new ModelBus())->selectModelList($data);
+        return showSuccess($result);
+    }
+
+    public function bindModel()
+    {
+        $task_id = request()->param('id', '', 'int');
+        $data=[
+            'endtime_cydsb' => request()->param('endtime_cydsb', '', 'trim'),
+            'is_divide'=>request()->param('is_divide', '0', 'int'),
+            'test_model_id' => request()->param('test_model_id', '', 'int')
+        ];
+        $result = (new ModelBus())->updateInfoByTaskID($task_id,$data);
+        return showSuccess($result);
+    }
+
+    //获取模型信息
+    public function getModelInfo()
+    {
+        $model_id = request()->param('id','','int');
+        $result = (new ModelBus())->getModelInfo($model_id);
+        return showSuccess($result);
+    }
+
+    //更新模型
+    public function updateModelInfo()
+    {
+        //更新testModel;当提交时,修改updatetime
+        $model_id = request()->param('id','','int');
+        $model_type_id = request()->param('type_id','','int');
+        $model_name = request()->param('name','','trim');
+
+        $model_info = ['name' => $model_name, 'type_id' => $model_type_id];
+        $product=request()->param('product');
+        $pesticides=request()->param('pesticides');
+
+        //todo 下面这个修改在不修改本表时无法自增updatetime,需要修改一下
+        //更新模型信息包括三步,1、更新test_model 2、删除&重新添加test_product 3、删除&重新添加test_pesticides
+        $result = (new ModelBus())->updateModelInfo($model_id,$model_info,$product,$pesticides);//==true
+
+        return showSuccess($result);
+    }
+
+    //新增模型
+    public function createModelInfo()
+    {
+        //新增test_model表信息
+        $model_type_id = request()->param('type_id');
+        $model_name = request()->param('name');
+        $product_data = request()->param('product');
+        $pesticides_data = request()->param('pesticides');
+        $result = (new ModelBus())->createModelInfo($model_name, $model_type_id,$product_data,$pesticides_data);
+        return showSuccess($result);
+
+    }
+
+    //删除模型
+    public function deleteModelInfo()
+    {
+        $del_arr = request()->param('delarr');
+        $result = (new ModelBus())->deleteModelInfo($del_arr);
+        return showSuccess($result);
+    }
+
+    public function delModel(){
+        $data = $this->request->post();
+        $delarr = $data['delarr'];
+
+        $id = '';
+        for($j = 0; $j<count($delarr) ; $j++){
+            if ($j == 0){
+                $id = $delarr[$j]['id'];
+            }else{
+                $id = $delarr[$j]['id'].",".$id;
+            }
+        }
+
+        $map=[];
+        $map=[['test_model_id','in',$id]];
+
+        $map1 = [['id','in',$id]];
+
+        $result1 = Db::name("test_product")->where($map)->delete();
+
+        $result2 = Db::name("test_pesticides")->where($map)->delete();
+
+        $result3 = Db::name("test_model")->where($map1)->delete();
+
+
+        if($result1 && $result2 && $result3){
+            return $this->jsonData(0,"信息删除成功");
+        }else{
+            return $this->jsonData(-1,"信息删除失败");
+        }
+        return $this->jsonSuccessData($id);
+    }
+}

+ 48 - 0
app/api/controller/v1/Organizer.php

@@ -0,0 +1,48 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/12
+ */
+
+namespace app\api\controller\v1;
+
+//牵头单位
+
+use app\api\business\TaskBusOrganizer;
+use app\api\business\TaskBusUndertaker;
+
+class Organizer
+{
+    public function selectTaskList()
+    {
+        $task_class = request()->param('task_class');
+        $pageNum = request()->param('pageNum',1,'int');
+        $pageSize = request()->param('pageSize',10,'int');
+        $data=[
+            'year'=>request()->param('year','','trim'),//年度
+            'ispublic'=>request()->param('ispublic','','trim'),//任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+            'starttime' => request()->param('starttime','','trim'),//任务开始时间
+            'endtime' => request()->param('endtime','','trim'),//任务结束时间
+            'task_name' => request()->param('task_name','','trim'),//任务名称
+        ];
+        $result = (new TaskBusOrganizer())->selectTask($task_class,$pageNum,$pageSize,$data);
+        return showSuccess($result);
+    }
+
+    public function getTaskInfo()
+    {
+        $pageNum = request()->param('pageNum', 1, 'int');
+        $pageSize = request()->param('pageSize', null, 'trim');
+        $task_id = request()->param('task_id');
+        $result = (new TaskBusOrganizer())->getTaskInfo($task_id,$pageNum,$pageSize);
+        return showSuccess($result);
+    }
+
+    public function qtRelease()
+    {
+        $task_id = request()->param('task_id', '', 'int');
+        $result = (new TaskBusOrganizer())->releaseTask($task_id);
+        return showSuccess($result);
+    }
+}

+ 45 - 0
app/api/controller/v1/Pesticides.php

@@ -0,0 +1,45 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\PesticidesBus;
+
+class Pesticides
+{
+    public function selectPesticidesList()
+    {
+        //todo validate
+        $pageNum = request()->param('pageNum', 1, 'int');
+        $pageSize = request()->param('pageSize', 10, 'int');
+        $key_word = request()->param('keyword', '', 'trim');
+        $result = (new PesticidesBus())->selectPesticidesList($pageNum,$pageSize,$key_word);
+        return showSuccess($result);
+    }
+
+
+    public function getPesticidesList(){
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        if(isset($data['keyword'])){
+            $res['rows'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("pesticides")->where('name','like','%'.$data['keyword'].'%')->count();
+
+        }else{
+            $res['rows'] = Db::name("pesticides")->page($pageNum,$pageSize)->select();
+            $res['total'] = Db::name("pesticides")->count();
+
+        }
+        return $this->jsonSuccessData($res);
+
+    }
+
+
+
+
+}

+ 189 - 0
app/api/controller/v1/Product.old.php

@@ -0,0 +1,189 @@
+<?php
+namespace app\api\controller\v1;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+use think\exception\ValidateException;
+use think\facade\Request as re;
+use think\Request;
+use thans\jwt\JWT;
+use app\api\model\Chandi as ChandiModel;
+use app\api\model\Qy_basic;
+use app\api\model\Zd_cpmc;
+use app\api\model\Nszy as NszyModel;
+use think\File;
+use app\validate\Product as ProductValidate;
+use rsa\Rsa;
+
+class Product extends BaseController{
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' 	=> ['except' 	=> [] ],
+//        'login','AddProductInfo','DelProductInfo','DoEditProductInfo','QueryProductInfo'
+    ];
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+
+    /*产品增加*/
+    public function AddProductInfo() {
+//        加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $qydm=$data['qydm'];
+//        $cpmc=$data['cpmc'];
+//        try{
+//            validate(ProductValidate::class)->check(
+//                [
+//                    'qydm'=>$qydm,
+//                    'cpmc'=>$cpmc,
+//                    'ms' =>$data['ms'],
+//                    'cpgg'=>$data['cpgg'],
+//                    'bzq'=>$data['bzq'] ,
+//                ]
+//            );
+//        }catch (ValidateException $e){
+//            return ($e->getError());
+//        }
+        $qy=Qy_basic::Where('qydm','=',$qydm)->find();
+        if($qy){
+            $jd=Zd_cpmc::field('cpbh')->where('qydm','=',$qydm)->select();
+            //dump($jd);die;
+            $wz=count($jd) - 1;//产品数量-1
+            // dump($wz);die;
+            if(count($jd)){
+                $x="1".$jd[$wz]['cpbh'];//对应最后一条cpbh
+                $y=intval($x)+1;
+                $data["cpbh"]=substr($y,1);
+            }else{
+                $data["cpbh"]='001';
+            }
+
+            //dump($data);die;
+            //新增记录
+            $result = Zd_cpmc::create($data);
+
+//            $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+
+            if($result) {
+                return $this->jsonData(0,"添加成功");
+            }else {
+                return $this->jsonData(-1,"添加错误");
+            }
+        }
+        else{
+            return $this->jsonData(-2,"企业未注册");
+        }
+
+
+    }
+
+
+    /*产品删除*/
+    public function DelProductInfo(){
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $Zd_cpmc = new Zd_cpmc();
+        $bh = $data['bh'];
+        $del=$Zd_cpmc->delproduct($bh);
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($data)); //公钥加密
+        if ($del == '1') {
+            return $this->jsonData(
+                0,
+                "删除成功"
+            );
+        } else {
+            return $this->jsonData(-1, "删除失败");
+        }
+
+    }
+
+
+    /*执行产品修改*/
+    public function DoEditProductInfo() {
+        $data = $this->request->post();
+        //设置更新条件
+        $condition = ['bh'=>$data['bh']];
+
+        //更新当前记录
+        $result = Zd_cpmc::update($data,$condition);
+
+        if ($result) {
+            return $this->jsonData(0,"修改成功");
+
+        } else {
+            return $this->jsonData(-1, "修改失败");
+        }
+    }
+
+
+    /*产品查询*/
+    public function QueryProductInfo(){
+   
+
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $query=$data['query'];
+        $qydm=$data['qydm'];
+        if($query){
+            $result['rows']=Zd_cpmc::where([
+                ['cpmc', 'like', '%'.$query .'%'],
+                ['t_zd_cpmc.qydm', '=', $qydm]
+            ])
+                ->field("t_zd_cpmc.*,t_qy_basic.qymc")
+                ->leftjoin('t_qy_basic',' t_zd_cpmc.qydm=t_qy_basic.qydm')
+                ->page($pageNum,$pageSize)
+                ->select();
+            $result['pages']=$pageNum;
+            $result['total']=Zd_cpmc::where(
+                [
+                    ['cpmc', 'like', '%'.$query .'%'],
+                    ['t_zd_cpmc.qydm', '=', $qydm]
+                ]
+            )
+                ->select()
+                ->count('bh');
+        }
+        else{
+            $result['rows']=Zd_cpmc::where([
+                ['t_zd_cpmc.qydm', '=', $qydm]
+            ])
+                ->field("t_zd_cpmc.*,t_qy_basic.qymc")
+                ->leftjoin('t_qy_basic',' t_zd_cpmc.qydm=t_qy_basic.qydm')
+                ->page($pageNum,$pageSize)
+                ->select();
+            $result['pages']=$pageNum;
+            $result['total']=Zd_cpmc::where(
+                [
+                    ['cpmc', 'like', '%'.$query .'%'],
+                    ['t_zd_cpmc.qydm', '=', $qydm]
+                ]
+            )
+                ->select()
+                ->count('bh');
+        }
+
+  
+
+        if($result){
+            return $this->jsonSuccessData($result);
+        }
+        else{
+            return $this->jsonData('-1',"查询错误");
+        }
+    }
+
+
+
+
+}

+ 21 - 0
app/api/controller/v1/Product.php

@@ -0,0 +1,21 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\ProductBus;
+
+class Product
+{
+    public function selectProductList()
+    {
+        $type_id = request()->param('type_id', 1, 'int');
+        $result = (new ProductBus())->selectProductList($type_id);
+        return showSuccess($result);
+    }
+
+}

+ 140 - 0
app/api/controller/v1/Production.php

@@ -0,0 +1,140 @@
+<?php
+namespace app\api\controller\v1;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+use think\exception\ValidateException;
+use think\facade\Request as re;
+use think\Request;
+use thans\jwt\JWT;
+use app\api\model\Chandi as ChandiModel;
+use app\api\model\Qy_basic;
+use app\api\model\Zd_cpmc;
+use app\api\model\Nszy as NszyModel;
+use think\File;
+use app\validate\Production as ProductValidate;
+use app\api\model\Chanpin;
+use rsa\Rsa;
+
+class Production extends BaseController{
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' 	=> ['except' 	=> []],
+//        'login','AddProductionInfo','DelProductionInfo','DoEditProductionInfo','QueryProductionInfo'
+    ];
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+
+    /*产品生产增加*/
+    public function AddProductionInfo(){
+        $data = $this->request->post();
+        $qydm=$data['qydm'];
+        $rq=$data['rq'];
+
+        $jd=Chanpin::where([['qydm','=',$qydm], ['rq','=',$rq]])->field('pch')->order('pch','desc')->select();
+        $pcqz = substr($rq,2,2).substr($rq,5,2).substr($rq,8,2);
+        if(count($jd)){
+            $data["pch"]=$jd[0]['pch']+1;
+        }else{
+            $data["pch"]=$pcqz.'01';
+        }
+        $result=Chanpin::create($data);
+        if($result){
+            return $this->jsonData(0,"信息添加成功");
+        }else{
+            return $this->jsonData(-1,"信息添加失败");
+        }
+    }
+
+
+    /*产品生产删除*/
+    public function DelProductionInfo(){
+        $data = $this->request->post();
+        $result = Chanpin::where('bh',$data['bh'])->delete();
+        if($result){
+            return $this->jsonData(0,"信息删除成功");
+        }else{
+            return $this->jsonData(-1,"信息删除失败");
+        }
+    }
+
+
+    /*产品生产修改*/
+    public function DoEditProductionInfo(){
+        $data = $this->request->post();
+        //设置更新条件
+        $condition = ['bh'=>$data['bh']];
+
+        //更新当前记录
+        $result = Chanpin::update($data,$condition);
+
+        if ($result) {
+            return $this->jsonData(0, "信息修改成功");
+        } else {
+            return $this->jsonData(-1, "信息修改失败");
+        }
+    }
+
+
+    /*生产产品查询*/
+    public function QueryProductionInfo(){
+
+        $data = $this->request->post();
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $query=$data['query'];
+        $qydm=$data['qydm'];
+
+        if($query){
+            $result['rows']=Chanpin::where([
+                ['cpmc', 'like', '%'.$query .'%'],
+                ['t_chanpin.qydm', '=', $qydm]
+            ])
+                ->field("t_chanpin.*,t_qy_basic.qymc,t_zd_cpmc.cpgg,t_zd_cpmc.cpmc")
+                ->join('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->join('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->page($pageNum,$pageSize)
+                ->select();
+            $result['pages']=$pageNum;
+            $result['total']=Chanpin::where([
+                ['cpmc', 'like', '%'.$query .'%'],
+                ['t_chanpin.qydm', '=', $qydm]
+            ])
+                ->join('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->join('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->select()
+                ->count('bh');
+        }
+        else{
+            $result['rows']=$result['rows']=Chanpin::where([
+                ['t_chanpin.qydm', '=', $qydm]
+            ])
+                ->field("t_chanpin.*,t_qy_basic.qymc,t_zd_cpmc.cpgg,t_zd_cpmc.cpmc")
+                ->join('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->join('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->page($pageNum,$pageSize)
+                ->select();
+            $result['pages']=$pageNum;
+            $result['total']=Chanpin::where([
+                ['t_chanpin.qydm', '=', $qydm]
+            ])
+                ->join('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->join('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->select()
+                ->count('bh');
+        }
+
+        if($result){
+            return $this->jsonSuccessData($result);
+        }
+        else{
+            return $this->jsonData('-1',"查询错误");
+        }
+    }
+
+
+}

+ 30 - 0
app/api/controller/v1/ResponseJson.php

@@ -0,0 +1,30 @@
+<?php
+// 此为ResponseJson.php
+namespace app\api\controller\v1;
+trait ResponseJson
+{
+ 
+    // 当接口出现异常时的返回
+    public function jsonData($code,$message,$data = [])
+    {
+        return $this->jsonResponse($code,$message,$data);
+    }
+ 
+    // app接口请求成功的返回
+    public function jsonSuccessData($data = [])
+    {
+        return $this->jsonResponse(0,'success',$data);
+    }
+ 
+    // 返回一个json
+	private function jsonResponse($code,$message,$data = [])
+	{
+		$content = [
+			'code'=>$code,
+			'message'=>$message,
+			'data'=>$data,
+		];
+		return json($content)->cookie('url','http://jcsy.aielab.net');
+	}
+ 
+}

+ 130 - 0
app/api/controller/v1/Sample.old.php

@@ -0,0 +1,130 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\business\SampleBus;
+use app\api\model\Ry;
+use app\api\model\Ryjr as RyjrModel;
+use app\api\model\Subject;
+use app\api\model\Ry as RyModel;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+use think\exception\ValidateException;
+use think\facade\Db;
+use think\facade\Filesystem;
+use think\facade\Request as re;
+use think\Request;
+use think\facade\Cache;
+use thans\jwt\JWT;
+use rsa\Rsa;
+
+class Sample extends BaseController{
+
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' => ['except' => ['uploadfile']],
+//        'check' => ['except' => ['login']]
+
+    ];
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    /*
+* 上传文件
+*/
+    public function uploadfile(){
+        $file = request() -> file('file');              //接收文件
+//        dump($file);die();
+        if ($file == null) {                                    //判断文件是否为空
+            return $this ->jsonResponse(-1,'未上传文件');
+        }
+        /*
+         * 截取上传文件名后缀
+         * 将文件名以.分割为数组
+         * 用PHP end函数取数组最后一个
+         * 即可得到上传文件后缀
+         */
+        $temp = explode(".", $_FILES["file"]["name"]);
+//        dump($temp);die();
+        $extension = end($temp);
+        /*
+         * 判断上传文件是否合法
+         * 判断截取上传文件名是否为
+         * jpeg,jpg,png其中之一
+         */
+        if(!in_array($extension, array("pdf","PDF","DOC","doc","docx","DOCX","PNG","png"))){
+            return $this ->jsonResponse(-2,'上传文件不合法');
+        }
+        try {
+            validate(['file' => ['fileSize:10*1024*1024']])->check(['file' => $file]);
+        } catch (ValidateException $e) {
+            $return['msg'] = $e->getMessage();
+
+        }
+        /*
+         * 调用disk方法
+         * 此时根目录为/public/uploads
+         * 再把文件移动至uploads下的photo文件夹里
+         * 文件名用md5
+         */
+        $saveName = Filesystem::disk('public') -> putFile('file', $file, 'md5');
+        /*
+         * 这里只返回从uploads开始的路径
+         * 可以根据自己的需求返回需要的路径
+         */
+
+        $res = str_replace('\\', '/', 'http://syjc.aielab.net/uploads/'.$saveName);
+//       $res=(str_replace('\\', '', '/uploads/' . $saveName));
+
+        if($res){
+            return $this->jsonSuccessData($res);
+        }
+        else{
+            return $this->jsonData(-1,"上传文件失败");
+        }
+
+    }
+
+    /**
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * 获取任务接口:param: id pageNum  pageSize
+     */
+    public function getSampleList(){
+        $data = $this->request->post();
+        $id=$data['id'];
+        $pageNum=$data['pageNum'];
+        $pageSize=$data['pageSize'];
+        $res['rows'] = Db::name("cyd")->where('rwid','=',$id)->field('ypmc,ypbh,cyjs,cycs,status,brand')->page($pageNum,$pageSize)->select();
+        $res['total'] = Db::name("cyd")->count();
+        return $this->jsonSuccessData($res);
+    }
+
+//获取抽样单详情
+    public function getSampleDetail(){
+        $data = $this->request->post();
+        $id=$data['id'];
+        $res['rows'] = Db::name("cyd")->where('id','=',$id)
+            ->field('ypmc,ypbh,cyjs,cycs,status,brand')
+            ->leftJoin('t_','student_user.auth=student_teacher.auth and student_user.login_name=student_teacher.number and student_user.name=student_teacher.name')
+            ->find();
+        $res['total'] = Db::name("cyd")->count();
+        return $this->jsonSuccessData($res);
+    }
+    /**、
+     * @return \think\response\Json
+     * 添加任务
+     */
+    public function addSample(){
+        $data = $this->request->post();
+        $resid=Db::name("cyd")->strict(false)->insertGetId($data);
+        return $this->jsonSuccessData($resid);
+    }
+
+
+}

+ 54 - 0
app/api/controller/v1/Sample.php

@@ -0,0 +1,54 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/14
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\SampleBus;
+
+class Sample
+{
+
+    public function selectSampleList()
+    {
+        $task_id = request()->param('task_id', '', 'int');
+        $pageNum = request()->param('pageNum', '1', 'int');
+        $pageSize = request()->param('pageSize', '10', 'int');
+        $result = (new SampleBus())->selectSampleList($task_id, $pageNum, $pageSize);
+        return showSuccess($result);
+    }
+
+    public function getSampleObj()
+    {
+        $task_id = request()->param('id','','int');
+        $result = (new SampleBus())->getSampleObj($task_id);
+        return showSuccess($result);
+    }
+
+    public function createSampleId()
+    {
+//
+//        $data=$this->request->post();
+//        $task = Db::name('ccjc')->where('id',$data['id'])->field('task_class')->find();
+//        $count = Db::name('cyd')->whereDay('createtime','today')->count();
+//        if($task['task_class']=="例行监测"){
+//            $id['id'] = 'LXJC'.date('Y').date('m').date('d').date('H').date('m').str_pad(($count+1),4,0,STR_PAD_LEFT);
+//        }else{
+//            $id['id'] = 'ZXJC'.date('Y').date('m').date('d').date('H').date('m').str_pad(($count+1),4,0,STR_PAD_LEFT);
+//
+//        }
+    }
+
+    public function createSample()
+    {
+
+        return $this->jsonSuccessData($res);
+        $data=[
+            ''
+        ];
+    }
+
+}

+ 83 - 0
app/api/controller/v1/Superviser.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/9
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\SuperviserTaskBus;
+use app\api\business\TestUnitBus;
+
+//监管单位
+class Superviser
+{
+
+    //查找任务
+    public function select()
+    {
+        //获取请求参数
+        $data=[
+            'pageNum' => request()->param('pageNum',1,'trim'),//页码
+            'pageSize' => request()->param('pageSize',10,'trim'),//每页显示数量
+            'task_class' => request()->param('task_class','例行监测','trim'),//任务列表:例行监测  专项监测
+            'year'=>request()->param('year','','trim'),//年度
+            'ispublic'=>request()->param('ispublic','','trim'),//任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+            'starttime' => request()->param('starttime','','trim'),//任务开始时间
+            'endtime' => request()->param('endtime','','trim'),//任务结束时间
+            'task_name' => request()->param('task_name','','trim'),//任务名称
+        ];
+        //todo validate
+
+        $res= (new SuperviserTaskBus())->selectTask($data);
+        return showSuccess($res);
+    }
+
+    //添加任务
+    public function create()
+    {
+        //获取请求参数
+        $data=[
+            'task_name'=>request()->param('task_name','','trim'),//任务名称
+            'level'=>request()->param('level','','trim'),//任务优先级,0:一般,1:紧急,2:特急
+            'year'=>request()->param('year','','trim'),//年度
+            'batch' => request()->param('batch', '', 'trim'),//批次,第一季度,第二季度,第三季度,第四季度
+            'starttime' => request()->param('starttime','','trim'),//任务开始时间
+            'endtime' => request()->param('endtime','','trim'),//任务结束时间
+            'filenum' => request()->param('filenum', '', 'trim'),//文件号---选填
+            'log' => request()->param('log', '', 'trim'),//备注---选填
+            'file_url' => request()->param('file_url'),//附件地址
+            'file_name' => request()->param('file_name', '', 'trim'),//附件名称
+            'releaser' => request()->param('releaser', '', 'trim'),//发布单位//todo 固定好的,禁止修改,不需要传参
+            'task_class' => request()->param('task_class', '', 'trim'),//任务类型:task_class
+            'ispublic' => request()->param('ispublic', 0, 'trim'),//发布状态 todo 默认为0
+            'main_unit' => request()->param('main_unit', '', 'trim'),//牵头单位 //是orgs的name字段 二班,三班,四班,
+        ];
+        $orgs=request()->param('orgs', '', 'trim');
+
+        //todo validate
+        $res= (new SuperviserTaskBus())->createTask($data,$orgs);
+        return showSuccess($res);
+    }
+
+
+    //删除任务
+    public function delete()
+    {
+        //获取需要删除的数据的id号码
+        $arr_del_task=request()->param('delarr', '', 'trim');
+        $result = (new SuperviserTaskBus())->deleteTask($arr_del_task);
+        return showSuccess($result);
+
+    }
+
+    //修改任务
+    public function update()
+    {
+        $data = request()->param('pubarr', '', 'trim');
+        $result = (new SuperviserTaskBus())->updateTask($data);
+        return showSuccess($result);
+    }
+
+}

+ 37 - 0
app/api/controller/v1/TaskCommon.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/13
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\business\TaskBusOrganizer;
+use app\api\business\TestUnitBus;
+
+class TaskCommon
+{
+    //获取检测单位列表(抽样机构 todo 增加查询功能 检测单位和抽样单位可以写到一起
+
+    public function getTestUnitList()
+    {
+        $pageNum = request()->param('pageNum',1,'int');
+        $pageSize = request()->param('pageSize',10,'int');
+        $group_type = request()->param('groupname', '检测机构', 'trim');//todo 这里看以后的数据安排,先默认显示检测机构的分组
+        $data=[
+            'name' => request()->param('name','','trim'),
+        ];
+        $result = (new TestUnitBus())->selectTestUnit($data,$group_type,$pageNum,$pageSize);
+        return showSuccess($result);
+    }
+
+    public function getTaskInfo()
+    {
+        $task_id = request()->param('task_id');
+        $result = (new TaskBusOrganizer())->getTaskInfo($task_id);
+        return showSuccess($result);
+
+    }
+
+}

+ 252 - 0
app/api/controller/v1/Traceability.php

@@ -0,0 +1,252 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\model\Chanpin;
+use app\api\model\Chandi;
+use app\api\model\Qy_basic;
+use app\api\model\Zd_cpmc;
+use app\api\model\Sym;
+use app\api\model\Nszy;
+use app\api\model\Trpsy;
+use OpenApi\Annotations as OA;
+use app\BaseController;
+use thans\jwt\facade\JWTAuth;
+//use think\Db;
+use think\facade\Request as re;
+use think\Request;
+use thans\jwt\JWT;
+use app\validate\Chandi as ChandiValidate;
+use think\exception\ValidateException;
+use rsa\Rsa;
+//use think\Facade\Db;
+
+class Traceability extends BaseController
+{
+    use ResponseJson;
+    protected $request;
+    protected $middleware = [
+        'jwt' => ['except' => []],
+//        'SelectProductionInfo','TraceabilityPrint','TraceabilityPrint2','ShowInformation'
+    ];
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+
+    //溯源码打印界面,选择产品批次号接口
+    public function SelectProductionInfo(){
+
+        $data = $this->request->post();
+        $query=$data['query'];
+        $qydm=$data['qydm'];
+
+        if($query){
+            $result['rows']=Chanpin::
+                where([
+                    ['t_chanpin.qydm', '=', $qydm],
+                    ['t_zd_cpmc.cpmc', 'like', '%'.$query .'%']
+                ])
+                ->field("t_chanpin.*,t_qy_basic.qymc,t_zd_cpmc.cpgg,t_zd_cpmc.cpmc")
+                ->leftJoin('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->leftJoin('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->select();
+            $result['total']=Chanpin::
+            where([
+                ['t_chanpin.qydm', '=', $qydm],
+                ['t_zd_cpmc.cpmc', 'like', '%'.$query .'%']
+            ])
+                ->field("t_chanpin.*,t_qy_basic.qymc,t_zd_cpmc.cpgg,t_zd_cpmc.cpmc")
+                ->leftJoin('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->leftJoin('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->count();
+        }
+
+        else{
+            $result['rows']=Db::name('chanpin')
+                ->where('t_chanpin.qydm', '=', $qydm)
+                ->field("t_chanpin.*,t_qy_basic.qymc,t_zd_cpmc.cpgg,t_zd_cpmc.cpmc")
+                ->leftJoin('t_zd_cpmc','t_chanpin.cpbh=t_zd_cpmc.cpbh and t_chanpin.qydm=t_zd_cpmc.qydm')
+                ->leftJoin('t_qy_basic','t_chanpin.qydm=t_qy_basic.qydm')
+                ->select();
+            $result['total']=Db::name('chanpin')->where('t_chanpin.qydm', '=', $qydm)->count();
+        }
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($result)); //公钥加密
+
+            if($result){
+                return $this->jsonSuccessData($result);
+            }
+            else{
+                return $this->jsonData(-1,"无查询结果");
+            }
+    }
+
+
+
+    /*溯源码打印功能,先输入信息,后打码*/
+    public function TraceabilityPrint(){
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $nums = $data['nums'];
+        $cpmc = $data['cpmc'];
+        $pch = $data['pch'];
+        $qydm= $data['qydm'];
+
+        $bh = Qy_basic::where('t_qy_basic.qydm','=',$qydm)->field('t_qy_basic.bh,t_qy_basic.qymc,t_qy_basic.fzrtel')->find();
+        $result = Chanpin::where([
+            ['t_chanpin.qydm', '=', $qydm],
+            ['t_chanpin.pch', '=',$pch]
+        ])
+            ->field('t_chanpin.chandi,t_chanpin.rq')
+            ->find();
+        $chandi = $result['chandi'];
+        $ret = Chandi::where([
+            ['t_chandi.qydm', '=', $qydm],
+            ['t_chandi.chandi', '=',$chandi]
+        ])
+            ->field('t_chandi.*')
+            ->find();
+        $rets = Zd_cpmc::where([
+            ['t_zd_cpmc.qydm', '=', $qydm],
+            ['t_zd_cpmc.cpmc', '=',$cpmc]
+        ])
+            ->find();
+
+
+        for($i=0;$i<$nums;$i++){
+
+            $numbers=rand(10000,19999);
+            $symMes['qydm'] = $qydm;
+            $symMes['cpbh'] = $rets['cpbh'];
+            $symMes['cdbh'] = $ret['cdbh'];
+            $symMes['pch'] = $pch;
+            $symMes['date'] = date("Y-m-d");
+            $symMes['sym']=$bh['bh'].reter(substr($data['pch'],0,2)).
+                reter(substr($data['pch'],2,2)).
+                reter(substr($data['pch'],4,2)).
+                substr($data['pch'],6,2).substr($numbers,0,5);
+            $Infomation[$i]['sym'] = $symMes['sym'];
+            $symres = Sym::create($symMes);
+        }
+
+//        dump($symres);die();
+        /*以上部分完成溯源码的生成*/
+        /*下面开始完成根据$symres['bh']查找该条溯源码的信息*/
+
+        $infomations = array();
+        for($i=0;$i<$nums;$i++) {
+            $infomations[$i]['qymc'] = $bh['qymc'];
+            $infomations[$i]['fzrtel'] = $bh['fzrtel'];
+            $infomations[$i]['sym'] = $Infomation[$i]['sym'];
+            $infomations[$i]['date'] = $result['rq'];
+            $infomations[$i]['cpmc'] = $cpmc;
+            $infomations[$i]['chandi'] = $ret['chandi'];
+            $infomations[$i]['cpgg'] = $rets['cpgg'];
+            $infomations[$i]['url'] = 'http://www.aielab.net/ah/S?'.$Infomation[$i]['sym'];
+        }
+
+//        $infomations['qymc'] = $bh['qymc'];
+//        $infomations['fzrtel'] = $bh['fzrtel'];
+//        $infomations['sym'] = $symres['sym'];
+//        $infomations['date'] = $result['rq'];
+//        $infomations['cpmc'] = $cpmc;
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($infomations)); //公钥加密
+
+        if($infomations){
+            return $this->jsonSuccessData($infomations);
+        }else{
+            return $this->jsonData(-1,'无查询结果');
+        }
+
+    }
+
+
+
+    /*溯源码打印功能,先生成溯源码,后补充信息*/
+    public function TraceabilityPrint2(){
+
+        $data = $this->request->post();
+        $qydm = $data['qydm'];
+
+        $bh = Qy_basic::where('qydm','=',$qydm)->field('bh')->find();
+        $randomnums = generate_word();
+        $numbers=rand(10000,19999);
+        $symMes['sym']=$bh['bh'].$randomnums.substr($numbers,0,5);
+        $symMes['date'] = date("Y-m-d");
+        $symMes['qydm'] = $qydm;
+        $symres = Sym::create($symMes);
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($symres)); //公钥加密
+
+        if($symres){
+            return $this->jsonSuccessData($symres);
+        }else{
+            return $this->jsonData(-1,'无查询结果');
+        }
+    }
+
+
+
+    /*扫码显示界面的信息*/
+    public function ShowInformation(){
+        //加密
+//        require_once(dirname(__FILE__)."/Rsa.php");
+//        $rsa = new Rsa();
+
+        $data = $this->request->post();
+        $qydm = $data['qydm'];
+
+        $symresult  =  Sym::where('t_sym.sym','=',$data['sym'])->field("t_sym.pch,t_sym.cdbh,t_sym.cpbh,t_sym.qydm")->find();
+//        dump($symresult);die();
+        $information  =  Qy_basic::where('t_qy_basic.qydm','=',$qydm)->field("t_qy_basic.dwjj,t_qy_basic.qymc,t_qy_basic.fzrtel")->find();
+        $productresult  =  Zd_cpmc::where([
+            ['t_zd_cpmc.cpbh','=',$symresult['cpbh']],
+            ['t_zd_cpmc.qydm','=',$qydm]
+        ])
+            ->field("t_zd_cpmc.cpmc,t_zd_cpmc.picname,t_zd_cpmc.bzq,t_zd_cpmc.ms,t_zd_cpmc.cpgg")
+            ->find();
+        $chanpinresult  = Chanpin::where([
+            ['t_chanpin.pch','=',$symresult['pch']],
+            ['t_chanpin.qydm','=',$qydm]
+        ])
+            ->field("t_chanpin.rq,t_chanpin.chandi")
+            ->find();
+        $nszyresult  = Nszy::where([
+            ['t_nszy.cdbh','=',$symresult['cdbh']],
+            ['t_nszy.qydm','=',$qydm]
+        ])
+            ->field("t_nszy.nszy,t_nszy.trpmc,t_nszy.zyl,t_nszy.zyldw,t_nszy.rq,t_nszy.zyr")
+            ->select();
+        $trpresult  = Trpsy::where([
+            ['t_trpsy.cdbh','=',$symresult['cdbh']],
+            ['t_trpsy.qydm','=',$qydm]
+        ])
+            ->field("t_trpsy.trpm,t_trpsy.trpgg,t_trpsy.cgrq,t_trpsy.cgr")
+            ->select();
+
+        $information['cpmc'] = $productresult['cpmc'];
+        $information['bzq'] = $productresult['bzq'];
+        $information['ms'] = $productresult['ms'];
+        $information['cpgg'] = $productresult['cpgg'];
+        $information['picname'] = "http://qklapi.ahaia.net/Uploads/".$qydm."/".$productresult['picname'];
+        $information['rq'] = $chanpinresult['rq'];
+        $information['chandi'] = $chanpinresult['chandi'];
+        $information['nszy'] = $nszyresult;
+        $information['trpsy'] = $trpresult;
+
+//        $publicEncrypt = $rsa->publicEncrypt(json_encode($information)); //公钥加密
+
+        if($symresult['pch']&&$symresult['cpbh']!=null) {
+            return $this->jsonSuccessData($information);
+        }else if($symresult==null) {
+            return $this->jsonData(-1, "该溯源码不存在");
+        }
+
+    }
+
+}

+ 54 - 0
app/api/controller/v1/Undertaker.php

@@ -0,0 +1,54 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/12
+ */
+
+namespace app\api\controller\v1;
+
+//承担单位
+use app\api\business\TaskBusOrganizer;
+use app\api\business\TaskBusUndertaker;
+use app\api\model\Undertake;
+
+class Undertaker
+{
+    public function createUnderTaker()
+    {
+        $data = [
+            'task_id' => request()->param('task_id','','int'),
+            'bear_id' => request()->param('bear_id','','int'),//抽样机构
+            'check_id' => request()->param('check_id','','int'),//检测机构
+            'report_id' => request()->param('report_id','','int'),//报告上传单位
+            'address' => request()->param('address','','trim'),//抽样地址
+            'upload_time' => request()->param('uploadtime'),//报告上传时间
+            'sample_number' => request()->param('sample_number'),//样本数量
+        ];
+        $result = (new TaskBusUndertaker())->createUnderTakerInfo($data);
+        return showSuccess($result);
+    }
+
+    public function deleteUnderTaskList()
+    {
+        $del_arr = request()->param('delarr', '', 'trim');
+        $result = (new TaskBusUndertaker())->deleteUnderTaker($del_arr);
+        return showSuccess($result);
+    }
+
+    public function selectUndertakerTaskList()
+    {
+        $task_class = request()->param('task_class','例行监测','trim');
+        $pageNum = request()->param('pageNum',1,'int');
+        $pageSize = request()->param('pageSize',10,'int');
+        $data=[
+            'year'=>request()->param('year','','trim'),//年度
+            'ispublic'=>request()->param('ispublic','','trim'),//任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
+            'starttime' => request()->param('starttime','','trim'),//任务开始时间
+            'endtime' => request()->param('endtime','','trim'),//任务结束时间
+            'task_name' => request()->param('task_name','','trim'),//任务名称
+        ];
+        $result = (new TaskBusUndertaker())->selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data);
+        return showSuccess($result);
+    }
+}

+ 23 - 0
app/api/controller/v1/Upload.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/10
+ */
+
+namespace app\api\controller\v1;
+
+use app\api\exception\ApiException;
+use app\common\lib\upload\AliyunOss;
+use think\Exception;
+use think\exception\ValidateException;
+
+class Upload
+{
+    public function upload()
+    {
+        $file = request()->file('file');
+        $upload = (new AliyunOss())->Upload($file);
+        return $upload;
+    }
+}

+ 24 - 0
app/api/exception/ApiException.php

@@ -0,0 +1,24 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/8/29
+ */
+
+namespace app\api\exception;
+
+use Throwable;
+
+//具体的handle方法在app\ExceptionHandle.php 中
+class ApiException extends \RuntimeException
+{
+
+    public function __construct(array $apiErrCode,Throwable $previous = null)
+        //ApiException(config('status.err_user_not_exist')
+        //这里array $apiErrCode改成数组是为了方便调用配置文件。config('status.success')
+    {
+        $code = $apiErrCode[0];
+        $message = $apiErrCode[1];
+        parent::__construct($message, $code, $previous);
+    }
+}

+ 49 - 0
app/api/middleware/CheckAllow.php

@@ -0,0 +1,49 @@
+<?php
+namespace app\api\middleware;
+use think\Request;
+use think\facade\Cache;
+class CheckAllow
+{
+    /*
+* 中间件验证redis中ip和token
+*/
+    protected $request;
+    public function handle($request, \Closure $next)
+    {
+//        1.拿到token
+        $data = $request->param();
+//        2.获取ip
+        $ip= $request->ip();
+        
+        $iip = @file_get_contents("https://opendata.baidu.com/api.php?query=".$ip."&co=&resource_id=6006&oe=utf8");
+
+		$iip = json_decode($iip,true);
+		
+//        3.获取redis缓存token
+       $token1 =  Cache::store('redis')->get($ip);
+       if($token1){
+//           存在该token,比对
+           if($token1!=$data['token']){
+               return json('非法请求!');
+           }else{
+               /*if($iip["status"]=="0"){
+		            if (explode("省",$iip["data"][0]["location"])[0]!="安徽") {
+				        if ($ip!="121.41.26.116"&$ip!="47.114.151.35"&$ip!="116.62.247.203") {
+					        return json('非法请求!');
+				            }else{
+				             //               存在且相同,下一步请求
+                                 return $next($request);
+				        }
+		        	}else{
+				            return $next($request);
+			       }
+		}else{
+		    return $next($request);
+		}*/
+return $next($request);
+           }
+       }else{
+           return json('非法请求!');
+       }
+    }
+}

+ 42 - 0
app/api/middleware/Ip.php

@@ -0,0 +1,42 @@
+<?php
+/**
+ * Created by PhpStorm
+ * Author: ihavoc
+ * Date: 2020/11/22
+ * Time: 16:46
+ *
+ */
+
+
+namespace app\api\middleware;
+
+class Ip
+{
+    public function handle($request, \Closure $next)
+    {
+        $request->ip = $this->get_ip();
+
+        return $next($request);
+    }
+    /*
+    * 获取用户真实IP地址
+    */
+    public function get_ip()
+    {
+        if(!empty($_SERVER['HTTP_CLIENT_IP'])){
+            $cip = $_SERVER['HTTP_CLIENT_IP'];
+        }
+        else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
+            $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
+        }
+        else if(!empty($_SERVER["REMOTE_ADDR"])){
+            $cip = $_SERVER["REMOTE_ADDR"];
+        }else{
+            $cip = '';
+        }
+        preg_match("/[\d\.]{7,15}/", $cip, $cips);
+        $cip = isset($cips[0]) ? $cips[0] : 'unknown';
+        unset($cips);
+        return $cip;
+    }
+}

+ 80 - 0
app/api/middleware/Rsa.php

@@ -0,0 +1,80 @@
+<?php
+namespace app\api\middleware;
+
+class Rsa {
+
+    /**
+     * 获取私钥
+     * @return bool|resource
+     */
+    private static function getPrivateKey()
+    {
+        $abs_path = dirname(__FILE__) . '/rsa_private_key.pem';
+        $content = file_get_contents($abs_path);
+        return openssl_pkey_get_private($content);
+    }
+
+    /**
+     * 获取公钥
+     * @return bool|resource
+     */
+    private static function getPublicKey()
+    {
+        $abs_path = dirname(__FILE__) . '/rsa_public_key.pem';
+        $content = file_get_contents($abs_path);
+        return openssl_pkey_get_public($content);
+    }
+
+    /**
+     * 私钥加密
+     * @param string $data
+     * @return null|string
+     */
+    public static function privEncrypt($data = '')
+    {
+        if (!is_string($data)) {
+            return null;
+        }
+        return openssl_private_encrypt($data,$encrypted,self::getPrivateKey()) ? base64_encode($encrypted) : null;
+    }
+
+    /**
+     * 公钥加密
+     * @param string $data
+     * @return null|string
+     */
+    public static function publicEncrypt($data = '')
+    {
+        if (!is_string($data)) {
+            return null;
+        }
+        return openssl_public_encrypt($data,$encrypted,self::getPublicKey()) ? base64_encode($encrypted) : null;
+    }
+
+    /**
+     * 私钥解密
+     * @param string $encrypted
+     * @return null
+     */
+    public static function privDecrypt($encrypted = '')
+    {
+        if (!is_string($encrypted)) {
+            return null;
+        }
+        return (openssl_private_decrypt(base64_decode($encrypted), $decrypted, self::getPrivateKey())) ? $decrypted : null;
+    }
+
+    /**
+     * 公钥解密
+     * @param string $encrypted
+     * @return null
+     */
+    public static function publicDecrypt($encrypted = '')
+    {
+        if (!is_string($encrypted)) {
+            return null;
+        }
+        return (openssl_public_decrypt(base64_decode($encrypted), $decrypted, self::getPublicKey())) ? $decrypted : null;
+    }
+
+}

+ 47 - 0
app/api/middleware/WxMiddleware.php

@@ -0,0 +1,47 @@
+<?php
+namespace app\api\middleware;
+use app\api\middleware\Rsa;
+
+
+class WxMiddleware {
+    /*
+* 中间件验证
+*/
+
+    public function handle($request, \Closure $next)
+    {
+        $rsa = new Rsa();
+// 1、获取参数
+        $data = $request->post();
+        if(empty($data['signData'])){
+            return json('非法请求!');
+        }else{
+            //        2.解参数
+            $privDecrypt = $rsa->privDecrypt($data['signData']);
+            $sign = substr($privDecrypt,0,36);
+            $timestamp = substr($privDecrypt,36);
+            if($sign!='DQEBAQUAA4GNADCBiQKBgQCk7WKdggwBOtte'){
+                return  json('密钥错误!');
+            }else{
+                // 时间判断 大于3600s返回 系统错误
+                $time_limit = 300;
+//                $ttl= time();
+                list($msec, $sec) = explode(' ', microtime());
+                $msectime =  (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
+                $msectimes = substr($msectime,0,13);
+                if(abs((int)$timestamp - $msectimes) > $time_limit){
+                    // var_dump($msectimes);
+                    // var_dump($timestamp);
+                    return  json('超时请求');
+                }else{
+                    return $next($request);
+                }
+            }
+        }
+
+
+//        return($publicDecrypt);
+
+    }
+
+}

+ 15 - 0
app/api/middleware/rsa_private_key.pem

@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQCvNEAH7ACrxatSRZlZh+0pqz/vNxbrT2gWI8OsUXnqLO/0/s2q
+z3rvEUfwgOvqIkWbwlKh5XKg+UuOlEo73voeKdb4oJw6PMmg8vr0mWZkonX7ywXb
+rvX8HjEzt7kBtLSOGceAS4v3hNBuTXxJvucLSKK7+jhhl6rXmXCwEIyBBQIDAQAB
+AoGAF+hqYGpdAROdOEHVFjmNLGV4+PysfPm9+19wASCxITp2mBj5GbjsTpkuFuyQ
+xMdedk3DFuKHjN3X6KHlq1vXB3LjEF0RgD0NmAy6gp0mFniCIVmVVQIX5gcIMcqq
+PyUriptNOqCvOjGzAPWxNlIpzZ7twd4c4+e9g0DfXCrQALUCQQDVT5tjblYq9OIr
+FwcPNF4ixzNQhkJswNqSBRug/F0epRVGXBZQUVJ+7mExhkIEtQtVu/Wc5xovh1lH
+5020PmEfAkEA0kRYHHbDZE580WDImABmNMfVruSEHuLUHe2b8WhnHWIe8g3H/aNG
+chUobUgoNPBd/fgDbUwu20Jozz5MOlmlWwJAFUlYbFe6aZb+auZlYfML4dSXHlYH
+kuq75Q51b18/u6slsFvILkOvQ9NuB48qT2Xxt6CGJh450rxjAHXonzAKaQJBAJuS
+6caVsNhEomGgxIqCsRyYRuhSN9dKaTuDlQA3CSRadx8NR03JQtQiB3lkDCuvNTw2
+BwMVfQ3Jwxajt27s6UUCQA9axCMxGKpAl/wtUvIGAsmUPFXVD1XMXh823IKyBv5b
+DszMztwR1t9hxrEBxR8rttFE637x6IzrjSvwOJ2ugOM=
+-----END RSA PRIVATE KEY-----

+ 6 - 0
app/api/middleware/rsa_public_key.pem

@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvNEAH7ACrxatSRZlZh+0pqz/v
+NxbrT2gWI8OsUXnqLO/0/s2qz3rvEUfwgOvqIkWbwlKh5XKg+UuOlEo73voeKdb4
+oJw6PMmg8vr0mWZkonX7ywXbrvX8HjEzt7kBtLSOGceAS4v3hNBuTXxJvucLSKK7
++jhhl6rXmXCwEIyBBQIDAQAB
+-----END PUBLIC KEY-----

+ 123 - 0
app/api/model/Ccjc.php

@@ -0,0 +1,123 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+/**
+ * Created by PhpStorm
+ * Author: ihavoc
+ * Date: 2020/11/22
+ * Time: 16:24
+ *
+ */
+class Ccjc extends model{
+
+    protected $table = 't_ccjc';
+    protected $pk = 'id';
+
+
+    function undertake()
+    {
+        return $this->hasMany('undertake', 'task_id', 'id');
+    }
+
+    function orgs()
+    {
+        return $this->hasOne('orgs', 'task_id', 'id');
+    }
+
+    public function selectCcjcAndOrgsData($task_uid,$task_class='例行监测',$pageNum=1,$pageSize=10)
+    {
+        $ccjc = new Ccjc();
+        return $ccjc->where([['task_class', '=', $task_class],])->with([
+            'orgs'=>function ($query) use ($task_uid){
+                $query->where('unit_id',$task_uid);
+            }
+        ])->page((int)$pageNum,(int)$pageSize)->select();
+    }
+
+
+    public function selectUndertakeData($task_class,$where, $pageNum, $pageSize)
+    {
+//        $Ccjc = new Ccjc();
+//        return $Ccjc->where('task_class','=',$task_class)
+//            ->with([
+//                'undertake'=> function ($query) use ($where){
+//                    $query->where($where);
+//                }
+//            ])->page($pageNum,$pageSize)->select();
+        return Ccjc::hasWhere('undertake', function ($query) use ($where){
+            $query->where($where);
+        })->where('task_class','=',$task_class)->select();
+
+    }
+    public function countUndertakeData($task_class,$where)
+    {
+        $Ccjc = new Ccjc();
+        return $Ccjc->where('task_class','=',$task_class)
+            ->with([
+                'undertake'=> function ($query) use ($where){
+                    $query->where($where);
+                }
+            ])->count();
+    }
+
+    //查询任务列表数据
+    public function getInfoByTaskClass($where,$pageNum=1,$pageSize=10)
+    {
+        return $this->where($where)->page($pageNum,$pageSize)->select();
+    }
+
+    public function getInfoListCount($where='')
+    {
+        return $this->where($where)->select()->count();
+    }
+
+
+    //删除任务
+    public function deleteTaskByID($id)
+    {
+        if (empty($id)) {
+            return false;
+        }
+        return $this->select($id)->delete();
+    }
+
+    //根据id查询任务发布者releaser
+    public function getReleaserById($id)
+    {
+        return $this->select($id)->column('releaser');
+    }
+
+    //添加任务 返回添加数据的主键id
+    public function createTask($data)
+    {
+        return $this->insertGetId($data);
+    }
+    public function getTaskInfoByTaskID($task_id)
+    {
+        return $this->where('id','=',$task_id)->find();
+    }
+    public function updateInfoByTaskID($task_id, $data)
+    {
+        return $this->where('id', '=', $task_id)->save($data);
+    }
+
+    /**
+     * 更新任务状态
+     * @param $arr_condition:['id'=>1,'task_name'=>'更改的名称','isPublish'=>'2']
+     * @return false|\think\Collection
+     * @throws \Exception
+     */
+    public function updateTaskByArrCondition($arr_condition)
+    {
+        if (empty($arr_condition)) {
+            return false;
+        }
+        $result = $this->saveAll($arr_condition);
+        return $result;
+    }
+
+
+
+
+}

+ 37 - 0
app/api/model/Cyd.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/14
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class Cyd extends Model
+{
+    function production()
+    {
+        return $this->belongsTo('production', 'product_unit','id');
+    }
+
+    function unitsTest()
+    {
+        return $this->belongsTo('unitsTest', 'units_id', 'id');
+    }
+
+
+    public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null)
+    {
+        $cyd = (new Cyd());
+        $data = $cyd->with(['Production', 'UnitsTest'])->where($where)->page($pageNum,$pageSize)->select();
+        return $data;
+    }
+    public function countSampleListByTaskIdAndUid($where)
+    {
+        $cyd = (new Cyd());
+        $count = $cyd->with(['Production', 'UnitsTest'])->where($where)->count();
+        return $count;
+    }
+}

+ 46 - 0
app/api/model/Jcdw.php

@@ -0,0 +1,46 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+/**
+ * Created by PhpStorm
+ * Author: ihavoc
+ * Date: 2020/11/22
+ * Time: 16:24
+ *
+ */
+class Jcdw extends model{
+
+    protected $table = 't_jcdw';
+    //主键定义为rybh:人员编号
+    protected $pk = 'id';
+
+
+    public function getInfoByLoginName($login_name)
+    {
+        if (empty($login_name)) {
+            return false;
+        }
+        return $this->where('login_name','=', $login_name)->find();
+    }
+
+
+    public function getInfoById($id)
+    {
+        if (empty($id)) {
+            return false;
+        }
+        return $this->where('id', '=', $id)->find();
+    }
+
+    public function getInfoList($where='',$pageNum=1,$pageSize=10)
+    {
+        return $this->where($where)->page($pageNum,$pageSize)->select();
+    }
+
+    public function getInfoListCount($where='')
+    {
+        return $this->where($where)->select()->count();
+    }
+
+}

+ 21 - 0
app/api/model/Jgry.php

@@ -0,0 +1,21 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/13
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class Jgry extends Model
+{
+    public function getJgryInfoByRymc($rymc)
+    {
+        if (empty($rymc)) {
+            return false;
+        }
+        return $this->where('rymc', '=', $rymc)->field('groupname,rymc')->find();
+    }
+}

+ 54 - 0
app/api/model/Orgs.php

@@ -0,0 +1,54 @@
+<?php
+namespace app\api\model;
+
+use think\facade\Db;
+use think\Model;
+
+/**
+ * Created by PhpStorm
+ * Author: ihavoc
+ * Date: 2020/11/22
+ * Time: 16:24
+ *
+ */
+class Orgs extends Model {
+
+    protected $table = 't_orgs';
+    protected $pk = 'id';
+
+
+
+    //添加任务 返回添加数据的主键id
+    public function createOrgsInfo($data)
+    {
+        return $this->insertAll($data);
+    }
+
+    //连表查询对应的ccjc信息
+    public function selectCcjcData($where,$pageNum=1,$pageSize=10)
+    {        //todo 模型我写不出来,只能用db了
+        $result= Db::name("orgs")
+            ->join('t_ccjc','t_orgs.task_id=t_ccjc.id')
+            ->where($where)
+            ->page((int)$pageNum,(int)$pageSize)
+            ->select();
+        return $result;
+    }
+    public function countCcjcData($where)
+    {        //todo 模型我写不出来,只能用db了
+        $result= Db::name("orgs")
+            ->Join('t_ccjc','t_orgs.task_id=t_ccjc.id')
+            ->where($where)
+            ->count();
+        return $result;
+    }
+
+    public function getUnitIdByTaskID($task_id)
+    {
+        if (empty($task_id)) {
+            return false;
+        }
+        return $this->where('task_id', '=', $task_id)->find();
+    }
+
+}

+ 28 - 0
app/api/model/Pesticides.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class Pesticides extends Model
+{
+    protected $table = 't_pesticides';
+    protected $pk = 'id';
+
+    public function selectPesticidesList($name='',$pageNum=1,$pageSize=10)
+    {
+        return $this->where('name', 'like', '%' . $name . '%')->page($pageNum, $pageSize)->select();
+    }
+
+    public function countPesticidesList($name = '')
+    {
+        return $this->where('name', 'like', '%' . $name . '%')->count();
+    }
+
+
+}

+ 21 - 0
app/api/model/ProductClass.php

@@ -0,0 +1,21 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class ProductClass extends Model
+{
+    protected $table = 't_product_class';
+    protected $pk = 'id';
+
+    public function selectProductListByTypeID($type_id,$field='')
+    {
+        return $this->where('type_id','=',$type_id)->field($field)->select();
+    }
+}

+ 15 - 0
app/api/model/Production.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/14
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class Production extends Model
+{
+
+}

+ 26 - 0
app/api/model/Ry.php

@@ -0,0 +1,26 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+/**
+ * Created by PhpStorm
+ * Author: ihavoc
+ * Date: 2020/11/22
+ * Time: 16:24
+ *
+ */
+class Ry extends model{
+
+    protected $table = 't_ry';
+    //主键定义为rybh:人员编号
+    protected $pk = 'rybh';
+
+
+    public function getInfoByRybh($rybh)
+    {
+        if (empty($rybh)) {
+            return false;
+        }
+        return $this->where('rybh','=', $rybh)->find();
+    }
+}

+ 97 - 0
app/api/model/TestModel.php

@@ -0,0 +1,97 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class TestModel extends Model
+{
+    protected $table = 't_test_model';
+    protected $pk = 'id';
+
+    //关联模型一对多定义
+    public function testProduct()
+    {
+        return $this->hasMany(TestProduct::class, 'test_model_id', 'id');
+    }
+    //关联模型一对多定义
+    public function testPesticides()
+    {
+        return $this->hasMany(TestPesticides::class, 'test_model_id', 'id');
+    }
+
+    //关联模型一对多使用
+    public function getProductInfo($model_id,$where='')
+    {
+        $models = TestModel::find($model_id);
+        $productInfo = $models->testProduct()->where($where)->select();
+        return $productInfo;
+    }
+
+    //关联模型一对多使用
+    public function getPesticidesInfo($model_id,$where='')
+    {
+        $models = TestModel::find($model_id, $where = '');
+        $pesticides = $models->testPesticides()->where($where)->select();
+        return $pesticides;
+    }
+
+    /**
+     * @param $uid
+     * @param int $pageNum
+     * @param int $pageSize
+     * @param array $where:type_id为int
+     */
+    public function getListByUserId($uid,$pageNum=1,$pageSize=10,$where=[])
+    {
+        return $this->where('user_id','=',(int)$uid)->where($where)->page($pageNum,$pageSize)->select();
+    }
+
+    public function countListByUserId($uid, $where = [])
+    {
+        return $this->where('user_id','=',(int)$uid)->where($where)->count();
+
+    }
+
+    public function getModelInfoByModelID($model_id)
+    {
+        return $this->find($model_id);
+    }
+
+    public function updateModelInfoByModelID($model_id,$update_data)
+    {
+        return $this->find($model_id)->save($update_data);
+    }
+
+    public function createModelInfo($model_name,$type_id,$user_id)
+    {
+        return $this->insertGetId([
+            'name'=>$model_name,
+            'type_id'=>$type_id,
+            'user_id'=>$user_id
+        ]);
+    }
+
+
+
+    public function getUserIdByModelID($model_id)
+    {
+        if (empty($model_id)) {
+            return false;
+        }
+        return $this->where('id', '=', $model_id)->field('user_id')->find();
+    }
+
+    public function deleteModelInfoByID($model_id)
+    {
+        if (empty($model_id)) {
+            return false;
+        }
+        return $this->where('id', '=', $model_id)->delete();
+    }
+}

+ 26 - 0
app/api/model/TestPesticides.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class TestPesticides extends Model
+{
+    protected $table = 't_test_pesticides';
+    protected $pk = 'id';
+    public function deletePesticidesInfoByTestModelID($test_model_id)
+    {
+        return $this->where('test_model_id', '=', $test_model_id)->delete();//return 2
+    }
+
+    public function insertPesticidesInfo($update_data)
+    {
+        return $this->insertAll($update_data);
+    }
+
+}

+ 31 - 0
app/api/model/TestProduct.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/11
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class TestProduct extends Model
+{
+    protected $table = 't_test_product';
+    protected $pk = 'id';
+
+    public function deleteProductInfoByTestModelID($test_model_id)
+    {
+        return $this->where('test_model_id', '=', $test_model_id)->delete();//return 2
+    }
+
+    public function insertProductInfo($update_data)
+    {
+        return $this->insertAll($update_data);
+    }
+
+    public function createProductInfo($update_data)
+    {
+        return $this->insertAll($update_data);
+    }
+}

+ 63 - 0
app/api/model/Undertake.php

@@ -0,0 +1,63 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/13
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class Undertake extends Model
+{
+    public function insert(array $data = [], bool $getLastInsID = false)
+    {
+        return parent::insert($data, $getLastInsID); // TODO: Change the autogenerated stub
+    }
+
+    public function deleteInfoByID($id_arr)
+    {
+        return $this->select($id_arr)->delete();
+    }
+
+
+    public function selectUndertakeInfoByTaskIdAndUnitId($task_id,$unit_id='',$bear_id='',$report_id='',$pageNum=1,$pageSize=null)
+    {
+        $where=[
+            ['task_id', '=', $task_id],
+        ];
+
+        if ($unit_id!='') {
+            array_push($where, ['unit_id', '=', $unit_id]);
+        }
+        if ($bear_id!='') {
+            array_push($where, ['bear_id', '=', $bear_id]);
+        }
+        if ($report_id!='') {
+            array_push($where,['report_id', '=', $report_id]);
+
+        }
+        return $this->where($where)->page($pageNum,$pageSize)->select();
+    }
+
+    public function countUndertakeInfoByTaskIdAndUnitId($task_id,$unit_id='',$bear_id='',$report_id='')
+    {
+        $where=[
+            ['task_id', '=', $task_id],
+        ];
+
+        if ($unit_id != '') {
+            array_push($where, ['unit_id', '=', $unit_id]);
+        }
+        if ($bear_id != '') {
+            array_push($where, ['bear_id', '=', $bear_id]);
+        }
+        if ($report_id != '') {
+            array_push($where,['report_id', '=', $report_id]);
+
+        }
+        return $this->where($where)->count();
+    }
+
+}

+ 15 - 0
app/api/model/UnitsTest.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/18
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class UnitsTest extends Model
+{
+
+}

+ 47 - 0
app/api/model/User.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/19
+ */
+
+namespace app\api\model;
+
+use think\Model;
+
+class User extends Model
+{
+    //一个用户可以有多个评论,在User模型中是一对多的关系
+    function comment()
+    {
+        return $this->hasMany('comment', 'user_id', 'id');
+    }
+    //一个用户只有唯一的简介,在User模型中是一对一的关系
+    function profile()
+    {
+        return $this->hasOne('profile', 'user_id', 'id');
+    }
+    //三张表在同一级显示:user、profile、comment
+    public function UserData1()
+    {
+        $user = new User();
+        $data = $user->with(['profile', 'comment',])->find();
+        return $data;
+    }
+    //三张表分级显示
+    public function UserData2()
+    {
+        $user = new User();
+        $data = $user->with([
+            'profile' => function ($query) {
+                $query->with([
+                    'comment' => function ($query) {
+
+                    }
+                ]);
+            }
+        ])->select();
+        return $data;
+    }
+
+}

+ 96 - 0
app/api/route/app.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\api\route;
+use app\common\middleware\JwtAuth;
+use think\facade\Route;
+//-1已完成,-12正在改,-13没改的
+//登录 & 等出 路由表
+Route::group(function () {
+    Route::post(":version.login",":version.Login/login");        //登出
+    Route::post(":version.logout1",":version.Login/logout");        //登出 todo 还没写
+
+})->allowCrossDomain();
+
+Route::group(function () {
+    //监管单位路由
+    Route::post(":version.AddTask",":version.superviser/create");        //增 添加任务
+    Route::post(":version.delTask",":version.superviser/delete");        //删 删除任务
+    Route::post(":version.isPublicTask",":version.superviser/update");        //改 修改任务状态(发布状态)
+    Route::post(":version.getTaskList",":version.superviser/select");        //查找:监管端渲染任务列表-ok
+    //监测模型相关的路由
+    Route::post(":version.getModelList",":version.Model/selectModelList");    //显示模型配置页面的列表
+    Route::post(":version.saveModel",":version.Model/createModelInfo");       //创建模型信息
+    Route::post(":version.delModel",":version.Model/deleteModelInfo");        //删除模型
+    Route::post(":version.bindModel",":version.Model/bindModel");        //在执行任务中绑定模型
+
+    Route::post(":version.DoEditModelInfo",":version.Model/updateModelInfo"); //修改模型详情
+    Route::post(":version.getModeldetail",":version.Model/getModelInfo");     //获取某个模型的详情信息
+    Route::post(":version.getProductList",":version.Product/selectProductList");    //获取检测对象列表
+    Route::post(":version.getPesticidesList",":version.Pesticides/selectPesticidesList"); //获取检测项列表
+    //牵头单位相关路由
+    Route::post(":version.getTaskTest",":version.Organizer/selectTaskList");        //获取牵头单位所属任务
+    Route::post(":version.getTaskDetail",":version.Organizer/getTaskInfo");        //获取任务信息
+    Route::post(":version.AddUnderTask",":version.Undertaker/createUnderTaker");      //在牵头单位中添加承担单位
+    Route::post(":version.delUnderTask",":version.Undertaker/deleteUnderTaskList");      //在牵头单位中获取任务的获取承担单位
+    Route::post(":version.qtRelease",":version.Organizer/qtRelease");        //牵头单位发布任务
+
+
+    //承担单位相关路由
+    Route::post(":version.getTaskcd",":version.Undertaker/selectUndertakerTaskList");      //承担单位获取承担单位任务列表
+    //  Route::post(":version.getTaskDetail",":version.Organizer/getTaskInfo");        //获取任务信息--same牵头单位路由获取任务信息
+    Route::post(":version.getSampleList",":version.Sample/selectSampleList");        // 查询抽样单详细信息列表
+//    Route::post(":version.getUnderTask",":version.index/getUnderTask");      //获取承担单位--same牵头单位路由获取承担单位信息
+
+    //填报抽样单
+    Route::post(":version.getTestObj",":version.Sample/getSampleObj");        //填报抽样单-step1 获取信息
+   // Route::post(":version.saveSample",":version.Sample/createSample");        //填报抽样单-step2 保存信息
+    Route::post(":version.getSampleId",":version.Sample/createSampleId");        //抽样单中生成样品编码
+
+
+
+
+
+
+    //通用的路由,获取检测单位,抽样单位
+    Route::post(":version.getTestList",":version.TaskCommon/getTestUnitList");        //获取检测单位列表--ok
+
+})->allowCrossDomain()->middleware(JwtAuth::class);
+
+//通用库的controller路由
+Route::post(":version.ossUpload",":version.Upload/upload")->allowCrossDomain();       //上传文件到oss todo 增加工厂模式
+
+/**
+ *
+POST(CREATE):在服务器新建一个资源。
+DELETE(DELETE):从服务器删除资源。
+PUT(UPDATE):在服务器更新资源(客户端提供改变后的完整资源)。
+GET(SELECT):从服务器取出资源(一项或多项)。
+PATCH(UPDATE):在服务器更新资源(客户端提供改变的属性)。
+ */
+//
+//Route::post(":version.loginOut",":version.Index/loginOut");        //登出
+//
+//Route::post(":version.rsa",":version.Ha/rsa");        //登录
+//
+//Route::post(":version.uploadfile",":version.Sample/uploadfile");        //登录
+//Route::post(":version.test",":version.index/test");        //登录
+//Route::post(":version.saveSample",":version.index/saveSample");        //登录
+//Route::post(":version.getSampleId",":version.index/getSampleId");        //登录
+//Route::post(":version.setSampleStatus",":version.index/setSampleStatus");        //登录
+//Route::post(":version.delSample",":version.index/delSample");        //登录
+//Route::post(":version.getSampleDetail",":version.index/getSampleDetail");        //登录
+//Route::post(":version.getTestPesticides",":version.index/getTestPesticides");        //登录
+//Route::post(":version.saveSamplePesticides",":version.index/saveSamplePesticides");        //登录
+//Route::post(":version.editSamplePesticides",":version.index/editSamplePesticides");        //登录
+//Route::post(":version.getTestValue",":version.index/getTestValue");        //登录
+//Route::post(":version.saveTestFile",":version.index/saveTestFile");        //登录
+//Route::post(":version.getUnitsFileList",":version.index/getUnitsFileList");        //登录
+//Route::post(":version.getGovFileList",":version.index/getGovFileList");        //登录
+
+
+
+
+
+
+
+

+ 39 - 0
app/common.php

@@ -0,0 +1,39 @@
+<?php
+// 应用公共文件
+/**
+ * 通用化api输出模块
+ * @param $code
+ * @param $msg
+ * @param array $data
+ * @param int $httpStatus
+ * @return \think\response\Json
+ */
+function show($code,$msg,$data=[],$httpStatus=200)
+{
+    $result=[
+        'code'=>$code,
+        'message'=>$msg,
+        'data'=>$data,
+    ];
+    return json($result,$httpStatus);
+}
+
+function showSuccess($data = [],$httpStatus=200)
+{
+    $result=[
+        'code' => config('status.success')[0],
+        'message' => config('status.success')[1],
+        'data' => $data,
+    ];
+    return json($result, $httpStatus);
+}
+
+function showError($status, $httpStatus = 400)
+{
+    $result=[
+        'code' => $status[0],
+        'message' => $status[1],
+        'data' => [],
+    ];
+    return json($result, $httpStatus);
+}

+ 105 - 0
app/common/lib/Arr.php

@@ -0,0 +1,105 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/3
+ */
+
+namespace app\common\lib;
+
+class Arr
+{
+    /**
+     * 数组分页显示
+     * @param $array:数组
+     * @param $page_number:当前页码
+     * @param string $items:每页显示几条
+     * @return array
+     */
+    public function Arr_page($array,$page_number,$items='')
+    {
+        if ($items) {
+            $page_total = ceil(count($array) / $items);//总共有多少页
+            $start= ($page_number-1)*$items;                  //计算偏移量
+            $data=array_slice($array, $start, $items);
+        }else{
+            $page_total=1;
+            $data = array_slice($array, 0);//如果不存在每页数量则全部显示
+        }
+        //todo 分页功能可以更加完善点,在controller里添加参数认证,这里可以再写一次
+        return [
+            'page'=>[
+                'total'=>$page_total,//总页数
+                'current'=>$page_number,//当前页码
+                'items'=>$items,
+            ],
+            'data'=>$data,
+        ];
+    }
+
+    /**
+     *移除二维数组中不要的字段
+     * @param $arr
+     * @param ...$args
+     * @return mixed
+     */
+    public function Arr_remove($arr, ...$args)
+    {
+        foreach ($arr as $k => &$v) {
+            foreach ($args as $a => $b) {
+                unset($v[$b]);
+            }
+        }
+        return $arr;
+    }
+    /**
+     * 返回数组中指定多列
+     * @param $array:需要取出数组列的多维数组
+     * @param null $column_keys:要取出的列名,逗号分隔,如不传则返回所有列
+     * @param null $index_key:作为返回数组的索引的列
+     * @return array
+     */
+    function Arr_columns($array, $column_keys=null, $index_key=null){
+        $result = array();
+        $keys =isset($column_keys)? explode(',', $column_keys) : array();
+        if($array){
+            foreach($array as $k=>$v){
+                // 指定返回列
+                if($keys){
+                    $tmp = array();
+                    foreach($keys as $key){
+                        $tmp[$key] = $v[$key];
+                    }
+                }else{
+                    $tmp = $v;
+                }
+                // 指定索引列
+                if(isset($index_key)){
+                    $result[$v[$index_key]] = $tmp;
+                }else{
+                    $result[] = $tmp;
+                }
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 数组树状化
+     * @param $arr
+     * @param $parent_id
+     * @return array
+     */
+    function Arr_tree($arr,$parent_id){
+        $tmp_arr=[];
+        foreach ($arr as $k=> $v){
+
+            if($v['parent_id']==$parent_id){
+                unset($arr[$k]);
+                $v['children']=$this->Arr_tree($arr, $v['product_code']);
+                $tmp_arr[]=$v;
+            }
+        }
+        return $tmp_arr;
+    }
+}

+ 202 - 0
app/common/lib/auth/JwtAuth.php

@@ -0,0 +1,202 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/9/29
+ */
+
+namespace app\common\lib\auth;
+use Lcobucci\JWT\Parser;
+use Lcobucci\JWT\Builder;
+use Lcobucci\JWT\Signer\Hmac\Sha256;
+use Lcobucci\JWT\Token;
+use Lcobucci\JWT\ValidationData;
+
+/**
+ *  * 单例 一次请求中所有出现使用jwt的地方都是一个用户
+ */
+
+class JwtAuth
+{
+    private $qydm;//企业代码
+    private $rybh;//人员编号
+    private $rymc;//人员名称
+    private $groupname;//组名
+    private $name;//名称//这个我不知到是什么,后面再改//Todo
+    private $uid;//t_ry表的id
+
+    private $token;
+    private $decodeToken;
+
+    /**
+     * 单例模式 jwtAuth句柄
+     * @var
+     */
+    private static $instance;
+
+    /**
+     * 获取jwtAuth的句柄
+     * @return JwtAuth
+     */
+    public static function getInstance()
+    {
+        if (is_null(self::$instance)) {
+            self::$instance = new self();
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 私有化构造函数 防止new
+     */
+    private function __construct(){}
+
+    /**
+     * 私有化 clone函数 防止clone
+     */
+    private function __clone(){}
+
+    //Token
+    public function getToken()
+    {
+        return (string)$this->token;
+    }
+    public function setToken($token)
+    {
+        $this->token=$token;
+        return $this;
+    }
+
+    //Uid
+    public function getUid()
+    {
+        return (string)$this->uid;
+    }
+    public function setUid($uid)
+    {
+        $this->uid=$uid;
+        return $this;
+    }
+
+    //人员编号
+    public function setRybh($rybh)
+    {
+        $this->rybh=$rybh;
+        return $this;
+    }
+    public function getRybh()
+    {
+        return $this->rybh;
+    }
+
+    //$groupname
+    public function setGroupname($groupname)
+    {
+        $this->groupname=$groupname;
+        return $this;
+    }
+    public function getGroupname()
+    {
+        return $this->groupname;
+    }
+
+    //name
+    public function setName($name)
+    {
+        $this->name=$name;
+        return $this;
+    }
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    //人员名称
+    public function setRymc($rymc)
+    {
+        $this->rymc=$rymc;
+        return $this;
+    }
+    public function getRymc()
+    {
+        return $this->rymc;
+    }
+
+    //企业代码
+    public function setQydm($qydm)
+    {
+        $this->qydm=$qydm;
+        return $this;
+    }
+    public function getQydm()
+    {
+        return $this->qydm;
+    }
+
+
+
+    /**
+     * @return $this
+     */
+    public function encode(): JwtAuth
+    {
+        //设置签发人、接收人、唯一标识、签发时间、立即生效、过期时间、用户id、签名
+        $time=time();
+        $this->token = (new Builder())
+            ->setHeader('alg', 'HS256')
+            ->setIssuer(config('jwt.issuer'))
+            ->setAudience(config('jwt.audience'))
+            ->setExpiration($time + config('jwt.expiration'))
+
+            ->set('uid',$this->uid)
+            ->set('name', $this->name)
+            ->set('rymc', $this->rymc)
+            ->set('groupname', $this->groupname)
+            ->set('rybh',$this->rybh)
+            ->set('qydm',$this->qydm)
+            ->sign(new Sha256(),config('jwt.secret'))
+            ->getToken();
+    return $this;
+    }
+
+    /**
+     * @return Token|void
+     */
+    public function decode()
+    {
+        if (!$this->decodeToken) {
+            $this->decodeToken = (new Parser())->parse((string)$this->token);
+            $this->uid = $this->decodeToken->getClaim('uid');
+            $this->rybh = $this->decodeToken->getClaim('rybh');
+            $this->qydm = $this->decodeToken->getClaim('qydm');
+            $this->name = $this->decodeToken->getClaim('name');
+            $this->rymc = $this->decodeToken->getClaim('rymc');
+            $this->groupname = $this->decodeToken->getClaim('groupname');
+        }
+        return $this->decodeToken;
+    }
+
+    /**
+     * verify token
+     * @return bool
+     */
+    public function verify(): bool
+    {
+        $result = $this->decode()->verify(new Sha256(), config('jwt.secret'));
+        return $result;
+    }
+
+    /**
+     * validate
+     * @return bool
+     */
+    public function validate(): bool
+    {
+        $data = new ValidationData();
+        $data->setIssuer(config('jwt.issuer'));
+        $data->setAudience(config('jwt.audience'));
+
+        return $this->decode()->validate($data);
+    }
+
+}

+ 94 - 0
app/common/lib/upload/AliyunOss.php

@@ -0,0 +1,94 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/10
+ */
+
+namespace app\common\lib\upload;
+
+use app\api\exception\ApiException;
+use OSS\Core\OssException;
+use OSS\OssClient;
+
+class AliyunOss
+{
+    public function Upload(){
+        $name = $_FILES['file']['name'];//1.png
+        $tmp_name = $_FILES['file']['tmp_name'];//C:\Users\Administrator\AppData\Local\Temp\phpD08.tmp
+        $error = $_FILES['file']['error'];
+        //过滤错误(临时测试时使用,代码写的比较简陋)
+        if ($error) {
+            switch ($error) {
+                case 1 :
+                    $error_message = '您上传的文件超过了PHP.INI配置文件中UPLOAD_MAX-FILESIZE的大小';
+                    break;
+                case 2 :
+                    $error_message = '您上传的文件超过了PHP.INI配置文件中的post_max_size的大小';
+                    break;
+                case 3 :
+                    $error_message = '文件只被部分上传';
+                    break;
+                case 4 :
+                    $error_message = '文件不能为空';
+                    break;
+                default :
+                    $error_message = '未知错误';
+            }
+            die($error_message);
+        }
+        //文件名生成
+        $arr_name = explode('.', $name);// [0 => "1" ,  1 => "png"]
+        //源文件的后缀
+        $extension = end($arr_name); //png
+
+        /**
+         * 判断上传文件是否合法
+         * 判断截取上传文件名是否为
+         * jpeg,jpg,png其中之一
+         */
+        if (!in_array($extension, array("jpeg", "jpg", "png", "PNG", "JPG", "JPEG","pdf","PDF","XLS","xls","doc","DOC","docx","xlsx"))) {
+            return show(-2, '上传文件不合法');
+        }
+
+//            try {
+//                validate(['file' => ['fileSize:2*1024*1024']])->check(['file' => $file]);
+//            } catch (ValidateException $e) {
+//                $return['msg'] = $e->getMessage();
+//
+//            }
+        //新的文件名
+        $new_name = $name;//1.png
+
+        //文件在OSS上的URL
+        $url=config('upload.aliyun_oss_save_path_syjc').$new_name;
+        //抛出异常
+
+        try{
+            //相比传统的操作,其实就多了两个步骤
+            //第一步是根据上面的参数实例化一个对象
+            $ossClient = new OssClient(
+                config('upload.aliyun_oss_accessKeyId_syjc'),
+                config('upload.aliyun_oss_accessKeySecret_syjc'),
+                config('upload.aliyun_oss_endpoint_syjc')
+            );
+            //这一步相当于之前把临时文件移入到设置的地址那步,只是以前的是自己的服务器上,现在是OSS;
+            $result =$ossClient->uploadFile(config('upload.aliyun_oss_bucket_syjc'),$url,$tmp_name);
+            //返回的参数
+            if (isset($result['info']['http_code']) AND $result['info']['http_code']==200) {
+                $arr=[
+                    'fileName' => $new_name,
+                    'fileUrl'  => $result['info']['url']
+                ];
+
+                return showSuccess($arr);
+            }else{
+                return show('3', '上传失败');
+            }
+        } catch(OssException $e) {
+            return config($e->getCode(), $e->getMessage());
+        }
+
+
+    }
+}

+ 34 - 0
app/common/middleware/JwtAuth.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/1
+ */
+
+namespace app\common\middleware;
+
+//调用自定义的异常处理类
+use app\api\exception\ApiException;
+
+class JwtAuth
+{
+    public function handle($request,\Closure $next)
+    {
+        $token = request()->header('Authorization');//access-token
+        //$token = request()->param('token');
+
+        if ($token) {
+            $jwtAuth = \app\common\lib\auth\JwtAuth::getInstance();
+            $jwtAuth->setToken($token);
+
+            if ($jwtAuth->validate() && $jwtAuth->verify()) {
+                return $next($request);
+            } else {
+                throw new ApiException(config('status.err_unKnow'));
+            }
+        } else {
+            throw new ApiException(config('status.err_params'));
+            //return show(config('status.err_params')[0],config('status.err_params')[1]);
+        }
+    }
+}

+ 27 - 0
app/common/model/mysql/Ry.php

@@ -0,0 +1,27 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/8
+ */
+
+namespace app\common\model\mysql;
+
+use think\Model;
+
+
+class Ry extends Model
+{
+    protected $table = 't_ry';
+    //主键定义为rybh:人员编号
+    protected $pk = 'rybh';
+
+
+    public function getUserInfoByRybh($rybh)
+    {
+        if (empty($rybh)) {
+            return false;
+        }
+        return $this->where('rybh','=', $rybh)->find();
+    }
+}

+ 17 - 0
app/event.php

@@ -0,0 +1,17 @@
+<?php
+// 事件定义文件
+return [
+    'bind'      => [
+    ],
+
+    'listen'    => [
+        'AppInit'  => [],
+        'HttpRun'  => [],
+        'HttpEnd'  => [],
+        'LogLevel' => [],
+        'LogWrite' => [],
+    ],
+
+    'subscribe' => [
+    ],
+];

+ 10 - 0
app/middleware.php

@@ -0,0 +1,10 @@
+<?php
+// 全局中间件定义文件
+return [
+    // 全局请求缓存
+    // \think\middleware\CheckRequestCache::class,
+    // 多语言加载
+    // \think\middleware\LoadLangPack::class,
+    // Session初始化
+    // \think\middleware\SessionInit::class
+];

+ 9 - 0
app/provider.php

@@ -0,0 +1,9 @@
+<?php
+use app\ExceptionHandle;
+use app\Request;
+
+// 容器Provider定义文件
+return [
+    'think\Request'          => Request::class,
+    'think\exception\Handle' => ExceptionHandle::class,
+];

+ 9 - 0
app/service.php

@@ -0,0 +1,9 @@
+<?php
+
+use app\AppService;
+
+// 系统服务定义文件
+// 服务在完成全局初始化之后执行
+return [
+    AppService::class,
+];

+ 51 - 0
composer.json

@@ -0,0 +1,51 @@
+{
+    "name": "topthink/think",
+    "description": "the new thinkphp framework",
+    "type": "project",
+    "keywords": [
+        "framework",
+        "thinkphp",
+        "ORM"
+    ],
+    "homepage": "http://thinkphp.cn/",
+    "license": "Apache-2.0",
+    "authors": [
+        {
+            "name": "liu21st",
+            "email": "liu21st@gmail.com"
+        },
+        {
+            "name": "yunwuxin",
+            "email": "448901948@qq.com"
+        }        
+    ],
+    "require": {
+        "php": ">=7.1.0",
+        "topthink/framework": "^6.0.0",
+        "topthink/think-orm": "^2.0",
+        "topthink/think-multi-app": "^1.0",
+        "lcobucci/jwt": "3.2.0",
+        "aliyuncs/oss-sdk-php": "^2.4"
+    },
+    "require-dev": {
+        "symfony/var-dumper": "^4.2",
+        "topthink/think-trace":"^1.0"
+    },
+    "autoload": {
+        "psr-4": {
+            "app\\": "app"
+        },
+        "psr-0": {
+            "": "extend/"
+        }
+    },
+    "config": {
+        "preferred-install": "dist"
+    },
+    "scripts": {
+        "post-autoload-dump": [
+            "@php think service:discover",
+            "@php think vendor:publish"
+        ]
+    }
+}

+ 1118 - 0
composer.lock

@@ -0,0 +1,1118 @@
+{
+    "_readme": [
+        "This file locks the dependencies of your project to a known state",
+        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+        "This file is @generated automatically"
+    ],
+    "content-hash": "a7d92075dce80d6c8d7707a1c17e6bc4",
+    "packages": [
+        {
+            "name": "aliyuncs/oss-sdk-php",
+            "version": "v2.4.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
+                "reference": "4ccead614915ee6685bf30016afb01aabd347e46"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/4ccead614915ee6685bf30016afb01aabd347e46",
+                "reference": "4ccead614915ee6685bf30016afb01aabd347e46",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "*",
+                "satooshi/php-coveralls": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "OSS\\": "src/OSS"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Aliyuncs",
+                    "homepage": "http://www.aliyun.com"
+                }
+            ],
+            "description": "Aliyun OSS SDK for PHP",
+            "homepage": "http://www.aliyun.com/product/oss/",
+            "support": {
+                "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
+                "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.4.3"
+            },
+            "time": "2021-08-25T13:03:58+00:00"
+        },
+        {
+            "name": "lcobucci/jwt",
+            "version": "3.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/lcobucci/jwt.git",
+                "reference": "7668cb045296f290588d04c391569c7b7fc1f899"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/lcobucci/jwt/zipball/7668cb045296f290588d04c391569c7b7fc1f899",
+                "reference": "7668cb045296f290588d04c391569c7b7fc1f899",
+                "shasum": ""
+            },
+            "require": {
+                "ext-openssl": "*",
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "mdanter/ecc": "~0.3.1",
+                "mikey179/vfsstream": "~1.5",
+                "phpmd/phpmd": "~2.2",
+                "phpunit/php-invoker": "~1.1",
+                "phpunit/phpunit": "~4.5",
+                "squizlabs/php_codesniffer": "~2.3"
+            },
+            "suggest": {
+                "mdanter/ecc": "Required to use Elliptic Curves based algorithms."
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "3.1-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Lcobucci\\JWT\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Luís Otávio Cobucci Oblonczyk",
+                    "email": "lcobucci@gmail.com",
+                    "role": "Developer"
+                }
+            ],
+            "description": "A simple library to work with JSON Web Token and JSON Web Signature",
+            "keywords": [
+                "JWS",
+                "jwt"
+            ],
+            "support": {
+                "issues": "https://github.com/lcobucci/jwt/issues",
+                "source": "https://github.com/lcobucci/jwt/tree/3.2"
+            },
+            "time": "2016-08-13T23:12:58+00:00"
+        },
+        {
+            "name": "league/flysystem",
+            "version": "1.1.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/thephpleague/flysystem.git",
+                "reference": "18634df356bfd4119fe3d6156bdb990c414c14ea"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/18634df356bfd4119fe3d6156bdb990c414c14ea",
+                "reference": "18634df356bfd4119fe3d6156bdb990c414c14ea",
+                "shasum": ""
+            },
+            "require": {
+                "ext-fileinfo": "*",
+                "league/mime-type-detection": "^1.3",
+                "php": "^7.2.5 || ^8.0"
+            },
+            "conflict": {
+                "league/flysystem-sftp": "<1.0.6"
+            },
+            "require-dev": {
+                "phpspec/prophecy": "^1.11.1",
+                "phpunit/phpunit": "^8.5.8"
+            },
+            "suggest": {
+                "ext-ftp": "Allows you to use FTP server storage",
+                "ext-openssl": "Allows you to use FTPS server storage",
+                "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
+                "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
+                "league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
+                "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
+                "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
+                "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
+                "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
+                "league/flysystem-webdav": "Allows you to use WebDAV storage",
+                "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
+                "spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
+                "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.1-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "League\\Flysystem\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Frank de Jonge",
+                    "email": "info@frenky.net"
+                }
+            ],
+            "description": "Filesystem abstraction: Many filesystems, one API.",
+            "keywords": [
+                "Cloud Files",
+                "WebDAV",
+                "abstraction",
+                "aws",
+                "cloud",
+                "copy.com",
+                "dropbox",
+                "file systems",
+                "files",
+                "filesystem",
+                "filesystems",
+                "ftp",
+                "rackspace",
+                "remote",
+                "s3",
+                "sftp",
+                "storage"
+            ],
+            "support": {
+                "issues": "https://github.com/thephpleague/flysystem/issues",
+                "source": "https://github.com/thephpleague/flysystem/tree/1.1.5"
+            },
+            "funding": [
+                {
+                    "url": "https://offset.earth/frankdejonge",
+                    "type": "other"
+                }
+            ],
+            "time": "2021-08-17T13:49:42+00:00"
+        },
+        {
+            "name": "league/flysystem-cached-adapter",
+            "version": "1.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/thephpleague/flysystem-cached-adapter.git",
+                "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff",
+                "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
+                "shasum": ""
+            },
+            "require": {
+                "league/flysystem": "~1.0",
+                "psr/cache": "^1.0.0"
+            },
+            "require-dev": {
+                "mockery/mockery": "~0.9",
+                "phpspec/phpspec": "^3.4",
+                "phpunit/phpunit": "^5.7",
+                "predis/predis": "~1.0",
+                "tedivm/stash": "~0.12"
+            },
+            "suggest": {
+                "ext-phpredis": "Pure C implemented extension for PHP"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "League\\Flysystem\\Cached\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "frankdejonge",
+                    "email": "info@frenky.net"
+                }
+            ],
+            "description": "An adapter decorator to enable meta-data caching.",
+            "support": {
+                "issues": "https://github.com/thephpleague/flysystem-cached-adapter/issues",
+                "source": "https://github.com/thephpleague/flysystem-cached-adapter/tree/master"
+            },
+            "time": "2020-07-25T15:56:04+00:00"
+        },
+        {
+            "name": "league/mime-type-detection",
+            "version": "1.8.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/thephpleague/mime-type-detection.git",
+                "reference": "b38b25d7b372e9fddb00335400467b223349fd7e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b38b25d7b372e9fddb00335400467b223349fd7e",
+                "reference": "b38b25d7b372e9fddb00335400467b223349fd7e",
+                "shasum": ""
+            },
+            "require": {
+                "ext-fileinfo": "*",
+                "php": "^7.2 || ^8.0"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^2.18",
+                "phpstan/phpstan": "^0.12.68",
+                "phpunit/phpunit": "^8.5.8 || ^9.3"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "League\\MimeTypeDetection\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Frank de Jonge",
+                    "email": "info@frankdejonge.nl"
+                }
+            ],
+            "description": "Mime-type detection for Flysystem",
+            "support": {
+                "issues": "https://github.com/thephpleague/mime-type-detection/issues",
+                "source": "https://github.com/thephpleague/mime-type-detection/tree/1.8.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/frankdejonge",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/league/flysystem",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-09-25T08:23:19+00:00"
+        },
+        {
+            "name": "psr/cache",
+            "version": "1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/cache.git",
+                "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
+                "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Cache\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "http://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for caching libraries",
+            "keywords": [
+                "cache",
+                "psr",
+                "psr-6"
+            ],
+            "support": {
+                "source": "https://github.com/php-fig/cache/tree/master"
+            },
+            "time": "2016-08-06T20:24:11+00:00"
+        },
+        {
+            "name": "psr/container",
+            "version": "1.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/container.git",
+                "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
+                "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.2.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Container\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "https://www.php-fig.org/"
+                }
+            ],
+            "description": "Common Container Interface (PHP FIG PSR-11)",
+            "homepage": "https://github.com/php-fig/container",
+            "keywords": [
+                "PSR-11",
+                "container",
+                "container-interface",
+                "container-interop",
+                "psr"
+            ],
+            "support": {
+                "issues": "https://github.com/php-fig/container/issues",
+                "source": "https://github.com/php-fig/container/tree/1.1.1"
+            },
+            "time": "2021-03-05T17:36:06+00:00"
+        },
+        {
+            "name": "psr/log",
+            "version": "1.1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/log.git",
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Log\\": "Psr/Log/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "https://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for logging libraries",
+            "homepage": "https://github.com/php-fig/log",
+            "keywords": [
+                "log",
+                "psr",
+                "psr-3"
+            ],
+            "support": {
+                "source": "https://github.com/php-fig/log/tree/1.1.4"
+            },
+            "time": "2021-05-03T11:20:27+00:00"
+        },
+        {
+            "name": "psr/simple-cache",
+            "version": "1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/simple-cache.git",
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\SimpleCache\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "http://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interfaces for simple caching",
+            "keywords": [
+                "cache",
+                "caching",
+                "psr",
+                "psr-16",
+                "simple-cache"
+            ],
+            "support": {
+                "source": "https://github.com/php-fig/simple-cache/tree/master"
+            },
+            "time": "2017-10-23T01:57:42+00:00"
+        },
+        {
+            "name": "topthink/framework",
+            "version": "v6.0.9",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/framework.git",
+                "reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/framework/zipball/0b5fb453f0e533de3af3a1ab6a202510b61be617",
+                "reference": "0b5fb453f0e533de3af3a1ab6a202510b61be617",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "ext-mbstring": "*",
+                "league/flysystem": "^1.1.4",
+                "league/flysystem-cached-adapter": "^1.0",
+                "php": ">=7.2.5",
+                "psr/container": "~1.0",
+                "psr/log": "~1.0",
+                "psr/simple-cache": "^1.0",
+                "topthink/think-helper": "^3.1.1",
+                "topthink/think-orm": "^2.0"
+            },
+            "require-dev": {
+                "mikey179/vfsstream": "^1.6",
+                "mockery/mockery": "^1.2",
+                "phpunit/phpunit": "^7.0"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [],
+                "psr-4": {
+                    "think\\": "src/think/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "liu21st",
+                    "email": "liu21st@gmail.com"
+                },
+                {
+                    "name": "yunwuxin",
+                    "email": "448901948@qq.com"
+                }
+            ],
+            "description": "The ThinkPHP Framework.",
+            "homepage": "http://thinkphp.cn/",
+            "keywords": [
+                "framework",
+                "orm",
+                "thinkphp"
+            ],
+            "support": {
+                "issues": "https://github.com/top-think/framework/issues",
+                "source": "https://github.com/top-think/framework/tree/v6.0.9"
+            },
+            "time": "2021-07-22T03:24:49+00:00"
+        },
+        {
+            "name": "topthink/think-helper",
+            "version": "v3.1.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/think-helper.git",
+                "reference": "f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/think-helper/zipball/f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905",
+                "reference": "f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "think\\": "src"
+                },
+                "files": [
+                    "src/helper.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "yunwuxin",
+                    "email": "448901948@qq.com"
+                }
+            ],
+            "description": "The ThinkPHP6 Helper Package",
+            "support": {
+                "issues": "https://github.com/top-think/think-helper/issues",
+                "source": "https://github.com/top-think/think-helper/tree/v3.1.5"
+            },
+            "time": "2021-06-21T06:17:31+00:00"
+        },
+        {
+            "name": "topthink/think-multi-app",
+            "version": "v1.0.14",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/think-multi-app.git",
+                "reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
+                "reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.0",
+                "topthink/framework": "^6.0.0"
+            },
+            "type": "library",
+            "extra": {
+                "think": {
+                    "services": [
+                        "think\\app\\Service"
+                    ]
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "think\\app\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "liu21st",
+                    "email": "liu21st@gmail.com"
+                }
+            ],
+            "description": "thinkphp6 multi app support",
+            "support": {
+                "issues": "https://github.com/top-think/think-multi-app/issues",
+                "source": "https://github.com/top-think/think-multi-app/tree/master"
+            },
+            "time": "2020-07-12T13:50:37+00:00"
+        },
+        {
+            "name": "topthink/think-orm",
+            "version": "v2.0.44",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/think-orm.git",
+                "reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/think-orm/zipball/5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
+                "reference": "5d3d5c1ebf8bfccf34bacd90edb42989b16ea409",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "ext-pdo": "*",
+                "php": ">=7.1.0",
+                "psr/log": "~1.0",
+                "psr/simple-cache": "^1.0",
+                "topthink/think-helper": "^3.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^7|^8|^9.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "think\\": "src"
+                },
+                "files": [
+                    "stubs/load_stubs.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "liu21st",
+                    "email": "liu21st@gmail.com"
+                }
+            ],
+            "description": "think orm",
+            "keywords": [
+                "database",
+                "orm"
+            ],
+            "support": {
+                "issues": "https://github.com/top-think/think-orm/issues",
+                "source": "https://github.com/top-think/think-orm/tree/v2.0.44"
+            },
+            "time": "2021-07-21T02:22:31+00:00"
+        }
+    ],
+    "packages-dev": [
+        {
+            "name": "symfony/polyfill-mbstring",
+            "version": "v1.23.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-mbstring.git",
+                "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
+                "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-mbstring": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Mbstring\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for the Mbstring extension",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "mbstring",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-05-27T12:26:48+00:00"
+        },
+        {
+            "name": "symfony/polyfill-php72",
+            "version": "v1.23.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-php72.git",
+                "reference": "9a142215a36a3888e30d0a9eeea9766764e96976"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976",
+                "reference": "9a142215a36a3888e30d0a9eeea9766764e96976",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Php72\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-05-27T09:17:38+00:00"
+        },
+        {
+            "name": "symfony/polyfill-php80",
+            "version": "v1.23.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-php80.git",
+                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
+                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Php80\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ],
+                "classmap": [
+                    "Resources/stubs"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Ion Bazan",
+                    "email": "ion.bazan@gmail.com"
+                },
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-07-28T13:41:28+00:00"
+        },
+        {
+            "name": "symfony/var-dumper",
+            "version": "v4.4.31",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/var-dumper.git",
+                "reference": "1f12cc0c2e880a5f39575c19af81438464717839"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1f12cc0c2e880a5f39575c19af81438464717839",
+                "reference": "1f12cc0c2e880a5f39575c19af81438464717839",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.3",
+                "symfony/polyfill-mbstring": "~1.0",
+                "symfony/polyfill-php72": "~1.5",
+                "symfony/polyfill-php80": "^1.16"
+            },
+            "conflict": {
+                "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
+                "symfony/console": "<3.4"
+            },
+            "require-dev": {
+                "ext-iconv": "*",
+                "symfony/console": "^3.4|^4.0|^5.0",
+                "symfony/process": "^4.4|^5.0",
+                "twig/twig": "^1.43|^2.13|^3.0.4"
+            },
+            "suggest": {
+                "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
+                "ext-intl": "To show region name in time zone dump",
+                "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
+            },
+            "bin": [
+                "Resources/bin/var-dump-server"
+            ],
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "Resources/functions/dump.php"
+                ],
+                "psr-4": {
+                    "Symfony\\Component\\VarDumper\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Provides mechanisms for walking through any arbitrary PHP variable",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "debug",
+                "dump"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/var-dumper/tree/v4.4.31"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-09-24T15:30:11+00:00"
+        },
+        {
+            "name": "topthink/think-trace",
+            "version": "v1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/think-trace.git",
+                "reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/think-trace/zipball/9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
+                "reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.0",
+                "topthink/framework": "^6.0.0"
+            },
+            "type": "library",
+            "extra": {
+                "think": {
+                    "services": [
+                        "think\\trace\\Service"
+                    ],
+                    "config": {
+                        "trace": "src/config.php"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "think\\trace\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "liu21st",
+                    "email": "liu21st@gmail.com"
+                }
+            ],
+            "description": "thinkphp debug trace",
+            "support": {
+                "issues": "https://github.com/top-think/think-trace/issues",
+                "source": "https://github.com/top-think/think-trace/tree/v1.4"
+            },
+            "time": "2020-06-29T05:27:28+00:00"
+        }
+    ],
+    "aliases": [],
+    "minimum-stability": "stable",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": {
+        "php": ">=7.1.0"
+    },
+    "platform-dev": [],
+    "plugin-api-version": "2.1.0"
+}

+ 32 - 0
config/app.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | 应用设置
+// +----------------------------------------------------------------------
+
+return [
+    // 应用地址
+    'app_host'         => env('app.host', ''),
+    // 应用的命名空间
+    'app_namespace'    => '',
+    // 是否启用路由
+    'with_route'       => true,
+    // 默认应用
+    'default_app'      => 'index',
+    // 默认时区
+    'default_timezone' => 'Asia/Shanghai',
+
+    // 应用映射(自动多应用模式有效)
+    'app_map'          => [],
+    // 域名绑定(自动多应用模式有效)
+    'domain_bind'      => [],
+    // 禁止URL访问的应用列表(自动多应用模式有效)
+    'deny_app_list'    => [],
+
+    // 异常页面的模板文件
+    'exception_tmpl'   => app()->getThinkPath() . 'tpl/think_exception.tpl',
+
+    // 错误显示信息,非调试模式有效
+    'error_message'    => '页面错误!请稍后再试~',
+    // 显示错误信息
+    'show_error_msg'   => false,
+];

+ 39 - 0
config/cache.php

@@ -0,0 +1,39 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | 缓存设置
+// +----------------------------------------------------------------------
+
+return [
+    // 默认缓存驱动
+    //'default' => env('cache.driver', 'file'),
+    'default' => env('cache.driver', 'redis'),
+
+    // 缓存连接方式配置
+    'stores'  => [
+        'file' => [
+            // 驱动方式
+            'type'       => 'File',
+            // 缓存保存目录
+            'path'       => '',
+            // 缓存前缀
+            'prefix'     => '',
+            // 缓存有效期 0表示永久缓存
+            'expire'     => 0,
+            // 缓存标签前缀
+            'tag_prefix' => 'tag:',
+            // 序列化机制 例如 ['serialize', 'unserialize']
+            'serialize'  => [],
+        ],
+        // 更多的缓存连接
+        'redis'   =>  [
+            // 驱动方式
+            'type'   => 'redis',
+            // 服务器地址
+            'host'       => '127.0.0.1',
+            'port'     => '6379',
+            'password' => '',
+            'select'   => '0',
+        ],
+    ],
+];

+ 9 - 0
config/console.php

@@ -0,0 +1,9 @@
+<?php
+// +----------------------------------------------------------------------
+// | 控制台配置
+// +----------------------------------------------------------------------
+return [
+    // 指令定义
+    'commands' => [
+    ],
+];

+ 20 - 0
config/cookie.php

@@ -0,0 +1,20 @@
+<?php
+// +----------------------------------------------------------------------
+// | Cookie设置
+// +----------------------------------------------------------------------
+return [
+    // cookie 保存时间
+    'expire'    => 0,
+    // cookie 保存路径
+    'path'      => '/',
+    // cookie 有效域名
+    'domain'    => '',
+    //  cookie 启用安全传输
+    'secure'    => false,
+    // httponly设置
+    'httponly'  => false,
+    // 是否使用 setcookie
+    'setcookie' => true,
+    // samesite 设置,支持 'strict' 'lax'
+    'samesite'  => '',
+];

+ 60 - 0
config/database.php

@@ -0,0 +1,60 @@
+<?php
+
+return [
+    // 默认使用的数据库连接配置
+    'default'         => env('database.driver', 'mysql'),
+
+    // 自定义时间查询规则
+    'time_query_rule' => [],
+
+    // 自动写入时间戳字段
+    // true为自动识别类型 false关闭
+    // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
+    'auto_timestamp'  => true,
+
+    // 时间字段取出后的默认时间格式
+    'datetime_format' => 'Y-m-d H:i:s',
+
+    // 数据库连接配置信息
+    'connections'     => [
+        'mysql' => [
+            // 数据库类型
+            'type'            => env('database.type', 'mysql'),
+            // 服务器地址
+            'hostname'        => env('database.hostname', '116.62.18.192'),
+            // 数据库名
+            'database'        => env('database.database', 'ahsy'),
+            // 用户名
+            'username'        => env('database.username', 'ahsy'),
+            // 密码
+            'password'        => env('database.password', 'zyh661130'),
+            // 端口
+            'hostport'        => env('database.hostport', '3306'),
+            // 数据库连接参数
+            'params'          => [],
+            // 数据库编码默认采用utf8
+            'charset'         => env('database.charset', 'utf8'),
+            // 数据库表前缀
+            'prefix'          => env('database.prefix', 't_'),
+
+            // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+            'deploy'          => 0,
+            // 数据库读写是否分离 主从式有效
+            'rw_separate'     => false,
+            // 读写分离后 主服务器数量
+            'master_num'      => 1,
+            // 指定从服务器序号
+            'slave_no'        => '',
+            // 是否严格检查字段是否存在
+            'fields_strict'   => true,
+            // 是否需要断线重连
+            'break_reconnect' => false,
+            // 监听SQL
+            'trigger_sql'     => env('app_debug', true),
+            // 开启字段缓存
+            'fields_cache'    => false,
+        ],
+
+        // 更多的数据库配置信息
+    ],
+];

+ 24 - 0
config/filesystem.php

@@ -0,0 +1,24 @@
+<?php
+
+return [
+    // 默认磁盘
+    'default' => env('filesystem.driver', 'local'),
+    // 磁盘列表
+    'disks'   => [
+        'local'  => [
+            'type' => 'local',
+            'root' => app()->getRuntimePath() . 'storage',
+        ],
+        'public' => [
+            // 磁盘类型
+            'type'       => 'local',
+            // 磁盘路径
+            'root'       => app()->getRootPath() . 'public/storage',
+            // 磁盘路径对应的外部URL路径
+            'url'        => '/storage',
+            // 可见性
+            'visibility' => 'public',
+        ],
+        // 更多的磁盘配置信息
+    ],
+];

+ 12 - 0
config/jwt.php

@@ -0,0 +1,12 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/8
+ */
+return [
+    'issuer' => 'SongGuiBin',//签发人
+    'audience' => 'new.suyuan.com',//接收人
+    'expiration' => '36000', //有效期
+    'secret' =>'poiuytrewq', // 秘钥
+];

+ 27 - 0
config/lang.php

@@ -0,0 +1,27 @@
+<?php
+// +----------------------------------------------------------------------
+// | 多语言设置
+// +----------------------------------------------------------------------
+
+return [
+    // 默认语言
+    'default_lang'    => env('lang.default_lang', 'zh-cn'),
+    // 允许的语言列表
+    'allow_lang_list' => [],
+    // 多语言自动侦测变量名
+    'detect_var'      => 'lang',
+    // 是否使用Cookie记录
+    'use_cookie'      => true,
+    // 多语言cookie变量
+    'cookie_var'      => 'think_lang',
+    // 多语言header变量
+    'header_var'      => 'think-lang',
+    // 扩展语言包
+    'extend_list'     => [],
+    // Accept-Language转义为对应语言包名称
+    'accept_language' => [
+        'zh-hans-cn' => 'zh-cn',
+    ],
+    // 是否支持语言分组
+    'allow_group'     => false,
+];

+ 45 - 0
config/log.php

@@ -0,0 +1,45 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | 日志设置
+// +----------------------------------------------------------------------
+return [
+    // 默认日志记录通道
+    'default'      => env('log.channel', 'file'),
+    // 日志记录级别
+    'level'        => [],
+    // 日志类型记录的通道 ['error'=>'email',...]
+    'type_channel' => [],
+    // 关闭全局日志写入
+    'close'        => false,
+    // 全局日志处理 支持闭包
+    'processor'    => null,
+
+    // 日志通道列表
+    'channels'     => [
+        'file' => [
+            // 日志记录方式
+            'type'           => 'File',
+            // 日志保存目录
+            'path'           => '',
+            // 单文件日志写入
+            'single'         => false,
+            // 独立日志级别
+            'apart_level'    => [],
+            // 最大日志文件数量
+            'max_files'      => 0,
+            // 使用JSON格式记录
+            'json'           => false,
+            // 日志处理
+            'processor'      => null,
+            // 关闭通道日志写入
+            'close'          => false,
+            // 日志输出格式化
+            'format'         => '[%s][%s] %s',
+            // 是否实时写入
+            'realtime_write' => false,
+        ],
+        // 其它日志通道配置
+    ],
+
+];

+ 8 - 0
config/middleware.php

@@ -0,0 +1,8 @@
+<?php
+// 中间件配置
+return [
+    // 别名或分组
+    'alias'    => [],
+    // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
+    'priority' => [],
+];

+ 45 - 0
config/route.php

@@ -0,0 +1,45 @@
+<?php
+// +----------------------------------------------------------------------
+// | 路由设置
+// +----------------------------------------------------------------------
+
+return [
+    // pathinfo分隔符
+    'pathinfo_depr'         => '/',
+    // URL伪静态后缀
+    'url_html_suffix'       => 'html',
+    // URL普通方式参数 用于自动生成
+    'url_common_param'      => true,
+    // 是否开启路由延迟解析
+    'url_lazy_route'        => false,
+    // 是否强制使用路由
+    'url_route_must'        => false,
+    // 合并路由规则
+    'route_rule_merge'      => false,
+    // 路由是否完全匹配
+    'route_complete_match'  => false,
+    // 访问控制器层名称
+    'controller_layer'      => 'controller',
+    // 空控制器名
+    'empty_controller'      => 'Error',
+    // 是否使用控制器后缀
+    'controller_suffix'     => false,
+    // 默认的路由变量规则
+    'default_route_pattern' => '[\w\.]+',
+    // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
+    'request_cache_key'     => false,
+    // 请求缓存有效期
+    'request_cache_expire'  => null,
+    // 全局请求缓存排除规则
+    'request_cache_except'  => [],
+    // 默认控制器名
+    'default_controller'    => 'Index',
+    // 默认操作名
+    'default_action'        => 'index',
+    // 操作方法后缀
+    'action_suffix'         => '',
+    // 默认JSONP格式返回的处理方法
+    'default_jsonp_handler' => 'jsonpReturn',
+    // 默认JSONP处理方法
+    'var_jsonp_handler'     => 'callback',
+];

+ 19 - 0
config/session.php

@@ -0,0 +1,19 @@
+<?php
+// +----------------------------------------------------------------------
+// | 会话设置
+// +----------------------------------------------------------------------
+
+return [
+    // session name
+    'name'           => 'PHPSESSID',
+    // SESSION_ID的提交变量,解决flash上传跨域
+    'var_session_id' => '',
+    // 驱动方式 支持file cache
+    'type'           => 'file',
+    // 存储连接标识 当type使用cache的时候有效
+    'store'          => null,
+    // 过期时间
+    'expire'         => 1440,
+    // 前缀
+    'prefix'         => '',
+];

+ 47 - 0
config/status.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/8
+ */
+
+return [
+    'success'=>[0,'success'],
+    'error' => [1, 'error'],
+
+
+    //用户登录相关的错误
+    'err_username_or_password'=>['-1', '用户名或密码错误'],
+    'err_user_not_exist'=>['100','用户不存在'],
+
+
+    //JwtMiddleware相关错误
+    'err_unKnow'=>['200','未知错误'],
+    'err_params'=>['300','参数错误'],
+
+
+    //数据操作有关错误
+    'none_authority' => ['400', '无权操作'],
+    'none_data' => ['401', '未选取有效数据'],
+    'err_public_status'=>['402','当前任务不可废止'],
+
+
+    //lib/update上传相关的错误
+    'undefined_error'=>['1000','上传文件发生未知错误'],
+    'no_file_to_uploaded' => ['1000', '未上传任何文件'],
+
+
+    //模型操作相关的错误
+    'none_model_info'=>['2004','未选取有效模型'],
+    'none_model_product'=>['2005','检测对象未选取有效数据'],
+    'none_model_pesticides'=>['2006','检测项未选取有效数据'],
+
+    //任务操作相关的错误
+    'err_task_auth'=>['3004','权限不足,无法操作该任务'],
+
+
+    //数据库操作相关错误
+    'err_data_upload' => ['4004', '数据上传失败,请重试'],
+
+
+];

+ 10 - 0
config/trace.php

@@ -0,0 +1,10 @@
+<?php
+// +----------------------------------------------------------------------
+// | Trace设置 开启调试模式后有效
+// +----------------------------------------------------------------------
+return [
+    // 内置Html和Console两种方式 支持扩展
+    'type'    => 'Html',
+    // 读取的日志通道名
+    'channel' => '',
+];

+ 19 - 0
config/upload.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ *
+ *User:Administrator
+ *Date:2021/10/10
+ */
+
+return [
+    // 阿里云主账号AccessKey,在OSS控制台主页常用入口处有快速通道可以快速查看你的AccessKey ID($accessKeyId)以及Access Key Secret($accessKeySecret )
+    'aliyun_oss_accessKeyId_syjc'=>'LTAI4G1xGunUnwkgq48jFWi9',
+    'aliyun_oss_accessKeySecret_syjc'=>'17PK5dY7WnLJR1ejgsopTUBUOzS05S',
+    'aliyun_oss_endpoint_syjc'=>'http://oss-cn-hangzhou.aliyuncs.com',        //Endpoint(地域节点)查看位置在文章下方
+    'aliyun_oss_bucket_syjc'=>'syjcimage',//创建Bucket填写的名称
+    'aliyun_oss_save_path_syjc'=>'govFile/'.date("Y/m/d"). '/',        //设置保存的路径(前面不要加'/',否则会出错)
+   // 'aliyun_oss_save_path_syjc'=>'govFile/'.time(). '/',        //设置保存的路径(前面不要加'/',否则会出错)
+
+
+
+];

+ 25 - 0
config/view.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | 模板设置
+// +----------------------------------------------------------------------
+
+return [
+    // 模板引擎类型使用Think
+    'type'          => 'Think',
+    // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
+    'auto_rule'     => 1,
+    // 模板目录名
+    'view_dir_name' => 'view',
+    // 模板后缀
+    'view_suffix'   => 'html',
+    // 模板文件名分隔符
+    'view_depr'     => DIRECTORY_SEPARATOR,
+    // 模板引擎普通标签开始标记
+    'tpl_begin'     => '{',
+    // 模板引擎普通标签结束标记
+    'tpl_end'       => '}',
+    // 标签库标签开始标记
+    'taglib_begin'  => '{',
+    // 标签库标签结束标记
+    'taglib_end'    => '}',
+];

+ 2 - 0
extend/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 0 - 0
nginx.htaccess


+ 0 - 0
public/.htaccess


BIN
public/favicon.ico


+ 24 - 0
public/index.php

@@ -0,0 +1,24 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+// [ 应用入口文件 ]
+namespace think;
+
+require __DIR__ . '/../vendor/autoload.php';
+
+// 执行HTTP应用并响应
+$http = (new App())->http;
+
+$response = $http->run();
+
+$response->send();
+
+$http->end($response);

+ 6 - 0
public/nginx.htaccess

@@ -0,0 +1,6 @@
+  location / {
+   if (!-e $request_filename) {
+   rewrite  ^(.*)$  /index.php?s=/$1  last;
+   break;
+    }
+ }

+ 2 - 0
public/robots.txt

@@ -0,0 +1,2 @@
+User-agent: *
+Disallow:

+ 19 - 0
public/router.php

@@ -0,0 +1,19 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+// $Id$
+
+if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
+    return false;
+} else {
+    $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php';
+
+    require __DIR__ . "/index.php";
+}

+ 2 - 0
public/static/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 22 - 0
route/app.php

@@ -0,0 +1,22 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+use think\facade\Route;
+//
+//Route::get('/swagger', function() {
+//    $openapi = \OpenApi\scan('../app/api/controller/v1');
+//
+//    header('Content-Type: application/json');
+//    echo $openapi->toJson();
+//})->middleware(function($request,\Closure $next){
+
+
+//    return $next($request);});
+

+ 2 - 0
runtime/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

Some files were not shown because too many files changed in this diff