Commit 27252b60583893f65d5079a53d052b7008846fcb

Authored by xu
1 parent 4df7fbdd
Exists in master

1. F 序列号管理更正

app-api/controllers/AuthDeviceController.php
... ... @@ -73,7 +73,8 @@ class AuthDeviceController extends BaseController
73 73 return $e;
74 74 }
75 75 // 检测是否授权过了的设备
76   - $deviceModel = DeviceRepository::findOne(['device_id' => $deviceId]);
  76 + // 这里还得判读删除之后恢复的,状态是未授权
  77 + $deviceModel = DeviceRepository::findOne(['device_id' => $deviceId, 'is_delete' => 0]);
77 78 if ($deviceModel && DeviceStatus::HAS_AUTH == $deviceModel->status) {
78 79 $e->mac = $deviceModel->mac;
79 80 $e->serial_no = $deviceModel->serial_no;
... ...
app-ht/modules/datas/views/device/device-list.php
... ... @@ -43,7 +43,6 @@ $this->params['breadcrumbs'][] = $this->title;
43 43 </div>
44 44  
45 45 <div class="form-group col-sm-12">
46   -
47 46 <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label>
48 47 <div class="col-sm-4 form-inline">
49 48 <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"> -
... ... @@ -62,7 +61,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
62 61 </div>
63 62 </div>
64 63 <div class="panel" style="margin-bottom: 0">
65   - <div style="padding:10px ;20px;box-sizing: border-box">><b>厂商:</b><?=$gets['manufacture']?> <b>项目:</b><?=$gets['manufacture']?> <b>型号:</b><?=$gets['model']?> <b>生产日期:</b><?=$gets['production']?>
  64 + <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']?>
66 65 <b> 批次编号:</b><?=$gets['batch_no']?>
67 66 </div>
68 67 </div>
... ...
app-ht/modules/datas/views/device/index.php
... ... @@ -70,8 +70,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
70 70 <th width="10%">生产日期</th>
71 71 <th width="10%">生成总数</th>
72 72 <th width="8%">删除数</th>
73   - <th width="10%">授权总数</th>
74   - <th width="15%">授权失败数</th>
  73 + <th width="8%">授权总数</th>
  74 + <th width="8%">超出总数</th>
  75 + <th width="8%">授权失败数</th>
75 76 <th width="15%">未授权数</th>
76 77 </tr>
77 78 </thead>
... ... @@ -88,6 +89,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
88 89 <td style="padding:12px;"><a href="<?=Url::toRoute(['device/device-list','batch_id' => $item['id']])?>"><?= (isset($item["num"]) ? $item["num"] : "0") ?></a></td>
89 90 <td style="padding:12px;"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></td>
90 91 <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td>
  92 + <td>4</td>
91 93 <td style="padding:12px;"><?= (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?></td>
92 94 <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td>
93 95 </tr>
... ...
app-ht/modules/device/controllers/DeviceController.php
... ... @@ -43,6 +43,8 @@ class DeviceController extends BaseController
43 43 $startAuthAt = $request->get('start_auth_at');
44 44 $endAuthAt = $request->get('end_auth_at');
45 45  
  46 + $has_re_auth = $request->get('has_re_auth');
  47 +
46 48 $page = $request->get('page');
47 49 $where = [
48 50 'and',
... ... @@ -81,6 +83,9 @@ class DeviceController extends BaseController
81 83 if ($endAuthAt) {
82 84 $where[] = ['>=', 'a.auth_at', strtotime($endAuthAt) + 86400];
83 85 }
  86 + if ($has_re_auth) {
  87 + $where[] = ['=', 'a.has_re_auth', $has_re_auth];
  88 + }
84 89 if (isset($_GET['status']) && -1 != $status) {
85 90 $where[] = ['=', 'a.status', $status];
86 91 } else {
... ... @@ -112,6 +117,7 @@ class DeviceController extends BaseController
112 117 'end_apply_at' => $endApplyAt,
113 118 'start_auth_at' => $startAuthAt,
114 119 'end_auth_at' => $endAuthAt,
  120 + 'has_re_auth' => $has_re_auth,
115 121 'status' => $status
116 122 ];
117 123  
... ... @@ -174,7 +180,7 @@ class DeviceController extends BaseController
174 180 $where[] = ['>=', 'a.auth_at', strtotime($startAuthAt)];
175 181 }
176 182 if ($endAuthAt) {
177   - $where[] = ['>=', 'a.auth_at', strtotime($endAuthAt) + 86400];
  183 + $where[] = ['<=', 'a.auth_at', strtotime($endAuthAt) + 86400];
178 184 }
179 185 if (isset($_GET['status']) && -1 != $status) {
180 186 $where[] = ['=', 'a.status', $status];
... ... @@ -637,6 +643,23 @@ class DeviceController extends BaseController
637 643 }
638 644 }
639 645  
  646 + /**
  647 + * 恢复删除的设备
  648 + * @return string
  649 + */
  650 + public function actionRestoreDevice()
  651 + {
  652 + $req = Yii::$app->request;
  653 + $id = $req->post('id');
  654 + $e = new stdClass();
  655 + $e->success = false;
  656 + $e->message = 'fail';
  657 + $delDevice = DeviceRepository::findOne(['id' => $id, 'is_delete' => 1]);
  658 +
  659 +
  660 + return $this->renderJson($e);
  661 + }
  662 +
640 663 public function actionBatchIndex()
641 664 {
642 665  
... ...
app-ht/modules/device/views/device/auth-fail-index.php
... ... @@ -42,7 +42,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
42 42  
43 43 <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label>
44 44 <div class="col-sm-5 form-inline">
45   - <input type="text" class="form-control" id="start_apply_at" name="start_apply_at" value="<?php if (!empty($gets['start_apply_at'])){ echo $gets['start_apply_at'];} ?>" autocomplete="off"> - <input type="text" class="form-control" id="end_apply_at" name="end_apply_at" value="<?php if (!empty($gets['end_apply_at'])){ echo $gets['end_apply_at'];} ?>" autocomplete="off">
  45 + <input type="date" class="form-control" id="start_apply_at" name="start_apply_at" value="<?php if (!empty($gets['start_apply_at'])){ echo $gets['start_apply_at'];} ?>" autocomplete="off"> - <input type="date" class="form-control" id="end_apply_at" name="end_apply_at" value="<?php if (!empty($gets['end_apply_at'])){ echo $gets['end_apply_at'];} ?>" autocomplete="off">
46 46 </div>
47 47  
48 48 </div>
... ... @@ -59,8 +59,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
59 59 <table class="table table-striped table-bordered" id="brand-table">
60 60 <thead>
61 61 <tr>
62   - <th width="5%"><input type="checkbox" value="all" class="all_check"/></th>
63   - <th width="6%">ID</th>
  62 + <th width="4%"></th>
  63 + <th width="5%">ID</th>
64 64 <th width="15%">厂商</th>
65 65 <th width="6%">项目</th>
66 66 <th width="8%">设备型号</th>
... ... @@ -102,7 +102,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
102 102  
103 103 <td class="td-cls">
104 104 <button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>" data-action="edit">编辑</button> &nbsp;|&nbsp;
105   - <button class="btn btn-primary btn-sm btn_re_auth" aid="<?=$item['id'] ?>">授权</button>
  105 + <button class="btn btn-primary btn-sm btn_re_auth" aid="<?=$item['id'] ?>">处理</button>
106 106 </td>
107 107 </tr>
108 108 <?php endforeach; ?>
... ... @@ -115,6 +115,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
115 115 <?php } ?>
116 116 </tbody>
117 117 </table>
  118 + <div class="action-box">
  119 + <label><input type="checkbox" class="check-all" value="all" /> 本页全选 </label> <button class="btn btn-primary btn-sm btn_batch_auth" >批量处理</button>
  120 + </div>
118 121 </div>
119 122  
120 123 <div class="panel-footer">
... ...
app-ht/modules/device/views/device/delete-index.php
... ... @@ -82,15 +82,16 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
82 82 <li ><a style="padding: 10px 20px;" href="<?=Url::toRoute('/device/device/index')?>" >全部序列号</a></li>
83 83 <li class="active" ><a style="padding: 10px 12px;" href="<?=Url::toRoute('/device/device/delete-index')?>" >删除序列号</a></li>
84 84 </ul>
85   - </div>
  85 +
86 86 <table class="table table-striped table-bordered" id="brand-table">
87 87 <thead>
88 88 <tr>
  89 + <th >ID</th>
89 90 <th width="6%">ID</th>
90 91 <th width="6%">序列号</th>
91 92 <th width="8%">厂商</th>
92 93 <th width="6%">项目</th>
93   - <th width="8%">设备型号</th>
  94 + <th width="7%">设备型号</th>
94 95 <th width="6%">生产日期</th>
95 96 <th>MAC地址</th>
96 97 <th width="7%">设备ID</th>
... ... @@ -105,6 +106,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
105 106 <?php if ($deviceList) { ?>
106 107 <?php foreach ($deviceList as $item) : ?>
107 108 <tr>
  109 + <td><input type="checkbox" class="check-cls check-item" value="<?= $item['id'] ?>"/></td>
108 110 <td class="td-cls">
109 111 <?= $item['id'] ?>
110 112 </td>
... ... @@ -139,7 +141,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
139 141 <?= $statusList[$item['status']] ?>
140 142 </td>
141 143 <td class="td-cls">
142   - <button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>" data-action="edit">编辑</button>
  144 + <button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>" data-action="edit">编辑</button> &nbsp;|&nbsp;
  145 + <button class="btn btn-warning btn-sm btn_restore" aid="<?=$item['id'] ?>">恢复</button>
143 146 </td>
144 147 </tr>
145 148 <?php endforeach; ?>
... ... @@ -152,6 +155,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
152 155 <?php } ?>
153 156 </tbody>
154 157 </table>
  158 + <div class="action-box">
  159 + <label><input type="checkbox" class="check-all" value="all" /> 本页全选 </label> <button class="btn btn-primary btn-sm btn_batch_auth" >批量恢复</button>
  160 + </div>
155 161 </div>
156 162  
157 163 <div class="panel-footer">
... ... @@ -167,6 +173,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
167 173 <script>
168 174 var authURL = "<?=Url::toRoute('/device/device/auth-device')?>";
169 175 var delURL = "<?=Url::toRoute('/device/device/del-device')?>";
  176 + var restoreURL = "<?=Url::toRoute('/device/device/restore-device')?>";
170 177 var doEditURL = "<?=Url::toRoute('/device/device/do-edit')?>";
171 178 $(function () {
172 179  
... ... @@ -216,6 +223,10 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
216 223  
217 224 })
218 225  
  226 + $('.btn_restore').click(function(){
  227 +
  228 + })
  229 +
219 230  
220 231 });
221 232 </script>
222 233 \ No newline at end of file
... ...
app-ht/modules/device/views/device/index.php
... ... @@ -48,13 +48,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
48 48 <div class="col-sm-2 form-inline">
49 49 <input type="text" class="form-control" id="manufacture" name="manufacture" value="<?php if (!empty($gets['manufacture'])){ echo $gets['manufacture'];} ?>" autocomplete="off">
50 50 </div>
51   - <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label>
52   - <div class="col-sm-5 form-inline">
53   - <input type="date" class="form-control" id="start_apply_at" name="start_apply_at" value="<?php if (!empty($gets['start_apply_at'])){ echo $gets['start_apply_at'];} ?>" autocomplete="off"> - <input type="date" class="form-control" id="end_apply_at" name="end_apply_at" value="<?php if (!empty($gets['end_apply_at'])){ echo $gets['end_apply_at'];} ?>" autocomplete="off">
54   - </div>
55   - </div>
56   -
57   - <div class="form-group col-sm-12">
58 51 <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label>
59 52 <div class="col-sm-2 form-inline">
60 53 <input type="text" class="form-control" id="mac" name="mac" value="<?php if (!empty($gets['mac'])){ echo $gets['mac'];} ?>" autocomplete="off">
... ... @@ -63,10 +56,26 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
63 56 <div class="col-sm-2 form-inline">
64 57 <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">
65 58 </div>
  59 + </div>
  60 + <div class="form-group col-sm-12">
  61 + <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label>
  62 + <div class="col-sm-4 form-inline">
  63 + <input type="date" class="form-control" id="start_apply_at" name="start_apply_at" value="<?php if (!empty($gets['start_apply_at'])){ echo $gets['start_apply_at'];} ?>" autocomplete="off"> - <input type="date" class="form-control" id="end_apply_at" name="end_apply_at" value="<?php if (!empty($gets['end_apply_at'])){ echo $gets['end_apply_at'];} ?>" autocomplete="off">
  64 + </div>
