likang 3 年之前
父節點
當前提交
722521ad9e

+ 4 - 4
app/common.php

@@ -318,9 +318,9 @@ function get_sms_config($type)
  * data: 额外数据
  * @time 2022年06月09日 14:22
  */
-function json_success($message, $data = '')
+function json_success($message, $data = '', $imei = '')
 {
-    echo json_encode(array('success' => true, 'message' => $message, 'data' => $data), JSON_UNESCAPED_UNICODE);
+    echo json_encode(array('success' => true, 'message' => $message, 'data' => $data, 'imei' => $imei), JSON_UNESCAPED_UNICODE);
     exit;
 }
 
@@ -330,9 +330,9 @@ function json_success($message, $data = '')
  * data: 额外数据
  * @time 2022年06月09日 14:22
  */
-function json_fail($message, $data = '')
+function json_fail($message, $data = '', $imei = '')
 {
-    echo json_encode(array('success' => false, 'message' => $message, 'data' => $data), JSON_UNESCAPED_UNICODE);
+    echo json_encode(array('success' => false, 'message' => $message, 'data' => $data, 'imei' => $imei), JSON_UNESCAPED_UNICODE);
     exit;
 }
 /**

+ 5 - 1
catch/api/Listen.php

@@ -25,6 +25,9 @@ trait Listen
             }
         }
         $time = msectime();
+        //塞入版本号
+        //类型
+        //操作方式
         $content = [
             'Type' => 'add',
             'ContentType' => $data['type'],
@@ -59,6 +62,7 @@ trait Listen
         $where = [];
         $where[] = ['ContentType', '=', $data['type']];
         $where[] = ['ContentId', '=', $data['data']['id']];
+
         $content = [
             'Type' => 'update',
             'Imei' => $obj->imei ? '' : $obj->imei,
@@ -90,12 +94,12 @@ trait Listen
         $where = [];
         $where[] = ['ContentType', '=', $data['type']];
         $where[] = ['ContentId', '=', $data['data']['id']];
+
         $content = [
             'Type' => 'delete',
             'Imei' => $obj->imei ? '' : $obj->imei,
             'Version' => $time,
             'Status' => 1,
-            //'Content' => json_encode($data['data'])
         ];
         Db::name('publish')->where($where)->update($content);
     }

+ 77 - 22
catch/api/controller/Tool.php

@@ -1,12 +1,4 @@
 <?php
-/*
- * @Descripttion: 下发工具等相关信息
- * @version: 1.0.0
- * @Author: likang
- * @Date: 2022-06-09 14:58:24
- * @LastEditors: likang
- * @LastEditTime: 2022-06-10 09:28:54
- */
 
 namespace catchAdmin\api\controller;
 
@@ -16,43 +8,106 @@ use catcher\base\CatchRequest as Request;
 use catcher\CatchResponse;
 use catcher\base\CatchController;
 use PhpParser\Node\Expr\FuncCall;
