Commit dbf4fbf4a038d9126bd99534c963a22cc5162d64
1 parent
29e87fd3
Exists in
master
app-ht(v1.8.6 build 12)
1.数据统计OTA升级统计功能实现 1.数据统计APP升级统计功能实现
Showing
17 changed files
with
720 additions
and
21 deletions
Show diff stats
app-ht/config/main.php
@@ -42,11 +42,14 @@ $config = [ | @@ -42,11 +42,14 @@ $config = [ | ||
42 | ], | 42 | ], |
43 | 'home' => [ | 43 | 'home' => [ |
44 | 'class' => 'app\ht\modules\home\Module', | 44 | 'class' => 'app\ht\modules\home\Module', |
45 | - ] | ||
46 | - , | 45 | + ], |
47 | 'production' => [ | 46 | 'production' => [ |
48 | 'class' => 'app\ht\modules\production\Module', | 47 | 'class' => 'app\ht\modules\production\Module', |
49 | ] | 48 | ] |
49 | + , | ||
50 | + 'datas' => [ | ||
51 | + 'class' => 'app\ht\modules\datas\Module', | ||
52 | + ] | ||
50 | ], | 53 | ], |
51 | 'components' => [ | 54 | 'components' => [ |
52 | 'user' => [ | 55 | 'user' => [ |
app-ht/config/params.php
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<?php namespace app\ht\modules\datas; | ||
2 | + | ||
3 | +/** | ||
4 | + * @author CM | ||
5 | + */ | ||
6 | +class Module extends \app\ht\modules\BaseModule | ||
7 | +{ | ||
8 | + public function init() | ||
9 | + { | ||
10 | + parent::init(); | ||
11 | + | ||
12 | + $this->params['perm'] = require(__DIR__ . '/config/perm.php'); | ||
13 | + } | ||
14 | +} | ||
0 | \ No newline at end of file | 15 | \ No newline at end of file |
app-ht/modules/datas/controllers/UpgradeLogController.php
0 → 100644
@@ -0,0 +1,126 @@ | @@ -0,0 +1,126 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace app\ht\modules\datas\controllers; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\data\Pagination; | ||
7 | +use domain\upgrade\UpgradeLogRepository; | ||
8 | +use domain\upgrade\UpgradeStatus; | ||
9 | +use app\ht\controllers\BaseController; | ||
10 | + | ||
11 | +/** | ||
12 | + * 版本日志管理 | ||
13 | + * Class UpgradeLogController | ||
14 | + * @package app\ht\modules\upgrade\controllers | ||
15 | + */ | ||
16 | +class UpgradeLogController extends BaseController | ||
17 | +{ | ||
18 | + /** | ||
19 | + * 版本日志管理 | ||
20 | + */ | ||
21 | + public function actionIndex() | ||
22 | + { | ||
23 | + $params = $this->dataList(1); | ||
24 | + /** | ||
25 | + * 渲染模板 | ||
26 | + */ | ||
27 | + return $this->render('index', $params); | ||
28 | + } | ||
29 | + | ||
30 | + /** | ||
31 | + * 查询数据列表 | ||
32 | + */ | ||
33 | + protected function dataList($type = '') | ||
34 | + { | ||
35 | + $request = Yii::$app->request; | ||
36 | + $creatTime = $request->get('creatTime'); | ||
37 | + $endTime = $request->get('endTime'); | ||
38 | + $status = $request->get('status'); | ||
39 | + $current_version = $request->get('current_version'); | ||
40 | + $target_version = $request->get('target_version'); | ||
41 | + $manufacture_name = $request->get('manufacture_name'); | ||
42 | + $device_no = $request->get('device_no'); | ||
43 | + $barcode = $request->get('barcode'); | ||
44 | + $error_code = $request->get('error_code'); | ||
45 | + $device_device_id = $request->get('device_device_id'); | ||
46 | + $dataType = !empty($request->get('type')) ? $request->get('type') : UpgradeStatus::TYPE_APP; | ||
47 | + | ||
48 | + $gets = [ | ||
49 | + 'creatTime' => $creatTime, | ||
50 | + 'endTime' => $endTime, | ||
51 | + 'status' => $status, | ||
52 | + 'current_version' => $current_version, | ||
53 | + 'target_version' => $target_version, | ||
54 | + 'manufacture_name' => $manufacture_name, | ||
55 | + 'device_no' => $device_no, | ||
56 | + 'barcode' => $barcode, | ||
57 | + 'error_code' => $error_code, | ||
58 | + 'device_device_id' => $device_device_id, | ||
59 | + 'type' => $dataType, | ||
60 | + ]; | ||
61 | + | ||
62 | + $where = ['and']; | ||
63 | + if ($creatTime) { | ||
64 | + $creatTime = strtotime($creatTime); | ||
65 | + $where[] = ['>=', 'ul.created_at', $creatTime]; | ||
66 | + } | ||
67 | + if ($endTime) { | ||
68 | + $endTime = strtotime($endTime) + 86400; | ||
69 | + $where[] = ['<=', 'ul.created_at', $endTime]; | ||
70 | + } | ||
71 | + if ($status) { | ||
72 | + $where[] = ['=', 'ul.status', $status]; | ||
73 | + } | ||
74 | + if ($current_version) { | ||
75 | + $where[] = ['like', 'ul.current_version', $current_version]; | ||
76 | + } | ||
77 | + if ($target_version) { | ||
78 | + $where[] = ['like', 'ul.target_version', $target_version]; | ||
79 | + } | ||
80 | + if ($manufacture_name) { | ||
81 | + $where[] = ['like', 'mf.name', $manufacture_name]; | ||
82 | + } | ||
83 | + if ($device_no) { | ||
84 | + $where[] = ['like', 'md.name', $device_no]; | ||
85 | + } | ||
86 | + if ($barcode) { | ||
87 | + $where[] = ['like', 'ul.barcode', $barcode]; | ||
88 | + } | ||
89 | + if ($error_code) { | ||
90 | + $where[] = ['like', 'ul.error_code', $error_code]; | ||
91 | + } | ||
92 | + if ($device_device_id) { | ||
93 | + $where[] = ['like', 'de.device_id', $device_device_id]; | ||
94 | + } | ||
95 | + if ($dataType) { | ||
96 | + $where[] = ['=', 'ul.type', $dataType]; | ||
97 | + } | ||
98 | + if ($type == 0) { | ||
99 | + $pageList = UpgradeLogRepository::getPageList($where, 0 , 0); | ||
100 | + $pages = null; | ||
101 | + } else { | ||
102 | + $pageSize = 20; | ||
103 | + $pages = new Pagination(['totalCount' => UpgradeLogRepository::getPageCount($where), 'pageSize' => $pageSize]); | ||
104 | + $pageList = UpgradeLogRepository::getPageList($where, $pages->offset, $pages->limit); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * 数据整理 | ||
109 | + */ | ||
110 | + return [ | ||
111 | + 'listdata' => $pageList, | ||
112 | + 'pages' => $pages, | ||
113 | + 'gets' => $gets | ||
114 | + ]; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * 导出版本日志数据 | ||
119 | + * @return string | ||
120 | + */ | ||
121 | + public function actionExport() | ||
122 | + { | ||
123 | + $params = $this->dataList(0); | ||
124 | + return $this->renderPartial('export', $params); | ||
125 | + } | ||
126 | +} | ||
0 | \ No newline at end of file | 127 | \ No newline at end of file |
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +use domain\upgrade\UpgradeLogStatus; | ||
4 | + | ||
5 | +header('Content-Type: application/vnd.ms-excel;charset=utf-8'); | ||
6 | +$title = date('Y-m-d') . '_升级统计数据'; | ||
7 | +$name = $title . ".xls"; | ||
8 | +header('Content-Disposition: attachment;filename=' . $name . ''); | ||
9 | +header('Cache-Control: max-age=0'); | ||
10 | +$fp = fopen('php://output', 'a'); | ||
11 | +$limit = 10000; | ||
12 | +$cnt = 0; | ||
13 | +?> | ||
14 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
15 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
16 | +<html xmlns:o="urn:schemas-microsoft-com:office:office" | ||
17 | + xmlns:x="urn:schemas-microsoft-com:office:excel" | ||
18 | + xmlns="http://www.w3.org/TR/REC-html40"> | ||
19 | + | ||
20 | +<head> | ||
21 | + <meta http-equiv=Content-Type content="text/html; charset=utf-8"> | ||
22 | + | ||
23 | +</head> | ||
24 | +<body> | ||
25 | +<div id="Classeur1_16681" align='center' x:publishsource="Excel"> | ||
26 | + <table border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse"> | ||
27 | + <thead> | ||
28 | + <tr> | ||
29 | + <th width="10%">设备ID</th> | ||
30 | + <th width="10%">当前版本</th> | ||
31 | + <th width="10%">目标版本</th> | ||
32 | + <th width="10%">厂商</th> | ||
33 | + <th width="10%">机器型号</th> | ||
34 | + <th width="10%">Barcode</th> | ||
35 | + <th width="10%">升级状态</th> | ||
36 | + <th width="15%">升级错误码</th> | ||
37 | + <th width="15%">时间</th> | ||
38 | + </tr> | ||
39 | + </thead> | ||
40 | + <tbody> | ||
41 | + <?php foreach ($listdata as $key => $item) : ?> | ||
42 | + <tr> | ||
43 | + <td style="padding:12px;"><?= (isset($item["device_device_id"]) ? $item["device_device_id"] : "") ?></td> | ||
44 | + <td style="padding:12px;"><?= (isset($item["current_version"]) ? $item["current_version"] : "") ?></td> | ||
45 | + <td style="padding:12px;"><?= (isset($item["target_version"]) ? $item["target_version"] : "") ?></td> | ||
46 | + <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "") ?></td> | ||
47 | + <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td> | ||
48 | + <td style="padding:12px;"><?= (isset($item["barcode"]) ? $item["barcode"] : "") ?></td> | ||
49 | + <td style="padding:12px;"><?= UpgradeLogStatus::statusLabel($item['status'])?></td> | ||
50 | + <td style="padding:12px;"><?= (isset($item["error_code"]) ? $item["error_code"] : "") ?></td> | ||
51 | + <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td> | ||
52 | + </tr> | ||
53 | + <?php | ||
54 | + $cnt++; | ||
55 | + if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题 | ||
56 | + ob_flush(); | ||
57 | + flush(); | ||
58 | + $cnt = 0; | ||
59 | + } | ||
60 | + ?> | ||
61 | + <?php endforeach; ?> | ||
62 | + </tbody> | ||
63 | + </table> | ||
64 | +</div> | ||
65 | +</body> | ||
66 | +</html> | ||
0 | \ No newline at end of file | 67 | \ No newline at end of file |
@@ -0,0 +1,180 @@ | @@ -0,0 +1,180 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Url; | ||
4 | +use app\ht\widgets\LinkPager; | ||
5 | +use domain\upgrade\UpgradeStatus; | ||
6 | +use domain\upgrade\UpgradeLogStatus; | ||
7 | + | ||
8 | +if (isset($gets["type"]) && UpgradeStatus::TYPE_OTA == $gets["type"]) { | ||
9 | + $this->title = 'OTA升级统计'; | ||
10 | +} else { | ||
11 | + $this->title = 'APP升级统计'; | ||
12 | +} | ||
13 | +$this->params['breadcrumbs'][] = $this->title; | ||
14 | +?> | ||
15 | +<style> | ||
16 | + .table > tbody > tr > td | ||
17 | + { | ||
18 | + border: white 0px solid; | ||
19 | + border-top: solid 1px #fff; | ||
20 | + border-bottom: 1px solid #fff; | ||
21 | + } | ||
22 | + .table{ | ||
23 | + margin-bottom: 0px!important; | ||
24 | + } | ||
25 | +</style> | ||
26 | +<div class="panel panel-default"> | ||
27 | + <div class="panel-body"> | ||
28 | + <form action="" method="get" id="search-form" class="filter-form"> | ||
29 | + <table width="100%" class="table"> | ||
30 | + <tbody> | ||
31 | + <tr > | ||
32 | + <td width="10%" class="text-right">当前版本</td> | ||
33 | + <td width="10%" class="text-left"> | ||
34 | + <input type="text" class="form-control" name="current_version" style="width: 150px;" placeholder="输入当前版本" value="<?php if (!empty($gets['current_version'])){ echo $gets['current_version']; } ?>"> | ||
35 | + </td> | ||
36 | + <td width="10%" class="text-right">目标版本</td> | ||
37 | + <td width="10%" class="text-left"> | ||
38 | + <input type="text" class="form-control" name="target_version" style="width: 150px;" placeholder="输入目标版本" value="<?php if (!empty($gets['target_version'])){ echo $gets['target_version']; } ?>"> | ||
39 | + </td> | ||
40 | + <td width="10%" class="text-right">厂商</td> | ||
41 | + <td width="10%" class="text-left"> | ||
42 | + <input type="text" class="form-control" name="manufacture_name" style="width: 150px;" placeholder="输入厂商" value="<?php if (!empty($gets['manufacture_name'])){ echo $gets['manufacture_name']; } ?>"> | ||
43 | + </td> | ||
44 | + <td width="10%" class="text-right">机器型号</td> | ||
45 | + <td width="30%" class="text-left"> | ||
46 | + <input type="text" class="form-control" name="device_no" style="width: 290px;" placeholder="输入机器型号" value="<?php if (!empty($gets['device_no'])){ echo $gets['device_no']; } ?>"> | ||
47 | + </td> | ||
48 | + </tr> | ||
49 | + <tr> | ||
50 | + <td class="text-right">Barcode</td> | ||
51 | + <td class="text-left"> | ||
52 | + <input type="text" class="form-control" name="barcode" style="width: 150px;" placeholder="输入Barcode" value="<?php if (!empty($gets['barcode'])){ echo $gets['barcode']; } ?>"> | ||
53 | + </td> | ||
54 | + <td class="text-right">升级状态</td> | ||
55 | + <td class="text-left"> | ||
56 | + <select class="form-control" style="width: 150px;" id="status" name="status"> | ||
57 | + <option>全部</option> | ||
58 | + <?php foreach (UpgradeLogStatus::statusLabels() as $key => $value) { ?> | ||
59 | + <option value="<?=$key ?>" <?php if (isset($gets['status']) && $gets['status'] == $key){ echo "selected"; } ?>><?=$value ?></option> | ||
60 | + <?php } ?> | ||
61 | + </select> | ||
62 | + </td> | ||
63 | + <td class="text-right">升级错误码</td> | ||
64 | + <td class="text-left"> | ||
65 | + <input type="text" class="form-control" name="error_code" style="width: 150px;" placeholder="输入升级错误码" value="<?php if (!empty($gets['error_code'])){ echo $gets['error_code']; } ?>"> | ||
66 | + </td> | ||
67 | + <td class="text-right">时间</td> | ||
68 | + <td class="text-left"> | ||
69 | + <div class="form-inline"> | ||
70 | + <input type="date" class="form-control" style="width: 140px;" name="creatTime" placeholder="起" value="<?php if (!empty($gets['creatTime'])){ echo $gets['creatTime']; } ?>"> - | ||
71 | + <input type="date" class="form-control" style="width: 140px;" name="endTime" placeholder="止" value="<?php if (!empty($gets['endTime'])){ echo $gets['endTime']; } ?>"> | ||
72 | + </div> | ||
73 | + </td> | ||
74 | + </tr> | ||
75 | + <tr> | ||
76 | + <td class="text-right">设备ID</td> | ||
77 | + <td class="text-left"> | ||
78 | + <input type="text" class="form-control" name="device_device_id" style="width: 150px;" placeholder="输入设备ID" value="<?php if (!empty($gets['device_device_id'])){ echo $gets['device_device_id']; } ?>"> | ||
79 | + </td> | ||
80 | + <td class="text-right"></td> | ||
81 | + <td class="text-left"></td> | ||
82 | + <td class="text-right"></td> | ||
83 | + <td class="text-left"></td> | ||
84 | + <td class="text-right"></td> | ||
85 | + <td class="text-left"></td> | ||
86 | + </tr> | ||
87 | + <tr class="search"> | ||
88 | + <td colspan="8" class="text-center"> | ||
89 | + <input type="hidden" name="type" value="<?= (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP) ?>"> | ||
90 | + <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询 </button> | ||
91 | + <a class="btn btn-default btncls" href="<?=Url::toRoute(["/datas/upgrade-log/index", "type" => (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP)])?>">重 置</a> | ||
92 | + <a class="btn btn-default" style="float: right;" href="javascript:void(0)" id="btn-export"> 导出数据 </a> | ||
93 | + </td> | ||
94 | + </tr> | ||
95 | + </tbody> | ||
96 | + </table> | ||
97 | + </form> | ||
98 | + </div> | ||
99 | +</div> | ||
100 | + | ||
101 | +<div class="panel panel-default"> | ||
102 | + <div class="panel-body"> | ||
103 | + <table class="table table-striped table-bordered" id="brand-table"> | ||
104 | + <thead> | ||
105 | + <tr> | ||
106 | + <th width="10%">设备ID</th> | ||
107 | + <th width="10%">当前版本</th> | ||
108 | + <th width="10%">目标版本</th> | ||
109 | + <th width="10%">厂商</th> | ||
110 | + <th width="10%">机器型号</th> | ||
111 | + <th width="10%">Barcode</th> | ||
112 | + <th width="10%">升级状态</th> | ||
113 | + <th width="15%">升级错误码</th> | ||
114 | + <th width="15%">时间</th> | ||
115 | + </tr> | ||
116 | + </thead> | ||
117 | + | ||
118 | + <tbody> | ||
119 | + <?php if ($listdata) { ?> | ||
120 | + <?php foreach ($listdata as $item) : ?> | ||
121 | + <tr> | ||
122 | + <td style="padding:12px;"><?= (isset($item["device_device_id"]) ? $item["device_device_id"] : "") ?></td> | ||
123 | + <td style="padding:12px;"><?= (isset($item["current_version"]) ? $item["current_version"] : "") ?></td> | ||
124 | + <td style="padding:12px;"><?= (isset($item["target_version"]) ? $item["target_version"] : "") ?></td> | ||
125 | + <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "") ?></td> | ||
126 | + <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td> | ||
127 | + <td style="padding:12px;"><?= (isset($item["barcode"]) ? $item["barcode"] : "") ?></td> | ||
128 | + <td style="padding:12px;"><?= UpgradeLogStatus::statusLabel($item['status'])?></td> | ||
129 | + <td style="padding:12px;"><?= (isset($item["error_code"]) ? $item["error_code"] : "") ?></td> | ||
130 | + <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td> | ||
131 | + </tr> | ||
132 | + <?php endforeach; ?> | ||
133 | + <?php } else { ?> | ||
134 | + <tr> | ||
135 | + <td colspan="9"> | ||
136 | + <center>暂无记录</center> | ||
137 | + </td> | ||
138 | + </tr> | ||
139 | + <?php } ?> | ||
140 | + </tbody> | ||
141 | + </table> | ||
142 | + </div> | ||
143 | + | ||
144 | + <div class="panel-footer"> | ||
145 | + <div class="hqy-panel-pager"> | ||
146 | + <?= LinkPager::widget([ | ||
147 | + 'pagination' => $pages, | ||
148 | + ]); ?> | ||
149 | + <div class="clearfix"></div> | ||
150 | + </div> | ||
151 | + </div> | ||
152 | +</div> | ||
153 | +<script> | ||
154 | + window.queryParams = function(params) { | ||
155 | + $("#search-form").find('input[name]').each(function () { | ||
156 | + var val = $(this).val(); | ||
157 | + var name = $(this).attr('name'); | ||
158 | + if(val){ | ||
159 | + params[name] = val; | ||
160 | + } | ||
161 | + }); | ||
162 | + return params; | ||
163 | + } | ||
164 | + $(document).ready(function () { | ||
165 | + $('#btn-export').click(function(e){ | ||
166 | + var params = {}; | ||
167 | + window.queryParams(params); | ||
168 | + | ||
169 | + $strQuery = "?"; | ||
170 | + if (params) { | ||
171 | + for (var p in params) { | ||
172 | + $strQuery += p + "=" + params[p] + "&"; | ||
173 | + } | ||
174 | + } | ||
175 | + $strQuery = $strQuery.substring(0, $strQuery.length-1); | ||
176 | + window.location.href = "export" + $strQuery; | ||
177 | + return false; | ||
178 | + }) | ||
179 | + }); | ||
180 | +</script> | ||
0 | \ No newline at end of file | 181 | \ No newline at end of file |
app-ht/modules/manufacturer/views/manufacturer/index.php
@@ -87,7 +87,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -87,7 +87,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
87 | <?php endforeach; ?> | 87 | <?php endforeach; ?> |
88 | <?php } else { ?> | 88 | <?php } else { ?> |
89 | <tr> | 89 | <tr> |
90 | - <td colspan="8"> | 90 | + <td colspan="6"> |
91 | <center>暂无记录</center> | 91 | <center>暂无记录</center> |
92 | </td> | 92 | </td> |
93 | </tr> | 93 | </tr> |
app-ht/modules/model/views/model/index.php
@@ -81,7 +81,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -81,7 +81,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
81 | <?php endforeach; ?> | 81 | <?php endforeach; ?> |
82 | <?php } else { ?> | 82 | <?php } else { ?> |
83 | <tr> | 83 | <tr> |
84 | - <td colspan="8"> | 84 | + <td colspan="4"> |
85 | <center>暂无记录</center> | 85 | <center>暂无记录</center> |
86 | </td> | 86 | </td> |
87 | </tr> | 87 | </tr> |
app-ht/modules/production/views/production/index.php
@@ -82,7 +82,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -82,7 +82,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
82 | <?php endforeach; ?> | 82 | <?php endforeach; ?> |
83 | <?php } else { ?> | 83 | <?php } else { ?> |
84 | <tr> | 84 | <tr> |
85 | - <td colspan="8"> | 85 | + <td colspan="4"> |
86 | <center>暂无记录</center> | 86 | <center>暂无记录</center> |
87 | </td> | 87 | </td> |
88 | </tr> | 88 | </tr> |
app-ht/modules/project/views/project/index.php
@@ -81,7 +81,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -81,7 +81,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
81 | <?php endforeach; ?> | 81 | <?php endforeach; ?> |
82 | <?php } else { ?> | 82 | <?php } else { ?> |
83 | <tr> | 83 | <tr> |
84 | - <td colspan="8"> | 84 | + <td colspan="4"> |
85 | <center>暂无记录</center> | 85 | <center>暂无记录</center> |
86 | </td> | 86 | </td> |
87 | </tr> | 87 | </tr> |
app-ht/modules/upgrade/views/upgrade/index.php
@@ -117,7 +117,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -117,7 +117,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
117 | <?php endforeach; ?> | 117 | <?php endforeach; ?> |
118 | <?php } else { ?> | 118 | <?php } else { ?> |
119 | <tr> | 119 | <tr> |
120 | - <td colspan="8"> | 120 | + <td colspan="7"> |
121 | <center>暂无记录</center> | 121 | <center>暂无记录</center> |
122 | </td> | 122 | </td> |
123 | </tr> | 123 | </tr> |
@@ -136,16 +136,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -136,16 +136,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
136 | </div> | 136 | </div> |
137 | </div> | 137 | </div> |
138 | <script> | 138 | <script> |
139 | - window.queryParams = function(params) { | ||
140 | - $("#search-form").find('input[name]').each(function () { | ||
141 | - var val = $(this).val(); | ||
142 | - var name = $(this).attr('name'); | ||
143 | - if(val){ | ||
144 | - params[name] = val; | ||
145 | - } | ||
146 | - }); | ||
147 | - return params; | ||
148 | - } | ||
149 | $(document).ready(function () { | 139 | $(document).ready(function () { |
150 | $(".btn_del").bind("click",function () { | 140 | $(".btn_del").bind("click",function () { |
151 | if (confirm("确定要删除该版本吗?")){ | 141 | if (confirm("确定要删除该版本吗?")){ |
app-ht/views/layouts/routes.php
1 | <?php | 1 | <?php |
2 | - | 2 | +use domain\upgrade\UpgradeStatus; |
3 | return [ | 3 | return [ |
4 | [ | 4 | [ |
5 | 'path' => '/dashboard', | 5 | 'path' => '/dashboard', |
@@ -81,8 +81,8 @@ return [ | @@ -81,8 +81,8 @@ return [ | ||
81 | 'redirect' => '/datas/datas/index' | 81 | 'redirect' => '/datas/datas/index' |
82 | ], | 82 | ], |
83 | ['label' => '序列号统计', 'path' => '/datas/datas/index'], | 83 | ['label' => '序列号统计', 'path' => '/datas/datas/index'], |
84 | - ['label' => 'OTA升级统计', 'path' => '/datas/datas/red-invoice'], | ||
85 | - ['label' => 'APP升级统计', 'path' => '/datas/datas-setting/default'], | 84 | + ['label' => 'OTA升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_OTA], |
85 | + ['label' => 'APP升级统计', 'path' => '/datas/upgrade-log/index?type=' . UpgradeStatus::TYPE_APP], | ||
86 | ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'], | 86 | ['label' => '机器状态统计', 'path' => '/datas/datas-setting/default'], |
87 | ] | 87 | ] |
88 | ], | 88 | ], |
@@ -0,0 +1,125 @@ | @@ -0,0 +1,125 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace domain\upgrade; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use domain\upgrade\models\UpgradeLog as UpgradeLogModel; | ||
7 | +use Exception; | ||
8 | + | ||
9 | +/** | ||
10 | + * 版本日志 | ||
11 | + * Class UpgradeLog | ||
12 | + * @package domain\upgrade | ||
13 | + */ | ||
14 | +class UpgradeLog | ||
15 | +{ | ||
16 | + /** | ||
17 | + * 创建版本日志 | ||
18 | + * @param $item | ||
19 | + */ | ||
20 | + static function create($item) | ||
21 | + { | ||
22 | + try { | ||
23 | + $upgradeLogModel = Yii::createObject(UpgradeLogModel::className()); | ||
24 | + if (isset($item["barcode"])) { | ||
25 | + $upgradeLogModel->barcode = $item["barcode"]; // 序列号前缀 | ||
26 | + } | ||
27 | + if (isset($item["device_id"])) { | ||
28 | + $upgradeLogModel->device_id = $item["device_id"]; // 设备ID | ||
29 | + } | ||
30 | + if (isset($item["manufacture_id"])) { | ||
31 | + $upgradeLogModel->manufacture_id = $item["manufacture_id"]; // 厂商ID | ||
32 | + } | ||
33 | + if (isset($item["project_id"])) { | ||
34 | + $upgradeLogModel->project_id = $item["project_id"]; // 项目ID | ||
35 | + } | ||
36 | + if (isset($item["model_id"])) { | ||
37 | + $upgradeLogModel->model_id = $item["model_id"]; // 设备型号ID | ||
38 | + } | ||
39 | + if (isset($item["current_version"])) { | ||
40 | + $upgradeLogModel->current_version = $item["current_version"]; // 当前版本 | ||
41 | + } | ||
42 | + if (isset($item["target_version"])) { | ||
43 | + $upgradeLogModel->target_version = $item["target_version"]; // 目标版本 | ||
44 | + } | ||
45 | + if (isset($item["status"])) { | ||
46 | + $upgradeLogModel->status = $item["status"]; // 升级状态,1:下载成功,2:取消下载,3:开始升级,4:取消升级,5:升级成功 | ||
47 | + } | ||
48 | + if (isset($item["error_code"])) { | ||
49 | + $upgradeLogModel->error_code = $item["error_code"]; // 错误码 | ||
50 | + } | ||
51 | + if (isset($item["type"])) { | ||
52 | + $upgradeLogModel->type = $item["type"]; // 日志类型 1 app 2.ota整机 | ||
53 | + } | ||
54 | + | ||
55 | + $saveResult = $upgradeLogModel->save(); | ||
56 | + return $saveResult; | ||
57 | + } catch (Exception $e) { | ||
58 | + return false; | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * 更新版本日志 | ||
64 | + * @param $id | ||
65 | + * @param $item | ||
66 | + * @return null|static | ||
67 | + */ | ||
68 | + static function update($id, $item) | ||
69 | + { | ||
70 | + $upgradeLogModel = UpgradeLogModel::findOne($id); | ||
71 | + if (empty($upgradeLogModel)) { | ||
72 | + return false; | ||
73 | + } | ||
74 | + if (isset($item["barcode"])) { | ||
75 | + $upgradeLogModel->barcode = $item["barcode"]; // 序列号前缀 | ||
76 | + } | ||
77 | + if (isset($item["device_id"])) { | ||
78 | + $upgradeLogModel->device_id = $item["device_id"]; // 设备ID | ||
79 | + } | ||
80 | + if (isset($item["manufacture_id"])) { | ||
81 | + $upgradeLogModel->manufacture_id = $item["manufacture_id"]; // 厂商ID | ||
82 | + } | ||
83 | + if (isset($item["project_id"])) { | ||
84 | + $upgradeLogModel->project_id = $item["project_id"]; // 项目ID | ||
85 | + } | ||
86 | + if (isset($item["model_id"])) { | ||
87 | + $upgradeLogModel->model_id = $item["model_id"]; // 设备型号ID | ||
88 | + } | ||
89 | + if (isset($item["current_version"])) { | ||
90 | + $upgradeLogModel->current_version = $item["current_version"]; // 当前版本 | ||
91 | + } | ||
92 | + if (isset($item["target_version"])) { | ||
93 | + $upgradeLogModel->target_version = $item["target_version"]; // 目标版本 | ||
94 | + } | ||
95 | + if (isset($item["status"])) { | ||
96 | + $upgradeLogModel->status = $item["status"]; // 升级状态,1:下载成功,2:取消下载,3:开始升级,4:取消升级,5:升级成功 | ||
97 | + } | ||
98 | + if (isset($item["error_code"])) { | ||
99 | + $upgradeLogModel->error_code = $item["error_code"]; // 错误码 | ||
100 | + } | ||
101 | + if (isset($item["type"])) { | ||
102 | + $upgradeLogModel->type = $item["type"]; // 日志类型 1 app 2.ota整机 | ||
103 | + } | ||
104 | + | ||
105 | + | ||
106 | + $resultSave = $upgradeLogModel->save(); | ||
107 | + return $resultSave; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * 删除版本日志 | ||
112 | + * @param $id | ||
113 | + * @param $item | ||
114 | + * @return null|static | ||
115 | + */ | ||
116 | + public static function delete($id) | ||
117 | + { | ||
118 | + $upgradeModel = UpgradeLogModel::findOne($id); | ||
119 | + if (empty($upgradeModel)) { | ||
120 | + return false; | ||
121 | + } | ||
122 | + | ||
123 | + return UpgradeLogModel::deleteAll(["id" => $id]); | ||
124 | + } | ||
125 | +} | ||
0 | \ No newline at end of file | 126 | \ No newline at end of file |
@@ -0,0 +1,101 @@ | @@ -0,0 +1,101 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace domain\upgrade; | ||
4 | + | ||
5 | +use domain\device\models\Device as DeviceModel; | ||
6 | +use domain\manufacturer\models\Manufacturer as ManufacturerModel; | ||
7 | +use domain\model\models\Model; | ||
8 | +use domain\project\models\Project; | ||
9 | +use domain\upgrade\models\UpgradeLog as UpgradeLogModel; | ||
10 | + | ||
11 | + | ||
12 | +/** | ||
13 | + | ||
14 | + * Class UpgradeLogRepository | ||
15 | + * @package domain\model | ||
16 | + */ | ||
17 | +class UpgradeLogRepository | ||
18 | +{ | ||
19 | + /** | ||
20 | + * 获取分页数据 | ||
21 | + * @param $where | ||
22 | + * @param $offset | ||
23 | + * @param $limit | ||
24 | + * @return array|\yii\db\ActiveRecord[] | ||
25 | + */ | ||
26 | + static function getPageList($where, $offset, $limit) | ||
27 | + { | ||
28 | + $upgradeFind = UpgradeLogModel::find()->alias("ul") | ||
29 | + ->select([ | ||
30 | + "ul.*", | ||
31 | + "mf.name as manufacture_name", | ||
32 | + 'de.serial_no', | ||
33 | + 'de.device_id as device_device_id', | ||
34 | + 'pj.name as project_name', | ||
35 | + 'md.name as model_name', | ||
36 | + ]); | ||
37 | + $upgradeFind->leftJoin(ManufacturerModel::tableName() . " mf", "mf.id = ul.manufacture_id"); | ||
38 | + $upgradeFind->leftJoin(DeviceModel::tableName() . " de", "de.id = ul.device_id"); | ||
39 | + $upgradeFind->leftJoin(Project::tableName() . " pj", "pj.id = ul.project_id"); | ||
40 | + $upgradeFind->leftJoin(Model::tableName() . " md", "md.id = ul.model_id"); | ||
41 | + | ||
42 | + if (!empty($where)) { | ||
43 | + $upgradeFind->where($where); | ||
44 | + } | ||
45 | + if ($offset) { | ||
46 | + $upgradeFind->offset($offset); | ||
47 | + } | ||
48 | + if ($limit) { | ||
49 | + $upgradeFind->limit($limit); | ||
50 | + } | ||
51 | + $upgradeFind->orderBy("ul.id desc"); | ||
52 | + $upgradeFind->asArray(); | ||
53 | + $dataList = $upgradeFind->all(); | ||
54 | + | ||
55 | + return $dataList; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 列表页面分页器数量 | ||
60 | + * @param string $map | ||
61 | + */ | ||
62 | + static function getPageCount($map = '') | ||
63 | + { | ||
64 | + $upgradeFind = UpgradeLogModel::find()->alias("ul"); | ||
65 | + $upgradeFind->leftJoin(ManufacturerModel::tableName() . " mf", "mf.id = ul.manufacture_id"); | ||
66 | + $upgradeFind->leftJoin(DeviceModel::tableName() . " de", "de.id = ul.device_id"); | ||
67 | + $upgradeFind->leftJoin(Project::tableName() . " pj", "pj.id = ul.project_id"); | ||
68 | + $upgradeFind->leftJoin(Model::tableName() . " md", "md.id = ul.model_id"); | ||
69 | + if (!empty($map)) { | ||
70 | + $upgradeFind->where($map); | ||
71 | + } | ||
72 | + $pageCount = $upgradeFind->count(); | ||
73 | + | ||
74 | + return $pageCount; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * @param $id | ||
79 | + * @param bool|false $asArr | ||
80 | + * @return null|static | ||
81 | + */ | ||
82 | + static function selectOne($id, $asArr = false) | ||
83 | + { | ||
84 | + $model = UpgradeLogModel::findOne($id); | ||
85 | + if ($asArr && $model) { | ||
86 | + $model = $model->toArray(); | ||
87 | + } | ||
88 | + return $model; | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * @param $id | ||
93 | + * @param bool|false $asArr | ||
94 | + * @return null|static | ||
95 | + */ | ||
96 | + static function findOne($condition) | ||
97 | + { | ||
98 | + $model = UpgradeLogModel::findOne($condition); | ||
99 | + return $model; | ||
100 | + } | ||
101 | +} | ||
0 | \ No newline at end of file | 102 | \ No newline at end of file |
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace domain\upgrade; | ||
4 | + | ||
5 | +/** | ||
6 | + * 版本发布状态 | ||
7 | + * Class UpgradeLogStatus | ||
8 | + * @package domain\upgrade | ||
9 | + */ | ||
10 | +class UpgradeLogStatus | ||
11 | +{ | ||
12 | + /** | ||
13 | + * 升级状态,1:下载成功,2:取消下载,3:开始升级,4:取消升级,5:升级成功 | ||
14 | + */ | ||
15 | + const STATUS_DOWNLOAD_SUCCESS = 1; // 下载成功 | ||
16 | + const STATUS_CANCEL_DOWNLOAD = 2; // 取消下载 | ||
17 | + const STATUS_START_UPDATE = 3; // 开始升级 | ||
18 | + const STATUS_CANCEL_UPDATE = 4; // 取消升级 | ||
19 | + const STATUS_UPDATE_SUCCESS = 5; // 升级成功 | ||
20 | + | ||
21 | + /** | ||
22 | + * @return array | ||
23 | + */ | ||
24 | + public static function statusLabels() | ||
25 | + { | ||
26 | + return [ | ||
27 | + self::STATUS_DOWNLOAD_SUCCESS => '下载成功', | ||
28 | + self::STATUS_CANCEL_DOWNLOAD => '取消下载', | ||
29 | + self::STATUS_START_UPDATE => '开始升级', | ||
30 | + self::STATUS_CANCEL_UPDATE => '取消升级', | ||
31 | + self::STATUS_UPDATE_SUCCESS => '升级成功', | ||
32 | + ]; | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * @param string $status | ||
37 | + * @return mixed|string | ||
38 | + */ | ||
39 | + public static function statusLabel($status = null) | ||
40 | + { | ||
41 | + $statusLabels = self::statusLabels(); | ||
42 | + return isset($statusLabels[$status]) ? $statusLabels[$status] : ''; | ||
43 | + } | ||
44 | +} | ||
0 | \ No newline at end of file | 45 | \ No newline at end of file |
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace domain\upgrade\models; | ||
4 | + | ||
5 | +use yii\db\ActiveRecord; | ||
6 | +use yii\behaviors\TimestampBehavior; | ||
7 | + | ||
8 | +/** | ||
9 | + * 版本日志管理 | ||
10 | + * Class UpgradeLog | ||
11 | + * @package domain\upgrade\models | ||
12 | + */ | ||
13 | +class UpgradeLog extends ActiveRecord | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public static function tableName() | ||
19 | + { | ||
20 | + return '{{%upgrade_log}}'; | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * @return array | ||
25 | + */ | ||
26 | + public function behaviors() | ||
27 | + { | ||
28 | + return [ | ||
29 | + 'time' => [ | ||
30 | + 'class' => TimestampBehavior::className(), | ||
31 | + 'createdAtAttribute' => 'created_at', | ||
32 | + 'updatedAtAttribute' => 'updated_at', | ||
33 | + ] | ||
34 | + ]; | ||
35 | + } | ||
36 | +} | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |