likang vor 2 Jahren
Ursprung
Commit
c6f6cf2dba

+ 23 - 0
catch/equipment/EquipmentService.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\equipment;
+
+use catcher\ModuleService;
+
+class EquipmentService extends ModuleService
+{
+    public function loadRouteFrom()
+    {
+        // TODO: Implement loadRouteFrom() method.
+        return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
+    }
+}

+ 107 - 0
catch/equipment/controller/EquipmentType.php

@@ -0,0 +1,107 @@
+<?php
+/*
+ * @Descripttion: 
+ * @version: 1.0.0
+ * @Author: likang
+ * @Date: 2022-06-17 15:45:05
+ * @LastEditors: likang
+ * @LastEditTime: 2022-06-21 11:03:53
+ */
+
+namespace catchAdmin\equipment\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\equipment\model\EquipmentType as equipmentTypeModel;
+
+class EquipmentType extends CatchController
+{
+    protected $equipmentTypeModel;
+    
+    public function __construct(EquipmentTypeModel $equipmentTypeModel)
+    {
+        $this->equipmentTypeModel = $equipmentTypeModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年06月17日 15:45
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        $pch =null;
+       $pch = $this->equipmentTypeModel->where('pid',0)->order('order asc')->select()->toArray();
+       foreach($pch as $key=>$value)
+       {    
+            $list= $this->equipmentTypeModel->where('pid',$value['id'])->order('order asc')->select()->toArray();
+            foreach($list as $k=>$v)
+            {
+                $list[$k]['pid'] = strval($v['pid']);
+                $list[$k]['status']=strval($v['status']);
+            }
+            $pch[$key]['children']= $list;
+            $pch[$key]['pid'] = strval($value['pid']);
+            $pch[$key]['status']=strval($value['status']);
+       }
+
+        return CatchResponse::success($pch);
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年06月17日 15:45
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        return CatchResponse::success($this->equipmentTypeModel->storeBy($request->post()));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年06月17日 15:45
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->equipmentTypeModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年06月17日 15:45
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        
+        return CatchResponse::success($this->equipmentTypeModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年06月17日 15:45
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        if($id<=7)
+        {
+            return CatchResponse::fail('该类型不能删除');
+        }
+        return CatchResponse::success($this->equipmentTypeModel->deleteBy($id,true));
+    }
+    /**
+     * @Descripttion: 获取父类设备种类
+     * @name: likang
+     * @return {*}
+     */    
+    public function findParentEquipmentType()
+    {
+        $pch = $this->equipmentTypeModel->where('pid',0)->order('order asc')->select();
+        return CatchResponse::success($pch);
+    }
+}

+ 42 - 0
catch/equipment/database/migrations/20220617154512_equipment_type.php

@@ -0,0 +1,42 @@
+<?php
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class EquipmentType 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('equipment_type', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '设备类型表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('pid', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '父类的id',])
+			->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '1 有效  -1 无效',])
+			->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '名称',])
+            ->addColumn('order', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'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' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 40 - 0
catch/equipment/model/EquipmentType.php

@@ -0,0 +1,40 @@
+<?php
+/*
+ * @Descripttion: 
+ * @version: 1.0.0
+ * @Author: likang
+ * @Date: 2022-06-17 15:45:06
+ * @LastEditors: likang
+ * @LastEditTime: 2022-06-20 20:16:14
+ */
+
+namespace catchAdmin\equipment\model;
+
+use catcher\base\CatchModel as Model;
+
+class EquipmentType extends Model
+{
+    // 表名
+    public $name = 'equipment_type';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 父类的id
+        'pid',
+        // 1 有效  -1 无效
+        'status',
+        // 名称
+        'name',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+        //顺序
+        'order'
+    );
+
+}

+ 15 - 0
catch/equipment/module.json

@@ -0,0 +1,15 @@
+{
+    "name": "equipment",
+    "alias": "equipment",
+    "description": "设备管理",
+    "version": "1.0.0",
+    "keywords": [""],
+    "order": 0,
+    "services": [
+        "\\catchAdmin\\equipment\\EquipmentService"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": [],
+    "enable": true
+}

+ 17 - 0
catch/equipment/route.php

@@ -0,0 +1,17 @@
+<?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){
+	// equipmentType路由
+	$router->resource('equipmentType', '\catchAdmin\equipment\controller\EquipmentType');
+	$router->get('findParentEquipmentTyp','\catchAdmin\equipment\controller\EquipmentType@findParentEquipmentType');
+})->middleware('auth');

+ 69 - 0
catch/hydraulic/controller/HydEquipment.php

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

+ 2 - 2
catch/hydraulic/controller/WrenchCheckRecord.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Date: 2022-06-10 16:59:25
  * @LastEditors: likang
- * @LastEditTime: 2022-06-13 15:19:23
+ * @LastEditTime: 2022-06-13 15:35:12
  */
 namespace catchAdmin\hydraulic\controller;
 
@@ -84,7 +84,7 @@ class WrenchCheckRecord extends CatchController
     {  
        $data = $request->get();
         $check_id = $data['id'];
-        $list =   WrenchCheckRecordData::where('wrench_check_id',$check_id)->order('stress','desc')->select();
+        $list =   WrenchCheckRecordData::where('wrench_check_id',$check_id)->order('stress','asc')->select();
         return CatchResponse::success($list);
     }
 }

+ 52 - 0
catch/hydraulic/database/migrations/20220621110250_hydraulic_equipment.php

@@ -0,0 +1,52 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class HydraulicEquipment 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('hydraulic_equipment', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('material_number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '物料号',])
+			->addColumn('equipment_type', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '设备类别',])
+			->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '工具名称',])
+			->addColumn('equipment_model', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '设备型号',])
+			->addColumn('issue_unit', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '发放单位',])
+			->addColumn('fixed_asset_number', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '固定资产编号',])
+			->addColumn('fixed_asset_number2', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '类固定资产编号',])
+			->addColumn('serial_number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '序列号',])
+			->addColumn('factory_number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '出厂编号',])
+			->addColumn('check_last_time', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '上次校验时间',])
+			->addColumn('check_next_time', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '下次校验时间',])
+			->addColumn('check_status', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '校验状态',])
+			->addColumn('status', 'string', ['limit' => 10,'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' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

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

@@ -0,0 +1,49 @@
+<?php
+
+namespace catchAdmin\hydraulic\model;
+
+use catcher\base\CatchModel as Model;
+
+class HydEquipment extends Model
+{
+    // 表名
+    public $name = 'hydraulic_equipment';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 物料号
+        'material_number',
+        // 设备类别
+        'equipment_type',
+        // 工具名称
+        'name',
+        // 设备型号
+        'equipment_model',
+        // 发放单位
+        'issue_unit',
+        // 固定资产编号
+        'fixed_asset_number',
+        // 类固定资产编号
+        'fixed_asset_number2',
+        // 序列号
+        'serial_number',
+        // 出厂编号
+        'factory_number',
+        // 上次校验时间
+        'check_last_time',
+        // 下次校验时间
+        'check_next_time',
+        // 校验状态
+        'check_status',
+        // 状态
+        'status',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 2 - 0
catch/hydraulic/route.php

@@ -25,4 +25,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');