likang преди 2 години
родител
ревизия
39f5cb9fb2

+ 112 - 23
catch/api/controller/Api.php

@@ -2,47 +2,136 @@
 
 
 namespace catchAdmin\api\controller;
 namespace catchAdmin\api\controller;
 
 
+use catchAdmin\hydraulic\model\DeviceMold;
+use catchAdmin\hydraulic\model\Hydraulic as ModelHydraulic;
+use catchAdmin\hydraulic\model\maintenancemapper;
+use catchAdmin\permissions\model\Users;
+use catchAdmin\worklocation\model\WorkRecord as ModelWorkRecord;
 use catcher\base\CatchRequest as Request;
 use catcher\base\CatchRequest as Request;
 use catcher\CatchResponse;
 use catcher\CatchResponse;
 use catcher\base\CatchController;
 use catcher\base\CatchController;
+use Hydraulic;
 use \think\facade\Db;
 use \think\facade\Db;
+use Workerman\Worker;
+use WorkRecord;
 
 
 class Api extends CatchController
 class Api extends CatchController
 {
 {
     /**
     /**
-     * 获取所有用户列表
-     * @time 2022年06月09日 14:22
+     * @Descripttion: 上传紧固模式
+     * @name: likang
+     * @return {*}
      */
      */
-    public function getUserList(){
-     
-        if (!isset($_GET['imei']) ||  $_GET['imei']=='') {
+    public function UploadWorkRecordFA()
+    {
+        $param = json_decode(file_get_contents("php://input"), true);
+        //校验imei是否存在
+        if (!isset($param['IMEI']) ||  $param['IMEI'] == '') {
             json_fail('缺少设备IMEI号参数');
             json_fail('缺少设备IMEI号参数');
         }
         }
-        //检测imei号是否在数据库中
+        $Imei = $param['IMEI'];
 
 
-        $list=Db::table('users')->select();
-        //请求成功返回数据
-        json_success('获取成功',$list);
-    }
 
 
+        if (!$this->IsImei($Imei)) {
+            json_fail('该Imei号不存在');
+        }
+        if (!($param['SoftVersion']) ||  $param['SoftVersion'] == '') {
+
+            $param['SoftVersion'] = 0;
+        }
+        $version = $param['SoftVersion'];
+        $this->Conversion($param, 1);
+        return json_success('获取成功', '', $Imei);
+    }
     /**
     /**
-     * 获取所有风场风机
-     * @time 2022年06月09日 14:22
+     * @Descripttion: 上传维护模式
+     * @name: likang
+     * @return {*}
      */
      */
-    public function getWindList(){
-     
-        if (!isset($_GET['imei']) ||  $_GET['imei']=='') {
+    public function UploadWorkRecordMA()
+    {
+        $param = json_decode(file_get_contents("php://input"), true);
+        //校验imei是否存在
+        if (!isset($param['IMEI']) ||  $param['IMEI'] == '') {
             json_fail('缺少设备IMEI号参数');
             json_fail('缺少设备IMEI号参数');
         }
         }
-        //检测imei号是否在数据库中
+        $Imei = $param['IMEI'];
+
+
+        if (!$this->IsImei($Imei)) {
+            json_fail('该Imei号不存在');
+        }
+        if (!($param['SoftVersion']) ||  $param['SoftVersion'] == '') {
+
+            $param['SoftVersion'] = 0;
+        }
+        $version = $param['SoftVersion'];
+        $this->Conversion($param, 2);
+        return json_success('获取成功', '', $Imei);
+    }
 
 
-        $list=Db::table('wind')->field("id,name,number")->select();
-        foreach($list as $val){
-            $val['fan_list']=Db::table('fan')->where('wind_id',$val['id'])->field("id,wind_id,number")->select();
+
+
+
+
+
+    /**
+     * @Descripttion: Imei 是否存在
+     * @name: likang
+     * @param {*} $imei
+     * @return {*}
+     */
+    private function IsImei($imei)
+    {
+        $data =  ModelHydraulic::where('imei', $imei)->find();
+        if ($data) {
+            return true;
+        } else {
+            return false;
         }
         }
-        //请求成功返回数据
-        json_success('获取成功',$list);
     }
     }
+    /**
+     * @Descripttion: 
+     * @name: likang
+     * @param {*} $data 数据内容
+     * @param {*} $type 工作类型
+     * @return {*}
+     */
+    private function Conversion($data, $type)
+    {
+        $content = [];
+        $content['creator_id'] =  Users::where('username', $data['Username'])->value('id');
+        $content['wrench_number'] = $data['WrenchNumber'];
+        $content['fan_number'] = $data['TurbineNumber'];
+        $content['fan_model'] = $data['Model'];
+        $content['parts'] = $data['PartNumber'];
+        $content['work_sign'] = $data['WorkPos'];
+        $content['boit_type'] = $data['BoltModel'];
+        $content['bolt_number'] = $data['BoltNumber'];
+        $content['boit_total'] = $data['BoltTotal'];
+        $content['set_torque'] = $data['SetTorque'];
+        $content['fastening_torque'] = $data['FasteningTorque'];
+        $content['set_stress'] = $data['SetStress'];
+        $content['fastening_stress'] = $data['FasteningStress'];
+        $content['fastening_status'] = $data['FasteningStatus'];
+        $content['fastening_time'] = $data['Time'];
+        $content['move_angle'] = $data['WrenchAngle'];
+        $content['imei'] = $data['IMEI'];
+        $content['FasteningStatus'] = $data['FasteningStatus'];
 
 
-    
-}
+        if ($type == 2) {
+            $content['wrench_type'] = $data['FasteningStatus'];
+            if ($data['FasteningStatus'] == 3) {
+                if ($content['move_angle'] > 2) {
+                    $content['FasteningStatus'] = 2;
+                }
+            } else {
+                $content['FasteningStatus'] = 1;
+            }
+        } else {
+            $content['wrench_type'] = 1;
+        }
+        $workRecod = new ModelWorkRecord();
+        $bool = $workRecod->save($content);
+    }
+}

