tongshanglei 3 years ago
parent
commit
85542378ca
34 changed files with 474 additions and 2625 deletions
  1. 0 23
      catch/device/DeviceService.php
  2. 0 808
      catch/device/controller/CardDevice.php
  3. 0 261
      catch/device/controller/Device.php
  4. 0 259
      catch/device/controller/Station.php
  5. 0 69
      catch/device/controller/StationPhoto.php
  6. 0 58
      catch/device/database/migrations/20220120094737_devices.php
  7. 0 55
      catch/device/database/migrations/20220120100954_stations.php
  8. 0 130
      catch/device/excel/DeviceExport.php
  9. 0 129
      catch/device/excel/StationExport.php
  10. 0 100
      catch/device/model/Device.php
  11. 0 82
      catch/device/model/Station.php
  12. 0 29
      catch/device/model/StationPhoto.php
  13. 0 180
      catch/device/model/get/DeviceGet.php
  14. 0 76
      catch/device/model/get/StationGet.php
  15. 0 69
      catch/device/model/search/DeviceSearch.php
  16. 0 15
      catch/device/module.json
  17. 0 29
      catch/device/route.php
  18. 1 1
      catch/hydraulic/controller/DeviceMold.php
  19. 4 2
      catch/hydraulic/controller/Hydraulic.php
  20. 77 0
      catch/hydraulic/controller/Wrench.php
  21. 6 17
      catch/hydraulic/database/migrations/20220303142809_hydraulic.php
  22. 0 41
      catch/hydraulic/database/migrations/20220504142809_hydraulic_add_Fields.php
  23. 59 0
      catch/hydraulic/database/migrations/20220506141132_wrench.php
  24. 52 1
      catch/hydraulic/model/DeviceMold.php
  25. 34 8
      catch/hydraulic/model/Hydraulic.php
  26. 74 0
      catch/hydraulic/model/Wrench.php
  27. 20 18
      catch/hydraulic/route.php
  28. 0 69
      catch/logs/controller/LocationLog.php
  29. 69 0
      catch/logs/controller/MaintainLog.php
  30. 0 40
      catch/logs/database/migrations/20210617111237_location_log.php
  31. 8 5
      catch/device/database/migrations/20220120105523_station_photos.php
  32. 0 28
      catch/logs/model/LocationLog.php
  33. 45 0
      catch/logs/model/MaintainLog.php
  34. 25 23
      catch/logs/route.php

+ 0 - 23
catch/device/DeviceService.php

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

+ 0 - 808
catch/device/controller/CardDevice.php

