Commit a0935a2ce5a4e0f26377bc083bccb8f952208e3e

Authored by xu
1 parent f656f33b
Exists in master

1. F 数据统计添加多个统计维度

2. F 数据统计添加导出
app-ht/modules/datas/controllers/DeviceController.php
... ... @@ -2,6 +2,7 @@
2 2  
3 3 namespace app\ht\modules\datas\controllers;
4 4  
  5 +use domain\device\DeviceAuthFailRepository;
5 6 use Yii;
6 7 use yii\data\Pagination;
7 8 use app\ht\controllers\BaseController;
... ... @@ -96,6 +97,16 @@ class DeviceController extends BaseController
96 97 */
97 98 public function actionDeviceList()
98 99 {
  100 + $params = $this->batchDataList(1);
  101 + return $this->render('device-list', $params);
  102 + }
  103 +
  104 + /**
  105 + * @param $type
  106 + * @return mixed
  107 + */
  108 + private function batchDataList($type)
  109 + {
99 110 $request = Yii::$app->request;
100 111 $serialNo = $request->get('serial_no');
101 112 $mac = $request->get('mac');
... ... @@ -146,23 +157,32 @@ class DeviceController extends BaseController
146 157 if (0 >= $page) {
147 158 $page = 1;
148 159 }
149   - $pageSize = 20;
150   - $page = ($page -1) * $pageSize;
151   -
152   - $deviceData = DeviceRepository::getList($where, $pageSize, $page);
153   - $pages = new Pagination(['totalCount' => DeviceRepository::getListCount($where), 'pageSize' => $pageSize]);
154 160 $statusList = DeviceStatus::statusLabels(); //
155   - if (empty($deviceData)) {
156   - $batchInfo = CreateBatchRepository::getBatchInfo($batchId);
  161 + if (1 == $type) {
  162 + $pageSize = 20;
  163 + $page = ($page -1) * $pageSize;
  164 + $deviceData = DeviceRepository::getList($where, $pageSize, $page);
  165 + $pages = new Pagination(['totalCount' => DeviceRepository::getListCount($where), 'pageSize' => $pageSize]);
  166 +
  167 + if (empty($deviceData)) {
  168 + $where = ['a.id' => $batchId];
  169 + $batchInfo = CreateBatchRepository::getBatchInfo($where);
  170 + } else {
  171 + $batchInfo = $deviceData[0];
  172 + }
  173 + $project = $batchInfo['project'];
  174 + $production = $batchInfo['production'];
  175 + $model = $batchInfo['model'];
  176 + $manufacture = $batchInfo['manufacture'];
  177 + $batchNo = $batchInfo['batch_no'];
  178 +
157 179 } else {
158   - $batchInfo = $deviceData[0];
  180 + $deviceData = DeviceRepository::getList($where, 0, 0);
  181 + $pages = null;
  182 + $project = $production = $model = $manufacture = $batchNo = null;
159 183 }
160 184  
161   - $project = $batchInfo['project'];
162   - $production = $batchInfo['production'];
163   - $model = $batchInfo['model'];
164   - $manufacture = $batchInfo['manufacture'];
165   - $batchNo = $batchInfo['batch_no'];
  185 +
166 186 $params['statusList'] = $statusList;
167 187 $params['deviceList'] = $deviceData;
168 188 $params['pages'] = $pages;
... ... @@ -183,6 +203,108 @@ class DeviceController extends BaseController
183 203 'status' => $status
184 204 ];
185 205  
186   - return $this->render('device-list', $params);
  206 + return $params;
  207 + }
  208 +
  209 +
  210 + /**
  211 + * 导出某个批次的数据
  212 + * @return string
  213 + */
  214 + public function actionBatchExport()
  215 + {
  216 + $params = $this->batchDataList(0);
  217 + return $this->renderPartial('batch-export', $params);
  218 + }
  219 +
  220 + /**
  221 + * @param $type
  222 + * @return mixed
  223 + */
  224 + private function batchFailDataList($type)
  225 + {
  226 + $request = Yii::$app->request;
  227 + $batchNo = $request->get('batch_no');
  228 + $deviceId = $request->get('device_id');
  229 + $startApplyAt = $request->get('start_apply_at');
  230 + $endApplyAt = $request->get('end_apply_at');
  231 +
  232 + $page = $request->get('page');
  233 + $where = [
  234 + 'and',
  235 + ['=','a.is_delete', 0],
  236 + ['=','concat(a.manufacture_no,a.project_no,a.model_no,a.production_no)', $batchNo]
  237 + ];
  238 +
  239 +
  240 + if (!empty($deviceId)) {
  241 + $where[] = ['like', 'a.device_id', $deviceId];
  242 + }
  243 +
  244 + if (!empty($startApplyAt)) {
  245 + $where[] = ['>=', 'a.apply_at', strtotime($startApplyAt)];
  246 + }
  247 + if (!empty($endApplyAt)) {
  248 + $where[] = ['<=', 'a.apply_at', strtotime($endApplyAt) + 3600 * 24];
  249 + }
  250 +
  251 +
  252 + if (0 >= $page) {
  253 + $page = 1;
  254 + }
  255 +
  256 + if (1 == $type) {
  257 + $pageSize = 20;
  258 + $page = ($page -1) * $pageSize;
  259 + $deviceData = DeviceAuthFailRepository::getList($where, $pageSize, $page);
  260 + $pages = new Pagination(['totalCount' => DeviceAuthFailRepository::getListCount($where), 'pageSize' => $pageSize]);
  261 +
  262 + $batchInfo = CreateBatchRepository::getBatchInfo(['a.batch_no' => $batchNo]);
  263 + $project = $batchInfo['project'];
  264 + $production = $batchInfo['production'];
  265 + $model = $batchInfo['model'];
  266 + $manufacture = $batchInfo['manufacture'];
  267 + $batchNo = $batchInfo['batch_no'];
  268 +
  269 + } else {
  270 + $deviceData = DeviceAuthFailRepository::getList($where, 0, 0);
  271 + $pages = null;
  272 + $project = $production = $model = $manufacture = $batchNo = null;
  273 + }
  274 +
  275 + $params['deviceList'] = $deviceData;
  276 + $params['pages'] = $pages;
  277 + $params["gets"] = [
  278 +
  279 + 'project' => $project,
  280 + 'model' => $model,
  281 + 'device_id' => $deviceId,
  282 + 'batch_no' => $batchNo,
  283 + 'production' => $production,
  284 + 'manufacture' => $manufacture,
  285 + 'start_apply_at' => $startApplyAt,
  286 + 'end_apply_at' => $endApplyAt,
  287 +
  288 + ];
  289 +
  290 + return $params;
  291 + }
  292 +
  293 + /**
  294 + * @return string
  295 + */
  296 + public function actionFailList()
  297 + {
  298 + $params = $this->batchFailDataList(1);
  299 + return $this->render('fail-list', $params);
  300 + }
  301 +
  302 + /**
  303 + * @return string
  304 + */
  305 + public function actionFailListExport()
  306 + {
  307 + $params = $this->batchFailDataList(0);
  308 + return $this->renderPartial('fail-list-export', $params);
187 309 }
188 310 }
189 311 \ No newline at end of file
... ...
app-ht/modules/datas/views/device/batch-export.php 0 → 100644
... ... @@ -0,0 +1,75 @@
  1 +<?php
  2 +
  3 +header('Content-Type: application/vnd.ms-excel;charset=utf-8');
  4 +$title = date('Y-m-d') . '_批次导出';
  5 +$name = $title . ".xls";
  6 +header('Content-Disposition: attachment;filename=' . $name . '');
  7 +header('Cache-Control: max-age=0');
  8 +$fp = fopen('php://output', 'a');
  9 +$limit = 10000;
  10 +$cnt = 0;
  11 +
  12 +?>
  13 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  14 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  15 +<html xmlns:o="urn:schemas-microsoft-com:office:office"
  16 + xmlns:x="urn:schemas-microsoft-com:office:excel"
  17 + xmlns="http://www.w3.org/TR/REC-html40">
  18 +
  19 +<head>
  20 + <meta http-equiv=Content-Type content="text/html; charset=utf-8">
  21 +
  22 +</head>
  23 +<body>
  24 +<div id="Classeur1_16681" align='center' x:publishsource="Excel">
  25 + <table x:str border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
  26 + <thead>
  27 + <tr>
  28 + <th width="10%">批次编码</th>
  29 + <th width="15%">序列号</th>
  30 + <th width="12%">MAC地址</th>
  31 + <th width="10%">设备ID</th>
  32 + <th width="10%">申请时间</th>
  33 + <th width="10%">授权时间</th>
  34 + <th width="10%">状态</th>
  35 + </tr>
  36 + </thead>
  37 + <tbody>
  38 + <?php foreach ($deviceList as $key => $item) : ?>
  39 + <tr>
  40 + <td class="td-cls">
  41 + <?= $item['batch_no'] ?>
  42 + </td>
  43 + <td class="td-cls">
  44 + <div class="cell-cls"><?= $item['serial_no'] ?></div>
  45 + </td>
  46 + <td class="td-cls">
  47 + <?= $item['mac'] ?>
  48 + </td>
  49 + <td class="td-cls">
  50 + <?= $item['device_id']? $item['device_id']:'暂无'?>
  51 + </td>
  52 + <td class="td-cls">
  53 + <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
  54 + </td>
  55 + <td class="td-cls">
  56 + <?= $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?>
  57 + </td>
  58 + <td class="td-cls">
  59 + <?= $statusList[$item['status']] ?>
  60 + </td>
  61 + </tr>
  62 + <?php
  63 + $cnt++;
  64 + if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
  65 + ob_flush();
  66 + flush();
  67 + $cnt = 0;
  68 + }
  69 + ?>
  70 + <?php endforeach; ?>
  71 + </tbody>
  72 + </table>
  73 +</div>
  74 +</body>
  75 +</html>