+ 59 - 18
catch/api/controller/Tool.php

@@ -2,13 +2,16 @@
 
 
 namespace catchAdmin\api\controller;
 namespace catchAdmin\api\controller;
 
 
+use catchAdmin\hydraulic\model\Hydraulic;
 use catchAdmin\hydraulic\model\maintenancemapper;
 use catchAdmin\hydraulic\model\maintenancemapper;
 use catchAdmin\hydraulic\model\Wrench as ModelWrench;
 use catchAdmin\hydraulic\model\Wrench as ModelWrench;
+use catchAdmin\worklocation\model\WorkRecord;
 use catcher\base\CatchRequest as Request;
 use catcher\base\CatchRequest as Request;
 use catcher\CatchResponse;
 use catcher\CatchResponse;
 use catcher\base\CatchController;
 use catcher\base\CatchController;
 use PhpParser\Node\Expr\FuncCall;
 use PhpParser\Node\Expr\FuncCall;
 use think\facade\Db;
 use think\facade\Db;
+use Workerman\Worker;
 use Wrench;
 use Wrench;
 
 
 class Tool extends Base
 class Tool extends Base
@@ -18,43 +21,56 @@ class Tool extends Base
      * @name: likang
      * @name: likang
      * @return {*}
      * @return {*}
      */
      */