@@ -1,808 +0,0 @@
-<?php
-
-namespace catchAdmin\device\controller;
-
-use catcher\base\CatchRequest as Request;
-use catcher\CatchResponse;
-use catcher\base\CatchController;
-use catchAdmin\device\model\Device as deviceModel;
-use catcher\Utils;
-use catcher\library\excel\Excel;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use catchAdmin\device\excel\BadgesExport;
-use catchAdmin\device\excel\CardsExport;
-use catchAdmin\permissions\model\Roles;
-use catchAdmin\permissions\model\Users;
-use catcher\generate\build\types\Arr;
-use \think\facade\Db;
-use think\facade\Cache;
-
-class CardDevice extends CatchController
-{
-    protected $deviceModel;
-
-    public function __construct(DeviceModel $deviceModel)
-    {
-        $this->deviceModel = $deviceModel;
-    }
-
-    /**
-     * 列表
-     * @time 2021年08月28日 16:57
-     * @param Request $request 
-     */
-    public function index(Request $request): \think\Response
-    {
-        $device_type = $request->get('device_type');
-        $field = $request->get('field') ?: 'id';
-        $order = $request->get('order') ?: 'desc';
-        $list = $this->deviceModel->getDeviceList($device_type, $field, $order);
-
-        foreach ($list as &$item) {
-            if ($item['online_time'] < $item['wifi_online_time']) {
-                $item['last_online_time'] = $item['wifi_online_time'];
-                $item['longitude'] = $item['wifi_longitude'];
-                $item['latitude'] = $item['wifi_latitude'];
-            } else {
-                $item['last_online_time'] = $item['online_time'];
-            }
-        }
-        return CatchResponse::paginate($list);
-    }
-    /**
-     * 根据用户id获取设备
-     * @time 2021年08月28日 16:57
-     * @param Request $request 
-     */
-    public function getDeviceByUserId(Request $request): \think\Response
-    {
-        return CatchResponse::paginate($this->deviceModel->getList());
-    }
-    /**
-     * 保存信息
-     * @time 2021年08月28日 16:57
-     * @param Request $request 
-     */
-    public function save(Request $request): \think\Response
-    {
-        $depart_id = $request->post('department_id');
-        if (!$depart_id) {
-            return CatchResponse::fail('请选择所属部门');
-        }
-        $imei = $request->post('imei');
-        if (!$imei) {
-            return CatchResponse::fail('请输入设备imei号');
-        }
-        if (mb_strlen($imei) != 15) {
-            return CatchResponse::fail('imei号格式不正确');
-        }
-        if ($this->deviceModel->where('imei', $imei)->find()) {
-            return CatchResponse::fail('imei号已存在');
-        }
-        $creator_id = $request->post('creator_id');
-        $type = $request->post('type');
-        if ($type == 1) { //个人卡牌导入
-            $data = array(
-                'department_id' => $depart_id,
-                'imei' => $imei,
-                'rfid' => substr($imei, -8),
-                'device_name' => '设备' . substr($imei, -4),
-                'alarm_state' => 0,
-                'device_type' => 0,
-                'use_state' => 0,
-                'net_state' => 2,
-                'creator_id'      => $creator_id,
-                'created_at' => time(),
-                'updated_at' => time()
-            );
-            if (!$this->deviceModel->storeBy($data)) {
-                return CatchResponse::fail('添加设备失败');
-            }
-            $redis=Cache::store('redis')->handler();
-            $redis->rpush('c61_voice_cneter_add_list', $imei);
-            return CatchResponse::success();
-        } else {
-            $realname = $request->post('realname');
-            $user_no = $request->post('user_no');
-            $phone = $request->post('phone');
-            //realname user_no phone 有一个存在,其他也应该必填
-            if (!$realname) {
-                return CatchResponse::fail('请输入用户姓名');
-            }
-            if (!$user_no) {
-                return CatchResponse::fail('请输入用户编号');
-            }
-            if (!$phone) {
-                return CatchResponse::fail('请输入手机号码');
-            }
-            //添加用户
-            $role_id_card_group = (new Roles())->where('identify', 'group_card_user')->value('id');
-            $user_info = (new Users())
-                ->alias('u')
-                ->where('u.username', $phone)
-                ->join('user_has_roles r', 'u.id = r.uid and r.role_id=' . $role_id_card_group)
-                ->find();
-            if ($user_info) {
-                $uid = $user_info['uid'];
-                (new Users())->where('id', $uid)->update(['realname' => $realname, 'user_no' => $user_no]);
-            } else { //添加用户
-                $user = array(
-                    'username' => $phone,
-                    'password' => substr($imei, -8),
-                    'realname' => $realname,
-                    'user_no'  => $user_no,
-                    'phone'    => $phone,
-                    'department_id' => $depart_id,
-                    'creator_id'      => $creator_id,
-                    'created_at' => time(),
-                    'updated_at' => time()
-                );
-                // var_dump($user);
-                $uid = (new Users())->createBy($user);
-                Db::table('user_has_roles')->insert(['uid' => $uid, 'role_id' => $role_id_card_group]);
-            }
-            //保存设备信息
-            $data = array(
-                'department_id' => $depart_id,
-                'imei' => $imei,
-                'rfid' => substr($imei, -8),
-                'device_name' => '设备' . substr($imei, -4),
-                'user_id' => $uid,
-                'alarm_state' => 0,
-                'device_type' => 0,
-                'use_state' => 1,
-                'net_state' => 2,
-                'creator_id'      => $creator_id,
-                'created_at' => time(),
-                'updated_at' => time()
-            );
-            //添加设备
-            if ($this->deviceModel->storeBy($data)) {
-                $redis=Cache::store('redis')->handler();
-                $redis->rpush('c61_voice_cneter_add_list', $imei);
-                return CatchResponse::success();
-            }
-            return CatchResponse::fail('添加设备失败');
-        }
-    }
-
-    /**
-     * 读取
-     * @time 2021年08月28日 16:57
-     * @param $id 
-     */
-    public function read($id): \think\Response
-    {
-        return CatchResponse::success($this->deviceModel->findBy($id));
-    }
-
-    /**
-     * 更新
-     * @time 2021年08月28日 16:57
-     * @param Request $request 
-     * @param $id
-     */
-    public function update(Request $request, $id): \think\Response
-    {
-        $depart_id = $request->post('department_id');
-        if (!$depart_id) {
-            return CatchResponse::fail('请选择所属部门');
-        }
-        $imei = $request->post('imei');
-        if (count(explode(',', $imei)) > 1) {
-            return CatchResponse::fail('imei格式不正确');
-        }
-        $check_id = $this->deviceModel->where('imei', $imei)->value('id');
-        if ($check_id && $check_id != $id) {
-            return CatchResponse::fail('imei号已存在');
-        }
-        //更新设备信息
-        $data = array(
-            'department_id' => $depart_id,
-            'imei' => $imei,
-            'rfid' => substr($imei, -8),
-            'updated_at' => time()
-        );
-        if (isset(($request->post())['creator'])) {
-            $data['creator_id'] = $request->post('creator');
-        }
-        if ($this->deviceModel->where('id', $id)->update($data)) {
-            return CatchResponse::success();
-        }
-        return CatchResponse::fail('更新设备失败');
-
-        // return CatchResponse::success($this->deviceModel->updateBy($id, $request->post()));
-    }
-
-    /**
-     * 删除
-     * @time 2021年08月28日 16:57
-     * @param $id
-     */
-    public function delete($id): \think\Response
-    {
-        return CatchResponse::success($this->deviceModel->deleteBy($id, true));
-    }
-    /**
-     * 查询告警列表
-     * @time 2021年05月24日
-     * @return \think\response\Json
-     */
-    public function queryAlarmList(Request $request): \think\Response
-    {
-        return CatchResponse::paginate($this->deviceModel->queryAlarmList());
-    }
-    /**
-     * 导出
-     *
-     * @time 2020年09月08日
-     * @param Excel $excel
-     * @param DeviceExport $deviceExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function export_card(Excel $excel, CardsExport $CardsExport)
-    {
-        //  var_dump(Utils::publicPath('export/users'));//导出路径
-        return CatchResponse::success($excel->save($CardsExport, Utils::publicPath('export/cards'), 'local', '卡牌设备列表'));
-    }
-    /**
-     * 导入卡牌设备
-     *
-     * @time 2020年09月08日
-     * @param Excel $excel
-     * @param DeviceExport $deviceExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function importCards(Request $request)
-    {
-        $url = $request->post('url');
-        if (!$url) {
-            return CatchResponse::fail('请上传文件');
-        }
-        $depart_id = $request->post('depart_id');
-        if (!$depart_id) {
-            return CatchResponse::fail('请选择部门');
-        }
-        $creator_id = $request->post('creator_id');
-        //解析地址
-        $parse_url = parse_url($url)['path'];
-        //载入excel表格 
-        $objPHPExcel = IOFactory::load(public_path() . $parse_url);
-        // var_dump($objPHPExcel);
-        //获取表名,一维数组,值是表名。如:array('sheet1', 'sheet2', 'sheet3')
-        // $nameArr = $objPHPExcel->getSheetNames();
-        // var_dump($nameArr);
-        //获取表的数量
-        $sheetCount = $objPHPExcel->getSheetCount();
-        $fail = 0; //失败条数
-        $success = 0; //成功条数
-        $total = 0; //总共学生数
-        $personal_data = []; //个人卡牌
-        $group_data = []; //团体卡牌
-        //循环读取每一张表
-        for ($index = 0; $index < $sheetCount; $index++) {
-            //设置当前要读取的表
-            $sheet = $objPHPExcel->getSheet($index);   //excel中的第一张sheet
-            // var_dump($sheet);exit;
-            $highestRow  = $sheet->getHighestRow();       // 取得总行数
-            // var_dump($highestRow);
-            if ($highestRow <= 2) {
-                continue;
-            }
-            $total += $highestRow - 2;
-            for ($j = 3; $j <= $highestRow; $j++) {
-                $data = array(); //每条学生信息
-                $imei = trim($sheet->getCell("A" . $j)->getFormattedValue());  //imei
-                // var_dump($imei);
-                if (mb_strlen($imei) != 15) {
-                    $fail++;
-                    $msg = '导入设备:' . $imei . '失败:imei编号格式不正确';
-                    $this->importFailLog($msg);
-                    continue;
-                }
-                $realname = trim($sheet->getCell("B" . $j)->getFormattedValue());  //姓名
-                $user_no   = trim($sheet->getCell("C" . $j)->getFormattedValue()); //用户编号
-                $phone = trim($sheet->getCell("D" . $j)->getFormattedValue());  //手机号
-                if (!$realname && !$user_no && !$phone) { //导入个人用户设备
-                    $data = array(
-                        'department_id' => $depart_id,
-                        'imei' => $imei,
-                        'rfid' => substr($imei, -8),
-                        'device_name' => '设备' . substr($imei, -4),
-                        'alarm_state' => 0,
-                        'device_type' => 0,
-                        'use_state' => 0,
-                        'net_state' => 2,
-                        'creator_id'      => $creator_id,
-                        'created_at' => time(),
-                        'updated_at' => time()
-                    );
-                    //查询设备
-                    $info = $this->deviceModel->where('imei', $imei)->find();
-                    if ($info) {
-                        $fail++;
-                        $msg = '导入设备:' . $imei . '失败:imei编号已存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                    //添加设备
-                    // if ($this->deviceModel->createBy($data)) {
-                    //     $success++;
-                    // } else {
-                    //     $fail++;
-                    //     $msg = '导入设备:' . $imei . '失败:添加设备失败';
-                    //     $this->importFailLog($msg);
-                    //     continue;
-                    // }
-                    array_push($personal_data, $data);
-                } else { //团体用户设备
-                    if (!$realname) {
-                        $fail++;
-                        $msg = '导入设备:' . $imei . '失败:用户姓名不存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                    if (!$user_no) {
-                        $fail++;
-                        $msg = '导入设备:' . $imei . '失败:用户编号不存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                    if (!$phone) {
-                        $fail++;
-                        $msg = '导入设备:' . $imei . '失败:用户手机号不存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                    //保存用户信息
-                    $role_id_card_group = (new Roles())->where('identify', 'group_card_user')->value('id');
-                    $user_info = (new Users())
-                        ->alias('u')
-                        ->where('u.phone', $phone)
-                        ->join('user_has_roles r', 'u.id = r.uid and r.role_id=' . $role_id_card_group)
-                        ->find();
-                    if ($user_info) {
-                        $uid = $user_info['uid'];
-                        (new Users())->where('id', $uid)->update(['realname' => $realname, 'user_no' => $user_no]);
-                    } else { //添加用户
-                        $user = array(
-                            'username' => $phone,
-                            'password' => substr($imei, -8),
-                            'realname' => $realname,
-                            'user_no'  => $user_no,
-                            'phone'    => $phone,
-                            'department_id' => $depart_id,
-                            'creator_id'      => $creator_id,
-                            'created_at' => time(),
-                            'updated_at' => time()
-                        );
-                        // var_dump($user);
-                        $uid = (new Users())->createBy($user);
-                        Db::table('user_has_roles')->insert(['uid' => $uid, 'role_id' => $role_id_card_group]);
-                    }
-                    //保存设备信息
-                    $data = array(
-                        'department_id' => $depart_id,
-                        'imei' => $imei,
-                        'rfid' => substr($imei, -8),
-                        'device_name' => '设备' . substr($imei, -4),
-                        'user_id' => $uid,
-                        'alarm_state' => 0,
-                        'device_type' => 0,
-                        'use_state' => 1,
-                        'net_state' => 2,
-                        'creator_id'      => $creator_id,
-                        'created_at' => time(),
-                        'updated_at' => time()
-                    );
-                    //查询设备
-                    $info = $this->deviceModel->where('imei', $imei)->find();
-                    if ($info) {
-                        $fail++;
-                        $msg = '导入设备:' . $imei . '失败:imei编号已存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                    //添加设备
-                    // if ($this->deviceModel->createBy($data)) {
-                    //     $success++;
-                    // } else {
-                    //     $fail++;
-                    //     $msg = '导入设备:' . $imei . '失败:添加设备失败';
-                    //     $this->importFailLog($msg);
-                    //     continue;
-                    // }
-                    array_push($group_data, $data);
-                }
-            }
-        }
-        array_unique($personal_data, SORT_REGULAR);
-        array_unique($group_data, SORT_REGULAR);
-        $count1 = $this->deviceModel->limit(100)->insertAll($personal_data);
-        $count2 = $this->deviceModel->limit(100)->insertAll($group_data);
-        $redis=Cache::store('redis')->handler();
-        foreach($personal_data as $value){
-            $redis->rpush('c61_voice_cneter_add_list', $value['imei']);
-        }
-        foreach($group_data as $value){
-            $redis->rpush('c61_voice_cneter_add_list', $value['imei']);
-        }
-        if ($success = $count1 + $count2) {
-            return CatchResponse::success('共' . $total . '条数据,成功' . $success . '条,失败' . $fail . '条');
-        }
-        return CatchResponse::success(['error' => true, 'msg' => '导入失败']);
-        // return CatchResponse::success('共' . $total . '条数据,成功' . $success . '条,失败' . $fail . '条');
-    }
-    /**
-     * 导入设备失败日志
-     */
-    public function importFailLog($msg)
-    {
-        $file = runtime_path() . '/log/' . date("Ymd", time()) . "/import_devices_fail.log";
-        $folder = dirname($file);
-        if (!is_dir($folder)) {
-            mkdir($folder, 0777, true);
-        }
-        file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $msg . PHP_EOL, FILE_APPEND);
-    }
-    /**
-     * 检测下发配置选项
-     */
-    public function checkConfig(Request $request): \think\Response
-    {
-        // var_dump($request->post('ids'));
-        $ids = $request->post('ids');
-        if (empty($ids)) {
-            return CatchResponse::fail('未选中设备');
-        }
-        $has_use_num = 0;
-        foreach ($ids as $v) {
-            if ($this->deviceModel->where('id', $v)->value('use_state')) {
-                $has_use_num++;
-            }
-        }
-        if (count($ids) != $has_use_num) {
-            // return CatchResponse::fail('所选项含有未注册设备');
-        }
-        return CatchResponse::success();
-    }
-    /**
-     * 下发录音配置
-     */
-    public function sendVoiceConfig(Request $request): \think\Response
-    {
-        $ids = $request->post('ids');
-        $config = $request->post('config');
-        if (empty($ids)) {
-            return CatchResponse::fail('未选择设备');
-        }
-        if (empty($config)) {
-            return CatchResponse::fail('至少配置一项');
-        }
-        // $config['is_enabled'] = $config['is_enabled'] ? 1 : 0;
-        if (!$config['srv_addr']) {
-            unset($config['srv_addr']);
-        }
-        if (!$config['srv_port']) {
-            unset($config['srv_port']);
-        } else {
-            $config['srv_port'] = intval($config['srv_port']);
-        }
-
-        // if (!$config['max_ppt_duration_ms']) {
-        //     unset($config['max_ppt_duration_ms']);
-        // } else {
-        //     $config['max_ppt_duration_ms'] = intval($config['max_ppt_duration_ms']);
-        // }
-
-        $config['msg_id'] = 0xAAAA0008;
-        Db::startTrans();
-        $fail_imei = '';
-        foreach ($ids as $id) {
-            $imei = $this->deviceModel->where('id', $id)->value('imei');
-            if (!$imei) {
-                continue;
-            }
-            //下发日志
-            $log_data = array(
-                'send_contents' => json_encode($config),
-                'imei' => $imei,
-                'type' => 'voice',
-                'created_at' => time(),
-                'device_id' => $id
-            );
-            $id = Db::table('send_config_log')->insertGetId($log_data);
-            if (!$id) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-            $config['id'] = $id;
-            $redis = Cache::store('redis')->handler();
-            $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($config));
-            if (!$res) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-        }
-        if ($fail_imei != '') {
-            return CatchResponse::fail('下发失败');
-        }
-        Db::commit();
-        return CatchResponse::success('下发成功');
-    }
-    /**
-     * 下发传感器配置
-     */
-    public function sendSensorConfig(Request $request): \think\Response
-    {
-        $ids = $request->post('ids');
-        $config = $request->post('config');
-        if (empty($ids)) {
-            return CatchResponse::fail('未选择设备');
-        }
-        if (empty($config)) {
-            return CatchResponse::fail('至少配置一项');
-        }
-        if (!$config['stopped_rtc_invl']) {
-            unset($config['stopped_rtc_invl']);
-        } else {
-            $config['stopped_rtc_invl'] = intval($config['stopped_rtc_invl']);
-        }
-        if (!$config['stopped_rpt_invl']) {
-            unset($config['stopped_rpt_invl']);
-        } else {
-            $config['stopped_rpt_invl'] = intval($config['stopped_rpt_invl']);
-        }
-        if (!$config['not_moving_threshold']) {
-            unset($config['not_moving_threshold']);
-        } else {
-            $config['not_moving_threshold'] = intval($config['not_moving_threshold']);
-        }
-        if (!$config['stopped_rtc_invl']) {
-            unset($config['stopped_rtc_invl']);
-        } else {
-            $config['stopped_rtc_invl'] = intval($config['stopped_rtc_invl']);
-        }
-        if (!$config['stopped_rpt_invl']) {
-            unset($config['stopped_rpt_invl']);
-        } else {
-            $config['stopped_rpt_invl'] = intval($config['stopped_rpt_invl']);
-        }
-        if (!$config['tbd_cnt_max']) {
-            unset($config['tbd_cnt_max']);
-        } else {
-            $config['tbd_cnt_max'] = intval($config['tbd_cnt_max']);
-        }
-        if (empty($config)) {
-            return CatchResponse::fail('您还没有配置任何一项');
-        }
-        $config['msg_id'] = 0xAAAA0007;
-        Db::startTrans();
-        $fail_imei = '';
-        foreach ($ids as $id) {
-            $imei = $this->deviceModel->where('id', $id)->value('imei');
-            if (!$imei) {
-                continue;
-            }
-            //下发日志
-            $log_data = array(
-                'send_contents' => json_encode($config),
-                'imei' => $imei,
-                'created_at' => time(),
-                'type' => 'sensor',
-                'device_id' => $id
-            );
-            $id = Db::table('send_config_log')->insertGetId($log_data);
-            if (!$id) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-            $config['id'] = $id;
-            $redis = Cache::store('redis')->handler();
-            $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($config));
-            if (!$res) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-        }
-        if ($fail_imei != '') {
-            return CatchResponse::fail('下发失败');
-        }
-        Db::commit();
-        return CatchResponse::success('下发成功');
-    }
-    /**
-     * 下发gps配置
-     */
-    public function sendGpsConfig(Request $request): \think\Response
-    {
-        $ids = $request->post('ids');
-        $config = $request->post('config');
-        if (empty($ids)) {
-            return CatchResponse::fail('未选择设备');
-        }
-        if (empty($config)) {
-            return CatchResponse::fail('至少配置一项');
-        }
-        $config['pos_mode'] = intval($config['pos_mode']);
-
-        // $config['msg_id'] = 0xAAAA0001;
-        $config['msg_id'] = 0xAAAA0010;
-        Db::startTrans();
-        $fail_imei = '';
-        foreach ($ids as $id) {
-            $imei = $this->deviceModel->where('id', $id)->value('imei');
-            if (!$imei) {
-                continue;
-            }
-            //判断是不是定时模式
-            if ($config['pos_mode'] == 2) {
-
-                $config_arr = array(
-                    'stopped_rtc_invl' => intval($config['stopped_rtc_invl']),
-                    'stopped_rpt_invl' => intval($config['stopped_rpt_invl']),
-                    'msg_id' => 0xAAAA0007
-                );
-
-                //下发日志
-                $log_data = array(
-                    'send_contents' => json_encode($config_arr),
-                    'imei' => $imei,
-                    'type' => 'sensor',
-                    'created_at' => time(),
-                    'device_id' => $id
-                );
-                $lg_id = Db::table('send_config_log')->insertGetId($log_data);
-                if (!$lg_id) {
-                    $fail_imei += $imei . ' ';
-                    Db::rollback();
-                }
-                $config_arr['id'] = $lg_id;
-                $redis = Cache::store('redis')->handler();
-                $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($config_arr));
-                if (!$res) {
-                    $fail_imei += $imei . ' ';
-                    Db::rollback();
-                }
-               
-            }else{
-                $config_arr = array(
-                    'stopped_rtc_invl' => 3000,
-                    'stopped_rpt_invl' => 3600,
-                    'msg_id' => 0xAAAA0007
-                );
-                //下发日志
-                $log_data = array(
-                    'send_contents' => json_encode($config_arr),
-                    'imei' => $imei,
-                    'type' => 'sensor',
-                    'created_at' => time(),
-                    'device_id' => $id
-                );
-                $lg_id = Db::table('send_config_log')->insertGetId($log_data);
-                if (!$lg_id) {
-                    $fail_imei += $imei . ' ';
-                    Db::rollback();
-                }
-                $config_arr['id'] = $lg_id;
-                $redis = Cache::store('redis')->handler();
-                $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($config_arr));
-                if (!$res) {
-                    $fail_imei += $imei . ' ';
-                    Db::rollback();
-                }
-                
-            }
-            //重新赋值 删除多余参数
-            $mode_config=$config;
-            unset($mode_config['stopped_rpt_invl'],$mode_config['stopped_rtc_invl']);
-            //下发日志
-            $log_data = array(
-                'send_contents' => json_encode($mode_config),
-                'imei' => $imei,
-                'type' => 'pos_mode',
-                'created_at' => time(),
-                'device_id' => $id
-            );
-            $id = Db::table('send_config_log')->insertGetId($log_data);
-            if (!$id) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-            $mode_config['id'] = $id;
-            $redis = Cache::store('redis')->handler();
-            $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($mode_config));
-            if (!$res) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-        }
-        if ($fail_imei != '') {
-            return CatchResponse::fail('下发失败');
-        }
-        Db::commit();
-        return CatchResponse::success('下发成功');
-    }
-    /**
-     * 设备终端操作命令
-     */
-    public function sendcmd(Request $request): \think\Response
-    {
-        $ids = $request->post('ids');
-
-        if (empty($ids)) {
-            return CatchResponse::fail('未选择设备');
-        }
-        $config['msg_id'] = 0xAAAA0011;
-        $config['cmd'] = intval($request->post('cmd'));
-        Db::startTrans();
-        $fail_imei = '';
-        foreach ($ids as $id) {
-            $imei = $this->deviceModel->where('id', $id)->value('imei');
-            if (!$imei) {
-                continue;
-            }
-            //下发日志
-            $log_data = array(
-                'send_contents' => json_encode($config),
-                'imei' => $imei,
-                'type' => 'cmd',
-                'created_at' => time(),
-                'device_id' => $id
-            );
-            $id = Db::table('send_config_log')->insertGetId($log_data);
-            if (!$id) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-            $config['id'] = $id;
-            $redis = Cache::store('redis')->handler();
-            $res = $redis->rpush('c61_gps_device_configs_' . $imei, json_encode($config));
-            if (!$res) {
-                $fail_imei += $imei . ' ';
-                Db::rollback();
-            }
-        }
-        if ($fail_imei != '') {
-            return CatchResponse::fail('操作失败');
-        }
-        Db::commit();
-        return CatchResponse::success('操作成功');
-    }
-    /*
-    默认配置
-    */
-    public function getDefaultConfig()
-    {
-        $type_id = Db::table('sys_dict_type')->where('code', 'DeviceConfigDefault')->value('id');
-        $list = Db::table('sys_dict_data')->where('type_id', $type_id)->field('code,value,sort')->select();
-        $cnf1 = [];
-        $cnf2 = [];
-        $cnf3 = [];
-        foreach ($list as $value) {
-            if ($value['sort'] == 1) {
-                //    array_push($cnf1,[$value['code']=>$value['value']]);
-                if ($value['value'] == 'true') {
-                    $value['value'] = true;
-                }
-                $cnf1[$value['code']] = $value['value'];
-            }
-            if ($value['sort'] == 2) {
-                $cnf2[$value['code']] = $value['value'];
-            }
-            if ($value['sort'] == 3) {
-                $cnf3[$value['code']] = $value['value'];
-                $cnf3['stopped_rtc_invl'] = '50';
-                $cnf3['stopped_rpt_invl'] = '300';
-            }
-        }
-        $config = array(
-            'voice_config' => $cnf1,
-            'sensor_config' => $cnf2,
-            'gps_config' => $cnf3,
-        );
-        return CatchResponse::success($config);
-    }
-}