+use think\facade\Db;
 use Wrench;
 
 class Tool extends Base
 {
     /**
+     * @Descripttion: 下发设备   携带的参数 imei号  版本号
+     * @name: likang
+     * @return {*}
+     */
+    public function Issued()
+    {
+        //校验imei是否存在
+        if (!isset($_GET['imei']) ||  $_GET['imei'] == '') {
+            json_fail('缺少设备IMEI号参数');
+        }
+        $Imei = $_GET['imei'];
+        if (!isset($_GET['version']) ||  $_GET['version'] == '') {
+            json_fail('缺少版本号参数', '', $Imei);
+        }
+        $version = $_GET['version'];
+        $where1 = [];
+        $where2 = [];
+        $content = [];
+        $CntVersion = '';
+        //判断版本号是否存在,不存在则下发全部,存在则下发部分
+
+        $where1 = [
+            // ['Imei', '<>', $Imei],
+            ['Version', '>', $version]
+        ];
+        $where2 = [
+            ['Imei', '=', $Imei],
+            ['ContentType', '=', 'File'],
+            ['Version', '>', $version]
+        ];
+
+        $list = Db::name('publish')
+            //->whereOr([$where1, $where2])
+            ->where($where1)
+            ->order('Version asc')->limit(5)->select();
+
+
+        foreach ($list as $key => $value) {
+
+            $da = json_decode($value['Content'], true);
+            $content[] = [
+                'OpType' => $value['Type'],
+                'CntType' => $value['ContentType'],
+                'CntVersion' => strval($value['Version']),
+                'id' => strval($value['ContentId']),
+                'Content' => $da
+            ];
+            $CntVersion = strval($value['Version']);
+        }
+        //保存下发的记录
+        $ack = [
+            'PublishVersion' => $CntVersion,
+            'PublishContent' => json_encode($content),
+            'Imei' => $Imei,
+            'AddTime' => msectime()
+        ];
+        Db::name('publish_ack')->save($ack);
+        return json_success('获取成功', $content, $Imei);
+    }
+    //接收上传的日志
+
+
+    /**
      * @Descripttion: 获取扳手列表
      * @name: likang
      * @return {*}
-     */    
+     */
     public function getWrenchList()
     {
-       $list =  ModelWrench::select();
-       return json_success('获取成功',$list);
-
+        $list =  ModelWrench::select();
+        return json_success('获取成功', $list);
     }
     /**
      * @Descripttion: 获取工作位置列表
      * @name: likang
      * @return {*}
-     */    
+     */
     public function getWorkLocal()
     {
-        $list =  maintenancemapper::where('device_type',2)->select();
-        return json_success('获取成功',$list);
+        $list =  maintenancemapper::where('device_type', 2)->select();
+        return json_success('获取成功', $list);
     }
-     
 
-    public function getUserList(){
-     
-        if (!isset($_GET['imei']) ||  $_GET['imei']=='') {
+
+    public function getUserList()
+    {
+
+        if (!isset($_GET['imei']) ||  $_GET['imei'] == '') {
             json_fail('缺少设备IMEI号参数');
         }
         //检测imei号是否在数据库中
 
 
         //请求成功返回数据
-       json_success('获取成功','');
+        json_success('获取成功', '');
     }
-
-}
+}

+ 3 - 3
catch/api/database/migrations/20220706114453_publish.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Date: 2022-07-06 11:44:53
  * @LastEditors: likang
- * @LastEditTime: 2022-07-07 15:30:20
+ * @LastEditTime: 2022-07-11 11:18:04
  */
 
 use think\migration\Migrator;
@@ -43,8 +43,8 @@ class Publish extends Migrator
             ->addColumn('Content', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'signed' => true, 'comment' => '内容 json',])
             ->addColumn('Imei', 'string', ['limit' => 255, 'null' => true, 'signed' => true, 'comment' => '网关imei',])
             ->addColumn('ContentId', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '内容id',])
-            ->addColumn('AddTime', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '添加时间',])
-            ->addColumn('Version', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '毫秒时间戳',])
+            ->addColumn('AddTime', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => true, 'signed' => true, 'comment' => '添加时间',])
+            ->addColumn('Version', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => true, 'signed' => true, 'comment' => '毫秒时间戳',])
             ->addColumn('Status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 更新 2 只读',])
             ->create();
     }

+ 0 - 42
catch/api/database/migrations/20220706135109_publish_ack.php

@@ -1,42 +0,0 @@
-<?php
-
-use think\migration\Migrator;
-use think\migration\db\Column;
-use Phinx\Db\Adapter\MysqlAdapter;
-
-class PublishAck 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('publish_ack', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '已发记录表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
-        $table->addColumn('PublishVersion', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '下发表版本号',])
-			->addColumn('PublishContent', 'text', ['limit' => MysqlAdapter::TEXT_LONG,'null' => true,'signed' => true,'comment' => '内容',])
-			->addColumn('AddTime', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '添加时间',])
-			->addColumn('Succ', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '1 成功  -1 失败',])
-			->addColumn('ErrStr', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '失败原因',])
-			->addColumn('AckTime', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '回复时间',])
-			->addColumn('Imei', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '网关',])
-            ->create();
-    }
-}