0 76 \ No newline at end of file
... ...
app-ht/modules/datas/views/device/device-list.php
... ... @@ -55,7 +55,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
55 55 </div>
56 56 </div>
57 57 <div class="form-group col-sm-12" style="text-align: center;">
58   - <button type="submit" class="btn btn-primary font-1" id="submitFilterBtn">查询</button>
  58 + <div style="display: flex;justify-content: space-between;width:40%;margin:0 auto"><button type="submit" class="btn btn-primary font-1" id="submitFilterBtn">查询</button>
  59 + <a class="btn btn-default" href="javascript:void(0)" id="btn-export"> 导出数据 </a></div>
59 60 </div>
60 61 </form>
61 62 </div>
... ... @@ -131,5 +132,30 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
131 132 </div>
132 133  
133 134 <script>
  135 + window.queryParams = function(params) {
  136 + $("#search-form").find('input[name]').each(function () {
  137 + var val = $(this).val();
  138 + var name = $(this).attr('name');
  139 + if(val){
  140 + params[name] = val;
  141 + }
  142 + });
  143 + return params;
  144 + }
  145 + $(document).ready(function () {
  146 + $('#btn-export').click(function(e){
  147 + var params = {};
  148 + window.queryParams(params);
134 149  
  150 + $strQuery = "?";
  151 + if (params) {
  152 + for (var p in params) {
  153 + $strQuery += p + "=" + params[p] + "&";
  154 + }
  155 + }
  156 + $strQuery = $strQuery.substring(0, $strQuery.length-1);
  157 + window.location.href = "batch-export" + $strQuery;
  158 + return false;
  159 + })
  160 + });
