Commit d1ded260ab0c3a32398102ee4decfdb72e049315
1 parent
6e80ba68
Exists in
master
1. F 版本管理列表增加显示项目和型号
2. F 版本管理同一个厂商+ 项目+ 型号的不能增加多一个版本,也不能发布多一个版本, 必须先取消版本 3. A 数据统计那里增加可以导出删除的设备 4. A 可以按批次追加新的序列号
Showing
16 changed files
with
711 additions
and
80 deletions
Show diff stats
.gitignore
app-ht/modules/datas/controllers/DeviceController.php
... | ... | @@ -102,10 +102,28 @@ class DeviceController extends BaseController |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | + * @return string | |
106 | + */ | |
107 | + public function actionDeleteDeviceList() | |
108 | + { | |
109 | + $params = $this->batchDataList(1,1); | |
110 | + return $this->render('delete-device-list', $params); | |
111 | + } | |
112 | + | |
113 | + /** | |
114 | + * @return string | |
115 | + */ | |
116 | + public function actionBatchDeleteExport() | |
117 | + { | |
118 | + $params = $this->batchDataList(0,1); | |
119 | + return $this->renderPartial('batch-delete-export', $params); | |
120 | + } | |
121 | + | |
122 | + /** | |
105 | 123 | * @param $type |
106 | 124 | * @return mixed |
107 | 125 | */ |
108 | - private function batchDataList($type) | |
126 | + private function batchDataList($type, $isDelete = 0) | |
109 | 127 | { |
110 | 128 | $request = Yii::$app->request; |
111 | 129 | $serialNo = $request->get('serial_no'); |
... | ... | @@ -121,7 +139,7 @@ class DeviceController extends BaseController |
121 | 139 | $page = $request->get('page'); |
122 | 140 | $where = [ |
123 | 141 | 'and', |
124 | - ['=','a.is_delete', 0], | |
142 | + ['=','a.is_delete', $isDelete], | |
125 | 143 | ['=','a.batch_id', $batchId] |
126 | 144 | ]; |
127 | 145 | if (!empty($serialNo)) { | ... | ... |
app-ht/modules/datas/views/device/batch-delete-export.php
0 → 100644
... | ... | @@ -0,0 +1,79 @@ |
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 | + <th width="10%">操作</th> | |
36 | + </tr> | |
37 | + </thead> | |
38 | + <tbody> | |
39 | + <?php foreach ($deviceList as $key => $item) : ?> | |
40 | + <tr> | |
41 | + <td class="td-cls"> | |
42 | + <?= $item['batch_no'] ?> | |
43 | + </td> | |
44 | + <td class="td-cls"> | |
45 | + <div class="cell-cls"><?= $item['serial_no'] ?></div> | |
46 | + </td> | |
47 | + <td class="td-cls"> | |
48 | + <?= $item['mac'] ?> | |
49 | + </td> | |
50 | + <td class="td-cls"> | |
51 | + <?= $item['device_id']? $item['device_id']:'暂无'?> | |
52 | + </td> | |
53 | + <td class="td-cls"> | |
54 | + <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?> | |
55 | + </td> | |
56 | + <td class="td-cls"> | |
57 | + <?= $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?> | |
58 | + </td> | |
59 | + <td class="td-cls"> | |
60 | + <?= $statusList[$item['status']] ?> | |
61 | + </td> | |
62 | + <td> | |
63 | + 已删除 | |
64 | + </td> | |
65 | + </tr> | |
66 | + <?php | |
67 | + $cnt++; | |
68 | + if (1000 == $cnt) { //刷新一下输出buffer,防止由于数据过多造成问题 | |
69 | + ob_flush(); | |
70 | + flush(); | |
71 | + $cnt = 0; | |
72 | + } | |
73 | + ?> | |
74 | + <?php endforeach; ?> | |
75 | + </tbody> | |
76 | + </table> | |
77 | +</div> | |
78 | +</body> | |
79 | +</html> | |
0 | 80 | \ No newline at end of file | ... | ... |
app-ht/modules/datas/views/device/delete-device-list.php
0 → 100644
... | ... | @@ -0,0 +1,164 @@ |
1 | +<?php | |
2 | +use yii\helpers\Url; | |
3 | +use app\ht\widgets\LinkPager; | |
4 | +use domain\device\DeviceStatus; | |
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_id" value="<?=$gets['batch_id']?>" /> | |
19 | + <div class="form-group col-sm-12"> | |
20 | + <label for="serial_no" class="col-sm-1 control-label text-right">序列号:</label> | |
21 | + <div class="col-sm-2 form-inline"> | |
22 | + <input type="text" class="form-control" id="serial_no" name="serial_no" value="<?php if (!empty($gets['serial_no'])){ echo $gets['serial_no'];} ?>" autocomplete="off"> | |
23 | + </div> | |
24 | + <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label> | |
25 | + <div class="col-sm-2 form-inline"> | |
26 | + <input type="text" class="form-control" id="mac" name="mac" value="<?php if (!empty($gets['mac'])){ echo $gets['mac'];} ?>" autocomplete="off"> | |
27 | + </div> | |
28 | + <label for="device_id" class="col-sm-1 control-label text-right">设备ID:</label> | |
29 | + <div class="col-sm-2 form-inline"> | |
30 | + <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"> | |
31 | + </div> | |
32 | + | |
33 | + <label for="status" class="col-sm-1 control-label text-right">状态:</label> | |
34 | + <div class="col-sm-2 form-inline"> | |
35 | + <select id="status" class="form-control" name="status"> | |
36 | + <option value="-1">全部</option> | |
37 | + <?php foreach($statusList as $k => $v):?> | |
38 | + <option value="<?=$k?>" <?php if($k == $gets['status']): ?>selected<?php endif; ?>><?=$v?></option> | |
39 | + <?php endforeach;?> | |
40 | + </select> | |
41 | + | |
42 | + </div> | |
43 | + </div> | |
44 | + | |
45 | + <div class="form-group col-sm-12"> | |
46 | + <label for="apply_at" class="col-sm-1 control-label text-right">申请时间:</label> | |
47 | + <div class="col-sm-4 form-inline"> | |
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"> - | |
49 | + <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"> | |
50 | + </div> | |
51 | + <label for="auth_at" class="col-sm-1 control-label text-right">授权时间:</label> | |
52 | + <div class="col-sm-4 form-inline"> | |
53 | + <input type="date" class="form-control" style="width:140px" id="start_auth_at" name="start_auth_at" value="<?php if (!empty($gets['start_auth_at'])){ echo $gets['start_auth_at'];} ?>" autocomplete="off"> - | |
54 | + <input type="date" class="form-control" style="width:140px" id="end_auth_at" name="end_auth_at" value="<?php if (!empty($gets['end_auth_at'])){ echo $gets['end_auth_at'];} ?>" autocomplete="off"> | |
55 | + </div> | |
56 | + </div> | |
57 | + <div class="form-group col-sm-12" style="text-align: center;"> | |
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> | |
60 | + </div> | |
61 | + </form> | |
62 | + </div> | |
63 | +</div> | |
64 | +<div class="panel" style="margin-bottom: 0"> | |
65 | + <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 | + <b> 批次编号:</b><?=$gets['batch_no']?> | |
67 | + </div> | |
68 | +</div> | |
69 | +<div class="panel panel-default"> | |
70 | + <div class="panel-body"> | |
71 | + <table class="table table-striped table-bordered" id="brand-table"> | |
72 | + <thead> | |
73 | + <tr> | |
74 | + <th width="6%">ID</th> | |
75 | + <th width="15%">序列号</th> | |
76 | + <th>MAC地址</th> | |
77 | + <th width="12%">设备ID</th> | |
78 | + <th width="12%">申请时间</th> | |
79 | + <th width="12%">授权时间</th> | |
80 | + <th width="12%">状态</th> | |
81 | + <th width="12%">操作</th> | |
82 | + </tr> | |
83 | + </thead> | |
84 | + | |
85 | + <tbody> | |
86 | + <?php if ($deviceList) { ?> | |
87 | + <?php foreach ($deviceList as $item) : ?> | |
88 | + <tr> | |
89 | + <td class="td-cls"> | |
90 | + <?= $item['id'] ?> | |
91 | + </td> | |
92 | + <td class="td-cls"> | |
93 | + <div class="cell-cls"><?= $item['serial_no'] ?></div> | |
94 | + </td> | |
95 | + <td class="td-cls"> | |
96 | + <div class="cell-cls edit_mac edit_mac_<?=$item['id']?>" data-id="<?=$item['id']?>" data="<?= $item['mac'] ?>"><?= $item['mac'] ?></div> | |
97 | + </td> | |
98 | + <td class="td-cls"> | |
99 | + <div class="edit_device edit_device_<?=$item['id']?>" data-id="<?=$item['id']?>" data="<?=$item['device_id']?>"><?= $item['device_id']? $item['device_id']:'暂无'?></div> | |
100 | + </td> | |
101 | + <td class="td-cls"> | |
102 | + <?= $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?> | |
103 | + </td> | |
104 | + <td class="td-cls"> | |
105 | + <?= $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?> | |
106 | + </td> | |
107 | + <td class="td-cls"> | |
108 | + <?= $statusList[$item['status']] ?> | |
109 | + </td> | |
110 | + <td> | |
111 | + 已删除 | |
112 | + </td> | |
113 | + | |
114 | + </tr> | |
115 | + <?php endforeach; ?> | |
116 | + <?php } else { ?> | |
117 | + <tr> | |
118 | + <td colspan="7"> | |
119 | + <center>暂无记录</center> | |
120 | + </td> | |
121 | + </tr> | |
122 | + <?php } ?> | |
123 | + </tbody> | |
124 | + </table> | |
125 | + </div> | |
126 | + | |
127 | + <div class="panel-footer"> | |
128 | + <div class="hqy-panel-pager"> | |
129 | + <?= LinkPager::widget([ | |
130 | + 'pagination' => $pages, | |
131 | + ]); ?> | |
132 | + <div class="clearfix"></div> | |
133 | + </div> | |
134 | + </div> | |
135 | +</div> | |
136 | + | |
137 | +<script> | |
138 | + window.queryParams = function(params) { | |
139 | + $("#search-form").find('input[name]').each(function () { | |
140 | + var val = $(this).val(); | |
141 | + var name = $(this).attr('name'); | |
142 | + if(val){ | |
143 | + params[name] = val; | |
144 | + } | |
145 | + }); | |
146 | + return params; | |
147 | + } | |
148 | + $(document).ready(function () { | |
149 | + $('#btn-export').click(function(e){ | |
150 | + var params = {}; | |
151 | + window.queryParams(params); | |
152 | + | |
153 | + $strQuery = "?"; | |
154 | + if (params) { | |
155 | + for (var p in params) { | |
156 | + $strQuery += p + "=" + params[p] + "&"; | |
157 | + } | |
158 | + } | |
159 | + $strQuery = $strQuery.substring(0, $strQuery.length-1); | |
160 | + window.location.href = "batch-delete-export" + $strQuery; | |
161 | + return false; | |
162 | + }) | |
163 | + }); | |
164 | +</script> | |
0 | 165 | \ No newline at end of file | ... | ... |
app-ht/modules/datas/views/device/index.php
... | ... | @@ -88,7 +88,7 @@ $this->params['breadcrumbs'][] = $this->title; |
88 | 88 | <td style="padding:12px;"><?= (isset($item["model_name"]) ? $item["model_name"] : "") ?></td> |
89 | 89 | <td style="padding:12px;"><?= (isset($item["production_name"]) ? $item["production_name"] : "") ?></td> |
90 | 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> |
91 | - <td style="padding:12px;"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></td> | |
91 | + <td style="padding:12px;"><a href="<?=Url::toRoute(['device/delete-device-list','batch_id' => $item['id']])?>"><?= (isset($item["del_num"]) ? $item["del_num"] : "0") ?></a></td> | |
92 | 92 | <td style="padding:12px;"><?= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?></td> |
93 | 93 | <td style="padding:12px;"><?= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?></td> |
94 | 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> | ... | ... |
app-ht/modules/device/controllers/DeviceController.php
... | ... | @@ -264,7 +264,7 @@ class DeviceController extends BaseController |
264 | 264 | return $this->renderJson($e); |
265 | 265 | } |
266 | 266 | if (1 * $num > 30000) { |
267 | - $e->message = '数量不能超过3万0'; | |
267 | + $e->message = '数量不能超过3万'; | |
268 | 268 | return $this->renderJson($e); |
269 | 269 | } |
270 | 270 | |
... | ... | @@ -445,7 +445,10 @@ class DeviceController extends BaseController |
445 | 445 | return $this->renderJson($e); |
446 | 446 | } |
447 | 447 | |
448 | - | |
448 | + /** | |
449 | + * 批量授权 | |
450 | + * @return string | |
451 | + */ | |
449 | 452 | public function actionBatchAuthDevice() |
450 | 453 | { |
451 | 454 | $req = Yii::$app->request; |
... | ... | @@ -495,6 +498,7 @@ class DeviceController extends BaseController |
495 | 498 | } |
496 | 499 | |
497 | 500 | /** |
501 | + * 删除设备 | |
498 | 502 | * @return string |
499 | 503 | */ |
500 | 504 | public function actionDelDevice() |
... | ... | @@ -526,6 +530,7 @@ class DeviceController extends BaseController |
526 | 530 | } |
527 | 531 | |
528 | 532 | /** |
533 | + * 批量删除 | |
529 | 534 | * @return string |
530 | 535 | */ |
531 | 536 | public function actionBatchDelDevice() |
... | ... | @@ -570,6 +575,7 @@ class DeviceController extends BaseController |
570 | 575 | } |
571 | 576 | |
572 | 577 | /** |
578 | + * 编辑 | |
573 | 579 | * @return string |
574 | 580 | */ |
575 | 581 | public function actionDoEdit() |
... | ... | @@ -993,9 +999,92 @@ class DeviceController extends BaseController |
993 | 999 | return $this->renderJson($e); |
994 | 1000 | } |
995 | 1001 | |
996 | - public function actionBatchIndex() | |
1002 | + /** | |
1003 | + * 追加生成新序列号 | |
1004 | + * @return string | |
1005 | + * @throws \yii\db\Exception | |
1006 | + */ | |
1007 | + public function actionAppendSerialNo() | |
1008 | + { | |
1009 | + $req = Yii::$app->request; | |
1010 | + $batchId = $req->post('batch_id'); | |
1011 | + $appendNum = $req->post('append_num'); | |
1012 | + $e = new stdClass(); | |
1013 | + $e->success = false; | |
1014 | + $e->message = 'fail'; | |
1015 | + if (empty($appendNum)) { | |
1016 | + $e->message = '追加数量不能为0'; | |
1017 | + return $this->renderJson($e); | |
1018 | + } | |
1019 | + | |
1020 | + $batchModel = CreateBatchRepository::findOne(['id' => $batchId]); | |
1021 | + if (empty($batchModel)) { | |
1022 | + $e->message = '未找到批次'; | |
1023 | + return $this->renderJson($e); | |
1024 | + } | |
1025 | + $trans = Yii::$app->getDb()->beginTransaction(); | |
1026 | + try { | |
1027 | + | |
1028 | + $batchModel->num = $batchModel->num + $appendNum; | |
1029 | + $batchModel->save(); | |
1030 | + | |
1031 | + $batchNo = $batchModel->batch_no; | |
1032 | + $batchId = $batchModel->id; | |
1033 | + $saveData = []; | |
1034 | + $tt = time(); | |
1035 | + $exitDeviceModel = DeviceModel::find(); | |
1036 | + $exitDeviceModel->where(['batch_id' => $batchId]); | |
1037 | + $exitDeviceModel->orderBy('serial_no desc'); | |
1038 | + $exitDevice = $exitDeviceModel->one(); | |
1039 | + $no1 = 0; | |
1040 | + if ($exitDevice) { | |
1041 | + $numNo = mb_substr($exitDevice->serial_no, -4); | |
1042 | + $no1 = hexdec($numNo); | |
1043 | + } | |
1044 | + | |
1045 | + for ($i = 1 ; $i <= $appendNum; $i++) { | |
1046 | + $saveData[] = [ | |
1047 | + strtoupper($batchNo.sprintf('%04X', ($no1 * 1) + $i)), | |
1048 | + Utils::macGenerate(), | |
1049 | + 0, | |
1050 | + $batchId, | |
1051 | + 0, | |
1052 | + 0, | |
1053 | + 0, | |
1054 | + 0, | |
1055 | + $tt, | |
1056 | + $tt | |
1057 | + ]; | |
1058 | + | |
1059 | + } | |
1060 | + $res = Yii::$app->db->createCommand()->batchInsert(DeviceModel::tableName(), | |
1061 | + array('serial_no','mac','status','batch_id','is_delete','has_re_auth','apply_at','auth_at','created_at','updated_at'), | |
1062 | + $saveData)->execute();//执行批量添加 | |
1063 | + $trans->commit(); | |
1064 | + $e->success = true; | |
1065 | + $e->message = 'ok'; | |
1066 | + | |
1067 | + return $this->renderJson($e); | |
1068 | + } catch (Exception $exception) { | |
1069 | + $trans->rollBack(); | |
1070 | + $e->message = '生成失败'; | |
1071 | + | |
1072 | + return $this->renderJson($e); | |
1073 | + } | |
1074 | + } | |
1075 | + | |
1076 | + /** | |
1077 | + * @return string | |
1078 | + */ | |
1079 | + public function actionGetBatchSelect() | |
997 | 1080 | { |
1081 | + $e = new stdClass(); | |
1082 | + $e->success = false; | |
1083 | + $where = ['>', 'a.id', 0]; | |
1084 | + $batchList = CreateBatchRepository::getBatchSelectList($where); | |
1085 | + $e->list = $batchList; | |
1086 | + $e->success = true; | |
998 | 1087 | |
999 | - return $this->render('batch-index'); | |
1088 | + return $this->renderJson($e); | |
1000 | 1089 | } |
1001 | 1090 | } |
1002 | 1091 | \ No newline at end of file | ... | ... |
app-ht/modules/device/views/device/createDevice.php
... | ... | @@ -18,57 +18,100 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css'); |
18 | 18 | </style> |
19 | 19 | <div class="panel panel-default"> |
20 | 20 | <div class="panel-body form-inline create-div"> |
21 | - <form action="" method="get" id="create-form" class="filter-form"> | |
22 | - <div class="form-group col-sm-12"> | |
23 | - <label for="manufacture" class="col-sm-4 control-label text-right">厂商:</label> | |
24 | - <div class="col-sm-4 form-inline"> | |
25 | - <select class="form-control full-width searchInput" id="manufacture" name="manufacture"> | |
26 | 21 | |
27 | - </select> | |
22 | + <ul class="nav nav-tabs" role="tablist"> | |
23 | + <li role="presentation" class="active"><a href="#new" aria-controls="new" role="tab" data-toggle="tab">新创建</a></li> | |
24 | + <li role="presentation"><a href="#append" aria-controls="append" role="tab" data-toggle="tab">追加创建</a></li> | |
25 | + </ul> | |
28 | 26 | |
29 | - </div> | |
30 | - <div class="col-sm-4"><a href="<?=Url::toRoute('/manufacturer/manufacturer/create')?>">+创建厂商</a></div> | |
31 | - </div> | |
32 | - <div class="form-group col-sm-12"> | |
33 | - <label for="project" class="col-sm-4 control-label text-right">项目名:</label> | |
34 | - <div class="col-sm-4 form-inline"> | |
35 | - <select class="form-control full-width searchInput" id="project" name="project"> | |
27 | + <!-- Tab panes --> | |
28 | + <div class="tab-content"> | |
29 | + <div role="tabpanel" class="tab-pane active" id="new"> | |
30 | + <form action="" method="get" id="create-form" class="filter-form"> | |
31 | + <div class="form-group col-sm-12"> | |
32 | + <label for="manufacture" class="col-sm-4 control-label text-right">厂商:</label> | |
33 | + <div class="col-sm-4 form-inline"> | |
34 | + <select class="form-control full-width select-cls" id="manufacture" name="manufacture"> | |
36 | 35 | |
37 | - </select> | |
38 | - </div> | |
39 | - <div class="col-sm-4"><a href="<?=Url::toRoute('/project/project/create')?>">+创建项目</a></div> | |
36 | + </select> | |
40 | 37 | |
41 | - </div> | |
42 | - <div class="form-group col-sm-12"> | |
43 | - <label for="model" class="col-sm-4 control-label text-right">设备型号:</label> | |
44 | - <div class="col-sm-4 form-inline"> | |
45 | - <select class="form-control full-width searchInput" id="model" name="model"> | |
38 | + </div> | |
39 | + <div class="col-sm-4"><a href="<?=Url::toRoute('/manufacturer/manufacturer/create')?>">+创建厂商</a></div> | |
40 | + </div> | |
41 | + <div class="form-group col-sm-12"> | |
42 | + <label for="project" class="col-sm-4 control-label text-right">项目名:</label> | |
43 | + <div class="col-sm-4 form-inline"> | |
44 | + <select class="form-control full-width select-cls" id="project" name="project"> | |
46 | 45 | |
47 | - </select> | |
48 | - </div> | |
49 | - <div class="col-sm-4"><a href="<?=Url::toRoute('/model/model/create')?>">+创建型号</a></div> | |
50 | - </div> | |
51 | - <div class="form-group col-sm-12"> | |
52 | - <label for="production" class="col-sm-4 control-label text-right">生产日期:</label> | |
53 | - <div class="col-sm-4 form-inline"> | |
54 | - <select class="form-control full-width searchInput" id="production" name="production"> | |
46 | + </select> | |
47 | + </div> | |
48 | + <div class="col-sm-4"><a href="<?=Url::toRoute('/project/project/create')?>">+创建项目</a></div> | |
49 | + | |
50 | + </div> | |
51 | + <div class="form-group col-sm-12"> | |
52 | + <label for="model" class="col-sm-4 control-label text-right">设备型号:</label> | |
53 | + <div class="col-sm-4 form-inline"> | |
54 | + <select class="form-control full-width select-cls" id="model" name="model"> | |
55 | + | |
56 | + </select> | |
57 | + </div> | |
58 | + <div class="col-sm-4"><a href="<?=Url::toRoute('/model/model/create')?>">+创建型号</a></div> | |
59 | + </div> | |
60 | + <div class="form-group col-sm-12"> | |
61 | + <label for="production" class="col-sm-4 control-label text-right">生产日期:</label> | |
62 | + <div class="col-sm-4 form-inline"> | |
63 | + <select class="form-control full-width select-cls" id="production" name="production"> | |
64 | + | |
65 | + </select> | |
66 | + </div> | |
67 | + <div class="col-sm-4"><a href="<?=Url::toRoute('/production/production/create')?>">+生产日期</a></div> | |
68 | + </div> | |
69 | + <div class="form-group col-sm-12"> | |
70 | + <label for="batch_no" class="col-sm-4 control-label text-right">编码预览:</label> | |
71 | + <div class="col-sm-4 form-inline"> | |
72 | + <span id="preview_batch_no">----</span> | |
73 | + </div> | |
74 | + </div> | |
75 | + <div class="form-group col-sm-12"> | |
76 | + <label for="production" class="col-sm-4 control-label text-right">数量:</label> | |
77 | + <div class="col-sm-4 form-inline"> | |
78 | + <input type="number" class="form-control full-width" id="num" name="num" value="" autocomplete="off"> | |
79 | + </div> | |
80 | + </div> | |
81 | + | |
82 | + <div class="form-group col-sm-12" style="text-align: center;"> | |
83 | + <div><button type="submit" class="btn btn-primary font-1" id="createDeviceBtn">创建</button></div> | |
84 | + </div> | |
85 | + </form> | |
55 | 86 | |
56 | - </select> | |
57 | 87 | </div> |
58 | - <div class="col-sm-4"><a href="<?=Url::toRoute('/production/production/create')?>">+生产日期</a></div> | |
59 | - </div> | |
60 | 88 | |
61 | - <div class="form-group col-sm-12"> | |
62 | - <label for="production" class="col-sm-4 control-label text-right">数量:</label> | |
63 | - <div class="col-sm-4 form-inline"> | |
64 | - <input type="number" class="form-control full-width" id="num" name="num" value="" autocomplete="off"> | |
89 | + | |
90 | + <div role="tabpanel" class="tab-pane" id="append"> | |
91 | + <form action="" id="append-form" class="filter-form"> | |
92 | + <div class="form-group col-sm-12"> | |
93 | + <label for="batch_id" class="col-sm-4 control-label text-right">批次编码:</label> | |
94 | + <div class="col-sm-4 form-inline"> | |
95 | + <select class="form-control full-width batch-select-cls" id="batch_id" name="batch_id"></select> | |
96 | + </div> | |
97 | + </div> | |
98 | + <div class="form-group col-sm-12"> | |
99 | + <label for="append_num" class="col-sm-4 control-label text-right">追加数量:</label> | |
100 | + <div class="col-sm-4 form-inline"> | |
101 | + <input type="number" class="form-control full-width" id="append_num" name="append_num" value="" autocomplete="off"> | |
102 | + </div> | |
103 | + </div> | |
104 | + | |
105 | + <div class="form-group col-sm-12" style="text-align: center;"> | |
106 | + <div><button type="submit" class="btn btn-primary font-1" id="appendDeviceBtn">追加创建</button></div> | |
107 | + </div> | |
108 | + </form> | |
65 | 109 | </div> |
66 | - </div> | |
67 | 110 | |
68 | - <div class="form-group col-sm-12" style="text-align: center;"> | |
69 | - <div><button type="submit" class="btn btn-primary font-1" id="createDeviceBtn">创建</button></div> | |
70 | 111 | </div> |
71 | - </form> | |
112 | + | |
113 | + | |
114 | + | |
72 | 115 | </div> |
73 | 116 | |
74 | 117 | </div> |
... | ... | @@ -78,6 +121,8 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css'); |
78 | 121 | <script type="text/javascript"> |
79 | 122 | var searchItemUrl = "<?=Url::toRoute('/device/device/batch-item')?>"; |
80 | 123 | var saveUrl = "<?=Url::toRoute('/device/device/do-create-device')?>"; |
124 | + var getBatchSelectUrl = "<?=Url::toRoute('/device/device/get-batch-select')?>"; | |
125 | + var appendSerialUrl = "<?=Url::toRoute('/device/device/append-serial-no')?>"; | |
81 | 126 | $(function() { |
82 | 127 | |
83 | 128 | function selectAll(id) { |
... | ... | @@ -99,6 +144,56 @@ $(function() { |
99 | 144 | selectAll('model'); |
100 | 145 | selectAll('production'); |
101 | 146 | |
147 | + // 追加选批次 | |
148 | + function getBatchSelectList() { | |
149 | + $.post(getBatchSelectUrl, {type:0}, function(res) { | |
150 | + if(res.list.length > 0) { | |
151 | + var wrapper = '<option value="">请选择</option>'; | |
152 | + $.each(res.list, function(i,n){ | |
153 | + wrapper = wrapper + '<option value="'+ n.id+'">'+ n.batch_no+' | '+ n.manufacture + '-' + n.project +'-'+ n.model +'</option>'; | |
154 | + }) | |
155 | + $('#batch_id').html(wrapper); | |
156 | + $('#batch_id').comboSelect(); | |
157 | + } | |
158 | + | |
159 | + }, 'json') | |
160 | + } | |
161 | + getBatchSelectList(); | |
162 | + | |
163 | + $('.select-cls').change(function(e){ | |
164 | + var manufacture = $('#manufacture').val(); | |
165 | + var project = $('#project').val(); | |
166 | + var model = $('#model').val(); | |
167 | + var production = $('#production').val(); | |
168 | + var manufactureArr = manufacture.split('_'); | |
169 | + var projectArr = project.split('_'); | |
170 | + var modelArr = model.split('_'); | |
171 | + var productionArr = production.split('_'); | |
172 | + if (undefined !== manufactureArr[1]) { | |
173 | + manufacture = manufactureArr[1]; | |
174 | + } else { | |
175 | + manufacture = '-'; | |
176 | + } | |
177 | + | |
178 | + if (undefined !== projectArr[1]) { | |
179 | + project = projectArr[1]; | |
180 | + } else { | |
181 | + project = '-'; | |
182 | + } | |
183 | + | |
184 | + if (undefined !== modelArr[1]) { | |
185 | + model = modelArr[1]; | |
186 | + } else { | |
187 | + model = '-'; | |
188 | + } | |
189 | + if (undefined !== productionArr[1]) { | |
190 | + production = productionArr[1]; | |
191 | + } else { | |
192 | + production = '-'; | |
193 | + } | |
194 | + $('#preview_batch_no').html(manufacture+ project+ model + production +''); | |
195 | + }) | |
196 | + | |
102 | 197 | $('#createDeviceBtn').click(function(e) { |
103 | 198 | e.preventDefault(); |
104 | 199 | var manufacture = $('#manufacture').val(); |
... | ... | @@ -157,5 +252,30 @@ $(function() { |
157 | 252 | }, 'json') |
158 | 253 | }) |
159 | 254 | |
255 | + $('#appendDeviceBtn').click(function(e){ | |
256 | + var batch_id = $('#batch_id').val(); | |
257 | + var append_num = $('#append_num').val(); | |
258 | + if ('' == batch_id || 0 == batch_id) { | |
259 | + alert('请选择批次'); | |
260 | + return false; | |
261 | + } | |
262 | + if ('' == append_num || 0 == append_num) { | |
263 | + alert('请录入数量'); | |
264 | + return false; | |
265 | + } | |
266 | + if (append_num*1 > 3000) { | |
267 | + alert('追加数量不要超过3000'); | |
268 | + return false; | |
269 | + } | |
270 | + $.post(appendSerialUrl,{batch_id:batch_id, append_num:append_num}, function(ajaxRes){ | |
271 | + if (ajaxRes.success) { | |
272 | + alert('成功追加'); | |
273 | + window.location.href = '<?=Url::toRoute('/datas/device/index')?>' | |
274 | + } else { | |
275 | + alert(ajaxRes.message); | |
276 | + } | |
277 | + }, 'json') | |
278 | + }) | |
279 | + | |
160 | 280 | }) |
161 | 281 | </script> | ... | ... |
app-ht/modules/device/views/device/index.php
... | ... | @@ -80,7 +80,7 @@ $this->params['breadcrumbs'][] = $this->title; |
80 | 80 | |
81 | 81 | <div class="form-group col-sm-12" style="text-align: center;"> |
82 | 82 | <button type="submit" class="btn btn-primary font-1" id="submitFilterBtn">查询</button> |
83 | - <a class="btn btn-default" style="float: right;" href="javascript:void(0)" id="btn-export"> 导出数据 </a> | |
83 | + <a class="btn btn-default" href="javascript:void(0)" id="btn-export"> 导出数据 </a> | |
84 | 84 | </div> |
85 | 85 | </form> |
86 | 86 | </div> | ... | ... |
app-ht/modules/upgrade/controllers/UpgradeController.php
... | ... | @@ -90,6 +90,7 @@ class UpgradeController extends BaseController |
90 | 90 | /** |
91 | 91 | * 数据整理 |
92 | 92 | */ |
93 | + | |
93 | 94 | return [ |
94 | 95 | 'listdata' => $pageList, |
95 | 96 | 'pages' => $pages, |
... | ... | @@ -629,17 +630,54 @@ class UpgradeController extends BaseController |
629 | 630 | $request = Yii::$app->request; |
630 | 631 | $selFocuse = $request->post("focuse"); |
631 | 632 | $uid = $request->post("uid"); |
633 | + $type = $request->post("type"); | |
632 | 634 | |
633 | 635 | if (empty($uid)) { |
634 | 636 | Yii::$app->session->setFlash('error', '版本编号不能为空'); |
635 | 637 | $params = $this->dataList(1); |
636 | 638 | return $this->render('index', $params); |
637 | 639 | } |
638 | - if (empty($selFocuse)) { | |
639 | - Yii::$app->session->setFlash('error', '请选择是否强制升级'); | |
640 | + $upgradeModel = UpgradeRepository::findOne(['id' => $uid, 'is_delete' => 0]); | |
641 | + if (!$upgradeModel) { | |
642 | + Yii::$app->session->setFlash('error', '未找到升级记录'); | |
640 | 643 | $params = $this->dataList(1); |
641 | 644 | return $this->render('index', $params); |
642 | 645 | } |
646 | + if (UpgradeStatus::TYPE_OTA == $upgradeModel->type) { | |
647 | + $upgradeURL = 'push-ota?uid='.$uid; | |
648 | + } else { | |
649 | + $upgradeURL = 'push-app?uid='.$uid; | |
650 | + } | |
651 | + if (empty($selFocuse)) { | |
652 | + Yii::$app->session->setFlash('error', '请选择是否强制升级'); | |
653 | + return $this->redirect($upgradeURL); | |
654 | + } | |
655 | + | |
656 | + | |
657 | + if (empty($upgradeModel->manufacture_id)) { | |
658 | + Yii::$app->session->setFlash('error', '请先配置好厂商'); | |
659 | + return $this->redirect($upgradeURL); | |
660 | + } | |
661 | + if (empty($upgradeModel->project_id)) { | |
662 | + Yii::$app->session->setFlash('error', '请先配置版本项目'); | |
663 | + return $this->redirect($upgradeURL); | |
664 | + } | |
665 | + if (empty($upgradeModel->model_id)) { | |
666 | + Yii::$app->session->setFlash('error', '请先配置版本型号'); | |
667 | + return $this->redirect($upgradeURL); | |
668 | + } | |
669 | + $exitUpgradeModel = UpgradeRepository::findOne([ | |
670 | + 'manufacture_id' => $upgradeModel->manufacture_id, | |
671 | + 'project_id' => $upgradeModel->project_id, | |
672 | + 'model_id' => $upgradeModel->model_id, | |
673 | + 'is_delete' => 0, | |
674 | + 'status' => UpgradeStatus::STATUS_ON | |
675 | + ]); | |
676 | + | |
677 | + if ($exitUpgradeModel && $upgradeModel->id != $exitUpgradeModel->id) { | |
678 | + Yii::$app->session->setFlash('error', '该厂商该批次已经存在一个版本号为:'.$exitUpgradeModel->version.'的发布版本,请先取消它再发布'); | |
679 | + return $this->redirect($upgradeURL); | |
680 | + } | |
643 | 681 | |
644 | 682 | $result = Upgrade::update($uid, $request->post()); |
645 | 683 | |
... | ... | @@ -667,4 +705,47 @@ class UpgradeController extends BaseController |
667 | 705 | $savePath = $basePath . '/' . $filename; |
668 | 706 | return $savePath; |
669 | 707 | } |
708 | + | |
709 | + /** | |
710 | + * @return string | |
711 | + */ | |
712 | + public function actionCheckUpgrade() | |
713 | + { | |
714 | + $e = new stdClass(); | |
715 | + $e->success = false; | |
716 | + $request = Yii::$app->request; | |
717 | + $manufactureId = $request->post("manufacture"); | |
718 | + $projectId = $request->post("project"); | |
719 | + $modelId = $request->post("model"); | |
720 | + $id = $request->post('id'); | |
721 | + if (empty($manufactureId)) { | |
722 | + $e->message = '请先选择厂商'; | |
723 | + return $this->renderJson($e); | |
724 | + } | |
725 | + | |
726 | + if (empty($projectId)) { | |
727 | + $e->message = '请先选择项目'; | |
728 | + return $this->renderJson($e); | |
729 | + } | |
730 | + | |
731 | + if (empty($modelId)) { | |
732 | + $e->message = '请先选择型号'; | |
733 | + return $this->renderJson($e); | |
734 | + } | |
735 | + | |
736 | + $upgradeModel = UpgradeRepository::findOne(['manufacture_id' => $manufactureId, 'project_id' => $projectId, 'model_id' => $modelId, 'is_delete' => 0, 'status' => UpgradeStatus::STATUS_ON]); | |
737 | + if ($upgradeModel && empty($id)) { | |
738 | + $e->message = '该厂商该批次已经存在一个版本号为:'.$upgradeModel->version.'的发布版本,请先取消发布的版本再上传'; | |
739 | + return $this->renderJson($e); | |
740 | + } | |
741 | + | |
742 | + if ($upgradeModel && !empty($id) && $id != $upgradeModel->id) { | |
743 | + $e->message = '该厂商该批次已经存在一个版本号为:'.$upgradeModel->version.'的发布版本,请先取消发布的版本再上传'; | |
744 | + return $this->renderJson($e); | |
745 | + } | |
746 | + | |
747 | + $e->success = true; | |
748 | + $e->message = 'ok'; | |
749 | + return $this->renderJson($e); | |
750 | + } | |
670 | 751 | } |
671 | 752 | \ No newline at end of file | ... | ... |
app-ht/modules/upgrade/views/upgrade/create.php
... | ... | @@ -117,6 +117,7 @@ $this->params['breadcrumbs'][] = $this->title; |
117 | 117 | |
118 | 118 | <script> |
119 | 119 | var searchItemUrl = "<?=Url::toRoute('/device/device/batch-item')?>"; |
120 | + var checkUpgradeUrl = "<?=Url::toRoute('/upgrade/upgrade/check-upgrade')?>"; | |
120 | 121 | // 表单提交验证 |
121 | 122 | seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function () { |
122 | 123 | var validator = $("#myFrom").validate({ |
... | ... | @@ -256,10 +257,26 @@ $this->params['breadcrumbs'][] = $this->title; |
256 | 257 | }); |
257 | 258 | |
258 | 259 | $btn.on('click', function () { |
259 | - if ($(this).hasClass('disabled')) { | |
260 | - return false; | |
261 | - } | |
262 | - uploader.upload(); | |
260 | + var that = $(this); | |
261 | + var manufacture = $('#manufacture').val(); | |
262 | + var project = $('#project').val(); | |
263 | + var model = $('#model').val(); | |
264 | + $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model}, function(res){ | |
265 | + if (res.success) { | |
266 | + if (that.hasClass('disabled')) { | |
267 | + return false; | |
268 | + } | |
269 | + uploader.upload(); | |
270 | + } else { | |
271 | + alert(res.message); | |
272 | + return false; | |
273 | + } | |
274 | + }, 'json') | |
275 | + | |
276 | + return false; | |
277 | + | |
278 | + | |
279 | + | |
263 | 280 | // if (state === 'ready') { |
264 | 281 | // uploader.upload(); |
265 | 282 | // } else if (state === 'paused') { | ... | ... |
app-ht/modules/upgrade/views/upgrade/edit.php
... | ... | @@ -117,6 +117,7 @@ $this->params['breadcrumbs'][] = $this->title; |
117 | 117 | |
118 | 118 | <script> |
119 | 119 | var searchItemUrl = "<?=Url::toRoute('/device/device/batch-item')?>"; |
120 | + var checkUpgradeUrl = "<?=Url::toRoute('/upgrade/upgrade/check-upgrade')?>"; | |
120 | 121 | // 表单提交验证 |
121 | 122 | seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function () { |
122 | 123 | var validator = $("#myFrom").validate({ |
... | ... | @@ -246,10 +247,23 @@ $this->params['breadcrumbs'][] = $this->title; |
246 | 247 | }); |
247 | 248 | |
248 | 249 | $btn.on('click', function () { |
249 | - if ($(this).hasClass('disabled')) { | |
250 | - return false; | |
251 | - } | |
252 | - uploader.upload(); | |
250 | + var that = $(this); | |
251 | + var manufacture = $('#manufacture').val(); | |
252 | + var project = $('#project').val(); | |
253 | + var model = $('#model').val(); | |
254 | + $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model, id: $('#uid').val()}, function(res){ | |
255 | + if (res.success) { | |
256 | + if (that.hasClass('disabled')) { | |
257 | + return false; | |
258 | + } | |
259 | + uploader.upload(); | |
260 | + } else { | |
261 | + alert(res.message); | |
262 | + return false; | |
263 | + } | |
264 | + }, 'json') | |
265 | + | |
266 | + return false; | |
253 | 267 | // if (state === 'ready') { |
254 | 268 | // uploader.upload(); |
255 | 269 | // } else if (state === 'paused') { | ... | ... |
app-ht/modules/upgrade/views/upgrade/index.php
... | ... | @@ -74,12 +74,12 @@ $this->params['breadcrumbs'][] = $this->title; |
74 | 74 | <tr> |
75 | 75 | <th width="10%">APP版本号</th> |
76 | 76 | <th width="10%">安装包名称</th> |
77 | - <th width="10%">厂商名称</th> | |
77 | + <th width="12%">升级批次信息</th> | |
78 | 78 | <th width="10%">上传时间</th> |
79 | 79 | <th width="10%">发布状态</th> |
80 | 80 | <th width="10%">发布信息</th> |
81 | - <th width="10%">包信息</th> | |
82 | - <th width="20%">操作</th> | |
81 | + <th width="12%">包信息</th> | |
82 | + <th width="15%">操作</th> | |
83 | 83 | </tr> |
84 | 84 | </thead> |
85 | 85 | |
... | ... | @@ -88,8 +88,13 @@ $this->params['breadcrumbs'][] = $this->title; |
88 | 88 | <?php foreach ($listdata as $item) : ?> |
89 | 89 | <tr> |
90 | 90 | <td style="padding:12px;"><?= (isset($item["version"]) ? $item["version"] : "") ?></td> |
91 | - <td style="padding:12px;"><?= (isset($item["package_name"]) ? $item["package_name"] : "") ?> | |
92 | - <td style="padding:12px;"><?= (isset($item["name"]) ? $item["name"] : "") ?> | |
91 | + <td style="padding:12px;"><?= (isset($item["package_name"]) ? $item["package_name"] : "") ?></td> | |
92 | + <td style="padding:12px;"> | |
93 | + 批次编码:<?= (isset($item["barcode"]) ? $item["barcode"].'----' : "-") ?><br> | |
94 | + 厂商:<?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "-") ?><br> | |
95 | + 项目:<?= (isset($item["project_name"]) ? $item["project_name"] : "-") ?><br> | |
96 | + 型号:<?= (isset($item["model_name"]) ? $item["model_name"] : "-") ?> | |
97 | + </td> | |
93 | 98 | <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td> |
94 | 99 | <td style="padding:12px;"><?= UpgradeStatus::statusLabel($item['status'])?></td> |
95 | 100 | <td style="padding:12px;"> | ... | ... |
console/controllers/TestController.php
... | ... | @@ -119,8 +119,8 @@ class TestController extends Controller |
119 | 119 | public function actionCheckOtaUpdate() |
120 | 120 | { |
121 | 121 | //actionCheckAppVersion |
122 | - //$url = 'http://47.107.95.101/app-api/web/checkOtaVersion'; | |
123 | - $url = 'http://kingb:8012/app-api/web/checkOtaVersion'; | |
122 | + $url = 'http://47.107.95.101/app-api/web/checkOtaVersion'; | |
123 | + //$url = 'http://kingb:8012/app-api/web/checkOtaVersion'; | |
124 | 124 | $params = [ |
125 | 125 | 'barcode' => '0001000100010001', |
126 | 126 | 'device_id' => 'DGDEVBICEID00001', |
... | ... | @@ -128,7 +128,7 @@ class TestController extends Controller |
128 | 128 | 'hardware_version' => 'V1.0.1', |
129 | 129 | ]; |
130 | 130 | $params = json_encode($params); |
131 | - //$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}'; | |
131 | + $params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}'; | |
132 | 132 | $postResult = Http::POST($url, $params); |
133 | 133 | echo $postResult; |
134 | 134 | } |
... | ... | @@ -148,7 +148,7 @@ class TestController extends Controller |
148 | 148 | 'hardware_version' => 'V1.0.1', |
149 | 149 | ]; |
150 | 150 | $params = json_encode($params); |
151 | - $params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022","target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}'; | |
151 | + $params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022", "target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}'; | |
152 | 152 | $postResult = Http::POST($url, $params); |
153 | 153 | echo $postResult; |
154 | 154 | } | ... | ... |
domain/device/CreateBatchRepository.php
... | ... | @@ -36,7 +36,7 @@ class CreateBatchRepository |
36 | 36 | $q = new Query(); |
37 | 37 | $q->select(['concat(id, "_", manufacture_no) as uid', 'id','manufacture_no', 'name']); |
38 | 38 | $q->from('manufacture'); |
39 | - $q->where('id >1'); | |
39 | + $q->where('id >0'); | |
40 | 40 | |
41 | 41 | $list = $q->all(); |
42 | 42 | |
... | ... | @@ -45,7 +45,7 @@ class CreateBatchRepository |
45 | 45 | $q = new Query(); |
46 | 46 | $q->select(['concat(id,"_", project_no) as uid', 'id','project_no', 'name']); |
47 | 47 | $q->from('project'); |
48 | - $q->where('id >1'); | |
48 | + $q->where('id >0'); | |
49 | 49 | |
50 | 50 | $list = $q->all(); |
51 | 51 | |
... | ... | @@ -54,7 +54,7 @@ class CreateBatchRepository |
54 | 54 | $q = new Query(); |
55 | 55 | $q->select(['concat(id,"_", model_no) as uid','id','model_no', 'name']); |
56 | 56 | $q->from('model'); |
57 | - $q->where('id >1'); | |
57 | + $q->where('id >0'); | |
58 | 58 | $list = $q->all(); |
59 | 59 | |
60 | 60 | return $list; |
... | ... | @@ -62,7 +62,7 @@ class CreateBatchRepository |
62 | 62 | $q = new Query(); |
63 | 63 | $q->select(['concat(id,"_", production_no) as uid','id','production_no', 'name']); |
64 | 64 | $q->from('production'); |
65 | - $q->where('id >1'); | |
65 | + $q->where('id >0'); | |
66 | 66 | $list = $q->all(); |
67 | 67 | |
68 | 68 | return $list; |
... | ... | @@ -149,4 +149,24 @@ class CreateBatchRepository |
149 | 149 | |
150 | 150 | return $info; |
151 | 151 | } |
152 | + | |
153 | + /** | |
154 | + * @param $batchId | |
155 | + * @return array|null|\yii\db\ActiveRecord | |
156 | + */ | |
157 | + static function getBatchSelectList($where) | |
158 | + { | |
159 | + $batchModelFind = CreateBatchModel::find(); | |
160 | + $batchModelFind->alias('a'); | |
161 | + $batchModelFind->select(['a.*','m.name as manufacture','pro.name as project','mo.name as model','prod.name as production']); | |
162 | + $batchModelFind->leftJoin(ManufacturerModel::tableName(). ' m', 'm.id = a.manufacture_id'); | |
163 | + $batchModelFind->leftJoin(ProjectModel::tableName(). ' pro', 'pro.id = a.project_id'); | |
164 | + $batchModelFind->leftJoin(ModelModel::tableName(). ' mo', 'mo.id = a.model_id'); | |
165 | + $batchModelFind->leftJoin(ProductionModel::tableName(). ' prod', 'prod.id = a.production_id'); | |
166 | + $batchModelFind->where($where); | |
167 | + $batchModelFind->asArray(); | |
168 | + $info = $batchModelFind->all(); | |
169 | + | |
170 | + return $info; | |
171 | + } | |
152 | 172 | } |
153 | 173 | \ No newline at end of file | ... | ... |
domain/device/Device.php
... | ... | @@ -49,14 +49,14 @@ class Device |
49 | 49 | if ($exitDevice) { |
50 | 50 | $numNo = mb_substr($exitDevice->serial_no, -4); |
51 | 51 | $no1 = hexdec($numNo); |
52 | - $no =($no1 * 1) + 1; | |
52 | + $no = ($no1 * 1) + 1; | |
53 | 53 | $newNo = sprintf('%04X', $no); |
54 | 54 | $serialNo = $batchNo.$newNo; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $macAddress = Utils::macGenerate(); |
58 | 58 | $item = [ |
59 | - 'serial_no' => $serialNo, | |
59 | + 'serial_no' => strtoupper($serialNo), | |
60 | 60 | 'mac' => $macAddress, |
61 | 61 | 'device_id' => $deviceId, |
62 | 62 | 'batch_id' => $batchId, |
... | ... | @@ -119,6 +119,14 @@ class Device |
119 | 119 | $batchModel = CreateBatchRepository::findOne(['batch_no' => $batchNo]); |
120 | 120 | if (empty($batchModel)) { |
121 | 121 | $e->message = '没有该批次'; |
122 | + $item = [ | |
123 | + 'manufacture_no' => $manufactureNo, | |
124 | + 'project_no' => $projectNo, | |
125 | + 'model_no' => $modelNo, | |
126 | + 'production_no' => $productionNo, | |
127 | + 'device_id' => $deviceId, | |
128 | + ]; | |
129 | + DeviceAuthFail::create($item); | |
122 | 130 | return $e; |
123 | 131 | } |
124 | 132 | $batchId = $batchModel->id; |
... | ... | @@ -191,11 +199,17 @@ class Device |
191 | 199 | $newDeviceModel->status = DeviceStatus::HAS_AUTH; |
192 | 200 | $newDeviceModel->apply_at = $tt ; |
193 | 201 | $newDeviceModel->auth_at = $tt; |
194 | - $newDeviceModel->save(); | |
195 | - $e->message = '授权成功'; | |
196 | - $e->success = true; | |
197 | - $e->serial_no = $newDeviceModel->serial_no; | |
198 | - $e->mac = $newDeviceModel->mac; | |
202 | + if ($newDeviceModel->save()) { | |
203 | + $e->message = '授权成功'; | |
204 | + $e->success = true; | |
205 | + $e->serial_no = $newDeviceModel->serial_no; | |
206 | + $e->mac = $newDeviceModel->mac; | |
207 | + } else { | |
208 | + $e->message = '授权失败'; | |
209 | + $e->status = 9; //系统异常 | |
210 | + $e->success = true; | |
211 | + } | |
212 | + | |
199 | 213 | |
200 | 214 | return $e; |
201 | 215 | } | ... | ... |
domain/upgrade/UpgradeRepository.php
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 | namespace domain\upgrade; |
4 | 4 | |
5 | 5 | use domain\manufacturer\models\Manufacturer as ManufacturerModel; |
6 | +use domain\model\models\Model as ModelModel; | |
7 | +use domain\project\models\Project as ProjectModel; | |
6 | 8 | use domain\upgrade\models\Upgrade as UpgradeModel; |
7 | 9 | |
8 | 10 | |
... | ... | @@ -25,9 +27,14 @@ class UpgradeRepository |
25 | 27 | $upgradeFind = UpgradeModel::find()->alias("u") |
26 | 28 | ->select([ |
27 | 29 | "u.*", |
28 | - "mf.name" | |
30 | + "mf.name as manufacture_name", | |
31 | + "pro.name as project_name", | |
32 | + "mo.name as model_name", | |
33 | + "concat(mf.manufacture_no,project_no,model_no) as barcode" | |
29 | 34 | ]); |
30 | 35 | $upgradeFind->leftJoin(ManufacturerModel::tableName() . " mf", "mf.id = u.manufacture_id"); |
36 | + $upgradeFind->leftJoin(ProjectModel::tableName() . " pro", "pro.id = u.project_id"); | |
37 | + $upgradeFind->leftJoin(ModelModel::tableName() . " mo", "mo.id = u.model_id"); | |
31 | 38 | |
32 | 39 | if (!empty($where)) { |
33 | 40 | $upgradeFind->where($where); |
... | ... | @@ -54,6 +61,8 @@ class UpgradeRepository |
54 | 61 | { |
55 | 62 | $upgradeFind = UpgradeModel::find()->alias("u"); |
56 | 63 | $upgradeFind->leftJoin(ManufacturerModel::tableName() . " mf", "mf.id = u.manufacture_id"); |
64 | + $upgradeFind->leftJoin(ProjectModel::tableName() . " pro", "pro.id = u.project_id"); | |
65 | + $upgradeFind->leftJoin(ModelModel::tableName() . " mo", "mo.id = u.model_id"); | |
57 | 66 | if (!empty($map)) { |
58 | 67 | $upgradeFind->where($map); |
59 | 68 | } | ... | ... |