66 65 <label for="auth_at" class="col-sm-1 control-label text-right">授权时间:</label>
67   - <div class="col-sm-5 form-inline">
  66 + <div class="col-sm-4 form-inline">
68 67 <input type="date" class="form-control" id="start_auth_at" name="start_auth_at" value="<?php if (!empty($gets['start_auth_at'])){ echo $gets['start_auth_at'];} ?>" autocomplete="off"> - <input type="date" class="form-control" id="end_auth_at" name="end_auth_at" value="<?php if (!empty($gets['end_auth_at'])){ echo $gets['end_auth_at'];} ?>" autocomplete="off">
69 68 </div>
  69 +
  70 +
  71 + <label for="auth_at" class="col-sm-1 control-label text-right">处理:</label>
  72 + <div class="col-sm-1 form-inline">
  73 + <select name="has_re_auth" class="form-control">
  74 + <option value="">全部</option>
  75 + <option value="1" <?php if(1 ==$gets['has_re_auth']) {echo "selected";}?>>已处理</option>
  76 + <option value="2" <?php if(2 ==$gets['has_re_auth']) {echo "selected";}?>>未处理</option>
  77 + </select>
  78 + </div>
70 79 </div>
71 80  
72 81 <div class="form-group col-sm-12" style="text-align: center;">
... ... @@ -82,12 +91,13 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
82 91 <li class="active" ><a style="padding: 10px 20px;" href="<?=Url::toRoute('/device/device/index')?>" >全部序列号</a></li>
83 92 <li ><a style="padding: 10px 12px;" href="<?=Url::toRoute('/device/device/delete-index')?>" >删除序列号</a></li>
84 93 </ul>
85   - </div>
  94 +