135 161 </script>
136 162 \ No newline at end of file
... ...
app-ht/modules/datas/views/device/export.php
... ... @@ -22,18 +22,21 @@ $cnt = 0;
22 22 </head>
23 23 <body>
24 24 <div id="Classeur1_16681" align='center' x:publishsource="Excel">
25   - <table border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
  25 + <table x:str border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
26 26 <thead>
27 27 <tr>
28   - <th width="10%">编码</th>
29   - <th width="10%">厂商</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%">授权总数</th>
35   - <th width="15%">授权失败数</th>
36   - <th width="15%">未授权数</th>
  28 + <th width="9%">编码</th>
  29 + <th width="9%">厂商</th>
  30 + <th width="8%">项目</th>
  31 + <th width="8%">型号</th>
  32 + <th width="8%">生产日期</th>
  33 + <th width="7%">预 | 总生成</th>
  34 + <th width="7%">已删除</th>
  35 + <th width="7%">已授权</th>
  36 + <th width="7%">未授权</th>
  37 + <th width="7%">授权失败(超出)</th>
  38 + <th width="7%">已处理(超出)</th>
  39 + <th width="7%">授权失败(系统)</th>
37 40 </tr>
38 41 </thead>
39 42 <tbody>
... ... @@ -44,10 +47,13 @@ $cnt = 0;
44 47 <td style="padding:12px;"><?= (isset($item["project_name"]) ? $item["project_name"] : "") ?></td>
45 48 <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td>
46 49 <td style="padding:12px;"><?= (isset($item["production_name"]) ? $item["production_name"] : "") ?></td>
47   - <td style="padding:12px;"><?= (isset($item["num"]) ? $item["num"] : "0") ?></td>
  50 + <td style="padding:12px;"><?= (isset($item["num"]) ? $item["num"] : "0") ?>|<?= (isset($item["total_num"]) ? $item["total_num"] : "0") ?></td>
  51 + <td style="padding:12px;"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></td>
