likang 3 lat temu
rodzic
commit
25bfd2da6c

+ 1 - 1
catch/equipment/controller/EquipmentType.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Date: 2022-06-17 15:45:05
  * @LastEditors: likang
- * @LastEditTime: 2022-06-21 11:03:53
+ * @LastEditTime: 2022-06-21 14:19:07
  */
 
 namespace catchAdmin\equipment\controller;

+ 8 - 1
catch/equipment/model/EquipmentType.php

@@ -5,12 +5,13 @@
  * @Author: likang
  * @Date: 2022-06-17 15:45:06
  * @LastEditors: likang
- * @LastEditTime: 2022-06-20 20:16:14
+ * @LastEditTime: 2022-06-21 13:57:42
  */
 
 namespace catchAdmin\equipment\model;
 
 use catcher\base\CatchModel as Model;
+use think\Model as ThinkModel;
 
 class EquipmentType extends Model
 {
@@ -36,5 +37,11 @@ class EquipmentType extends Model
         //顺序
         'order'
     );
+    public function getParentNamebyChildId($id)
+    {
+        $pid =$this->where('id',$id)->value('pid');
+        $name =  $this->where('id',$pid)->value('name');
+        return $name;
+    }
 
 }

+ 8 - 6
catch/hydraulic/database/migrations/20220303142809_hydraulic.php

@@ -1,4 +1,12 @@
 <?php
+/*
+ * @Descripttion: 
+ * @version: 1.0.0
+ * @Author: likang
+ * @Date: 2022-05-27 13:34:31
+ * @LastEditors: likang
+ * @LastEditTime: 2022-06-21 16:40:42
+ */
 
 use think\migration\Migrator;
 use think\migration\db\Column;
@@ -32,13 +40,7 @@ class Hydraulic extends Migrator
         $table = $this->table('hydraulic', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
         //基础信息
         $table->addColumn('number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '编号',])
-			->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '型号',])
 			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
-			->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '名称',])
-			->addColumn('is_used', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '使用状态',])
-			->addColumn('brand', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '品牌',])
-			->addColumn('supplier', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '供应商',])
-			->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
             ->addColumn('remark', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '备注',])
 			->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '告警状态',])
 			->addColumn('net_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '网络状态',])

+ 1 - 1
catch/hydraulic/database/migrations/20220505112140_hydraulic_add_fields.php

@@ -42,7 +42,7 @@ class HydraulicAddFields extends Migrator
 
             $table  ->addColumn('imei', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => 'imei号',])
                     ->addColumn('sim_card', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => 'sim卡号',])
-                    ->addColumn('check_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => null,'signed' => true,'comment' => '校验时间',])
+                    ->addColumn('eq_id', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '设备id',])
                     ->addColumn('effective_period', 'string', ['limit' => 8,'null' => true,'signed' => true,'comment' => '有效周期',])
                     ->addColumn('effective_time', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '有效截止时间',])
                     ->update();

+ 11 - 13
catch/hydraulic/database/migrations/20220506141132_wrench.php

@@ -1,4 +1,12 @@
 <?php
+/*
+ * @Descripttion: 
+ * @version: 1.0.0
+ * @Author: likang
+ * @Date: 2022-05-27 13:34:31
+ * @LastEditors: likang
+ * @LastEditTime: 2022-06-21 16:46:12
+ */
 
 use think\migration\Migrator;
 use think\migration\db\Column;
@@ -31,29 +39,19 @@ class Wrench extends Migrator
     {
         $table = $this->table('wrench', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '液压扳手' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
         $table->addColumn('number', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '编号',])
-			->addColumn('model', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '型号',])
 			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
-			->addColumn('name', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '名称',])
-			->addColumn('is_used', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '使用状态',])
-			->addColumn('brand', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '品牌',])
-			->addColumn('supplier', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '供应商',])
-			->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
+			->addColumn('eq_id', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '设备id',])
 			->addColumn('remark', 'string', ['limit' => 256,'null' => true,'signed' => true,'comment' => '备注',])
 			->addColumn('alarm_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '告警状态',])
 			->addColumn('net_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '网络状态',])
 			->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '在线时间',])
-			->addColumn('max_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大压力',])
-            ->addColumn('min_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小压力',])
+			->addColumn('pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '压力',])
             ->addColumn('angle_sensor', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '角度传感器',])