+ 0 - 261
catch/device/controller/Device.php

@@ -1,261 +0,0 @@
-<?php
-
-namespace catchAdmin\device\controller;
-
-use catcher\base\CatchRequest as Request;
-use catcher\CatchResponse;
-use catcher\base\CatchController;
-use catcher\Utils;
-use catcher\library\excel\Excel;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use catchAdmin\device\excel\DeviceExport;
-use catchAdmin\device\model\Device as deviceModel;
-
-class Device extends CatchController
-{
-    protected $deviceModel;
-    
-    public function __construct(DeviceModel $deviceModel)
-    {
-        $this->deviceModel = $deviceModel;
-    }
-    
-    /**
-     * 列表
-     * @time 2022年01月20日 09:47
-     * @param Request $request 
-     */
-    public function index(Request $request) : \think\Response
-    {
-        $field = $request->get('field')?:'id';
-        $order = $request->get('order')?:'desc';
-        return CatchResponse::paginate($this->deviceModel->getDeviceList($field,$order));
-    }
-    
-    /**
-     * 保存信息
-     * @time 2022年01月20日 09:47
-     * @param Request $request 
-     */
-    public function save(Request $request) : \think\Response
-    {
-        $data = $request->post();
-        if(!$data['department_id']){
-            return CatchResponse::fail('请选择部门');
-        }
-        $data['imei'] = trim($data['imei']);
-        $data['rfid'] = trim($data['rfid']);
-        if(!$data['imei'] && !$data['rfid']){
-            return CatchResponse::fail('GPS编号和RFID编号必填一项');
-        }
-        //检测重复
-        if($data['imei']){
-            if($this->deviceModel->where('imei',$data['imei'])->limit(0,1)->find()){
-                return CatchResponse::fail('GPS编号已存在');
-            }
-        }
-        if($data['rfid']){
-                if($this->deviceModel->where('rfid',$data['rfid'])->limit(0,1)->find()){
-                    return CatchResponse::fail('RFID编号已存在');
-                }
-        }
-        $data['name'] = '设备'.substr($data['imei']?:$data['rfid'],-4);
-        return CatchResponse::success($this->deviceModel->storeBy($data));
-    }
-    
-    /**
-     * 读取
-     * @time 2022年01月20日 09:47
-     * @param $id 
-     */
-    public function read($id) : \think\Response
-    {
-        return CatchResponse::success($this->deviceModel->findBy($id));
-    }
-    
-    /**
-     * 更新
-     * @time 2022年01月20日 09:47
-     * @param Request $request 
-     * @param $id
-     */
-    public function update(Request $request, $id) : \think\Response
-    {
-        $data = $request->post();
-        if(!$data['department_id']){
-            return CatchResponse::fail('请选择部门');
-        }
-        $data['imei'] = trim($data['imei']);
-        $data['rfid'] = trim($data['rfid']);
-        if(!$data['imei'] && !$data['rfid']){
-            return CatchResponse::fail('GPS编号和RFID编号必填一项');
-        }
-        //检测重复
-        if($data['imei']){
-            $oid = $this->deviceModel->where('imei',$data['imei'])->limit(0,1)->value('id');
-            if( $oid && $oid != $id){
-                return CatchResponse::fail('GPS编号已存在');
-            }
-        }
-       if($data['rfid']){
-            $oid = $this->deviceModel->where('rfid',$data['rfid'])->limit(0,1)->value('id');
-            if($oid && $oid != $id){
-                return CatchResponse::fail('RFID编号已存在');
-            }
-       }
-        $data['name'] = $data['imei']?:$data['rfid'];
-        return CatchResponse::success($this->deviceModel->updateBy($id,$data));
-    }
-    
-    /**
-     * 删除
-     * @time 2022年01月20日 09:47
-     * @param $id
-     */
-    public function delete($id) : \think\Response
-    {
-        return CatchResponse::success($this->deviceModel->deleteBy($id,true));
-    }
-     /**
-     * 导出
-     *
-     * @time 2022年02月15日
-     * @param Excel $excel
-     * @param DeviceExport $deviceExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function export_device(Excel $excel, DeviceExport $DeviceExport)
-    {
-        //  var_dump(Utils::publicPath('export/users'));//导出路径
-        return CatchResponse::success($excel->save($DeviceExport, Utils::publicPath('export/devices'), 'local', '设备列表'));
-    }
-      /**
-     * 导入设备
-     *
-     * @time 2022年02月15日
-     * @param Excel $excel
-     * @param DeviceExport $deviceExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function import_device(Request $request)
-    {
-        $url = $request->post('url');
-        if (!$url) {
-            return CatchResponse::fail('请上传文件');
-        }
-        $depart_id = $request->post('depart_id');
-        if (!$depart_id) {
-            return CatchResponse::fail('请选择部门');
-        }
-        $model_id = $request->post('model_id');
-        if (!$model_id) {
-            return CatchResponse::fail('请选择型号');
-        }
-        $creator_id = $request->post('creator_id');
-        //解析地址
-        $parse_url = parse_url($url)['path'];
-        //载入excel表格 
-        $objPHPExcel = IOFactory::load(public_path() . $parse_url);
-        // var_dump($objPHPExcel);
-        //获取表名,一维数组,值是表名。如:array('sheet1', 'sheet2', 'sheet3')
-        // $nameArr = $objPHPExcel->getSheetNames();
-        // var_dump($nameArr);
-        //获取表的数量
-        $sheetCount = $objPHPExcel->getSheetCount();
-        $fail = 0; //失败条数
-        $success = 0; //成功条数
-        $total = 0; //总共设备数
-        $data = []; //设备数据
-        //循环读取每一张表
-        for ($index = 0; $index < $sheetCount; $index++) {
-            //设置当前要读取的表
-            $sheet = $objPHPExcel->getSheet($index);   //excel中的第一张sheet
-            // var_dump($sheet);exit;
-            $highestRow  = $sheet->getHighestRow();       // 取得总行数
-            // var_dump($highestRow);
-            if ($highestRow <= 2) {
-                continue;
-            }
-            $total += $highestRow - 2;
-            for ($j = 3; $j <= $highestRow; $j++) {
-                $arr = array(); //每条设备信息
-                $arr['imei'] = trim($sheet->getCell("A" . $j)->getFormattedValue());  //imei
-                if ($arr['imei'] && mb_strlen($arr['imei']) != 15) {
-                    $fail++;
-                    $msg = '导入设备:' . $arr['imei'] . '失败:imei编号格式不正确';
-                    $this->importFailLog($msg);
-                    continue;
-                }
-                //检测重复
-                if($arr['imei']){
-                    $isHas = $this->deviceModel->where('imei',$arr['imei'])->count();
-                    if($isHas){
-                        $fail++;
-                        $msg = '导入设备imei:' . $arr['imei'] . '失败:imei编号已存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                }
-                $arr['rfid'] = trim($sheet->getCell("B" . $j)->getFormattedValue());  //rfid
-                 //检测重复
-                 if($arr['rfid']){
-                    $isHas = $this->deviceModel->where('rfid',$arr['rfid'])->count();
-                    if($isHas){
-                        $fail++;
-                        $msg = '导入设备rfid:' . $arr['rfid'] . '失败:rfid编号已存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                }
-                $arr['remark']   = trim($sheet->getCell("C" . $j)->getFormattedValue()); //备注
-                $arr['department_id'] = $depart_id;
-                $arr['creator_id'] = $creator_id;
-                $arr['model'] = $model_id;
-                $arr['name'] = '设备'.substr($arr['imei']?:$arr['rfid'],-4);
-                $arr['created_at'] = time();
-                $arr['updated_at'] = time();
-               array_push($data,$arr);
-            }
-        }
-        array_unique($data, SORT_REGULAR);
-        // var_dump($data);return CatchResponse::success();
-        $count = $this->deviceModel->limit(100)->insertAll($data);
-        if ($success = $count) {
-
-            return CatchResponse::success('共' . $total . '条数据,成功' . $success . '条,失败' . $fail . '条');
-
-        }
-        return CatchResponse::success(['error' => true, 'msg' => '导入失败']);
-    }
-    /**
-     * 导入设备失败日志
-     */
-    public function importFailLog($msg)
-    {
-        $file = runtime_path() . '/log/' . date("Ymd", time()) . "/import_devices_fail.log";
-        $folder = dirname($file);
-        if (!is_dir($folder)) {
-            mkdir($folder, 0777, true);
-        }
-        file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $msg . PHP_EOL, FILE_APPEND);
-    }
-}
-
-//      ┏┛ ┻━━━━━┛ ┻┓
-//      ┃       ┃
-//      ┃   ━   ┃
-//      ┃ ┳┛   ┗┳ ┃
-//      ┃       ┃
-//      ┃   ┻   ┃
-//      ┃       ┃
-//      ┗━┓   ┏━━━┛
-//        ┃   ┃   神兽保佑
-//        ┃   ┃   代码无BUG!
-//        ┃   ┗━━━━━━━━━┓
-//        ┃           ┣┓
-//        ┃             ┏┛
-//        ┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
-//          ┃ ┫ ┫   ┃ ┫ ┫
-//          ┗━┻━┛   ┗━┻━┛