48 52 <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td>
49   - <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
50 53 <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td>
  54 + <td><?= (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?></td>
  55 + <td style="padding:12px;"><?= (!empty($item["handle_auth_fail_num"]) ? $item["handle_auth_fail_num"] : "0") ?></td>
  56 + <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
51 57 </tr>
52 58 <?php
53 59 $cnt++;
... ...
app-ht/modules/datas/views/device/fail-list-export.php 0 → 100644
... ... @@ -0,0 +1,85 @@
  1 +<?php
  2 +use domain\device\Device;
  3 +header('Content-Type: application/vnd.ms-excel;charset=utf-8');
  4 +$title = date('Y-m-d') . '_超出部分导出';
  5 +$name = $title . ".xls";
  6 +header('Content-Disposition: attachment;filename=' . $name . '');
  7 +header('Cache-Control: max-age=0');
  8 +$fp = fopen('php://output', 'a');
  9 +$limit = 10000;
  10 +$cnt = 0;
  11 +
  12 +?>
  13 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  14 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  15 +<html xmlns:o="urn:schemas-microsoft-com:office:office"
  16 + xmlns:x="urn:schemas-microsoft-com:office:excel"
  17 + xmlns="http://www.w3.org/TR/REC-html40">
  18 +
  19 +<head>
  20 + <meta http-equiv=Content-Type content="text/html; charset=utf-8">
  21 +
  22 +</head>
  23 +<body>
  24 +<div id="Classeur1_16681" align='center' x:publishsource="Excel">
  25 + <table x:str border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse">
  26 + <thead>
  27 + <tr>
  28 + <th width="6%">ID</th>
  29 + <th width="10%">批次编码</th>
  30 + <th width="10%">厂商</th>
  31 +
  32 + <th width="10%">项目</th>
  33 + <th width="10%">设备型号</th>
  34 + <th width="10%">生产日期</th>
  35 + <th width="10%">设备ID</th>
  36 + <th width="10%">申请时间</th>
  37 + <th width="10%">状态</th>
  38 + </tr>
  39 + </thead>
  40 + <tbody>
  41 + <?php foreach ($deviceList as $key => $item) : ?>
  42 + <tr>
  43 + <td class="td-cls">
  44 + <?= $item['id'] ?>
  45 + </td>
  46 + <td class="td-cls">
  47 + <?= Device::getBatchNo($item['manufacture_no'], $item['project_no'], $item['model_no'], $item['production_no']) ?>
  48 + </td>
  49 + <td class="td-cls">
  50 + <?= $item['manufacture'] ?>
  51 + </td>
  52 + <td class="td-cls">
  53 + <?= $item['project'] ?>
  54 + </td>
  55 + <td class="td-cls">
  56 + <?= $item['model'] ?>
  57 + </td>
  58 + <td class="td-cls">
  59 + <?= $item['production'] ?>
  60 + </td>
  61 +
  62 + <td class="td-cls">
  63 + <?= $item['device_id']? $item['device_id']:'暂无'?>
  64 + </td>
  65 + <td class="td-cls">
  66 + <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
  67 + </td>
  68 + <td>
  69 + 超出
  70 + </td>
  71 + </tr>
  72 + <?php
  73 + $cnt++;
  74 + if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题
  75 + ob_flush();
  76 + flush();
  77 + $cnt = 0;
  78 + }
  79 + ?>
  80 + <?php endforeach; ?>
  81 + </tbody>
  82 + </table>
  83 +</div>
  84 +</body>
  85 +</html>
