likang 2 년 전
부모
커밋
0c2bc0b538

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

@@ -167,7 +167,12 @@ class HydEquipment extends CatchController
         'check_status'=>$data['check_status'],
         // 状态
         'status'=>$data['status'],
+        'address'=>$data['address'],
+        'longitude'=>$data['longitude'],
+        'latitude'=>$data['latitude']
         ];
+
+
         if($data['equipment_type']==2)
         {
             $hydraulic=[

+ 0 - 285
catch/hydraulic/controller/StorageEquipment.php

@@ -1,285 +0,0 @@
-<?php
-namespace catchAdmin\hydraulic\controller;
-error_reporting(1);
-use catchAdmin\equipment\model\EquipmentType;
-use catcher\base\CatchRequest as Request;
-use catcher\CatchResponse;
-use catcher\base\CatchController;
-use catchAdmin\hydraulic\model\HydEquipment as hydEquipmentModel;
-use catchAdmin\hydraulic\model\Hydraulic;
-use catchAdmin\hydraulic\model\Wrench;
-use catchAdmin\system\model\SysDictData;
-use catcher\base\CatchRequest;
-use PhpParser\Node\Stmt\Catch_;
-use think\facade\Db;
-
-class StorageEquipment 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
-    {
-        $data = $request->post();
-        $hydraulic = null;
-        $wrench = null;
-        $hydequ=[
-        // 物料号
-        'material_number'=>$data['material_number'],
-        // 设备类别
-        'equipment_type'=>$data['equipment_type'],
-        // 工具名称
-        'name'=>$data['name'],
-        // 设备型号
-        'equipment_model'=>$data['equipment_model'],
-        // 发放单位
-        'issue_unit'=>$data['issue_unit'],
-        // 固定资产编号
-        'fixed_asset_number'=>$data['fixed_asset_number'],
-        // 类固定资产编号
-        'fixed_asset_number2'=>$data['fixed_asset_number2'],
-        // 序列号
-        'serial_number'=>$data['serial_number'],
-        // 出厂编号
-        'factory_number'=>$data['factory_number'],
-        // 上次校验时间
-        'check_last_time'=>$data['check_last_time'],
-        // 下次校验时间
-        'check_next_time'=>$data['check_next_time'],
-        // 校验状态
-        'check_status'=>$data['check_status'],
-        // 状态
-        'status'=>$data['status'],
-        ];
-        Db::startTrans();
-        try{
-        $id = $this->hydEquipmentModel->storeBy($hydequ);
-        if($data['equipment_type']==2)
-        {
-            $hydraulic=[
-                 // 编号
-                'number'=>$data['number'],
-                // 所属部门
-                'department_id'=>$data['department_id'],
-                'remark'=>$data['remark']?$data['remark']:'',
-                'max_pressure'=>$data['max_pressure'],
-                'min_pressure'=>$data['min_pressure'],
-                'imei'=>$data['imei'],
-                'effective_period'=>$data['effective_period'],
-                //设备的id
-                'eq_id'=>$id
-            ];
-
-            Hydraulic::create($hydraulic);
-        }
-        //保存扳手
-        if($data['equipment_type']==3||$data['equipment_type']==4)
-        {
-            
-            $wrench = [
-                // 编号
-                'number'=>$data['number'],
-                //设备id
-                'eq_id'=>$id,
-                // 所属部门
-                'department_id'=>$data['department_id'],
-                'remark'=>$data['remark']?$data['remark']:'',
-                'pressure'=>$data['pressure'],
-                'angle_sensor'=>$data['angle_sensor'],
-                // 扭矩
-                'torque'=>$data['torque'],
-            ];
-            Wrench::create($wrench);
-        }
-    }catch(\Exception $e)
-    {
-        Db::rollback();
-        return  CatchResponse::fail($e->getMessage());
-    }
-        Db::commit();
-        return CatchResponse::success();
-    }
-    
-    /**
-     * 读取
-     * @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
-    {
-        $data = $request->post();
-        $hydraulic = null;
-        $wrench = null;
-        $hydequ=[
-        // 物料号
-        'material_number'=>$data['material_number'],
-        // 设备类别
-        'equipment_type'=>$data['equipment_type'],
-        // 工具名称
-        'name'=>$data['name'],
-        // 设备型号
-        'equipment_model'=>$data['equipment_model'],
-        // 发放单位
-        'issue_unit'=>$data['issue_unit'],
-        // 固定资产编号
-        'fixed_asset_number'=>$data['fixed_asset_number'],
-        // 类固定资产编号
-        'fixed_asset_number2'=>$data['fixed_asset_number2'],
-        // 序列号
-        'serial_number'=>$data['serial_number'],
-        // 出厂编号
-        'factory_number'=>$data['factory_number'],
-        // 上次校验时间
-        'check_last_time'=>$data['check_last_time']?strstr($data['check_last_time'],'-')?strtotime($data['check_last_time']):$data['check_last_time']:'',
-        // 下次校验时间
-        'check_next_time'=>$data['check_next_time']?strstr($data['check_next_time'],'-')?strtotime($data['check_next_time']):$data['check_next_time']:'',
-        // 校验状态
-        'check_status'=>$data['check_status'],
-        // 状态
-        'status'=>$data['status'],
-        ];
-        if($data['equipment_type']==2)
-        {
-            $hydraulic=[
-                 // 编号
-                'number'=>$data['number'],
-                // 所属部门
-                'department_id'=>$data['department_id'],
-                //备注
-                'remark'=>$data['remark'],
-                'max_pressure'=>$data['max_pressure'],
-                'min_pressure'=>$data['min_pressure'],
-                'imei'=>$data['imei'],
-                'effective_period'=>$data['effective_period'],
-                //设备的id
-                'eq_id'=>$id
-            ];
-            Hydraulic::where('eq_id',$id)->update($hydraulic);
-        }
-        //保存扳手
-        if($data['equipment_type']==3||$data['equipment_type']==4)
-        {
-            
-            $wrench = [
-                // 编号
-                'number'=>$data['number'],
-                //设备id
-                'eq_id'=>$id,
-                // 所属部门
-                'department_id'=>$data['department_id'],
-                'remark'=>$data['remark'],
-            
-                'pressure'=>$data['pressure'],
-                'angle_sensor'=>$data['angle_sensor'],
-                // 扭矩
-                'torque'=>$data['torque'],
-            ];
-            Wrench::where('id',$data['list']['id'])->update($wrench);
-        }
-        return CatchResponse::success($this->hydEquipmentModel->updateBy($id, $hydequ));
-    }
-    
-    /**
-     * 删除
-     * @time 2022年06月21日 11:02
-     * @param $id
-     */
-    public function delete($id) : \think\Response
-    { 
-        $data = array();
-        $where = [];
-        if(is_array($id))
-        {
-            $where[]=['id','in',$id];
-          $data = $this->hydEquipmentModel->where($where)->select()->toArray();
-        }
-        else
-        {
-            $list =  $this->hydEquipmentModel->where('id',$id)->find();
-            $data[] = $list;
-        }
-        Db::startTrans();
-        try{
-            foreach($data as $item)
-            {
-                if($item['equipment_type']==2)
-                {
-                    Hydraulic::where('eq_id','=',$item['id'])->delete();
-                }
-                if($item['equipment_type']==3||$item['equipment_type']==4)
-                {
-                    Wrench::where('eq_id','=',$item['id'])->delete();
-                }
-
-            }
-           
-            $this->hydEquipmentModel->deleteBy($id,true);
-
-        }catch (\Exception $e)
-        {
-            Db::rollback();
-            return  CatchResponse::fail($e->getMessage());
-        }
-        Db::commit();
-        return CatchResponse::success();
-    }
-    /**
-     * @Descripttion: 获取设备状态和校验状态
-     * @name: likang
-     * @return {*}
-     */    
-    public function getHydEquipmentType(Request $request)
-    {
-       $data=$request->get();
-       $code =  $data['code'];
-        $sysDict = new SysDictData();
-        $list =  $sysDict->getTypesByCodeWithRemark($code,'');
-        return CatchResponse::success($list);
-        
-    }
-    /**
-     * 根据设备类别统计每个设备的总数
-     */
-    public function getTotalByEquipmentType()
-    {
-        
-        $list = EquipmentType::where('pid',1)->order('order asc')->field('id,name')->limit(4)->select();
-        foreach($list as $key=>$value)
-        {
-            $list[$key]['total']=$this->hydEquipmentModel->where('equipment_type',$value['id'])->count();
-        }
-       return CatchResponse::success($list);
-
-    }
-    
-}

+ 3 - 1
catch/hydraulic/database/migrations/20220621110250_hydraulic_equipment.php

@@ -1,5 +1,4 @@
 <?php
-
 use think\migration\Migrator;
 use think\migration\db\Column;
 use Phinx\Db\Adapter\MysqlAdapter;
@@ -43,6 +42,9 @@ class HydraulicEquipment extends Migrator
 			->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('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
+            ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
+            ->addColumn('address', 'string', ['limit' => 255,'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' => '更新时间',])

+ 9 - 1
catch/hydraulic/model/DeviceMold.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-25 16:36:52
+ */
 
 namespace catchAdmin\hydraulic\model;
 
@@ -40,7 +48,7 @@ class DeviceMold extends Model
         return $res;
     }
 
-    
+     
     /**
      * 名称搜索
      */

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

@@ -40,6 +40,9 @@ class HydEquipment extends Model
         // 校验状态
         'check_status',
         // 状态
+        'longitude',
+        'latitude',
+        'address',
         'status',
         // 创建人ID
         'creator_id',