+
     public function Issued()
     public function Issued()
     {
     {
+        $param = json_decode(file_get_contents("php://input"), true);
         //校验imei是否存在
         //校验imei是否存在
-        if (!isset($_GET['imei']) ||  $_GET['imei'] == '') {
+        if (!isset($param['IMEI']) ||  $param['IMEI'] == '') {
             json_fail('缺少设备IMEI号参数');
             json_fail('缺少设备IMEI号参数');
         }
         }
-        $Imei = $_GET['imei'];
-        if (!isset($_GET['version']) ||  $_GET['version'] == '') {
-            json_fail('缺少版本号参数', '', $Imei);
+        $Imei = $param['IMEI'];
+        if (!$this->IsImei($Imei)) {
+            json_fail('该Imei号不存在');
+        }
+        if (!($param['SoftVersion']) ||  $param['SoftVersion'] == '') {
+
+            $param['SoftVersion'] = 0;
         }
         }
-        $version = $_GET['version'];
+        $version = $param['SoftVersion'];
         return $this->DataIssued($Imei, $version);
         return $this->DataIssued($Imei, $version);
     }
     }
     //收到的数据
     //收到的数据
     public function receive()
     public function receive()
     {
     {
+        $param = json_decode(file_get_contents("php://input"), true);
         //校验imei是否存在
         //校验imei是否存在
         $where = [];
         $where = [];
-        if (!isset($_POST['imei']) ||  $_POST['imei'] == '') {
+        if (!isset($param['Imei']) ||  $param['Imei'] == '') {
+
             json_fail('缺少设备IMEI号参数');
             json_fail('缺少设备IMEI号参数');
         }
         }
-        $Imei = $_POST['imei'];
-        if (!isset($_POST['version']) ||  $_POST['version'] == '') {
-            json_fail('缺少版本号参数', '', $Imei);
+        $Imei = $param['Imei'];
+        //校验Imei是否存在
+        if (!$this->IsImei($Imei)) {
+            json_fail('该Imei号不存在');
+        }
+        if (!isset($param['CntVersion']) ||  $param['CntVersion'] == '') {
+            $param['CntVersion'] = 0;
         }
         }
-        $version = $_POST['version'];
+        $version = $param['CntVersion'];
 
 
-        if (!isset($_POST['Succ']) ||  $_POST['Succ'] == '') {
+        if (!isset($param['Succ']) ||  $param['Succ'] == '') {
             json_fail('缺少返回结果', '', $Imei);
             json_fail('缺少返回结果', '', $Imei);
         }
         }
-        $Succ = $_POST['Succ'];
-        if (!isset($_POST['Extra'])) {
+        $Succ = $param['Succ'];
+        if (!isset($param['Extra'])) {
             json_fail('缺少回复内容参数', '', $Imei);
             json_fail('缺少回复内容参数', '', $Imei);
         }
         }
-        $Extra = $_POST['Extra'];
+        $Extra = $param['Extra'];
         $where[] = ['PublishVersion', '=', $version];
         $where[] = ['PublishVersion', '=', $version];
         $where[] = ['Imei', '=', $Imei];
         $where[] = ['Imei', '=', $Imei];
+
         $ack =   Db::name("publish_ack")->where($where)->find();
         $ack =   Db::name("publish_ack")->where($where)->find();
         if (!$ack) {
         if (!$ack) {
             json_fail('没有找到下发记录', '', $Imei);
             json_fail('没有找到下发记录', '', $Imei);
@@ -83,16 +99,26 @@ class Tool extends Base
             ['ContentType', '=', 'File'],
             ['ContentType', '=', 'File'],
             ['Version', '>', $version]
             ['Version', '>', $version]
         ];
         ];
-
+        $where3 = [];
+        $CntVersion = $version;
+        $content = null;
         $list = Db::name('publish')
         $list = Db::name('publish')
             ->whereOr([$where1, $where2])
             ->whereOr([$where1, $where2])
-            //->where($where1)
             ->order('Version asc')->limit(5)->select();
             ->order('Version asc')->limit(5)->select();
-
-
+        if ($list->isEmpty()) {
+            return json_success('获取成功', $content, $Imei);
+        }
         foreach ($list as $key => $value) {
         foreach ($list as $key => $value) {
 
 
             $da = json_decode($value['Content'], true);
             $da = json_decode($value['Content'], true);
+            //如果是下发计划的话,或取当前长传记录  记录下数据
+            if ($value['ContentType'] == 'WorkPlan') {
+                $where3[] = ['wind_number', '=', $da['wnum']];
+                $where3[] = ['fan_number', '=', $da['fnum']];
+                $where3[] = ['parts', '=', $da['parts']];
+                $where3[] = ['work_sign', '=', $da['work']];
+                $da['lt'] = WorkRecord::where($where3)->order('fastening_time desc')->value('fastening_torque');
+            }
             $da['id'] = strval($da['id']);
             $da['id'] = strval($da['id']);
             $content[] = [
             $content[] = [
                 'OpType' => $value['Type'],
                 'OpType' => $value['Type'],
@@ -113,4 +139,19 @@ class Tool extends Base
         Db::name('publish_ack')->save($ack);
         Db::name('publish_ack')->save($ack);
         return json_success('获取成功', $content, $Imei);
         return json_success('获取成功', $content, $Imei);
     }
     }
+    /**
+     * @Descripttion: Imei 是否存在
+     * @name: likang
+     * @param {*} $imei
+     * @return {*}
+     */
+    private function IsImei($imei)
+    {
+        $data =  Hydraulic::where('imei', $imei)->find();
+        if ($data) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 }
 }

+ 7 - 4
catch/api/route.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Author: likang
  * @Date: 2022-06-09 10:11:32
  * @Date: 2022-06-09 10:11:32
  * @LastEditors: likang
  * @LastEditors: likang
- * @LastEditTime: 2022-07-11 17:23:27
+ * @LastEditTime: 2022-07-13 14:35:14
  */
  */
 // +----------------------------------------------------------------------
 // +----------------------------------------------------------------------
 // | CatchAdmin [Just Like ~ ]
 // | CatchAdmin [Just Like ~ ]
@@ -22,8 +22,11 @@ $router->group(function () use ($router) {
 	// api路由
 	// api路由
 	$router->get('api/getUserList', '\catchAdmin\api\controller\Api@getUserList');
 	$router->get('api/getUserList', '\catchAdmin\api\controller\Api@getUserList');
 });
 });
-$router->get('api/getUsers', '\catchAdmin\api\controller\Api@getUserList');
+//上传禁锢模式记录
+$router->post('api/UploadWorkRecordMA', '\catchAdmin\api\controller\Api@UploadWorkRecordMA');
+//上传维护模式记录
+$router->post('api/UploadWorkRecordFA', '\catchAdmin\api\controller\Api@UploadWorkRecordFA');
 //下发数据
 //下发数据
-$router->get('tool/Issued', '\catchAdmin\api\controller\Tool@Issued');
+$router->post('tool/Issued', '\catchAdmin\api\controller\Tool@Issued');
 //下发之后上传的信息
 //下发之后上传的信息
-$router->get('tool/receive', '\catchAdmin\api\controller\Tool@receive');
+$router->post('tool/receive', '\catchAdmin\api\controller\Tool@receive');

+ 2 - 1
catch/hydraulic/controller/Maintenance.php

@@ -99,8 +99,9 @@ class Maintenance extends CatchController
         if ($data['type']) {
         if ($data['type']) {
             $where[]  = ['device_type', '=', $data['type']];
             $where[]  = ['device_type', '=', $data['type']];
         }
         }
-        if ($data['type'] == 2 && isset($data['fan_model'])) {
+        if ($data['type'] == 2 && isset($data['fan_model']) &&  isset($data['part'])) {
             $where[] = ['fan_model', '=', $data['fan_model']];
             $where[] = ['fan_model', '=', $data['fan_model']];
+            $where[] = ['parts', '=', $data['part']];
         }
         }
         $list = $this->maintenanceModel->where($where)->field('value,name')->select();
         $list = $this->maintenanceModel->where($where)->field('value,name')->select();
         return CatchResponse::success($list);
         return CatchResponse::success($list);

+ 0 - 1
catch/permissions/model/Users.php

@@ -304,7 +304,6 @@ class Users extends CatchModel
                     'Type' => 'delete',
                     'Type' => 'delete',
                     'Version' => $time,
                     'Version' => $time,
                     'Status' => 1,
                     'Status' => 1,
-                    'Content' => json_encode($data)
                 ];
                 ];
                 Db::name('publish')->where($wheres)->update($content);
                 Db::name('publish')->where($wheres)->update($content);
             }
             }