0 86 \ No newline at end of file
... ...
app-ht/modules/datas/views/device/fail-list.php 0 → 100644
... ... @@ -0,0 +1,146 @@
  1 +<?php
  2 +use yii\helpers\Url;
  3 +use app\ht\widgets\LinkPager;
  4 +use domain\device\Device;
  5 +
  6 +$this->title = '授权失败管理';
  7 +$this->params['breadcrumbs'][] = '数据统计';
  8 +$this->params['breadcrumbs'][] = ['label' => '批次列表', 'url' => ['/datas/device/index']];
  9 +$this->params['breadcrumbs'][] = $this->title;
  10 +?>
  11 +<style>
  12 + .cell-cls{width:60%;word-wrap: break-word}
  13 + .td-cls{padding:8px 0}
  14 +</style>
  15 +<div class="panel panel-default">
  16 + <div class="panel-body">
  17 + <form action="" method="get" id="search-form" class="filter-form">
  18 + <input type="hidden" name="batch_no" value="<?=$gets['batch_no']?>" />
  19 + <div class="form-group col-sm-12">
  20 +
  21 + <label for="device_id" class="col-sm-1 control-label text-right">设备ID:</label>
  22 + <div class="col-sm-2 form-inline">
  23 + <input type="text" class="form-control" id="device_id" name="device_id" value="<?php if (!empty($gets['device_id'])){ echo $gets['device_id'];} ?>" autocomplete="off">
  24 + </div>
  25 +
  26 + <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label>
  27 + <div class="col-sm-4 form-inline">
  28 + <input type="date" class="form-control" style="width:140px" id="start_apply_at" name="start_apply_at" value="<?php if (!empty($gets['start_apply_at'])){ echo $gets['start_apply_at'];} ?>" autocomplete="off"> -
  29 + <input type="date" class="form-control" style="width:140px" id="end_apply_at" name="end_apply_at" value="<?php if (!empty($gets['end_apply_at'])){ echo $gets['end_apply_at'];} ?>" autocomplete="off">
  30 + </div>
  31 + </div>
  32 +
  33 + <div class="form-group col-sm-12" style="text-align: center;">
  34 + <div style="display: flex;justify-content: space-between;width:40%;margin:0 auto"><button type="submit" class="btn btn-primary font-1" id="submitFilterBtn">查询</button>
  35 + <a class="btn btn-default" href="javascript:void(0)" id="btn-export"> 导出数据 </a></div>
  36 + </div>
  37 + </form>
  38 + </div>
  39 +</div>
  40 +<div class="panel" style="margin-bottom: 0">
  41 + <div style="padding:10px ;20px;box-sizing: border-box"><b>厂商:</b><?=$gets['manufacture']?> <b>项目:</b><?=$gets['project']?> <b>型号:</b><?=$gets['model']?> <b>生产日期:</b><?=$gets['production']?>
  42 + <b> 批次编号:</b><?=$gets['batch_no']?>
  43 + </div>
  44 +</div>
  45 +<div class="panel panel-default">
  46 + <div class="panel-body">
  47 + <table class="table table-striped table-bordered" id="brand-table">
  48 + <thead>
  49 + <tr>
  50 + <th width="6%">ID</th>
  51 + <th width="10%">批次编码</th>
  52 + <th width="10%">厂商</th>
  53 +
  54 + <th width="10%">项目</th>
  55 + <th width="10%">设备型号</th>
  56 + <th width="10%">生产日期</th>
  57 + <th width="10%">设备ID</th>
  58 + <th width="10%">申请时间</th>
  59 + <th width="10%">状态</th>
  60 +
  61 + </tr>
  62 + </thead>
  63 +
  64 + <tbody>
  65 + <?php if ($deviceList) { ?>
  66 + <?php foreach ($deviceList as $item) : ?>
  67 + <tr>
  68 + <td class="td-cls">
  69 + <?= $item['id'] ?>
  70 + </td>
  71 + <td class="td-cls">
  72 + <?= Device::getBatchNo($item['manufacture_no'], $item['project_no'], $item['model_no'], $item['production_no']) ?>
  73 + </td>
  74 + <td class="td-cls">
  75 + <?= $item['manufacture'] ?>
  76 + </td>
  77 + <td class="td-cls">
  78 + <?= $item['project'] ?>
  79 + </td>
  80 + <td class="td-cls">
  81 + <?= $item['model'] ?>
  82 + </td>
  83 + <td class="td-cls">
  84 + <?= $item['production'] ?>
  85 + </td>
  86 +
  87 + <td class="td-cls">
  88 + <?= $item['device_id']? $item['device_id']:'暂无'?>
  89 + </td>
  90 + <td class="td-cls">
  91 + <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
  92 + </td>
  93 + <td>
  94 + 超出
  95 + </td>
  96 + </tr>
  97 + <?php endforeach; ?>
  98 + <?php } else { ?>
  99 + <tr>
  100 + <td colspan="7">
  101 + <center>暂无记录</center>
  102 + </td>
  103 + </tr>
  104 + <?php } ?>
  105 + </tbody>
  106 + </table>
  107 + </div>
  108 +
  109 + <div class="panel-footer">
  110 + <div class="hqy-panel-pager">
  111 + <?= LinkPager::widget([
  112 + 'pagination' => $pages,
  113 + ]); ?>
  114 + <div class="clearfix"></div>
  115 + </div>
  116 + </div>
  117 +</div>
  118 +
  119 +<script>
  120 + window.queryParams = function(params) {
  121 + $("#search-form").find('input[name]').each(function () {
  122 + var val = $(this).val();
  123 + var name = $(this).attr('name');
  124 + if(val){
  125 + params[name] = val;
  126 + }
  127 + });
  128 + return params;
  129 + }
  130 + $(document).ready(function () {
  131 + $('#btn-export').click(function(e){
  132 + var params = {};
  133 + window.queryParams(params);
  134 +
  135 + $strQuery = "?";
  136 + if (params) {
  137 + for (var p in params) {
  138 + $strQuery += p + "=" + params[p] + "&";
  139 + }
  140 + }
  141 + $strQuery = $strQuery.substring(0, $strQuery.length-1);
  142 + window.location.href = "fail-list-export" + $strQuery;
  143 + return false;
  144 + })
  145 + });
  146 +</script>