86 95 <table class="table table-striped table-bordered" id="brand-table">
87 96 <thead>
88 97 <tr>
  98 + <th></th>
89 99 <th width="6%">ID</th>
90   - <th width="6%">序列号</th>
  100 + <th width="5%">序列号</th>
91 101 <th width="8%">厂商</th>
92 102 <th width="6%">项目</th>
93 103 <th width="8%">设备型号</th>
... ... @@ -105,6 +115,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
105 115 <?php if ($deviceList) { ?>
106 116 <?php foreach ($deviceList as $item) : ?>
107 117 <tr>
  118 + <td><input type="checkbox" class="check-cls check-item" value="<?= $item['id'] ?>"/></td>
108 119 <td class="td-cls">
109 120 <?= $item['id'] ?>
110 121 </td>
... ... @@ -139,9 +150,12 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
139 150 <?= $statusList[$item['status']] ?>
140 151 </td>
141 152 <td class="td-cls">
142   - <button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>" data-action="edit">编辑</button> &nbsp;|&nbsp;
143   - <?php if(DeviceStatus::HAS_AUTH != $item['status']){?> <button class="btn btn-primary btn-sm btn_auth" aid="<?=$item['id'] ?>">授权</button> &nbsp;|&nbsp; <?php }?>
144   - <button class="btn btn-danger btn-sm btn_del" aid="<?=$item['id'] ?>">删除</button>
  153 + <button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>" data-action="edit">编辑</button>
  154 + <?php if(DeviceStatus::HAS_AUTH != $item['status']){?>&nbsp;|&nbsp;<button class="btn btn-primary btn-sm btn_auth" aid="<?=$item['id'] ?>">授权</button> <?php }?>
  155 + <?php if(DeviceStatus::HAS_AUTH == $item['status']) :?>
  156 + &nbsp;|&nbsp;
  157 + <button class="btn btn-danger btn-sm btn_del" aid="<?=$item['id'] ?>">删除</button>
  158 + <?php endif;?>
145 159 </td>
146 160 </tr>
147 161 <?php endforeach; ?>
... ... @@ -154,8 +168,12 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
154 168 <?php } ?>
155 169 </tbody>
156 170 </table>
  171 + <div class="action-box">
  172 + <label><input type="checkbox" class="check-all" value="all" /> 本页全选 </label> <button class="btn btn-primary btn-sm btn_batch_auth" >批量授权</button> <button class="btn btn-danger btn-sm btn_batch_del" >批量删除</button>
  173 + </div>