+ 42 - 0
catch/api/database/migrations/20220709165747_publish_ack.php

@@ -0,0 +1,42 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class PublishAck 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('publish_ack', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '回复的信息', 'id' => 'id', 'signed' => true, 'primary_key' => ['id']]);
+        $table->addColumn('PublishVersion', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => true, 'signed' => true, 'comment' => '版本',])
+            ->addColumn('PublishContent', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'signed' => true, 'comment' => '下发的内容',])
+            ->addColumn('AddTime', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => true, 'signed' => true, 'comment' => '创建时间',])
+            ->addColumn('Succ', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => true, 'signed' => true, 'comment' => '1 成功  -1 失败',])
+            ->addColumn('Imei', 'string', ['limit' => 50, 'null' => true, 'signed' => true, 'comment' => '网关imei',])
+            ->addColumn('AckTime', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => true, 'signed' => true, 'comment' => '回复时间',])
+            ->addColumn('Extra', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'signed' => true, 'comment' => '回复的内容',])
+            ->create();
+    }
+}

+ 17 - 9
catch/api/model/Publishack.php

@@ -1,4 +1,12 @@
 <?php
+/*
+ * @Descripttion: 
+ * @version: 1.0.0
+ * @Author: likang
+ * @Date: 2022-07-09 16:57:43
+ * @LastEditors: likang
+ * @LastEditTime: 2022-07-11 14:16:02
+ */
 
 namespace catchAdmin\api\model;
 
@@ -6,7 +14,7 @@ use catcher\base\CatchModel as Model;
 use catcher\traits\db\BaseOptionsTrait;
 use catcher\traits\db\ScopeTrait;
 
-class Publishack extends Model
+class PublishAck extends Model
 {
     use BaseOptionsTrait, ScopeTrait;
     // 表名
@@ -14,19 +22,19 @@ class Publishack extends Model
     // 数据库字段映射
     public $field = array(
         'id',
-        // 下发表版本
+        // 版本
         'PublishVersion',
-        // 内容
+        // 下发的内容
         'PublishContent',
-        // 添加时间
+        // 创建时间
         'AddTime',
         // 1 成功  -1 失败
         'Succ',
-        // 失败原因
-        'ErrStr',
         // 回复时间
         'AckTime',
-        // 网关
-        'Imei',
+        // 回复的内容
+        'Extra',
+        //网关Imei号
+        'Imei'
     );
-}
+}

+ 4 - 3
catch/api/route.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Date: 2022-06-09 10:11:32
  * @LastEditors: likang
- * @LastEditTime: 2022-06-10 09:41:04
+ * @LastEditTime: 2022-07-11 14:21:55
  */
 // +----------------------------------------------------------------------
 // | CatchAdmin [Just Like ~ ]
@@ -18,9 +18,10 @@
 // +----------------------------------------------------------------------
 
 // you should use `$router`