+ 21 - 3
catch/wind/controller/Fan.php

@@ -86,8 +86,9 @@ class Fan extends CatchController
                 array_push($add_fans, $save_data);
                 array_push($add_fans, $save_data);
             }
             }
         }
         }
-
         $count1 = $this->fanModel->saveAll($add_fans);
         $count1 = $this->fanModel->saveAll($add_fans);
+        //下发风机模型
+        $this->fanModel->IssuedFanModel($data['wind_id']);
         return CatchResponse::success('添加成功,共' . count($count1) . '条');
         return CatchResponse::success('添加成功,共' . count($count1) . '条');
         // return CatchResponse::success($this->fanModel->storeBy($data));
         // return CatchResponse::success($this->fanModel->storeBy($data));
     }
     }
@@ -116,7 +117,10 @@ class Fan extends CatchController
             $data['out_date'] = date('Y-m-d', $data['out_date']);
             $data['out_date'] = date('Y-m-d', $data['out_date']);
         }
         }
         $data['id'] = $id;
         $data['id'] = $id;
-        return CatchResponse::success($this->fanModel->updateBy($id, $data));
+        $this->fanModel->updateBy($id, $data);
+        //下发风机模型
+        $this->fanModel->IssuedFanModel($data['wind_id']);
+        return CatchResponse::success();
     }
     }
 
 
     /**
     /**
@@ -126,6 +130,20 @@ class Fan extends CatchController
      */
      */
     public function delete($id): \think\Response
     public function delete($id): \think\Response
     {
     {
-        return CatchResponse::success($this->fanModel->deleteBy($id, true));
+        if (is_array($id)) {
+
+            $data = $this->fanModel->findBy($id);
+            $this->fanModel->deleteBy($id, true);
+            $this->fanModel->IssuedFanModel($data['wind_id']);
+        } else {
+            $where[] = ['id', 'in', $id];
+            $list =  $this->fanModel->where($where)->group('wind_id')->column('wind_id');
+            $this->fanModel->deleteBy($id, true);
+            foreach ($list as $item) {
+                $this->fanModel->IssuedFanModel($item['wind_id']);
+            }
+        }
+
+        return CatchResponse::success();
     }
     }
 }
 }

