123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace catchAdmin\api\controller;
- use catchAdmin\hydraulic\model\maintenancemapper;
- use catchAdmin\hydraulic\model\Wrench as ModelWrench;
- 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);
- }
- /**
- * @Descripttion: 获取工作位置列表
- * @name: likang
- * @return {*}
- */
- public function getWorkLocal()
- {
- $list = maintenancemapper::where('device_type', 2)->select();
- return json_success('获取成功', $list);
- }
- public function getUserList()
- {
- if (!isset($_GET['imei']) || $_GET['imei'] == '') {
- json_fail('缺少设备IMEI号参数');
- }
- //检测imei号是否在数据库中
- //请求成功返回数据
- json_success('获取成功', '');
- }
- }
|