0 147 \ No newline at end of file
... ...
app-ht/modules/datas/views/device/index.php
... ... @@ -49,7 +49,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
49 49  
50 50 <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询 </button>
51 51 <a class="btn btn-default btncls" href="<?=Url::toRoute(["/datas/device/index"])?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
52   - <a class="btn btn-default" style="float: right;" href="javascript:void(0)" id="btn-export"> 导出数据 </a>&nbsp;&nbsp;
  52 + <a class="btn btn-default" href="javascript:void(0)" id="btn-export"> 导出数据 </a>&nbsp;&nbsp;
53 53 </td>
54 54 </tr>
55 55 </tbody>
... ... @@ -63,17 +63,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
63 63 <table class="table table-striped table-bordered" id="brand-table">
64 64 <thead>
65 65 <tr>
66   - <th width="10%">编码</th>
67   - <th width="10%">厂商</th>
68   - <th width="10%">项目</th>
69   - <th width="10%">型号</th>
70   - <th width="10%">生产日期</th>
71   - <th width="10%">生成总数</th>
72   - <th width="8%">删除数</th>
73   - <th width="8%">授权总数</th>
74   - <th width="8%">超出总数</th>
75   - <th width="8%">授权失败数</th>
76   - <th width="15%">未授权数</th>
  66 + <th width="9%">编码</th>
  67 + <th width="9%">厂商</th>
  68 + <th width="8%">项目</th>
  69 + <th width="8%">型号</th>
  70 + <th width="8%">生产日期</th>
  71 + <th width="7%" ><span title="预生成数,总生成包含超出部分,但是不包含删除的">预 | 总生成</span></th>
  72 + <th width="7%">已删除</th>
  73 + <th width="7%">已授权</th>
  74 + <th width="7%">未授权</th>
  75 + <th width="7%">授权失败(超出)</th>
  76 + <th width="7%">已处理(超出)</th>
  77 + <th width="7%">授权失败(系统)</th>
