Prechádzať zdrojové kódy

Merge branch 'master' of http://gogs.renlianiot.com:4000/zmcoding/smart-tool-api

tongshanglei 3 rokov pred
rodič
commit
b7ef440983

+ 26 - 1
catch/flange/controller/Flange.php

@@ -8,6 +8,7 @@ use catcher\base\CatchController;
 use catchAdmin\flange\model\Flange as model;
 use PhpParser\Node\Expr\FuncCall;
 use think\facade\Db;
+use think\response\Json;
 
 class Flange extends CatchController
 {
@@ -90,16 +91,40 @@ class Flange extends CatchController
           $where[]=['name','like','%'.$data['wind'].'%'];
         }
     
-        $wind_list = Db::name("wind")->field('id as wid,name as text')->select();
+        $wind_list = Db::name("wind")->field('id as wid,number as value,name as text')->select();
         $wind_list =json_decode(json_encode($wind_list),true);
+        
         foreach($wind_list as $key=>$item)
         {
             $wind_list[$key]['children'] = Db::name('fan')
             ->where('wind_id',$item['wid'])
             ->field('id as value,number as text')
             ->select();
+            $wind_list[$key]['value'] =(int)$item['value'];
         }
        return CatchResponse::success($wind_list);
     }
     
+    /**
+     * Undocumented 选择扳手
+     *
+     * @param [type] $request
+     * @return void
+     */
+   public function chooseWrench(Request $request)
+   {    
+       $data = $request->get();
+       $where = [];
+       if(!empty($data["id"]))
+       {
+           $ids = implode(',',$data['id']);
+            $where[] =["w.id","in",$ids];
+       }
+
+       $wrenchList =  Db::name("wrench")->alias('w')->leftJoin("device_mold d",'w.model=d.id')
+       ->where($where)->field('w.id as value,w.name as text,w.number,d.name as name')->select();
+
+       return CatchResponse::success($wrenchList);
+   }
+
 }

+ 69 - 6
catch/flange/model/Flange.php

@@ -59,12 +59,17 @@ class Flange extends Model
         'bolt_size',
         // 螺丝数量
         'bolt_number',
+        // 螺丝尺寸
+        'wind_id',
+        // 扳手
+        'wrench',
+        // 外径
+        'outside',
     );
-
     public function getList()
     {
         return $this->catchSearch()
-        ->append(['depart_name'])
+        ->append(['depart_name','model_type','wind_name','fan_number'])
         ->field('*')
         ->catchOrder()
         ->creator()
@@ -75,9 +80,67 @@ class Flange extends Model
         $id=$this->department_id;
         return Db::table('departments')->where('id', $id)->value('department_name');
     }
+    public function getModelTypeAttr()
+    { 
+        return Db::name('device_mold')->where('device_type',2)->where('id',$this->model)->value('name');
+    }
+    public function getModelAttr()
+    {
+        return (int) $this->getData('model');
+    }
+    public function getDepartmentIdAttr()
+    {
+        return (int) $this->getData('department_id');
+    }
+    public function getFanIdAttr()
+    {
+        return (int) $this->getData('fan_id');
+    }
+    public function setWrenchAttr($value)
+    {
+         $str = implode(',',$value);
+        return $str;
+    }
+    public function getWrenchAttr()
+    {
+        $str =null;
+        if(!empty($this->getData('wrench')))
+        {
+            $str =array_map('intval',explode(',', $this->getData('wrench')));
+        }
+        return $str;
+    }
+    /**
+     *获取风场名称
+     */
+    public function getWindNameAttr()
+    {
+        $fan_id =  $this->getData('fan_id');
+        $wind_id =  Db::name('fan')->where("id",$fan_id)->value("wind_id");
+        $name = Db::name("wind")->where('id',$wind_id)->value('name');
+        return $name;
+    }
+    //获取风机编号
+    public function getFanNumberAttr()
+    {
+        $fan_id =  $this->getData('fan_id');
+        $number =  Db::name('fan')->where("id",$fan_id)->value("number");
+        return $number;
+    }
+    //紧固方案
+    public function setFasteningSchemeAttr($value)
+    {
+         $str = implode(',',$value);
+        return $str;
+    }
+    public function getFasteningSchemeAttr()
+    {
+        $str =null;
+        if(!empty($this->getData('fastening_scheme')))
+        {
+            $str =array_map('intval',explode(',', $this->getData('fastening_scheme')));
+        }
+        return $str;
+    }
 