-            
-
-
 			->addColumn('checked_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '校验时间',])
 			->addColumn('checked_no', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验台编号',])
 			->addColumn('checked_res', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验结果',])
 			->addColumn('checked_user_id', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '操作员',])
-			->addColumn('max_torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大扭矩',])
-			->addColumn('min_torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小扭矩',])
+			->addColumn('torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '扭矩',])
 			->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' => '更新时间',])

+ 52 - 0
catch/hydraulic/model/HydEquipment.php

@@ -2,10 +2,14 @@
 
 namespace catchAdmin\hydraulic\model;
 
+use catchAdmin\equipment\model\EquipmentType;
 use catcher\base\CatchModel as Model;
+use catchAdmin\permissions\model\DataRangScopeTrait;
+use catchAdmin\system\model\SysDictData;
 
 class HydEquipment extends Model
 {
+    use DataRangScopeTrait;
     // 表名
     public $name = 'hydraulic_equipment';
     // 数据库字段映射
@@ -46,4 +50,52 @@ class HydEquipment extends Model
         // 软删除
         'deleted_at',
     );
+    public function getList()
+    {
+        $res =  $this->dataRange()
+            ->catchSearch()
+            ->append(['classification','equ_type_name', 'list'])
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+        return $res;
+    }
+    public function getClassificationAttr()
+    {
+        $id = $this->getData('equipment_type');
+        $eq = new EquipmentType();
+        $name = $eq->getParentNamebyChildId($id);
+        return $name;
+    }
+    public function getEquTypeNameAttr()
+    {
+        $id = $this->getData('equipment_type');
+        $name =  EquipmentType::where('id',$id)->value('name');
+        return $name;
+    }
+    public function getCheckStatusAttr()
+    {
+        $id = $this->getData('check_status');
+        $Dict =  new SysDictData();
+        $value = $Dict->getValueByCode('Check',$id);
+        return $value;
+    }
+    public function getStatusAttr()
+    {
+        $id = $this->getData('status');
+        $Dict =  new SysDictData();
+        $value = $Dict->getValueByCode('ToolStatus',$id);
+        return $value;
+    }
+    public function getCheckLastTimeAttr()
+    {
+        $time = $this->getData('check_last_time');
+        return date('Y-m-d',$time);
+    }
+    public function getCheckNextTimeAttr()
+    {
+        $time = $this->getData('check_next_time');
+        return date('Y-m-d',$time);
+    }
+    
+    
 }

+ 8 - 6
catch/hydraulic/model/Hydraulic.php

@@ -21,13 +21,13 @@ class Hydraulic extends Model
         // 所属部门
         'department_id',
         // 名称
-        'name',
+        //'name',
         // 使用状态
-        'is_used',
+        //'is_used',
         // 品牌
-        'brand',
+       // 'brand',
         // 供应商
-        'supplier',
+        //'supplier',
         // 出厂日期
         'out_date',
         // 告警状态
@@ -35,7 +35,7 @@ class Hydraulic extends Model
         // 网络状态
         'net_state',
         // 在线时间
-        'online_time',
+        //'online_time',
         //扭矩
         'torque',
         //压力
@@ -62,7 +62,9 @@ class Hydraulic extends Model
         'sim_card',
         'effective_time',
         'effective_period',
-        'check_time',
+        //设备的id
+        'eq_id'
+        
     );
      /**
      * 获取列表

+ 14 - 16
catch/hydraulic/model/Wrench.php

@@ -16,20 +16,22 @@ class Wrench extends Model
         'id',
         // 编号
         'number',
+        //设备id
+        'eq_id',
         // 型号
-        'model',
+        //'model',
         // 所属部门
         'department_id',
         // 名称
-        'name',
+        //'name',
         // 使用状态
-        'is_used',
+        //'is_used',
         // 品牌
-        'brand',
+        //'brand',
         // 供应商
-        'supplier',
+        //'supplier',
         // 出厂日期
-        'out_date',
+       // 'out_date',
         // 备注
         'remark',
         // 告警状态
@@ -37,24 +39,20 @@ class Wrench extends Model
         // 网络状态
         'net_state',
         // 在线时间
-        'online_time',
-        // 最大压力
-        'max_pressure',
+        //'online_time',
+        //最大压力
+        'pressure',
         // 最小压力
-        'min_pressure',
+       // 'min_pressure',
         'angle_sensor',
-        // 校验时间
-        'checked_at',
         // 校验台编号
         'checked_no',
         // 校验结果
         'checked_res',
         // 操作员
         'checked_user_id',
-        // 最大扭矩
-        'max_torque',
-        // 最小扭矩
-        'min_torque',
+        // 扭矩
+        'torque',
         // 创建人ID
         'creator_id',
         // 创建时间

+ 1 - 2
catch/hydraulic/route.php

@@ -1,5 +1,4 @@
 <?php
-
 // +----------------------------------------------------------------------
 // | CatchAdmin [Just Like ~ ]
 // +----------------------------------------------------------------------
@@ -25,6 +24,6 @@ $router->group(function () use ($router){
 	// 扳手校验路由
 	$router->resource('wrenchCheckRecord', '\catchAdmin\hydraulic\controller\WrenchCheckRecord');
 	$router->get('wrenchCheckRecordData', '\catchAdmin\hydraulic\controller\WrenchCheckRecord@decordDataList');
-	// hydEquipment路由
+	// 液压设备路由
 	$router->resource('hydEquipment', '\catchAdmin\hydraulic\controller\HydEquipment');
 })->middleware('auth');