157 174 </div>
158 175  
  176 +
159 177 <div class="panel-footer">
160 178 <div class="hqy-panel-pager">
161 179 <?= LinkPager::widget([
... ... @@ -236,11 +254,15 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
236 254 }
237 255  
238 256 }, 'json')
239   -
240 257 }
241 258  
242 259 })
243 260  
  261 + $('.check-all').click(function(e){
  262 + var checkVal = $(this).prop('checked');
  263 + $('.check-item').prop('checked', checkVal)
  264 +
  265 + })
244 266  
245 267 });
246 268 </script>
247 269 \ No newline at end of file
... ...
domain/device/Device.php
... ... @@ -62,7 +62,7 @@ class Device
62 62 if (($count *1) >= ($batchModel->num * 1)) {
63 63 // 超过了限制数,记录到另外一个表里面
64 64 // to do 记录到表里面
65   - $failRecord = DeviceAuthFailRepository::findOne(['device_id' => $deviceId]);
  65 + $failRecord = DeviceAuthFailRepository::findOne(['device_id' => $deviceId, 'is_delete' => 0]);
66 66 if (!$failRecord) {
67 67 $item = [
68 68 'manufacture_no' => $manufactureNo,
... ... @@ -100,6 +100,15 @@ class Device
100 100 $e->mac = $deviceModel->mac;
101 101 } elseif (DeviceStatus::FAIL_AUTH == $deviceModel->status) {
102 102 $e->message = '授权失败';
  103 + } elseif (DeviceStatus::NO_AUTH == $deviceModel->status) {
  104 + // 删除之后恢复的数据
  105 + $deviceModel->status = DeviceStatus::HAS_AUTH;
  106 + $deviceModel->auth_at = $tt;
  107 + $deviceModel->save();
  108 + $e->message = '授权成功';
  109 + $e->success = true;
  110 + $e->serial_no = $deviceModel->serial_no;
  111 + $e->mac = $deviceModel->mac;
103 112 } else {
104 113 $e->message = '授权失败!';
105 114 }
... ...