+ 3 - 0
catch/wind/model/Wind.php

@@ -104,10 +104,13 @@ class Wind extends Model
         //var_dump($obj);
         //var_dump($obj);
         $data = null;
         $data = null;
         $content = null;
         $content = null;
+        $jsonInfo = json_decode($obj->wind_info, true);
         $data = [
         $data = [
             'id' => $obj->id,
             'id' => $obj->id,
             'number' => $obj->number,
             'number' => $obj->number,
             'name' => $obj['name'],
             'name' => $obj['name'],
+            'lon' => $jsonInfo['center']['lng'],
+            'lat' => $jsonInfo['center']['lat']
         ];
         ];
         $content['data'] = $data;
         $content['data'] = $data;
         $content['type'] = 'Wind';
         $content['type'] = 'Wind';

+ 2 - 1
catch/worklocation/controller/WorkRecord.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Author: likang
  * @Date: 2022-07-12 10:11:04
  * @Date: 2022-07-12 10:11:04
  * @LastEditors: likang
  * @LastEditors: likang
- * @LastEditTime: 2022-07-12 10:39:34
+ * @LastEditTime: 2022-07-12 15:40:32
  */
  */
 
 
 namespace catchAdmin\worklocation\controller;
 namespace catchAdmin\worklocation\controller;
@@ -14,6 +14,7 @@ use catcher\base\CatchRequest as Request;
 use catcher\CatchResponse;
 use catcher\CatchResponse;
 use catcher\base\CatchController;
 use catcher\base\CatchController;
 use catchAdmin\worklocation\model\WorkRecord as workRecordModel;
 use catchAdmin\worklocation\model\WorkRecord as workRecordModel;