+ 0 - 259
catch/device/controller/Station.php

@@ -1,259 +0,0 @@
-<?php
-
-namespace catchAdmin\device\controller;
-
-use catcher\base\CatchRequest as Request;
-use catcher\CatchResponse;
-use catcher\base\CatchController;
-use catchAdmin\device\model\Station as stationModel;
-use catchAdmin\device\model\StationPhoto;
-use catcher\Utils;
-use catcher\library\excel\Excel;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use catchAdmin\device\excel\StationExport;
-use think\facade\Db;
-class Station extends CatchController
-{
-    protected $stationModel;
-    
-    public function __construct(StationModel $stationModel)
-    {
-        $this->stationModel = $stationModel;
-    }
-    
-    /**
-     * 列表
-     * @time 2022年01月20日 10:09
-     * @param Request $request 
-     */
-    public function index(Request $request) : \think\Response
-    {
-        $field = $request->get('field')?:'id';
-        $order = $request->get('order')?:'desc';
-        return CatchResponse::paginate($this->stationModel->getStationList($field,$order));
-    }
-    
-    /**
-     * 保存信息
-     * @time 2022年01月20日 10:09
-     * @param Request $request 
-     */
-    public function save(Request $request) : \think\Response
-    {
-        $data = $request->post();
-        //判断参数
-        if(!$data['department_id']){
-            return CatchResponse::fail('请选择所属部门');
-        }
-        if(!$data['model']){
-            return CatchResponse::fail('请选择基站型号');
-        }
-        $data['mac'] = trim($data['mac']);
-        if(!$data['mac']){
-            return CatchResponse::fail('请输入基站Mac');
-        }
-        if (!preg_match('/^[0-9a-zA-Z]{6,15}$/i',$data['mac'])){
-            return CatchResponse::fail('基站为6-15位字母数字');
-        }
-         //基站简码
-         $data['shortcode'] = substr($data['mac'],-6,6);
-         //校验重复
-         if($this->stationModel->where('mac',$data['mac'])->count()){
-             return CatchResponse::fail('该基站已存在');
-         }
-        //开启事务
-        Db::startTrans();
-        //开局状态
-        if($data['type'] == 1){
-            $data['open_status'] = 0;
-        }else{
-            $data['open_status'] = 1;
-            //开局时间
-            $data['open_time'] = date('Y-m-d H:i:s');
-            //开局员工
-            $data['open_user_id'] = $data['creator_id'];
-        }
-        $station_id = $this->stationModel->storeBy($data);
-        if(!$station_id){
-            return CatchResponse::fail('添加失败');
-        }
-         //基站图片
-         if(isset($data['install_photo'])){
-            $photo = array(
-                'url'=>$data['install_photo'],
-                'type'=>'station',
-                'station_id'=>$station_id,
-                'creator_id'=>$data['creator_id']
-            );
-            $res = (new StationPhoto())->storeBy($photo);
-            if(!$res){
-                Db::rollback();
-                return CatchResponse::fail('添加失败');
-            }
-        }
-        Db::commit();
-        return CatchResponse::success();
-    }
-    
-    /**
-     * 读取
-     * @time 2022年01月20日 10:09
-     * @param $id 
-     */
-    public function read($id) : \think\Response
-    {
-        return CatchResponse::success($this->stationModel->findBy($id));
-    }
-    
-    /**
-     * 更新
-     * @time 2022年01月20日 10:09
-     * @param Request $request 
-     * @param $id
-     */
-    public function update(Request $request, $id) : \think\Response
-    {
-        return CatchResponse::success($this->stationModel->updateBy($id, $request->post()));
-    }
-    
-    /**
-     * 删除
-     * @time 2022年01月20日 10:09
-     * @param $id
-     */
-    public function delete($id) : \think\Response
-    {
-        return CatchResponse::success($this->stationModel->deleteBy($id,true));
-    }
-     /**
-     * 导出
-     *
-     * @time 2022年02月15日
-     * @param Excel $excel
-     * @param StationExport $stationExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function export_station(Excel $excel, StationExport $StationExport)
-    {
-        //  var_dump(Utils::publicPath('export/users'));//导出路径
-        return CatchResponse::success($excel->save($StationExport, Utils::publicPath('export/stations'), 'local', '基站列表'));
-    }
-      /**
-     * 导入设备
-     *
-     * @time 2022年02月15日
-     * @param Excel $excel
-     * @param DeviceExport $deviceExport
-     * @throws \PhpOffice\PhpSpreadsheet\Exception
-     * @return \think\response\Json
-     */
-    public function import_station(Request $request)
-    {
-        $url = $request->post('url');
-        if (!$url) {
-            return CatchResponse::fail('请上传文件');
-        }
-        $depart_id = $request->post('depart_id');
-        if (!$depart_id) {
-            return CatchResponse::fail('请选择部门');
-        }
-        $model_id = $request->post('model_id');
-        if (!$model_id) {
-            return CatchResponse::fail('请选择型号');
-        }
-        $creator_id = $request->post('creator_id');
-        //解析地址
-        $parse_url = parse_url($url)['path'];
-        //载入excel表格 
-        $objPHPExcel = IOFactory::load(public_path() . $parse_url);
-        // var_dump($objPHPExcel);
-        //获取表名,一维数组,值是表名。如:array('sheet1', 'sheet2', 'sheet3')
-        // $nameArr = $objPHPExcel->getSheetNames();
-        // var_dump($nameArr);
-        //获取表的数量
-        $sheetCount = $objPHPExcel->getSheetCount();
-        $fail = 0; //失败条数
-        $success = 0; //成功条数
-        $total = 0; //总共设备数
-        $data = []; //基站数据
-        //循环读取每一张表
-        for ($index = 0; $index < $sheetCount; $index++) {
-            //设置当前要读取的表
-            $sheet = $objPHPExcel->getSheet($index);   //excel中的第一张sheet
-            // var_dump($sheet);exit;
-            $highestRow  = $sheet->getHighestRow();       // 取得总行数
-            // var_dump($highestRow);
-            if ($highestRow <= 2) {
-                continue;
-            }
-            $total += $highestRow - 2;
-            for ($j = 3; $j <= $highestRow; $j++) {
-                $arr = array(); //每条基站信息
-                $arr['mac'] = trim($sheet->getCell("A" . $j)->getFormattedValue());  //imei
-                if ($arr['mac'] && mb_strlen($arr['mac']) != 12) {
-                    $fail++;
-                    $msg = '导入基站:' . $arr['mac'] . '失败:mac编号格式不正确';
-                    $this->importFailLog($msg);
-                    continue;
-                }
-                if ($arr['mac']) {
-                    $isHas = $this->stationModel->where('mac',$arr['mac'])->count();
-                    if($isHas){
-                        $fail++;
-                        $msg = '导入基站:' . $arr['mac'] . '失败:mac编号已存在';
-                        $this->importFailLog($msg);
-                        continue;
-                    }
-                }
-                $arr['remark']   = trim($sheet->getCell("B" . $j)->getFormattedValue()); //备注
-                $arr['department_id'] = $depart_id;
-                $arr['shortcode'] = substr($arr['mac'],-6);
-                $arr['creator_id'] = $creator_id;
-                $arr['model'] = $model_id;
-                $arr['name'] = '基站'.substr($arr['mac'],-4);
-                $arr['created_at'] = time();
-                $arr['updated_at'] = time();
-               array_push($data,$arr);
-            }
-        }
-        array_unique($data, SORT_REGULAR);
-        // var_dump($data);return CatchResponse::success();
-        $count = $this->stationModel->limit(100)->insertAll($data);
-        if ($success = $count) {
-
-            return CatchResponse::success('共' . $total . '条数据,成功' . $success . '条,失败' . $fail . '条');
-
-        }
-        return CatchResponse::success(['error' => true, 'msg' => '导入失败']);
-    }
-    /**
-     * 导入设备失败日志
-     */
-    public function importFailLog($msg)
-    {
-        $file = runtime_path() . '/log/' . date("Ymd", time()) . "/import_stations_fail.log";
-        $folder = dirname($file);
-        if (!is_dir($folder)) {
-            mkdir($folder, 0777, true);
-        }
-        file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $msg . PHP_EOL, FILE_APPEND);
-    }
-
-//      ┏┛ ┻━━━━━┛ ┻┓
-//      ┃       ┃
-//      ┃   ━   ┃
-//      ┃ ┳┛   ┗┳ ┃
-//      ┃       ┃
-//      ┃   ┻   ┃
-//      ┃       ┃
-//      ┗━┓   ┏━━━┛
-//        ┃   ┃   神兽保佑
-//        ┃   ┃   代码无BUG!
-//        ┃   ┗━━━━━━━━━┓
-//        ┃           ┣┓
-//        ┃             ┏┛
-//        ┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
-//          ┃ ┫ ┫   ┃ ┫ ┫
-//          ┗━┻━┛   ┗━┻━┛
-}

