diff --git a/.gitignore b/.gitignore
index ac55631..8ee5c4a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,4 +33,5 @@ yii
# alipay demo runtime
-runtimes
\ No newline at end of file
+runtimes
+
diff --git a/app-ht/modules/datas/controllers/DeviceController.php b/app-ht/modules/datas/controllers/DeviceController.php
index c37a858..5d026cd 100644
--- a/app-ht/modules/datas/controllers/DeviceController.php
+++ b/app-ht/modules/datas/controllers/DeviceController.php
@@ -102,10 +102,28 @@ class DeviceController extends BaseController
}
/**
+ * @return string
+ */
+ public function actionDeleteDeviceList()
+ {
+ $params = $this->batchDataList(1,1);
+ return $this->render('delete-device-list', $params);
+ }
+
+ /**
+ * @return string
+ */
+ public function actionBatchDeleteExport()
+ {
+ $params = $this->batchDataList(0,1);
+ return $this->renderPartial('batch-delete-export', $params);
+ }
+
+ /**
* @param $type
* @return mixed
*/
- private function batchDataList($type)
+ private function batchDataList($type, $isDelete = 0)
{
$request = Yii::$app->request;
$serialNo = $request->get('serial_no');
@@ -121,7 +139,7 @@ class DeviceController extends BaseController
$page = $request->get('page');
$where = [
'and',
- ['=','a.is_delete', 0],
+ ['=','a.is_delete', $isDelete],
['=','a.batch_id', $batchId]
];
if (!empty($serialNo)) {
diff --git a/app-ht/modules/datas/views/device/batch-delete-export.php b/app-ht/modules/datas/views/device/batch-delete-export.php
new file mode 100644
index 0000000..6476574
--- /dev/null
+++ b/app-ht/modules/datas/views/device/batch-delete-export.php
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 批次编码 |
+ 序列号 |
+ MAC地址 |
+ 设备ID |
+ 申请时间 |
+ 授权时间 |
+ 状态 |
+ 操作 |
+
+
+
+ $item) : ?>
+
+
+ = $item['batch_no'] ?>
+ |
+
+ = $item['serial_no'] ?>
+ |
+
+ = $item['mac'] ?>
+ |
+
+ = $item['device_id']? $item['device_id']:'暂无'?>
+ |
+
+ = $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
+ |
+
+ = $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?>
+ |
+
+ = $statusList[$item['status']] ?>
+ |
+
+ 已删除
+ |
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app-ht/modules/datas/views/device/delete-device-list.php b/app-ht/modules/datas/views/device/delete-device-list.php
new file mode 100644
index 0000000..1a374b2
--- /dev/null
+++ b/app-ht/modules/datas/views/device/delete-device-list.php
@@ -0,0 +1,164 @@
+title = '序列号删除管理';
+$this->params['breadcrumbs'][] = '数据统计';
+$this->params['breadcrumbs'][] = ['label' => '批次列表', 'url' => ['/datas/device/index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
+
厂商:=$gets['manufacture']?> 项目:=$gets['project']?> 型号:=$gets['model']?> 生产日期:=$gets['production']?>
+ 批次编号:=$gets['batch_no']?>
+
+
+
+
+
+
+
+ ID |
+ 序列号 |
+ MAC地址 |
+ 设备ID |
+ 申请时间 |
+ 授权时间 |
+ 状态 |
+ 操作 |
+
+
+
+
+
+
+
+
+ = $item['id'] ?>
+ |
+
+ = $item['serial_no'] ?>
+ |
+
+ = $item['mac'] ?>
+ |
+
+ = $item['device_id']? $item['device_id']:'暂无'?>
+ |
+
+ = $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
+ |
+
+ = $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?>
+ |
+
+ = $statusList[$item['status']] ?>
+ |
+
+ 已删除
+ |
+
+
+
+
+
+
+ 暂无记录
+ |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app-ht/modules/datas/views/device/index.php b/app-ht/modules/datas/views/device/index.php
index 39fea58..07b16e7 100644
--- a/app-ht/modules/datas/views/device/index.php
+++ b/app-ht/modules/datas/views/device/index.php
@@ -88,7 +88,7 @@ $this->params['breadcrumbs'][] = $this->title;
= (isset($item["model_name"]) ? $item["model_name"] : "") ?> |
= (isset($item["production_name"]) ? $item["production_name"] : "") ?> |
= (isset($item["num"]) ? $item["num"] : "0") ?>|= (isset($item["total_num"]) ? $item["total_num"] : "0") ?> |
- = (isset($item["del_num"]) ? $item["del_num"] : "0") ?> |
+ = (isset($item["del_num"]) ? $item["del_num"] : "0") ?> |
= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?> |
= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?> |
= (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?> |
diff --git a/app-ht/modules/device/controllers/DeviceController.php b/app-ht/modules/device/controllers/DeviceController.php
index d6a7a8a..738bfe0 100644
--- a/app-ht/modules/device/controllers/DeviceController.php
+++ b/app-ht/modules/device/controllers/DeviceController.php
@@ -264,7 +264,7 @@ class DeviceController extends BaseController
return $this->renderJson($e);
}
if (1 * $num > 30000) {
- $e->message = '数量不能超过3万0';
+ $e->message = '数量不能超过3万';
return $this->renderJson($e);
}
@@ -445,7 +445,10 @@ class DeviceController extends BaseController
return $this->renderJson($e);
}
-
+ /**
+ * 批量授权
+ * @return string
+ */
public function actionBatchAuthDevice()
{
$req = Yii::$app->request;
@@ -495,6 +498,7 @@ class DeviceController extends BaseController
}
/**
+ * 删除设备
* @return string
*/
public function actionDelDevice()
@@ -526,6 +530,7 @@ class DeviceController extends BaseController
}
/**
+ * 批量删除
* @return string
*/
public function actionBatchDelDevice()
@@ -570,6 +575,7 @@ class DeviceController extends BaseController
}
/**
+ * 编辑
* @return string
*/
public function actionDoEdit()
@@ -993,9 +999,92 @@ class DeviceController extends BaseController
return $this->renderJson($e);
}
- public function actionBatchIndex()
+ /**
+ * 追加生成新序列号
+ * @return string
+ * @throws \yii\db\Exception
+ */
+ public function actionAppendSerialNo()
+ {
+ $req = Yii::$app->request;
+ $batchId = $req->post('batch_id');
+ $appendNum = $req->post('append_num');
+ $e = new stdClass();
+ $e->success = false;
+ $e->message = 'fail';
+ if (empty($appendNum)) {
+ $e->message = '追加数量不能为0';
+ return $this->renderJson($e);
+ }
+
+ $batchModel = CreateBatchRepository::findOne(['id' => $batchId]);
+ if (empty($batchModel)) {
+ $e->message = '未找到批次';
+ return $this->renderJson($e);
+ }
+ $trans = Yii::$app->getDb()->beginTransaction();
+ try {
+
+ $batchModel->num = $batchModel->num + $appendNum;
+ $batchModel->save();
+
+ $batchNo = $batchModel->batch_no;
+ $batchId = $batchModel->id;
+ $saveData = [];
+ $tt = time();
+ $exitDeviceModel = DeviceModel::find();
+ $exitDeviceModel->where(['batch_id' => $batchId]);
+ $exitDeviceModel->orderBy('serial_no desc');
+ $exitDevice = $exitDeviceModel->one();
+ $no1 = 0;
+ if ($exitDevice) {
+ $numNo = mb_substr($exitDevice->serial_no, -4);
+ $no1 = hexdec($numNo);
+ }
+
+ for ($i = 1 ; $i <= $appendNum; $i++) {
+ $saveData[] = [
+ strtoupper($batchNo.sprintf('%04X', ($no1 * 1) + $i)),
+ Utils::macGenerate(),
+ 0,
+ $batchId,
+ 0,
+ 0,
+ 0,
+ 0,
+ $tt,
+ $tt
+ ];
+
+ }
+ $res = Yii::$app->db->createCommand()->batchInsert(DeviceModel::tableName(),
+ array('serial_no','mac','status','batch_id','is_delete','has_re_auth','apply_at','auth_at','created_at','updated_at'),
+ $saveData)->execute();//执行批量添加
+ $trans->commit();
+ $e->success = true;
+ $e->message = 'ok';
+
+ return $this->renderJson($e);
+ } catch (Exception $exception) {
+ $trans->rollBack();
+ $e->message = '生成失败';
+
+ return $this->renderJson($e);
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function actionGetBatchSelect()
{
+ $e = new stdClass();
+ $e->success = false;
+ $where = ['>', 'a.id', 0];
+ $batchList = CreateBatchRepository::getBatchSelectList($where);
+ $e->list = $batchList;
+ $e->success = true;
- return $this->render('batch-index');
+ return $this->renderJson($e);
}
}
\ No newline at end of file
diff --git a/app-ht/modules/device/views/device/createDevice.php b/app-ht/modules/device/views/device/createDevice.php
index 5dfd8ed..61befda 100644
--- a/app-ht/modules/device/views/device/createDevice.php
+++ b/app-ht/modules/device/views/device/createDevice.php
@@ -18,57 +18,100 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css');