+use think\facade\Db;
 
 
 class WorkRecord extends CatchController
 class WorkRecord extends CatchController
 {
 {

+ 8 - 0
catch/worklocation/database/migrations/20220628095201_work_plan.php

@@ -1,5 +1,7 @@
 <?php
 <?php
 
 
+
+
 use think\migration\Migrator;
 use think\migration\Migrator;
 use think\migration\db\Column;
 use think\migration\db\Column;
 use Phinx\Db\Adapter\MysqlAdapter;
 use Phinx\Db\Adapter\MysqlAdapter;
@@ -36,6 +38,12 @@ class WorkPlan extends Migrator
             ->addColumn('parts_sign', 'string', ['limit' => 12, 'null' => true, 'signed' => true, 'comment' => '部件类型',])
             ->addColumn('parts_sign', 'string', ['limit' => 12, 'null' => true, 'signed' => true, 'comment' => '部件类型',])
             ->addColumn('boit_type_sign', 'string', ['limit' => 12, 'null' => true, 'signed' => true, 'comment' => '螺栓型号',])
             ->addColumn('boit_type_sign', 'string', ['limit' => 12, 'null' => true, 'signed' => true, 'comment' => '螺栓型号',])
             ->addColumn('plan_name', 'string', ['limit' => 255, 'null' => true, 'signed' => true, 'comment' => '计划名称',])
             ->addColumn('plan_name', 'string', ['limit' => 255, 'null' => true, 'signed' => true, 'comment' => '计划名称',])
+            ->addColumn('plan_number', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '计划编号',])
+            ->addColumn('bolt_num', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '螺栓总数',])
+            ->addColumn('tighten_mode', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '紧固模式',])
+            ->addColumn('last_torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '历史紧固扭矩',])
+            ->addColumn('torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '紧固扭矩',])
+            ->addColumn('bias', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '偏移禁锢数值',])
             ->addColumn('info', 'string', ['limit' => 255, 'null' => true, 'signed' => true, 'comment' => '详情',])
             ->addColumn('info', 'string', ['limit' => 255, 'null' => true, 'signed' => true, 'comment' => '详情',])
             ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '状态  1 启用,-1 失效',])
             ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '状态  1 启用,-1 失效',])
             ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'signed' => false, 'comment' => '创建人ID',])
             ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'signed' => false, 'comment' => '创建人ID',])

+ 5 - 3
catch/worklocation/database/migrations/20220712101110_work_record.php

@@ -1,6 +1,7 @@
 <?php
 <?php
 
 
 
 
+
 use think\migration\Migrator;
 use think\migration\Migrator;
 use think\migration\db\Column;
 use think\migration\db\Column;
 use Phinx\Db\Adapter\MysqlAdapter;
 use Phinx\Db\Adapter\MysqlAdapter;
@@ -42,13 +43,14 @@ class WorkRecord extends Migrator
             ->addColumn('wrench_number', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '扳手编号',])
             ->addColumn('wrench_number', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '扳手编号',])
             ->addColumn('set_torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '设定的扭矩1',])
             ->addColumn('set_torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '设定的扭矩1',])
             ->addColumn('fastening_torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '紧固扭矩1',])
             ->addColumn('fastening_torque', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '紧固扭矩1',])
-            ->addColumn('set_torque1', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '设定的扭矩2',])
-            ->addColumn('fastening_torque1', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '紧固扭矩2',])
+            ->addColumn('set_stress', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '设定的压力',])
+            ->addColumn('fastening_stress', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '紧固压力',])
             ->addColumn('fastening_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 紧固正常,2紧固异常',])
             ->addColumn('fastening_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 紧固正常,2紧固异常',])
             ->addColumn('fastening_time', 'string', ['limit' => 20, 'null' => true, 'signed' => true, 'comment' => '紧固时间',])
             ->addColumn('fastening_time', 'string', ['limit' => 20, 'null' => true, 'signed' => true, 'comment' => '紧固时间',])
             ->addColumn('move_angle', 'string', ['limit' => 10, 'null' => true, 'signed' => true, 'comment' => '搬动角度',])
             ->addColumn('move_angle', 'string', ['limit' => 10, 'null' => true, 'signed' => true, 'comment' => '搬动角度',])
             ->addColumn('imei', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '网关imei',])
             ->addColumn('imei', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '网关imei',])
-            ->addColumn('tyep', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 紧固模式,2维护模式',])
+            ->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 紧固模式,2维护模式',])
+            ->addColumn('wrench_type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1、普通扳手   2、角度扳手,未转角度    3、角度扳手,转动角度',])
             ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'signed' => false, 'comment' => '创建人ID',])
             ->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('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('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'signed' => false, 'comment' => '更新时间',])

+ 72 - 7
catch/worklocation/model/WorkRecord.php

@@ -4,6 +4,8 @@ namespace catchAdmin\worklocation\model;
 
 
 use catchAdmin\api\Listen;
 use catchAdmin\api\Listen;
 use catchAdmin\hydraulic\model\DeviceMold as ModelDeviceMold;
 use catchAdmin\hydraulic\model\DeviceMold as ModelDeviceMold;