+ 0 - 69
catch/device/controller/StationPhoto.php

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

+ 0 - 58
catch/device/database/migrations/20220120094737_devices.php

@@ -1,58 +0,0 @@
-<?php
-
-use think\migration\Migrator;
-use think\migration\db\Column;
-use Phinx\Db\Adapter\MysqlAdapter;
-
-class Devices 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('devices', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
-        $table->addColumn('imei', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => 'GPS编号',])
-			->addColumn('rfid', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '标签编号',])
-			->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '设备名称',])
-            ->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '告警状态',])
-			->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '设备型号',])
-			->addColumn('bind_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '关联物体',])
-			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '所属部门',])
-			->addColumn('iccid', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'ICCID',])
-			->addColumn('scenario', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '应用场景',])
-			->addColumn('sim_no', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'SIM卡号',])
-			->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('loc_mode', 'string', ['limit' => 16,'null' => true,'signed' => true,'comment' => '定位类型',])
-			->addColumn('address', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '安装地址',])
-			->addColumn('online_time', 'datetime', ['null' => true,'signed' => true,'comment' => '在线时间',])
-			->addColumn('soft_ver', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '软件版本',])
-			->addColumn('hard_ver', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '硬件版本',])
-			->addColumn('remark', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '备注',])
-            ->addColumn('battery_level', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'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();
-    }
-}

+ 0 - 55
catch/device/database/migrations/20220120100954_stations.php

@@ -1,55 +0,0 @@
-<?php
-
-use think\migration\Migrator;
-use think\migration\db\Column;
-use Phinx\Db\Adapter\MysqlAdapter;
-
-class Stations 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('stations', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
-        $table->addColumn('mac', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '基站Mac',])
-			->addColumn('shortcode', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '基站简码',])
-			->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站名称',])
-			->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站型号',])
-			->addColumn('serial_number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站序列号',])
-			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '所属部门',])
-			->addColumn('version', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '版本号',])
-			->addColumn('open_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '开局状态',])
-			->addColumn('sim_no', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'SIM卡号',])
-			->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '经度',])
-			->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '纬度',])
-			->addColumn('online_time', 'datetime', ['null' => true,'signed' => true,'comment' => '在线时间',])
-			->addColumn('address', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '安装地址',])
-			->addColumn('remark', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '备注',])
-			->addColumn('open_time', 'datetime', ['null' => true,'signed' => true,'comment' => '开局时间',])
-			->addColumn('open_user_id', '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();
-    }
-}

+ 0 - 130
catch/device/excel/DeviceExport.php

@@ -1,130 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CatchAdmin [Just Like ~ ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
-// +----------------------------------------------------------------------
-// | Author: JaguarJack [ njphper@gmail.com ]
-// +----------------------------------------------------------------------
-namespace catchAdmin\device\excel;
-
-use catcher\base\CatchRequest as Request;
-use catchAdmin\device\model\Device as deviceModel;
-use catcher\library\excel\ExcelContract;
-use PhpOffice\PhpSpreadsheet\Style\Alignment;
-
-class DeviceExport implements ExcelContract
-{
-    public $memory = '1024M';
-
-    protected $badgeModel;
-
-    public function __construct(deviceModel $deviceModel)
-    {
-        $this->deviceModel = $deviceModel;
-    }
-
-    /**
-     * 设置头部
-     *
-     * @time 2020年09月08日
-     * @return string[]
-     */
-    public function headers(): array
-    {
-        // TODO: Implement headers() method.
-        return [
-            '所属部门','告警状态','GPS编号','RFID编号','设备名称','设备状态','绑定物编号','设备型号','在线时间', '入库时间'
-        ];
-    }
-
-
-    /**
-     * 处理数据
-     *
-     * @time 2020年09月08日
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @return \think\Collection
-     */
-    public function sheets()
-    {
-        $list = $this->deviceModel->getDevicesExportList();
-        foreach ($list as &$val) {
-            $val->bind_number ="\t".$val->bind_number."\t";
-            $val->imei ="\t".$val->imei."\t";
-            $val->rfid ="\t".$val->rfid."\t";
-            $val->name ="\t".$val->name."\t";
-            if($val->device_state === 1){
-                $val->use_state = '已注册';
-            }else{
-                $val->use_state = '未注册';
-            }
-        }
-        return $list;
-    }
-    public function keys(): array
-    {
-        // TODO: Implement keys() method.
-        return [
-            'depart_name','alarm_state_text','imei','rfid','name','use_state','bind_number','model_text','online_time','created_at'
-        ];
-    }
-    /**
-     * 设置开始行
-     *
-     * @time 2020年09月08日
-     * @return int
-     */
-    public function setRow()
-    {
-        return 2;
-    }
-
-    /**
-     * 设置标题
-     *
-     * @time 2020年09月08日
-     * @return array
-     */
-    public function setTitle()
-    {
-        return [
-            'A1:I1', '导出设备', Alignment::HORIZONTAL_CENTER
-        ];
-    }
-     /**
-     * 设置宽度
-     *
-     * @time 2020年09月08日
-     * @return array
-     */
-    public function setWidth()
-    {
-        return [
-            'A' => 20,
-            'B' => 20,
-            'C' => 20,
-            'D' => 20,
-            'E' => 20,
-            'F' => 20,
-            'G' => 20,
-            'H' => 20,
-            'I' => 20,
-            'J' => 20
-        ];
-    }
-    public function getWorksheet($sheet)
-    {
-        // $sheet->getStyle('B')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
-        // $sheet->getColumnDimension('B')->setAutoSize(true);
-        // $sheet->getColumnDimension('C')->setAutoSize(true);
-        // $sheet->getColumnDimension('D')->setAutoSize(true);
-        // $sheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
-        // $sheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
-        return $sheet;
-    }
-}

+ 0 - 129
catch/device/excel/StationExport.php

@@ -1,129 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CatchAdmin [Just Like ~ ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
-// +----------------------------------------------------------------------
-// | Author: JaguarJack [ njphper@gmail.com ]
-// +----------------------------------------------------------------------
-namespace catchAdmin\device\excel;
-
-use catcher\base\CatchRequest as Request;
-use catchAdmin\device\model\Station as stationModel;
-use catcher\library\excel\ExcelContract;
-use PhpOffice\PhpSpreadsheet\Style\Alignment;
-
-class StationExport implements ExcelContract
-{
-    public $memory = '1024M';
-
-    protected $badgeModel;
-
-    public function __construct(stationModel $stationModel)
-    {
-        $this->stationModel = $stationModel;
-    }
-
-    /**
-     * 设置头部
-     *
-     * @time 2020年09月08日
-     * @return string[]
-     */
-    public function headers(): array
-    {
-        // TODO: Implement headers() method.
-        return [
-            '部门','名称','Mac','简码','基站状态','在线时间', '开局时间','入库时间','开局员工','安装地址','备注'
-        ];
-    }
-
-
-    /**
-     * 处理数据
-     *
-     * @time 2020年09月08日
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @return \think\Collection
-     */
-    public function sheets()
-    {
-        $list = $this->stationModel->getStationExportList();
-        foreach ($list as &$val) {
-            $val->mac ="\t".$val->mac."\t";
-            $val->shortmac ="\t".$val->shortmac."\t";
-            if($val->open_status){
-                $val->use_state = '已开局';
-            }else{
-                $val->use_state = '未开局';
-            }
-        }
-        return $list;
-    }
-    public function keys(): array
-    {
-        // TODO: Implement keys() method.
-        return [
-            'depart_name','name','mac','shortcode','use_state','online_time','open_time','created_at','open_user_name','address','remark'
-        ];
-    }
-    /**
-     * 设置开始行
-     *
-     * @time 2020年09月08日
-     * @return int
-     */
-    public function setRow()
-    {
-        return 2;
-    }
-
-    /**
-     * 设置标题
-     *
-     * @time 2020年09月08日
-     * @return array
-     */
-    public function setTitle()
-    {
-        return [
-            'A1:I1', '导出基站设备', Alignment::HORIZONTAL_CENTER
-        ];
-    }
-     /**
-     * 设置宽度
-     *
-     * @time 2020年09月08日
-     * @return array
-     */
-    public function setWidth()
-    {
-        return [
-            'A' => 20,
-            'B' => 20,
-            'C' => 20,
-            'D' => 20,
-            'E' => 20,
-            'F' => 20,
-            'G' => 20,
-            'H' => 20,
-            'I' => 20,
-            'J' => 30,
-            'K' => 20,
-        ];
-    }
-    public function getWorksheet($sheet)
-    {
-        // $sheet->getStyle('B')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
-        // $sheet->getColumnDimension('B')->setAutoSize(true);
-        // $sheet->getColumnDimension('C')->setAutoSize(true);
-        // $sheet->getColumnDimension('D')->setAutoSize(true);
-        // $sheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
-        // $sheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
-        return $sheet;
-    }
-}

+ 0 - 100
catch/device/model/Device.php

@@ -1,100 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model;
-
-use catcher\base\CatchModel as Model;
-use catchAdmin\device\model\search\DeviceSearch;
-use catchAdmin\device\model\get\DeviceGet;
-use catchAdmin\permissions\model\DataRangScopeTrait;
-class Device extends Model
-{
-    use DeviceSearch;
-    use DeviceGet;
-    use DataRangScopeTrait;
-    // 表名
-    public $name = 'devices';
-    // 数据库字段映射
-    public $field = array(
-        'id',
-        // GPS编号
-        'imei',
-        // 标签编号
-        'rfid',
-        // 设备名称
-        'name',
-        // 设备型号
-        'model',
-        // 关联物体
-        'bind_id',
-        // 所属部门
-        'department_id',
-        // ICCID
-        'iccid',
-        // 应用场景
-        'scenario',
-        // SIM卡号
-        'sim_no',
-        // 经度
-        'longitude',
-        // 纬度
-        'latitude',
-        // 在线时间
-        'online_time',
-        // 地址
-        'address',
-        // 定位模式
-        'loc_mode',
-        // 软件版本
-        'soft_ver',
-        // 硬件版本
-        'hard_ver',
-        // 备注
-        'remark',
-        // 创建人ID
-        'creator_id',
-        // 创建时间
-        'created_at',
-        // 更新时间
-        'updated_at',
-        // 软删除
-        'deleted_at',
-    );
-    /**
-     * 获取设备列表
-     */
-    public function getList()
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['status_icon','status_text'])
-            ->order($this->aliasField('online_time'), 'desc')
-            ->paginate();
-        return $res;
-    }
-
-      /**
-     * 获取设备列表
-     */
-    public function getDeviceList($field, $order)
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['depart_name', 'device_state', 'alarm_state_text', 'bind_number', 'creator_user', 'model_text','net_state','loc_mode_text','alarm_reason'])
-            ->order($this->aliasField($field), $order)
-            ->paginate();
-        return $res;
-    }
-    /**
-     * 获取设备导出列表
-     */
-    public function getDevicesExportList()
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['depart_name', 'device_state', 'alarm_state_text', 'bind_number', 'creator_user', 'model_text','net_state','loc_mode_text','alarm_reason'])
-            ->order($this->aliasField('id'), 'desc')
-            ->select();
-        return $res;
-    }
-   
-}

