likang 2 年之前
父节点
当前提交
39bf595003
共有 3 个文件被更改,包括 34 次插入20 次删除
  1. 2 2
      catch/api/controller/Tool.php
  2. 20 3
      catch/hydraulic/controller/HydEquipment.php
  3. 12 15
      catch/worklocation/model/WorkRecord.php

+ 2 - 2
catch/api/controller/Tool.php

@@ -58,7 +58,7 @@ class Tool extends Base
             json_fail('该Imei号不存在');
         }
         if (!isset($param['CntVersion']) ||  $param['CntVersion'] == '') {
-            $param['CntVersion'] = 0;
+            json_fail('版本号不存在');
         }
         $version = $param['CntVersion'];
 
@@ -69,7 +69,7 @@ class Tool extends Base
         if (!isset($param['Extra'])) {
             json_fail('缺少回复内容参数', '', $Imei);
         }
-        $Extra = $param['Extra'];
+        $Extra = json_encode($param['Extra']);
         $where[] = ['PublishVersion', '=', $version];
         $where[] = ['Imei', '=', $Imei];
 

+ 20 - 3
catch/hydraulic/controller/HydEquipment.php

@@ -93,7 +93,11 @@ class HydEquipment extends CatchController
                     //设备的id
                     'eq_id' => $id
                 ];
-
+                $hyd_exist =  Hydraulic::where('imei', $data['imei'])->find();
+                if ($hyd_exist) {
+                    Db::rollback();
+                    return  CatchResponse::fail('imei号已存在');
+                }
                 Hydraulic::create($hydraulic);
             }
             //保存扳手
@@ -116,6 +120,11 @@ class HydEquipment extends CatchController
 
                 ];
 
+                $wrench_exist =  Wrench::where('number', $data['number'])->find();
+                if ($wrench_exist) {
+                    Db::rollback();
+                    return  CatchResponse::fail('扳手编号已存在');
+                }
                 Wrench::create($wrench);
             }
         } catch (\Exception $e) {
@@ -179,7 +188,6 @@ class HydEquipment extends CatchController
             'latitude' => $data['latitude']
         ];
 
-
         if ($data['equipment_type'] == 2) {
             $hydraulic = [
                 // 编号
@@ -195,6 +203,11 @@ class HydEquipment extends CatchController
                 //设备的id
                 'eq_id' => $id
             ];
+            $hyd_exist =  Hydraulic::where('imei', $data['imei'])->where('eq_id', '<>', $id)->find();
+            if ($hyd_exist) {
+                Db::rollback();
+                return  CatchResponse::fail('imei号已存在');
+            }
             Hydraulic::where('eq_id', $id)->update($hydraulic);
         }
         //保存扳手
@@ -217,7 +230,11 @@ class HydEquipment extends CatchController
                 'angle_sensor' => $data['angle_sensor'],
                 // 扭矩
             ];
-
+            $wrench_exist =  Wrench::where('number', $data['number'])->where('id', '<>', $data['list']['id'])->find();
+            if ($wrench_exist) {
+                Db::rollback();
+                return  CatchResponse::fail('扳手编号已存在');
+            }
             Wrench::update($wrench, ['id' => $data['list']['id']]);
         }
         return CatchResponse::success($this->hydEquipmentModel->updateBy($id, $hydequ));

+ 12 - 15
catch/worklocation/model/WorkRecord.php

@@ -93,8 +93,8 @@ class WorkRecord extends Model
     }
     public function getFanModelNameAttr()
     {
-        $name =   ModelDeviceMold::where('id', $this->fan_model)->where('device_type', 4)->value('name');
-        return $name;
+
+        return $this->fan_model;
     }
     //获取部门名称
     public function getDepartmentNameAttr()
@@ -103,13 +103,6 @@ class WorkRecord extends Model
         $name = Db::name('departments')->where('id', $dep_id)->where('status', 1)->value('department_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;
-    }
 
     /**
      * 获取风场名称
@@ -141,6 +134,12 @@ class WorkRecord extends Model
             return '未知模式';
         }
     }
+    //时间
+    public function getFasteningTimeAttr()
+    {
+        $time = $this->getData('fastening_time');
+        return date('Y-m-d H:i:s', $time);
+    }
     //扳手类型
     public function getWrenchTypeAttr()
     {
@@ -175,15 +174,14 @@ class WorkRecord extends Model
     public function getPartsNameAttr()
     {
         $parts = $this->parts;
-        $value = $this->get_dict_data(1, $parts);
-        return $value;
+        return $parts;
     }
     //获取工作位置型号
     public function getWorkLocalNameAttr()
     {
         $code = $this->work_sign;
-        $value = $this->get_dict_data(2, $code);
-        return $value;
+
+        return $code;
     }
     /**
      * 螺栓型号
@@ -193,8 +191,7 @@ class WorkRecord extends Model
     public function getBoitTypeNameAttr()
     {
         $code = $this->boit_type;
-        $value = $this->get_dict_data(4, $code);
-        return $value;
+        return $code;
     }
     /**
      *