-
-
-
-  
 }

+ 2 - 0
catch/flange/route.php

@@ -14,4 +14,6 @@ $router->group(function () use ($router){
 	// flange路由
 	$router->resource('flange', '\catchAdmin\flange\controller\flange');
 	$router->get("getwindfan",'\catchAdmin\flange\controller\Flange@getWindFan');
+	//扳手类型
+	$router->get("wrenchtype",'\catchAdmin\flange\controller\Flange@chooseWrench');
 })->middleware('auth');

+ 23 - 0
catch/synscheme/SynschemeService.php

@@ -0,0 +1,23 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+namespace catchAdmin\synscheme;
+
+use catcher\ModuleService;
+
+class SynschemeService extends ModuleService
+{
+    public function loadRouteFrom()
+    {
+        // TODO: Implement loadRouteFrom() method.
+        return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
+    }
+}

+ 69 - 0
catch/synscheme/controller/Synscheme.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace catchAdmin\synscheme\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\synscheme\model\Synscheme as synschemeModel;
+
+class Synscheme extends CatchController
+{
+    protected $synschemeModel;
+    
+    public function __construct(SynschemeModel $synschemeModel)
+    {
+        $this->synschemeModel = $synschemeModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年05月09日 19:06
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->synschemeModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年05月09日 19:06
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        return CatchResponse::success($this->synschemeModel->storeBy($request->post()));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年05月09日 19:06
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->synschemeModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年05月09日 19:06
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        return CatchResponse::success($this->synschemeModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年05月09日 19:06
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->synschemeModel->deleteBy($id));
+    }
+}

+ 49 - 0
catch/synscheme/database/migrations/20220509112944_synscheme_add_field.php

@@ -0,0 +1,49 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+
+class SynschemeAddField extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        if ($this->hasTable('synscheme')) {
+            $table = $this->table('synscheme');
+
+            $table->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '名称',])
+                    ->update();
+        }
+
+
+    }
+}

+ 42 - 0
catch/synscheme/database/migrations/20220509190422_synscheme.php

@@ -0,0 +1,42 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class Synscheme extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        $table = $this->table('synscheme', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('hole', 'string', ['limit' => 11,'null' => true,'signed' => true,'comment' => '孔',])
+			->addColumn('step', 'string', ['limit' => 11,'null' => true,'signed' => true,'comment' => '步骤',])
+			->addColumn('data', 'string', ['limit' => 500,'null' => true,'signed' => true,'comment' => '同步数据 json',])
+			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
+			->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
+			->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 30 - 0
catch/synscheme/model/Synscheme.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace catchAdmin\synscheme\model;
+
+use catcher\base\CatchModel as Model;
+
+class Synscheme extends Model
+{
+    // 表名
+    public $name = 'synscheme';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 孔
+        'hole',
+        // 步骤
+        'step',
+        // 同步数据 json
+        'data',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+        'name'
+    );
+}

+ 15 - 0
catch/synscheme/module.json

@@ -0,0 +1,15 @@
+{
+    "name": "synscheme",
+    "alias": "synscheme",
+    "description": "同步方案",
+    "version": "1.0.0",
+    "keywords": [""],
+    "order": 0,
+    "services": [
+        "\\catchAdmin\\synscheme\\SynschemeService"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": [],
+    "enable": true
+}

+ 18 - 0
catch/synscheme/route.php

@@ -0,0 +1,18 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+// you should use `$router`
+$router->group(function () use ($router){
+	// synscheme路由
+	$router->resource('synscheme', '\catchAdmin\synscheme\controller\synscheme');
+	// synscheme路由
+	$router->resource('synscheme', '\catchAdmin\synscheme\controller\synscheme');
+})->middleware('auth');