diff --git a/app-ht/modules/datas/controllers/DeviceController.php b/app-ht/modules/datas/controllers/DeviceController.php
index b278268..c37a858 100644
--- a/app-ht/modules/datas/controllers/DeviceController.php
+++ b/app-ht/modules/datas/controllers/DeviceController.php
@@ -2,6 +2,7 @@
namespace app\ht\modules\datas\controllers;
+use domain\device\DeviceAuthFailRepository;
use Yii;
use yii\data\Pagination;
use app\ht\controllers\BaseController;
@@ -96,6 +97,16 @@ class DeviceController extends BaseController
*/
public function actionDeviceList()
{
+ $params = $this->batchDataList(1);
+ return $this->render('device-list', $params);
+ }
+
+ /**
+ * @param $type
+ * @return mixed
+ */
+ private function batchDataList($type)
+ {
$request = Yii::$app->request;
$serialNo = $request->get('serial_no');
$mac = $request->get('mac');
@@ -146,23 +157,32 @@ class DeviceController extends BaseController
if (0 >= $page) {
$page = 1;
}
- $pageSize = 20;
- $page = ($page -1) * $pageSize;
-
- $deviceData = DeviceRepository::getList($where, $pageSize, $page);
- $pages = new Pagination(['totalCount' => DeviceRepository::getListCount($where), 'pageSize' => $pageSize]);
$statusList = DeviceStatus::statusLabels(); //
- if (empty($deviceData)) {
- $batchInfo = CreateBatchRepository::getBatchInfo($batchId);
+ if (1 == $type) {
+ $pageSize = 20;
+ $page = ($page -1) * $pageSize;
+ $deviceData = DeviceRepository::getList($where, $pageSize, $page);
+ $pages = new Pagination(['totalCount' => DeviceRepository::getListCount($where), 'pageSize' => $pageSize]);
+
+ if (empty($deviceData)) {
+ $where = ['a.id' => $batchId];
+ $batchInfo = CreateBatchRepository::getBatchInfo($where);
+ } else {
+ $batchInfo = $deviceData[0];
+ }
+ $project = $batchInfo['project'];
+ $production = $batchInfo['production'];
+ $model = $batchInfo['model'];
+ $manufacture = $batchInfo['manufacture'];
+ $batchNo = $batchInfo['batch_no'];
+
} else {
- $batchInfo = $deviceData[0];
+ $deviceData = DeviceRepository::getList($where, 0, 0);
+ $pages = null;
+ $project = $production = $model = $manufacture = $batchNo = null;
}
- $project = $batchInfo['project'];
- $production = $batchInfo['production'];
- $model = $batchInfo['model'];
- $manufacture = $batchInfo['manufacture'];
- $batchNo = $batchInfo['batch_no'];
+
$params['statusList'] = $statusList;
$params['deviceList'] = $deviceData;
$params['pages'] = $pages;
@@ -183,6 +203,108 @@ class DeviceController extends BaseController
'status' => $status
];
- return $this->render('device-list', $params);
+ return $params;
+ }
+
+
+ /**
+ * 导出某个批次的数据
+ * @return string
+ */
+ public function actionBatchExport()
+ {
+ $params = $this->batchDataList(0);
+ return $this->renderPartial('batch-export', $params);
+ }
+
+ /**
+ * @param $type
+ * @return mixed
+ */
+ private function batchFailDataList($type)
+ {
+ $request = Yii::$app->request;
+ $batchNo = $request->get('batch_no');
+ $deviceId = $request->get('device_id');
+ $startApplyAt = $request->get('start_apply_at');
+ $endApplyAt = $request->get('end_apply_at');
+
+ $page = $request->get('page');
+ $where = [
+ 'and',
+ ['=','a.is_delete', 0],
+ ['=','concat(a.manufacture_no,a.project_no,a.model_no,a.production_no)', $batchNo]
+ ];
+
+
+ if (!empty($deviceId)) {
+ $where[] = ['like', 'a.device_id', $deviceId];
+ }
+
+ if (!empty($startApplyAt)) {
+ $where[] = ['>=', 'a.apply_at', strtotime($startApplyAt)];
+ }
+ if (!empty($endApplyAt)) {
+ $where[] = ['<=', 'a.apply_at', strtotime($endApplyAt) + 3600 * 24];
+ }
+
+
+ if (0 >= $page) {
+ $page = 1;
+ }
+
+ if (1 == $type) {
+ $pageSize = 20;
+ $page = ($page -1) * $pageSize;
+ $deviceData = DeviceAuthFailRepository::getList($where, $pageSize, $page);
+ $pages = new Pagination(['totalCount' => DeviceAuthFailRepository::getListCount($where), 'pageSize' => $pageSize]);
+
+ $batchInfo = CreateBatchRepository::getBatchInfo(['a.batch_no' => $batchNo]);
+ $project = $batchInfo['project'];
+ $production = $batchInfo['production'];
+ $model = $batchInfo['model'];
+ $manufacture = $batchInfo['manufacture'];
+ $batchNo = $batchInfo['batch_no'];
+
+ } else {
+ $deviceData = DeviceAuthFailRepository::getList($where, 0, 0);
+ $pages = null;
+ $project = $production = $model = $manufacture = $batchNo = null;
+ }
+
+ $params['deviceList'] = $deviceData;
+ $params['pages'] = $pages;
+ $params["gets"] = [
+
+ 'project' => $project,
+ 'model' => $model,
+ 'device_id' => $deviceId,
+ 'batch_no' => $batchNo,
+ 'production' => $production,
+ 'manufacture' => $manufacture,
+ 'start_apply_at' => $startApplyAt,
+ 'end_apply_at' => $endApplyAt,
+
+ ];
+
+ return $params;
+ }
+
+ /**
+ * @return string
+ */
+ public function actionFailList()
+ {
+ $params = $this->batchFailDataList(1);
+ return $this->render('fail-list', $params);
+ }
+
+ /**
+ * @return string
+ */
+ public function actionFailListExport()
+ {
+ $params = $this->batchFailDataList(0);
+ return $this->renderPartial('fail-list-export', $params);
}
}
\ No newline at end of file
diff --git a/app-ht/modules/datas/views/device/batch-export.php b/app-ht/modules/datas/views/device/batch-export.php
new file mode 100644
index 0000000..0d427a5
--- /dev/null
+++ b/app-ht/modules/datas/views/device/batch-export.php
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 批次编码 |
+ 序列号 |
+ 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/device-list.php b/app-ht/modules/datas/views/device/device-list.php
index 1b529a1..56f0131 100644
--- a/app-ht/modules/datas/views/device/device-list.php
+++ b/app-ht/modules/datas/views/device/device-list.php
@@ -55,7 +55,8 @@ $this->params['breadcrumbs'][] = $this->title;
@@ -131,5 +132,30 @@ $this->params['breadcrumbs'][] = $this->title;
\ No newline at end of file
diff --git a/app-ht/modules/datas/views/device/export.php b/app-ht/modules/datas/views/device/export.php
index 964e510..7293893 100644
--- a/app-ht/modules/datas/views/device/export.php
+++ b/app-ht/modules/datas/views/device/export.php
@@ -22,18 +22,21 @@ $cnt = 0;
-
+
- 编码 |
- 厂商 |
- 项目 |
- 型号 |
- 生产日期 |
- 生成总数 |
- 授权总数 |
- 授权失败数 |
- 未授权数 |
+ 编码 |
+ 厂商 |
+ 项目 |
+ 型号 |
+ 生产日期 |
+ 预 | 总生成 |
+ 已删除 |
+ 已授权 |
+ 未授权 |
+ 授权失败(超出) |
+ 已处理(超出) |
+ 授权失败(系统) |
@@ -44,10 +47,13 @@ $cnt = 0;
= (isset($item["project_name"]) ? $item["project_name"] : "") ?> |
= (isset($item["model_name"]) ? $item["model_name"] : "") ?> |
= (isset($item["production_name"]) ? $item["production_name"] : "") ?> |
- = (isset($item["num"]) ? $item["num"] : "0") ?> |
+ = (isset($item["num"]) ? $item["num"] : "0") ?>|= (isset($item["total_num"]) ? $item["total_num"] : "0") ?> |
+ = (isset($item["del_num"]) ? $item["del_num"] : "0") ?> |
= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?> |
- = (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?> |
= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?> |
+ = (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?> |
+ = (!empty($item["handle_auth_fail_num"]) ? $item["handle_auth_fail_num"] : "0") ?> |
+ = (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?> |
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ 批次编码 |
+ 厂商 |
+
+ 项目 |
+ 设备型号 |
+ 生产日期 |
+ 设备ID |
+ 申请时间 |
+ 状态 |
+
+
+
+ $item) : ?>
+
+
+ = $item['id'] ?>
+ |
+
+ = Device::getBatchNo($item['manufacture_no'], $item['project_no'], $item['model_no'], $item['production_no']) ?>
+ |
+
+ = $item['manufacture'] ?>
+ |
+
+ = $item['project'] ?>
+ |
+
+ = $item['model'] ?>
+ |
+
+ = $item['production'] ?>
+ |
+
+
+ = $item['device_id']? $item['device_id']:'暂无'?>
+ |
+
+ = $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
+ |
+
+ 超出
+ |
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app-ht/modules/datas/views/device/fail-list.php b/app-ht/modules/datas/views/device/fail-list.php
new file mode 100644
index 0000000..0da68ef
--- /dev/null
+++ b/app-ht/modules/datas/views/device/fail-list.php
@@ -0,0 +1,146 @@
+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 |
+ 批次编码 |
+ 厂商 |
+
+ 项目 |
+ 设备型号 |
+ 生产日期 |
+ 设备ID |
+ 申请时间 |
+ 状态 |
+
+
+
+
+
+
+
+
+
+ = $item['id'] ?>
+ |
+
+ = Device::getBatchNo($item['manufacture_no'], $item['project_no'], $item['model_no'], $item['production_no']) ?>
+ |
+
+ = $item['manufacture'] ?>
+ |
+
+ = $item['project'] ?>
+ |
+
+ = $item['model'] ?>
+ |
+
+ = $item['production'] ?>
+ |
+
+
+ = $item['device_id']? $item['device_id']:'暂无'?>
+ |
+
+ = $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
+ |
+
+ 超出
+ |
+
+
+
+
+
+ 暂无记录
+ |
+
+
+
+
+
+
+
+
+
+
\ 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 0c7dfe4..39fea58 100644
--- a/app-ht/modules/datas/views/device/index.php
+++ b/app-ht/modules/datas/views/device/index.php
@@ -49,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
">重 置
- 导出数据
+ 导出数据
@@ -63,17 +63,18 @@ $this->params['breadcrumbs'][] = $this->title;
- 编码 |
- 厂商 |
- 项目 |
- 型号 |
- 生产日期 |
- 生成总数 |
- 删除数 |
- 授权总数 |
- 超出总数 |
- 授权失败数 |
- 未授权数 |
+ 编码 |
+ 厂商 |
+ 项目 |
+ 型号 |
+ 生产日期 |
+ 预 | 总生成 |
+ 已删除 |
+ 已授权 |
+ 未授权 |
+ 授权失败(超出) |
+ 已处理(超出) |
+ 授权失败(系统) |
@@ -86,12 +87,14 @@ $this->params['breadcrumbs'][] = $this->title;
= (isset($item["project_name"]) ? $item["project_name"] : "") ?> |
= (isset($item["model_name"]) ? $item["model_name"] : "") ?> |
= (isset($item["production_name"]) ? $item["production_name"] : "") ?> |
- = (isset($item["num"]) ? $item["num"] : "0") ?> |
+ = (isset($item["num"]) ? $item["num"] : "0") ?>|= (isset($item["total_num"]) ? $item["total_num"] : "0") ?> |
= (isset($item["del_num"]) ? $item["del_num"] : "0") ?> |
= (isset($item["has_auth_num"]) ? $item["has_auth_num"] : "0") ?> |
- 4 |
- = (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?> |
= (!empty($item["no_auth_num"]) ? $item["no_auth_num"] : "0") ?> |
+ = (isset($item["out_of_num"]) ? $item["out_of_num"] : "0") ?> |
+ = (!empty($item["handle_auth_fail_num"]) ? $item["handle_auth_fail_num"] : "0") ?> |
+ = (!empty($item["auth_fail_num"]) ? $item["auth_fail_num"] : "0") ?> |
+
diff --git a/app-ht/modules/device/controllers/DeviceController.php b/app-ht/modules/device/controllers/DeviceController.php
index ecf051d..d6a7a8a 100644
--- a/app-ht/modules/device/controllers/DeviceController.php
+++ b/app-ht/modules/device/controllers/DeviceController.php
@@ -705,7 +705,7 @@ class DeviceController extends BaseController
if ($needGen) {
$trans = Yii::$app->getDb()->beginTransaction();
try {
- $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH);
+ $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 1, DeviceStatus::HAS_AUTH);
$deviceFailModel->is_delete = 1;
$deviceFailModel->save();
$trans->commit();
@@ -732,6 +732,7 @@ class DeviceController extends BaseController
$newDeviceModel->apply_at = $tt ;
$newDeviceModel->auth_at = $tt;
$newDeviceModel->save();
+
$deviceFailModel->is_delete = 1;
$deviceFailModel->save();
$trans->commit();
@@ -800,7 +801,7 @@ class DeviceController extends BaseController
if ($needGen) {
$trans = Yii::$app->getDb()->beginTransaction();
try {
- $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH);
+ $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 1, DeviceStatus::HAS_AUTH);
$deviceFailModel->is_delete = 1;
$deviceFailModel->save();
$trans->commit();
diff --git a/domain/device/CreateBatchRepository.php b/domain/device/CreateBatchRepository.php
index 4b8482e..5a0e04a 100644
--- a/domain/device/CreateBatchRepository.php
+++ b/domain/device/CreateBatchRepository.php
@@ -2,15 +2,16 @@
namespace domain\device;
+use domain\device\models\CreateBatch;
use yii\db\Expression;
use yii\db\Query;
use domain\device\models\CreateBatch as CreateBatchModel;
use domain\device\models\Device as DeviceModel;
-use domain\device\models\DeviceStats;
use domain\manufacturer\models\Manufacturer as ManufacturerModel;
use domain\model\models\Model as ModelModel;
use domain\production\models\Production as ProductionModel;
use domain\project\models\Project as ProjectModel;
+use domain\device\models\DeviceAuthFail as DeviceAuthFailModel;
class CreateBatchRepository
@@ -78,14 +79,21 @@ class CreateBatchRepository
*/
static function getPageList($where, $offset = 0, $limit = 0)
{
+ $totalNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.batch_id = a.id and dd.is_delete = 0) as total_num");
$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');
- $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');
-
+ $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');
$delNumExpress = new Expression("(select count(*) from ".DeviceModel::tableName(). "as dd where dd.is_delete = 1 and dd.batch_id = a.id) as del_num");
+ $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");
+ $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");
+ $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");
$batchModelFind = CreateBatchModel::find();
$batchModelFind->alias('a');
- $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]);
+ $batchModelFind->select([
+ 'a.*',
+ 'm.name as manufacture_name','pro.name as project_name','mo.name as model_name','prod.name as production_name',
+ $totalNumExpress, $hasAuthNumExpress, $noAuthNumExpress, $delNumExpress, $outOfLimitExpress, $sysFailNumExpress, $handleAuthFailNumExpress
+ ]);
$batchModelFind->leftJoin(ManufacturerModel::tableName(). ' m', 'm.id = a.manufacture_id');
$batchModelFind->leftJoin(ProjectModel::tableName(). ' pro', 'pro.id = a.project_id');
$batchModelFind->leftJoin(ModelModel::tableName(). ' mo', 'mo.id = a.model_id');
@@ -126,7 +134,7 @@ class CreateBatchRepository
* @param $batchId
* @return array|null|\yii\db\ActiveRecord
*/
- static function getBatchInfo($batchId)
+ static function getBatchInfo($where)
{
$batchModelFind = CreateBatchModel::find();
$batchModelFind->alias('a');
@@ -135,7 +143,7 @@ class CreateBatchRepository
$batchModelFind->leftJoin(ProjectModel::tableName(). ' pro', 'pro.id = a.project_id');
$batchModelFind->leftJoin(ModelModel::tableName(). ' mo', 'mo.id = a.model_id');
$batchModelFind->leftJoin(ProductionModel::tableName(). ' prod', 'prod.id = a.production_id');
- $batchModelFind->where(['a.id' => $batchId]);
+ $batchModelFind->where($where);
$batchModelFind->asArray();
$info = $batchModelFind->one();
--
libgit2 0.21.0