+use catchAdmin\hydraulic\model\HydEquipment;
+use catchAdmin\hydraulic\model\Wrench;
 use catcher\base\CatchModel as Model;
 use catcher\base\CatchModel as Model;
 use catchAdmin\permissions\model\DataRangScopeTrait;
 use catchAdmin\permissions\model\DataRangScopeTrait;
 use catchAdmin\wind\model\Fan;
 use catchAdmin\wind\model\Fan;
@@ -42,10 +44,10 @@ class WorkRecord extends Model
         'set_torque',
         'set_torque',
         // 紧固扭矩1
         // 紧固扭矩1
         'fastening_torque',
         'fastening_torque',
-        // 设定的扭矩2
-        'set_torque1',
-        // 紧固扭矩2
-        'fastening_torque1',
+        // 设定的压力
+        'set_stress',
+        // 紧固压力
+        'fastening_stress',
         // 1 紧固正常,2紧固异常
         // 1 紧固正常,2紧固异常
         'fastening_status',
         'fastening_status',
         // 紧固时间
         // 紧固时间
@@ -55,7 +57,9 @@ class WorkRecord extends Model
         // 网关imei
         // 网关imei
         'imei',
         'imei',
         // 1 紧固模式,2维护模式
         // 1 紧固模式,2维护模式
-        'tyep',
+        'type',
+        //1、普通扳手   2、角度扳手,未转角度    3、角度扳手,转动角度
+        'wrench_type',
         // 创建人ID
         // 创建人ID
         'creator_id',
         'creator_id',
         // 创建时间
         // 创建时间
@@ -69,12 +73,29 @@ class WorkRecord extends Model
     {
     {
         return $this->dataRange()
         return $this->dataRange()
             ->catchSearch()
             ->catchSearch()
-            ->append(['department_name', 'wind_name', 'work_local_name', 'parts_name', 'boit_type_name', 'work_name'])
+            ->append(['department_name', 'fan_model_name', 'wind_name', 'work_local_name', 'parts_name', 'boit_type_name', 'work_name', 'wrench_name'])
             ->field('*')
             ->field('*')
             ->catchOrder()
             ->catchOrder()
             ->creator()
             ->creator()
             ->paginate();
             ->paginate();
     }
     }
+    /**
+     * @Descripttion: 获取扳手的名称
+     * @name: likang
+     * @return {*}
+     */
+    public function getWrenchNameAttr()
+    {
+        $wrench =  $this->wrench_number;
+        $eq_id =  Wrench::where('number', $wrench)->value('eq_id');
+        $name = HydEquipment::where('id', $eq_id)->value('name');
+        return $name;
+    }
+    public function getFanModelNameAttr()
+    {
+        $name =   ModelDeviceMold::where('id', $this->fan_model)->where('device_type', 4)->value('name');
+        return $name;
+    }
     //获取部门名称
     //获取部门名称
     public function getDepartmentNameAttr()
     public function getDepartmentNameAttr()
     {
     {
@@ -82,6 +103,13 @@ class WorkRecord extends Model
         $name = Db::name('departments')->where('id', $dep_id)->where('status', 1)->value('department_name');
         $name = Db::name('departments')->where('id', $dep_id)->where('status', 1)->value('department_name');
         return $name;
         return $name;
     }
     }
