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