-$router->group(function () use ($router){
+$router->group(function () use ($router) {
 	// api路由
 	$router->get('api/getUserList', '\catchAdmin\api\controller\Api@getUserList');
 });
 $router->get('api/getUsers', '\catchAdmin\api\controller\Api@getUserList');
-$router->get('tool/getwrenchlist','\catchAdmin\api\controller\Tool@getWrenchList');
+//下发数据
+$router->get('tool/Issued', '\catchAdmin\api\controller\Tool@Issued');

+ 1 - 1
catch/hydraulic/model/MaintenanceMapper.php

@@ -105,7 +105,7 @@ class maintenancemapper extends Model
         } else if ($obj->device_type == 2) {
             $data = [
                 'id' => $obj->id,
-                'fan_model' => Db::name('device_mold')->where('id', $obj->fan_model)->value('name'),
+                'fmodel' => Db::name('device_mold')->where('id', $obj->fan_model)->value('name'),
                 'name' => $obj['name'],
                 'parts' => $this->where('device_type', 1)->where('value', $obj->parts)->value('name')
             ];

+ 2 - 2
catch/permissions/controller/User.php

@@ -84,7 +84,7 @@ class User extends CatchController
 
         //    $params['area_id']=json_encode($params['area_id']);
         $params['realname'] = $params['username'];
-        $params['equ_password'] = md5($params['password']);
+        $params['equ_password'] = strtoupper(substr(md5($params['password']), 8, 16));
         $this->user->storeBy($params);
         $this->user->attachRoles($request->param('roles'));
 
@@ -125,7 +125,7 @@ class User extends CatchController
         if ($params['password'] == "") {
             unset($params['password']);
         } else {
-            $params['equ_password'] = md5($params['password']);
+            $params['equ_password'] = strtoupper(substr(md5($params['password']), 8, 16));
         }
         $params['realname'] = $params['username'];
         $this->user->updateBy($id, $params);

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

@@ -275,6 +275,7 @@ class Users extends CatchModel
             ];
             //判断下发的数据库中是否存在
             if ($pubulish) {
+
                 $content = [
                     'Type' => 'update',
                     'ContentType' => 'Users',
@@ -285,6 +286,7 @@ class Users extends CatchModel
                 ];
                 Db::name('publish')->where($wheres)->update($content);
             } else {
+
                 $content = [
                     'Type' => 'add',
                     'ContentType' => 'Users',
@@ -298,10 +300,12 @@ class Users extends CatchModel
             }
         } else {
             if ($pubulish) {
+
                 $content = [
                     'Type' => 'delete',
                     'Version' => $time,
                     'Status' => 1,
+                    'Content' => json_encode($data)
                 ];
                 Db::name('publish')->where($wheres)->update($content);
             }

+ 5 - 5
catch/worklocation/model/WorkLocation.php

@@ -162,12 +162,12 @@ class Worklocation extends Model
         $content = null;
         $data = [
             'id' => $obj->wind_id . $obj->fan_id . $obj->fan_model . $obj->parts . $obj->work_local,
-            'wind_number' => $obj->id,
-            'fan_number' => Wind::where('id', $obj->wind_id)->value('number'),
-            'fan_model'  => ModelDeviceMold::where('device_type', 4)->where('id', $this->fan_model)->value('name'),
+            'wnum' => Wind::where('id', $obj->wind_id)->value('number'),
+            'fnum' =>  Db::name('fan')->where('id', $obj->fan_id)->value('number'),
+            'fmodel'  => ModelDeviceMold::where('device_type', 4)->where('id', $this->fan_model)->value('name'),
             'parts' => $this->get_dict_data(1, $obj->parts),
-            'fan_number' => Fan::where('id', $obj->fan_id)->value('number'),
-            'bolt_num' => $this->bolt_num,
+            'work' => $this->get_dict_data(2, $obj->work_local),
+            'bnum' => $this->bolt_num,
             'torque' => $this->torque
         ];
         $content['data'] = $data;

+ 13 - 4
catch/worklocation/model/Workplan.php

@@ -55,10 +55,19 @@ class Workplan extends Model
         $content = null;
         $data = [
             'id' => $obj->id,
-            'plan_number' => $obj->id,
-            'wind_number' => Wind::where('id', $obj->wind_id)->value('number'),
-            'wind_name' => Wind::where('id', $obj->wind_id)->value('name'),
-            'fan_number' => Fan::where('id', $obj->wind_id)->value('number'),
+            'pnum' => $obj->id,
+            'wnum' => Wind::where('id', $obj->wind_id)->value('number'),
+            '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
+
         ];
         $content['data'] = $data;
         $content['type'] = 'WorkPlan';