77 78 </tr>
78 79 </thead>
79 80  
... ... @@ -86,12 +87,14 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
86 87 <td style="padding:12px;"><?= (isset($item["project_name"]) ? $item["project_name"] : "") ?></td>
87 88 <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td>
88 89 <td style="padding:12px;"><?= (isset($item["production_name"]) ? $item["production_name"] : "") ?></td>
89   - <td style="padding:12px;"><a href="<?=Url::toRoute(['device/device-list','batch_id' => $item['id']])?>"><?= (isset($item["num"]) ? $item["num"] : "0") ?></a></td>
  90 + <td style="padding:12px;"><?= (isset($item["num"]) ? $item["num"] : "0") ?>|<a href="<?=Url::toRoute(['device/device-list','batch_id' => $item['id']])?>"><?= (isset($item["total_num"]) ? $item["total_num"] : "0") ?></a></td>
90 91 <td style="padding:12px;"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></td>
91 92 <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td>
92   - <td>4</td>
93   - <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
94 93 <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td>
  94 + <td><a href="<?=Url::toRoute(['device/fail-list','batch_no' => $item['batch_no']])?>"><?= (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?></a></td>
  95 + <td style="padding:12px;"><?= (!empty($item["handle_auth_fail_num"]) ? $item["handle_auth_fail_num"] : "0") ?></td>
  96 + <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
  97 +
95 98 </tr>
96 99 <?php endforeach; ?>
97 100 <?php } else { ?>
... ...
app-ht/modules/device/controllers/DeviceController.php
... ... @@ -705,7 +705,7 @@ class DeviceController extends BaseController
705 705 if ($needGen) {
706 706 $trans = Yii::$app->getDb()->beginTransaction();
707 707 try {
708   - $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH);
  708 + $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 1, DeviceStatus::HAS_AUTH);
709 709 $deviceFailModel->is_delete = 1;
710 710 $deviceFailModel->save();
711 711 $trans->commit();
... ... @@ -732,6 +732,7 @@ class DeviceController extends BaseController
732 732 $newDeviceModel->apply_at = $tt ;
733 733 $newDeviceModel->auth_at = $tt;
734 734 $newDeviceModel->save();
  735 +
735 736 $deviceFailModel->is_delete = 1;
736 737 $deviceFailModel->save();
737 738 $trans->commit();
... ... @@ -800,7 +801,7 @@ class DeviceController extends BaseController
800 801 if ($needGen) {
801 802 $trans = Yii::$app->getDb()->beginTransaction();
802 803 try {
803   - $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH);
  804 + $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 1, DeviceStatus::HAS_AUTH);
804 805 $deviceFailModel->is_delete = 1;
805 806 $deviceFailModel->save();
806 807 $trans->commit();
... ...
domain/device/CreateBatchRepository.php
... ... @@ -2,15 +2,16 @@
2 2  
3 3 namespace domain\device;
4 4  
  5 +use domain\device\models\CreateBatch;
5 6 use yii\db\Expression;
6 7 use yii\db\Query;
7 8 use domain\device\models\CreateBatch as CreateBatchModel;
8 9 use domain\device\models\Device as DeviceModel;
9   -use domain\device\models\DeviceStats;
10 10 use domain\manufacturer\models\Manufacturer as ManufacturerModel;
11 11 use domain\model\models\Model as ModelModel;
12 12 use domain\production\models\Production as ProductionModel;
13 13 use domain\project\models\Project as ProjectModel;
  14 +use domain\device\models\DeviceAuthFail as DeviceAuthFailModel;
14 15  
15 16  
16 17 class CreateBatchRepository
... ... @@ -78,14 +79,21 @@ class CreateBatchRepository
78 79 */
79 80 static function getPageList($where, $offset = 0, $limit = 0)
80 81 {
  82 + $totalNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.batch_id = a.id and dd.is_delete = 0) as total_num");
81 83 $hasAuthNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.status =".DeviceStatus::HAS_AUTH.' and dd.batch_id = a.id and dd.is_delete = 0) as has_auth_num');
82   - $noAuthNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.status =".DeviceStatus::NO_AUTH.' and dd.batch_id = a.id and dd.is_delete = 0) as del_num');
83   -
  84 + $noAuthNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.status =".DeviceStatus::NO_AUTH.' and dd.batch_id = a.id and dd.is_delete = 0) as no_auth_num');
84 85 $delNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.is_delete = 1 and dd.batch_id = a.id) as del_num");
  86 + $outOfLimitExpress = new Expression("(select count(*) from ".DeviceAuthFailModel::tableName(). "as dd where concat(dd.manufacture_no, dd.project_no, dd.model_no, dd.production_no) = a.batch_no and dd.is_delete = 0) as out_of_num");
  87 + $sysFailNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.status =".DeviceStatus::FAIL_AUTH." and dd.is_delete = 0 and dd.batch_id = a.id) as auth_fail_num");
  88 + $handleAuthFailNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.batch_id = a.id and dd.has_re_auth = 1 and dd.is_delete = 0) as handle_auth_fail_num");