+ 0 - 82
catch/device/model/Station.php

@@ -1,82 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model;
-
-use catcher\base\CatchModel as Model;
-use catchAdmin\permissions\model\DataRangScopeTrait;
-use catchAdmin\device\model\get\StationGet;
-class Station extends Model
-{
-    use DataRangScopeTrait;
-    use StationGet;
-    // 表名
-    public $name = 'stations';
-    // 数据库字段映射
-    public $field = array(
-        'id',
-        // 基站Mac
-        'mac',
-        // 基站简码
-        'shortcode',
-        // 基站名称
-        'name',
-        // 基站型号
-        'model',
-        // 基站序列号
-        'serial_number',
-        // 所属部门
-        'department_id',
-        // 版本号
-        'version',
-        // 开局状态
-        'open_status',
-        // SIM卡号
-        'sim_no',
-        // 经度
-        'longitude',
-        // 纬度
-        'latitude',
-        // 在线时间
-        'online_time',
-        // 安装地址
-        'address',
-        // 备注
-        'remark',
-        // 开局时间
-        'open_time',
-        // 开局用户
-        'open_user_id',
-        // 创建人ID
-        'creator_id',
-        // 创建时间
-        'created_at',
-        // 更新时间
-        'updated_at',
-        // 软删除
-        'deleted_at',
-    );
-     /**
-     * 获取基站列表
-     */
-    public function getStationList($field, $order)
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['depart_name', 'net_state', 'open_user_name', 'creator_name', 'model_text'])
-            ->order($this->aliasField($field), $order)
-            ->paginate();
-        return $res;
-    }
-    /**
-     * 获取基站导出列表
-     */
-    public function getStationExportList()
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['depart_name', 'net_state','open_user_name', 'creator_name', 'model_text'])
-            ->order($this->aliasField('id'), 'desc')
-            ->select();
-        return $res;
-    }
-}

+ 0 - 29
catch/device/model/StationPhoto.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model;
-
-use catcher\base\CatchModel as Model;
-
-class StationPhoto extends Model
-{
-    // 表名
-    public $name = 'station_photos';
-    // 数据库字段映射
-    public $field = array(
-        'id',
-        // 图片url
-        'url',
-        // 基站id
-        'station_id',
-        // 图片类型
-        'type',
-        // 创建人ID
-        'creator_id',
-        // 创建时间
-        'created_at',
-        // 更新时间
-        'updated_at',
-        // 软删除
-        'deleted_at',
-    );
-}

+ 0 - 180
catch/device/model/get/DeviceGet.php

@@ -1,180 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model\get;
-
-use catchAdmin\permissions\model\SysConfig;
-use catchAdmin\system\model\SysDictData;
-use think\facade\Db;
-
-trait DeviceGet
-{
-    /**
-     * 获取导入时间(文本)
-     */
-    public function getCreateAtAttr($value)
-    {
-
-        if ($value) {
-            return date('Y-m-d H:i:s', $value);
-        } else {
-            return '';
-        }
-    }
-    /**
-     * 获取设备型号(文本)
-     */
-    public function getModelTextAttr($value)
-    {
-
-        $value = $this->model;
-        return (new SysDictData())->getValueByCode('DeviceModel', $value) ?: '';
-    }
-    /**
-     * 获取绑定物体(文本)
-     */
-    public function getBindNumberAttr($value)
-    {
-
-        $bid = $this->bind_id;
-        return Db::table('vehicles')->where('id', $bid)->value('license_plate') ?: '';
-    }
-     /**
-     * 获取导入用户(文本)
-     */
-    public function getCreatorUserAttr($value)
-    {
-
-        $uid = $this->creator_id;
-        return Db::table('users')->where('id', $uid)->value('username') ?: '';
-    }
-    /**
-     * 获取使用状态(文本)
-     */
-    public function getDeviceStateAttr($value)
-    {
-        if($this->bind_id){
-            return 1;
-        }else{
-            return 0;
-        }
-    }
-    /**
-     * 获取部门名称(文本)
-     */
-    public function getDepartNameAttr()
-    {
-        $id = $this->getData('department_id');
-        return Db::table('departments')->where('id', $id)->value('department_name');
-    }
-    /**
-     * 获取定位模式(文本)
-     */
-    public function getLocModeTextAttr()
-    {
-        $code = $this->getData('loc_mode');
-        if(!$code){
-            return '未知';
-        }
-        return (new SysDictData())->getValueByCode('DeviceLocationMode', $code) ?: '';
-    }
-    /**
-     * 获取告警原因(文本)
-     */
-    public function getAlarmReasonListAttr()
-    {
-        $alarm_list=[];
-        $list=Db::table('alarm_records')->where('device_number', $this->imei)->where('state','start')->select();
-        foreach($list as $val){
-            $text=(new SysDictData())->getValueByCode('AlarmType', $val['alarm_reason']);
-            $continue_time=time()-$val['start_time'];
-            $hour=$continue_time/3600;
-            $minute=($continue_time % 3600)/60;
-            $second=($continue_time % 3600)%60;
-            $continue_str=(int)$hour.'小时'.(int)$minute.'分'.$second.'秒';
-            $item=array('value'=>$val['alarm_reason'],'text'=> $text,'start_time'=>date('Y-m-d H:i:s',$val['start_time']),'continue_time'=>$continue_str);
-            $alarm_list[]=$item;
-        }
-       return $alarm_list;
-    }
-    /**
-     * 获取告警状态文本
-     */
-    public function getAlarmStateTextAttr($value)
-    {
-      $alarm_state = $this->getData('alarm_state');
-      return  $alarm_state ? '告警' : '正常';
-    }
-     /**
-     * 获取在线状态文本
-     */
-    public function getNetStateAttr($value)
-    {
-      $online_time = $this->getData('online_time');
-      $offline_intval = (new SysConfig())->getConfigValueBy('device_offline_interval','basic_config');
-      if($online_time){
-        $diff = time()-strtotime($online_time);
-        if($diff - $offline_intval >= 0){
-            $value = 1;
-        }else{
-            $value = 0;
-        }
-      }else{
-          $value = 2;
-      }
-      return  $value;
-    }
-     /**
-     * 电量
-     */
-    public function getBatteryLevelAttr($value)
-    {
-        $online_time = $this->getData('online_time');
-       
-        if($online_time==''){
-            return '--';
-        }elseif($value==0){
-            return '<5';
-        }
-        return $value;   
-    }
-
-    /**
-     * 获取在线状态图标
-     */
-    public function getStatusIconAttr($value)
-    {
-      $online_time = $this->getData('online_time');
-      $offline_intval = (new SysConfig())->getConfigValueBy('device_offline_interval','basic_config');
-      if($online_time){
-        $diff = time()-strtotime($online_time);
-        if($diff - $offline_intval >= 0){
-            $value = 'offline';
-        }else{
-            $value = 'run';
-        }
-      }else{
-          $value = 'unuse';
-      }
-      return  $value;
-    }
-    /**
-     * 获取在线状态图标
-     */
-    public function getStatusTextAttr($value)
-    {
-      $online_time = $this->getData('online_time');
-      $offline_intval = (new SysConfig())->getConfigValueBy('device_offline_interval','basic_config');
-      if($online_time){
-        $diff = time()-strtotime($online_time);
-        if($diff - $offline_intval >= 0){
-            $value = '离线';
-        }else{
-            $value = '在线';
-        }
-      }else{
-          $value = '未使用';
-      }
-      return  $value;
-    }
-    
-}

