Tool.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace catchAdmin\api\controller;
  3. use catchAdmin\hydraulic\model\maintenancemapper;
  4. use catchAdmin\hydraulic\model\Wrench as ModelWrench;
  5. use catcher\base\CatchRequest as Request;
  6. use catcher\CatchResponse;
  7. use catcher\base\CatchController;
  8. use PhpParser\Node\Expr\FuncCall;
  9. use think\facade\Db;
  10. use Wrench;
  11. class Tool extends Base
  12. {
  13. /**
  14. * @Descripttion: 下发设备 携带的参数 imei号 版本号
  15. * @name: likang
  16. * @return {*}
  17. */
  18. public function Issued()
  19. {
  20. //校验imei是否存在
  21. if (!isset($_GET['imei']) || $_GET['imei'] == '') {
  22. json_fail('缺少设备IMEI号参数');
  23. }
  24. $Imei = $_GET['imei'];
  25. if (!isset($_GET['version']) || $_GET['version'] == '') {
  26. json_fail('缺少版本号参数', '', $Imei);
  27. }
  28. $version = $_GET['version'];
  29. $where1 = [];
  30. $where2 = [];
  31. $content = [];
  32. $CntVersion = '';
  33. //判断版本号是否存在,不存在则下发全部,存在则下发部分
  34. $where1 = [
  35. // ['Imei', '<>', $Imei],
  36. ['Version', '>', $version]
  37. ];
  38. $where2 = [
  39. ['Imei', '=', $Imei],
  40. ['ContentType', '=', 'File'],
  41. ['Version', '>', $version]
  42. ];
  43. $list = Db::name('publish')
  44. //->whereOr([$where1, $where2])
  45. ->where($where1)
  46. ->order('Version asc')->limit(5)->select();
  47. foreach ($list as $key => $value) {
  48. $da = json_decode($value['Content'], true);
  49. $content[] = [
  50. 'OpType' => $value['Type'],
  51. 'CntType' => $value['ContentType'],
  52. 'CntVersion' => strval($value['Version']),
  53. 'id' => strval($value['ContentId']),
  54. 'Content' => $da
  55. ];
  56. $CntVersion = strval($value['Version']);
  57. }
  58. //保存下发的记录
  59. $ack = [
  60. 'PublishVersion' => $CntVersion,
  61. 'PublishContent' => json_encode($content),
  62. 'Imei' => $Imei,
  63. 'AddTime' => msectime()
  64. ];
  65. Db::name('publish_ack')->save($ack);
  66. return json_success('获取成功', $content, $Imei);
  67. }
  68. //接收上传的日志
  69. /**
  70. * @Descripttion: 获取扳手列表
  71. * @name: likang
  72. * @return {*}
  73. */
  74. public function getWrenchList()
  75. {
  76. $list = ModelWrench::select();
  77. return json_success('获取成功', $list);
  78. }
  79. /**
  80. * @Descripttion: 获取工作位置列表
  81. * @name: likang
  82. * @return {*}
  83. */
  84. public function getWorkLocal()
  85. {
  86. $list = maintenancemapper::where('device_type', 2)->select();
  87. return json_success('获取成功', $list);
  88. }
  89. public function getUserList()
  90. {
  91. if (!isset($_GET['imei']) || $_GET['imei'] == '') {
  92. json_fail('缺少设备IMEI号参数');
  93. }
  94. //检测imei号是否在数据库中
  95. //请求成功返回数据
  96. json_success('获取成功', '');
  97. }
  98. }