85 89  
86 90 $batchModelFind = CreateBatchModel::find();
87 91 $batchModelFind->alias('a');
88   - $batchModelFind->select(['a.*','m.name as manufacture_name','pro.name as project_name','mo.name as model_name','prod.name as production_name', $hasAuthNumExpress, $noAuthNumExpress, $delNumExpress]);
  92 + $batchModelFind->select([
  93 + 'a.*',
  94 + 'm.name as manufacture_name','pro.name as project_name','mo.name as model_name','prod.name as production_name',
  95 + $totalNumExpress, $hasAuthNumExpress, $noAuthNumExpress, $delNumExpress, $outOfLimitExpress, $sysFailNumExpress, $handleAuthFailNumExpress
  96 + ]);
89 97 $batchModelFind->leftJoin(ManufacturerModel::tableName(). ' m', 'm.id = a.manufacture_id');
90 98 $batchModelFind->leftJoin(ProjectModel::tableName(). ' pro', 'pro.id = a.project_id');
91 99 $batchModelFind->leftJoin(ModelModel::tableName(). ' mo', 'mo.id = a.model_id');
... ... @@ -126,7 +134,7 @@ class CreateBatchRepository
126 134 * @param $batchId
127 135 * @return array|null|\yii\db\ActiveRecord
128 136 */
129   - static function getBatchInfo($batchId)
  137 + static function getBatchInfo($where)
130 138 {
131 139 $batchModelFind = CreateBatchModel::find();
132 140 $batchModelFind->alias('a');
... ... @@ -135,7 +143,7 @@ class CreateBatchRepository
135 143 $batchModelFind->leftJoin(ProjectModel::tableName(). ' pro', 'pro.id = a.project_id');
136 144 $batchModelFind->leftJoin(ModelModel::tableName(). ' mo', 'mo.id = a.model_id');
137 145 $batchModelFind->leftJoin(ProductionModel::tableName(). ' prod', 'prod.id = a.production_id');
138   - $batchModelFind->where(['a.id' => $batchId]);
  146 + $batchModelFind->where($where);
139 147 $batchModelFind->asArray();
140 148 $info = $batchModelFind->one();
141 149  
... ...