+ 0 - 76
catch/device/model/get/StationGet.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model\get;
-
-use catchAdmin\permissions\model\SysConfig;
-use catchAdmin\system\model\SysDictData;
-use think\facade\Db;
-
-trait StationGet
-{
-    /**
-     * 获取导入时间(文本)
-     */
-    public function getCreateAtAttr($value)
-    {
-
-        if ($value) {
-            return date('Y-m-d H:i:s', $value);
-        } else {
-            return '';
-        }
-    }
-    /**
-     * 获取设备型号(文本)
-     */
-    public function getModelTextAttr($value)
-    {
-        $value = $this->model;
-        return (new SysDictData())->getValueByCode('StationModel', $value) ?: '';
-    }
-     /**
-     * 获取开局用户(文本)
-     */
-    public function getOpenUserNameAttr($value)
-    {
-
-        $uid = $this->open_user_id;
-        return Db::table('users')->where('id', $uid)->value('username') ?: '';
-    }
-     /**
-     * 获取导入用户(文本)
-     */
-    public function getCreatorNameAttr($value)
-    {
-
-        $uid = $this->creator_id;
-        return Db::table('users')->where('id', $uid)->value('username') ?: '';
-    }
-    /**
-     * 获取部门名称(文本)
-     */
-    public function getDepartNameAttr()
-    {
-        $id = $this->getData('department_id');
-        return Db::table('departments')->where('id', $id)->value('department_name');
-    }
-     /**
-     * 获取在线状态文本
-     */
-    public function getNetStateAttr($value)
-    {
-      $online_time = $this->getData('online_time');
-      $offline_intval = (new SysConfig())->getConfigValueBy('station_offline_interval','basic_config');
-      if($online_time){
-        $diff = time()-strtotime($online_time);
-        if($diff - $offline_intval >= 0){
-            $value = 1;
-        }else{
-            $value = 0;
-        }
-      }else{
-          $value = 2;
-      }
-      return  $value;
-    }
-}

+ 0 - 69
catch/device/model/search/DeviceSearch.php

@@ -1,69 +0,0 @@
-<?php
-
-namespace catchAdmin\device\model\search;
-
-use catchAdmin\system\model\SysDictData;
-use Exception;
-use think\facade\Db;
-
-trait DeviceSearch
-{
-      /**
-     * 根据部门搜索
-     */
-    public function searchDepartmentIdAttr($query, $value, $data)
-    {
-        if ($value) {
-            $id = end($value);
-            return $query->where('department_id', '=', $id);
-        }
-    }
-     /**
-     * 根据imei搜索
-     */
-    public function searchImeiAttr($query, $value, $data)
-    {
-            return $query->where('imei', 'like', '%'.$value.'%');
-    }
-    /**
-     * iccid
-     */
-    public function searchIccidAttr($query, $value, $data)
-    {
-            return $query->where('iccid', 'like', '%'.$value.'%');
-    }
-     /**
-     * 根据rfid搜索
-     */
-    public function searchRfidAttr($query, $value, $data)
-    {
-            return $query->where('rfid', 'like', '%'.$value.'%');
-    }
-     /**
-     * 根据设备状态搜索
-     */
-    public function searchDeviceStateAttr($query, $value, $data)
-    {
-            if($value){
-                return $query->where('bind_id', '<>', 0);
-            }else{
-                return $query->where('bind_id', '=', 0); 
-            }
-            
-    }
-     /**
-     * 根据用户搜索
-     */
-    public function searchUserIdAttr($query, $value, $data)
-    {
-            return $query->where('user_id', '=', $value);
-    }
-    /**
-     * 设备号
-     */
-    public function searchDeviceNumberAttr($query, $value, $data)
-    {
-        return $query->where('imei|rfid', 'like', '%'. $value . '%');
-    }
-    
-}

+ 0 - 15
catch/device/module.json

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

+ 0 - 29
catch/device/route.php

@@ -1,29 +0,0 @@
-<?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) {
-	// device路由
-	$router->resource('device', '\catchAdmin\device\controller\Device');
-	// station路由
-	$router->resource('station', '\catchAdmin\device\controller\Station');
-	// station_photo路由
-	$router->resource('station_photo', '\catchAdmin\device\controller\StationPhoto');
-	//导出设备
-	$router->post('device/export_device','\catchAdmin\device\controller\Device@export_device');
-	//导出基站
-	$router->post('station/export_station','\catchAdmin\device\controller\Station@export_station');
-	//导入设备
-	$router->post('import_device', '\catchAdmin\device\controller\Device@import_device');
-	//导入基站
-	$router->post('import_station', '\catchAdmin\device\controller\Station@import_station');
-	
-})->middleware('auth');

+ 1 - 1
catch/hydraulic/controller/DeviceMold.php

@@ -74,6 +74,6 @@ class DeviceMold extends CatchController
     public function getDeviceMold(Request $request) : \think\Response
     {
         $type = $request->get('type');
-        return CatchResponse::success($this->deviceMoldModel->field('id as value,name as text')->select());
+        return CatchResponse::success($this->deviceMoldModel->where('device_type',$type)->field('id as value,name as text')->select());
     }
 }

+ 4 - 2
catch/hydraulic/controller/Hydraulic.php

@@ -34,7 +34,7 @@ class Hydraulic extends CatchController
     public function save(Request $request) : \think\Response
     {
         $data = $request->post();
-        if($data['out_date']){
+        if(isset($data['out_date']) && is_int($data['out_date'])){
             $data['out_date'] = date('Y-m-d',$data['out_date']);
         }
         return CatchResponse::success($this->hydraulicModel->storeBy($data));
@@ -59,7 +59,9 @@ class Hydraulic extends CatchController
     public function update(Request $request, $id) : \think\Response
     {
         $data = $request->post();
-        $data['out_date'] = date('Y-m-d H:i:s',$data['out_date']);
+        if(isset($data['out_date']) && is_int($data['out_date'])){
+            $data['out_date'] = date('Y-m-d',$data['out_date']);
+        }
         return CatchResponse::success($this->hydraulicModel->updateBy($id, $data));
     }
     

+ 77 - 0
catch/hydraulic/controller/Wrench.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace catchAdmin\hydraulic\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\hydraulic\model\Wrench as wrenchModel;
+
+class Wrench extends CatchController
+{
+    protected $wrenchModel;
+    
+    public function __construct(WrenchModel $wrenchModel)
+    {
+        $this->wrenchModel = $wrenchModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年05月06日 14:11
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->wrenchModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年05月06日 14:11
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        $data = $request->post();
+        if(isset($data['out_date'])  && is_int($data['out_date'])){
+            $data['out_date'] = date('Y-m-d',$data['out_date']);
+        }
+        return CatchResponse::success($this->wrenchModel->storeBy($data));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年05月06日 14:11
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->wrenchModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年05月06日 14:11
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        $data = $request->post();
+        if(isset($data['out_date']) && is_int($data['out_date'])){
+            $data['out_date'] = date('Y-m-d',$data['out_date']);
+        }
+        return CatchResponse::success($this->wrenchModel->updateBy($id, $data));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年05月06日 14:11
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->wrenchModel->deleteBy($id));
+    }
+}

+ 6 - 17
catch/hydraulic/database/migrations/20220303142809_hydraulic.php

@@ -40,29 +40,18 @@ class Hydraulic extends Migrator
 			->addColumn('supplier', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '供应商',])
 			->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
             ->addColumn('remark', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '备注',])
-            ->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '设备类型',])
 			->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '告警状态',])
 			->addColumn('net_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '网络状态',])
-			->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => null,'signed' => true,'comment' => '在线时间',])
+            ->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => null,'signed' => true,'comment' => '在线时间',])
+            //液压泵规格信息
+            ->addColumn('max_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大压力',])
+            ->addColumn('min_pressure', 'string', ['limit' => 32,'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('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' => '软删除',])
-
-        //液压泵规格信息
-            ->addColumn('pressure_range', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '压力范围(PSI)',])
-        //液压扳手实时维保信息
-            ->addColumn('coefficient_a', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '校准系数a',])
-            ->addColumn('coefficient_b', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '校准系数b',])
-            ->addColumn('checked_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '校验时间',])
-            ->addColumn('checked_no', 'string', ['limit' => 50,'null' => true,'default' => null,'signed' => false,'comment' => '校验台编号',])
-            ->addColumn('checked_res', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '校验结果',])
-            ->addColumn('checked_user_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'comment' => '操作员',])
-        //法兰规格信息
-            ->addColumn('diameter', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '直径',])
-            ->addColumn('bolts_num', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '螺栓数量',])
-            ->addColumn('bolts_size', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '螺栓尺寸',])
-            ->addColumn('preload', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '标准预紧力',])
             ->create();
     }
 }

+ 0 - 41
catch/hydraulic/database/migrations/20220504142809_hydraulic_add_Fields.php

@@ -1,41 +0,0 @@
-<?php
-
-use think\migration\Migrator;
-use think\migration\db\Column;
-use Phinx\Db\Adapter\MysqlAdapter;
-
-class HydraulicAddFields 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()
-    {
-        if ($this->hasTable('hydraulic')) {
-            $table = $this->table('hydraulic');
-
-            $table  ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
-                    ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
-                    ->update();
-        }
-      
-    }
-}

+ 59 - 0
catch/hydraulic/database/migrations/20220506141132_wrench.php