+    //风机模型
+    public function getWindModelAttr()
+    {
+        $wind_number = $this->wind_number;
+        $wind_name =  Db::name('wind')->where('number', $wind_number)->value('name');
+        return $wind_name;
+    }
 
 
     /**
     /**
      * 获取风场名称
      * 获取风场名称
@@ -101,7 +129,44 @@ class WorkRecord extends Model
         $name =  Db::name("users")->where('id', $user_id)->value('realname');
         $name =  Db::name("users")->where('id', $user_id)->value('realname');
         return $name;
         return $name;
     }
     }
-
+    //紧固模式
+    public function getTypeAttr()
+    {
+        $type = $this->getData('type');
+        if ($type == 1) {
+            return '紧固模式';
+        } else if ($type == 2) {
+            return '维护模式';
+        } else {
+            return '未知模式';
+        }
+    }
+    //扳手类型
+    public function getWrenchTypeAttr()
+    {
+        $type = $this->getData('wrench_type');
+        if ($type == 1) {
+            return '普通扳手';
+        } else if ($type == 2) {
+            return '角度扳手,未转角度';
+        } else if ($type == 3) {
+            return '角度扳手,转动角度';
+        } else {
+            return '未知扳手';
+        }
+    }
+    //紧固状态
+    public function getFasteningStatusAttr()
+    {
+        $type = $this->getData('fastening_status');
+        if ($type == 1) {
+            return '紧固正常';
+        } else if ($type == 2) {
+            return '紧固异常';
+        } else {
+            return '未知状态';
+        }
+    }
     /**
     /**
      * 获取部件名称
      * 获取部件名称
      *
      *

+ 28 - 12
catch/worklocation/model/Workplan.php

@@ -10,7 +10,7 @@ use catchAdmin\permissions\model\Users;
 use catchAdmin\wind\model\Fan;
 use catchAdmin\wind\model\Fan;
 use catchAdmin\wind\model\Wind;
 use catchAdmin\wind\model\Wind;
 use catcher\base\CatchModel as Model;
 use catcher\base\CatchModel as Model;
-
+use Maintenancemapper;
 
 
 class Workplan extends Model
 class Workplan extends Model
 {
 {
@@ -22,6 +22,8 @@ class Workplan extends Model
     public $field = array(
     public $field = array(
         'id',
         'id',
         // 风场id
         // 风场id
+        'plan_number',
+        //计划编号
         'wind_id',
         'wind_id',
         // 风机id
         // 风机id
         'fan_id',
         'fan_id',
@@ -33,6 +35,16 @@ class Workplan extends Model
         'boit_type_sign',
         'boit_type_sign',
         // 计划名称
         // 计划名称
         'plan_name',
         'plan_name',
+        //螺栓总数
+        'bolt_num',
+        //紧固模式
+        'tighten_mode',
+        //偏移紧固数值
+        'bias',
+        //历史紧固扭矩
+        'last_torque',
+        //当前设定紧固扭矩
+        'torque',
         // 详情
         // 详情
         'info',
         'info',
         // 状态  1 启用,-1 失效
         // 状态  1 启用,-1 失效
@@ -53,21 +65,25 @@ class Workplan extends Model
     {
     {
         $data = null;
         $data = null;
         $content = null;
         $content = null;
+        $fan = Fan::where('id', $obj->wind_id)->find();
+
+        $fan_model = DeviceMold::where('id', $fan['fan_model'])->value('name');
         $data = [
         $data = [
             'id' => $obj->id,
             'id' => $obj->id,
-            'pnum' => $obj->id,
+            'pnum' => $obj->plan_number,
             'wnum' => Wind::where('id', $obj->wind_id)->value('number'),
             'wnum' => Wind::where('id', $obj->wind_id)->value('number'),
             'wname' => Wind::where('id', $obj->wind_id)->value('name'),
             'wname' => Wind::where('id', $obj->wind_id)->value('name'),
-            'fnum' => Fan::where('id', $obj->wind_id)->value('number'),
-            'fmode' => $obj->id,
-            'work' => $obj->work_sign,
-            'bm' => $obj->id,
-            'bn' => $obj->id,
-            'tm' => $obj->id,
-            'bias' => $obj->id,
-            'lt' => $obj->id,
-            'torque' => $obj->id
-
+            'fnum' => $fan['number'],
+            'fmode' => $fan_model,
+            'parts' => ModelMaintenancemapper::where('device_type', 1)->where('value', $this->parts_sign)->value('name'),
+            'work' => ModelMaintenancemapper::where('device_type', 2)->where('value', $this->work_sign)->value('name'),
+            'bm' => ModelMaintenancemapper::where('device_type', 4)->where('value', $this->boit_type_sign)->value('name'),
+            'bn' => intval($obj->bolt_num),
+            'tm' => $obj->tighten_mode,
+            'bias' => intval($obj->bias),
+            'lt' => null,
+            'torque' => $obj->torque,
+            'info' => $obj->info
         ];
         ];
         $content['data'] = $data;
         $content['data'] = $data;
         $content['type'] = 'WorkPlan';
         $content['type'] = 'WorkPlan';