@@ -0,0 +1,59 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class Wrench 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('wrench', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '液压扳手' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('number', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '编号',])
+			->addColumn('model', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '型号',])
+			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
+			->addColumn('name', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '名称',])
+			->addColumn('is_used', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '使用状态',])
+			->addColumn('brand', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '品牌',])
+			->addColumn('supplier', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '供应商',])
+			->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
+			->addColumn('remark', 'string', ['limit' => 256,'null' => true,'signed' => true,'comment' => '备注',])
+			->addColumn('alarm_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '告警状态',])
+			->addColumn('net_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '网络状态',])
+			->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '在线时间',])
+			->addColumn('max_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大压力',])
+			->addColumn('min_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小压力',])
+			->addColumn('checked_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '校验时间',])
+			->addColumn('checked_no', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验台编号',])
+			->addColumn('checked_res', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验结果',])
+			->addColumn('checked_user_id', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '操作员',])
+			->addColumn('max_torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大扭矩',])
+			->addColumn('min_torque', 'string', ['limit' => 32,'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();
+    }
+}

+ 52 - 1
catch/hydraulic/model/DeviceMold.php

@@ -3,9 +3,12 @@
 namespace catchAdmin\hydraulic\model;
 
 use catcher\base\CatchModel as Model;
-
+use catchAdmin\system\model\SysDictData;
+use catchAdmin\permissions\model\DataRangScopeTrait;
+use \think\facade\Db;
 class DeviceMold extends Model
 {
+    use DataRangScopeTrait;
     // 表名
     public $name = 'device_mold';
     // 数据库字段映射
@@ -24,4 +27,52 @@ class DeviceMold extends Model
         // 软删除
         'deleted_at',
     );
+    /**
+     * 获取列表
+     */
+    public function getList()
+    {
+        $res =  $this->dataRange()
+            ->catchSearch()
+            ->append(['device_type_name','creator_name'])
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+        return $res;
+    }
+
+    
+    /**
+     * 名称搜索
+     */
+    public function searchNameAttr($query, $value, $data)
+    {
+        return $query->where('name', 'like', '%'.$value.'%');
+    }
+    /**
+     * 设备类型搜索
+    */
+    public function searchDeviceTypeAttr($query, $value, $data)
+    {
+
+        return $query->where('device_type', '=', $value);
+        
+    } 
+
+    /**
+     * 设备类型名称
+    */
+    public function getDeviceTypeNameAttr(){
+        $value=$this->getData('device_type');
+       
+        return (new SysDictData())->getValueByCode('DeviceType', $value) ?: '';
+    }
+     /**
+     * 获取导入用户(文本)
+     */
+    public function getCreatorNameAttr($value)
+    {
+        $uid = $this->creator_id;
+        return Db::table('users')->where('id', $uid)->value('username') ?: '';
+    }
+
 }

+ 34 - 8
catch/hydraulic/model/Hydraulic.php

@@ -4,6 +4,7 @@ namespace catchAdmin\hydraulic\model;
 
 use catcher\base\CatchModel as Model;
 use \think\facade\Db;
+use catchAdmin\system\model\SysDictData;
 use catchAdmin\permissions\model\DataRangScopeTrait;
 class Hydraulic extends Model
 {
@@ -45,6 +46,10 @@ class Hydraulic extends Model
         'updated_at',
         // 软删除
         'deleted_at',
+        'longitude',
+        'latitude',
+        'max_pressure',
+        'min_pressure',
     );
      /**
      * 获取列表
@@ -74,11 +79,22 @@ class Hydraulic extends Model
      */
     public function getCreatorUserAttr($value)
     {
-
         $uid = $this->creator_id;
         return Db::table('users')->where('id', $uid)->value('username') ?: '';
     }
     /**
+     * 使用状态
+     */
+    public function getIsUsedAttr($value)
+    {
+       if($value!=0){
+            return true;
+       }else{
+           return false;
+       }
+       
+    }
+    /**
      * 获取部门名称(文本)
      */
     public function getDepartNameAttr()
@@ -86,6 +102,23 @@ class Hydraulic extends Model
         $id = $this->getData('department_id');
         return Db::table('departments')->where('id', $id)->value('department_name');
     }
+
+     /**
+     * 获取类型名称
+     */
+    public function getModelAttr($value)
+    {
+       
+        return (int)$value;
+    }
+    /**
+     * 获取类型名称
+     */
+    public function getModelNameAttr()
+    {
+        $id = $this->getData('model');
+        return Db::table('device_mold')->where('id', $id)->value('name');
+    }
     /**
      * 获取部门名称(文本)
      */
@@ -115,13 +148,6 @@ class Hydraulic extends Model
             return $query->where('department_id', '=', $id);
         }
     }
-    /**
-     * 根据类型搜索
-     */
-    public function searchTypeAttr($query, $value, $data)
-    {
-            return $query->where('type', '=', $value);
-    }
      /**
      * 根据number搜索
      */

+ 74 - 0
catch/hydraulic/model/Wrench.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace catchAdmin\hydraulic\model;
+
+use catcher\base\CatchModel as Model;
+use catchAdmin\permissions\model\DataRangScopeTrait;
+class Wrench extends Model
+{
+    use DataRangScopeTrait;
+    // 表名
+    public $name = 'wrench';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 编号
+        'number',
+        // 型号
+        'model',
+        // 所属部门
+        'department_id',
+        // 名称
+        'name',
+        // 使用状态
+        'is_used',
+        // 品牌
+        'brand',
+        // 供应商
+        'supplier',
+        // 出厂日期
+        'out_date',
+        // 备注
+        'remark',
+        // 告警状态
+        'alarm_state',
+        // 网络状态
+        'net_state',
+        // 在线时间
+        'online_time',
+        // 最大压力
+        'max_pressure',
+        // 最小压力
+        'min_pressure',
+        // 校验时间
+        'checked_at',
+        // 校验台编号
+        'checked_no',
+        // 校验结果
+        'checked_res',
+        // 操作员
+        'checked_user_id',
+        // 最大扭矩
+        'max_torque',
+        // 最小扭矩
+        'min_torque',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+    public function getList()
+    {
+        $res =  $this->dataRange()
+            ->catchSearch()
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+        return $res;
+    }
+
+  
+}

+ 20 - 18
catch/hydraulic/route.php

@@ -1,19 +1,21 @@
-<?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){
-	// hydraulic路由
-	$router->resource('hydraulic', '\catchAdmin\hydraulic\controller\Hydraulic');
-	// deviceMold路由
-	$router->resource('deviceMold', '\catchAdmin\hydraulic\controller\DeviceMold');
-	$router->get('get_device_mold', '\catchAdmin\hydraulic\controller\DeviceMold@getDeviceMold');
+<?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){
+	// hydraulic路由
+	$router->resource('hydraulic', '\catchAdmin\hydraulic\controller\Hydraulic');
+	// deviceMold路由
+	$router->resource('deviceMold', '\catchAdmin\hydraulic\controller\DeviceMold');
+	$router->get('get_device_mold', '\catchAdmin\hydraulic\controller\DeviceMold@getDeviceMold');
+	// wrench路由
+	$router->resource('wrench', '\catchAdmin\hydraulic\controller\Wrench');
 })->middleware('auth');

+ 0 - 69
catch/logs/controller/LocationLog.php

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

+ 69 - 0
catch/logs/controller/MaintainLog.php

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

+ 0 - 40
catch/logs/database/migrations/20210617111237_location_log.php

@@ -1,40 +0,0 @@
-<?php
-
-use think\migration\Migrator;
-use think\migration\db\Column;
-use Phinx\Db\Adapter\MysqlAdapter;
-
-class LocationLog 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('location_log', ['engine' => 'InnoDB',  'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
-        $table->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '经度',])
-			->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '纬度',])
-			->addColumn('altitude', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '海拔',])
-			->addColumn('device_no', 'string', ['limit' => 18,'null' => true,'signed' => true,'comment' => '设备号',])
-			->addColumn('time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '定位时间',])
-            ->create();
-    }
-}

+ 8 - 5
catch/device/database/migrations/20220120105523_station_photos.php

@@ -4,7 +4,7 @@ use think\migration\Migrator;
 use think\migration\db\Column;
 use Phinx\Db\Adapter\MysqlAdapter;
 
-class StationPhotos extends Migrator
+class MaintainLog extends Migrator
 {
     /**
      * Change Method.
@@ -29,10 +29,13 @@ class StationPhotos extends Migrator
      */
     public function change()
     {
-        $table = $this->table('station_photos', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
-        $table->addColumn('url', 'string', ['limit' => 250,'null' => true,'signed' => true,'comment' => '图片url',])
-			->addColumn('station_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '基站id',])
-			->addColumn('type', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '图片类型',])
+        $table = $this->table('maintain_log', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '维护记录' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('device_number', 'string', ['limit' => 32,'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('device_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '设备状态',])
+			->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '运行时间',])
+			->addColumn('info', 'string', ['limit' => 64,'null' => false,'default' => '','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' => '更新时间',])

+ 0 - 28
catch/logs/model/LocationLog.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace catchAdmin\logs\model;
-
-use catcher\base\CatchModel as Model;
-use catcher\traits\db\BaseOptionsTrait;
-use catcher\traits\db\ScopeTrait;
-
-class LocationLog extends Model
-{
-    use BaseOptionsTrait, ScopeTrait;
-    // 表名
-    public $name = 'location_log';
-    // 数据库字段映射
-    public $field = array(
-        'id',
-        // 经度
-        'longitude',
-        // 纬度
-        'latitude',
-        // 海拔
-        'altitude',
-        // 设备号
-        'device_no',
-        // 定位时间
-        'time',
-    );
-}

+ 45 - 0
catch/logs/model/MaintainLog.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace catchAdmin\logs\model;
+
+use catcher\base\CatchModel as Model;
+
+class MaintainLog extends Model
+{
+    // 表名
+    public $name = 'maintain_log';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 设备编号
+        'device_number',
+        // 经度
+        'longitude',
+        // 纬度
+        'latitude',
+        // 设备状态
+        'device_state',
+        // 运行时间
+        'online_time',
+        // 维护信息
+        'info',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+    public function getList()
+    {
+        return $this->catchSearch()
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+    }
+    public function searchDeviceNumberAttr($query, $value, $data)
+    {
+        return $query->where('device_number',$value);
+    }
+}

+ 25 - 23
catch/logs/route.php

@@ -1,24 +1,26 @@
-<?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){
-	// configLog路由
-	$router->resource('configLog', '\catchAdmin\logs\controller\ConfigLog');
-	// dwLog路由
-	$router->resource('dwLog', '\catchAdmin\logs\controller\DwLog');
-	// wxPushResultLog路由
-	$router->resource('wxPushResultLog', '\catchAdmin\logs\controller\WxPushResultLog');
-	// heartBeat路由
-	$router->resource('heartBeat', '\catchAdmin\logs\controller\HeartBeat');
-	// batteryLog路由
-	$router->resource('batteryLog', '\catchAdmin\logs\controller\BatteryLog');
+<?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){
+	// configLog路由
+	$router->resource('configLog', '\catchAdmin\logs\controller\ConfigLog');
+	// dwLog路由
+	$router->resource('dwLog', '\catchAdmin\logs\controller\DwLog');
+	// wxPushResultLog路由
+	$router->resource('wxPushResultLog', '\catchAdmin\logs\controller\WxPushResultLog');
+	// heartBeat路由
+	$router->resource('heartBeat', '\catchAdmin\logs\controller\HeartBeat');
+	// batteryLog路由
+	$router->resource('batteryLog', '\catchAdmin\logs\controller\BatteryLog');
+	// maintainLog路由
+	$router->resource('maintainLog', '\catchAdmin\logs\controller\MaintainLog');
 })->middleware('auth');