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 @@ + + + + + + + + + +
+ + + + + + + + + + + + + + + $item) : ?> + + + + + + + + + + + + + +
批次编码序列号MAC地址设备ID申请时间授权时间状态操作
+ + +
+
+ + + + + + + + + + + 已删除 +
+
+ + \ 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; +?> + +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ + +
+
+ +
+ +
+ - + +
+ +
+ - + +
+
+
+
+ 导出数据
+
+
+
+
+
+
厂商: 项目: 型号: 生产日期: + 批次编号: +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID序列号MAC地址设备ID申请时间授权时间状态操作
+ + +
+
+
+
+
+
+ + + + + + + 已删除 +
+
暂无记录
+
+
+ + +
+ + \ 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; | - + 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');
-
-
- -
- + -
- -
-
- -
- - -
- + -
-
- -
- - -
- -
-
- -
- +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ ---- +
+
+
+ +
+ +
+
+ +
+
+
+
-
-
+生产日期
-
-
- -
- + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
-
-
-
- + + +
@@ -78,6 +121,8 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css'); diff --git a/app-ht/modules/device/views/device/index.php b/app-ht/modules/device/views/device/index.php index 1b16600..bfa3754 100644 --- a/app-ht/modules/device/views/device/index.php +++ b/app-ht/modules/device/views/device/index.php @@ -80,7 +80,7 @@ $this->params['breadcrumbs'][] = $this->title;
- 导出数据 + 导出数据
diff --git a/app-ht/modules/upgrade/controllers/UpgradeController.php b/app-ht/modules/upgrade/controllers/UpgradeController.php index bec585a..900953d 100644 --- a/app-ht/modules/upgrade/controllers/UpgradeController.php +++ b/app-ht/modules/upgrade/controllers/UpgradeController.php @@ -90,6 +90,7 @@ class UpgradeController extends BaseController /** * 数据整理 */ + return [ 'listdata' => $pageList, 'pages' => $pages, @@ -629,17 +630,54 @@ class UpgradeController extends BaseController $request = Yii::$app->request; $selFocuse = $request->post("focuse"); $uid = $request->post("uid"); + $type = $request->post("type"); if (empty($uid)) { Yii::$app->session->setFlash('error', '版本编号不能为空'); $params = $this->dataList(1); return $this->render('index', $params); } - if (empty($selFocuse)) { - Yii::$app->session->setFlash('error', '请选择是否强制升级'); + $upgradeModel = UpgradeRepository::findOne(['id' => $uid, 'is_delete' => 0]); + if (!$upgradeModel) { + Yii::$app->session->setFlash('error', '未找到升级记录'); $params = $this->dataList(1); return $this->render('index', $params); } + if (UpgradeStatus::TYPE_OTA == $upgradeModel->type) { + $upgradeURL = 'push-ota?uid='.$uid; + } else { + $upgradeURL = 'push-app?uid='.$uid; + } + if (empty($selFocuse)) { + Yii::$app->session->setFlash('error', '请选择是否强制升级'); + return $this->redirect($upgradeURL); + } + + + if (empty($upgradeModel->manufacture_id)) { + Yii::$app->session->setFlash('error', '请先配置好厂商'); + return $this->redirect($upgradeURL); + } + if (empty($upgradeModel->project_id)) { + Yii::$app->session->setFlash('error', '请先配置版本项目'); + return $this->redirect($upgradeURL); + } + if (empty($upgradeModel->model_id)) { + Yii::$app->session->setFlash('error', '请先配置版本型号'); + return $this->redirect($upgradeURL); + } + $exitUpgradeModel = UpgradeRepository::findOne([ + 'manufacture_id' => $upgradeModel->manufacture_id, + 'project_id' => $upgradeModel->project_id, + 'model_id' => $upgradeModel->model_id, + 'is_delete' => 0, + 'status' => UpgradeStatus::STATUS_ON + ]); + + if ($exitUpgradeModel && $upgradeModel->id != $exitUpgradeModel->id) { + Yii::$app->session->setFlash('error', '该厂商该批次已经存在一个版本号为:'.$exitUpgradeModel->version.'的发布版本,请先取消它再发布'); + return $this->redirect($upgradeURL); + } $result = Upgrade::update($uid, $request->post()); @@ -667,4 +705,47 @@ class UpgradeController extends BaseController $savePath = $basePath . '/' . $filename; return $savePath; } + + /** + * @return string + */ + public function actionCheckUpgrade() + { + $e = new stdClass(); + $e->success = false; + $request = Yii::$app->request; + $manufactureId = $request->post("manufacture"); + $projectId = $request->post("project"); + $modelId = $request->post("model"); + $id = $request->post('id'); + if (empty($manufactureId)) { + $e->message = '请先选择厂商'; + return $this->renderJson($e); + } + + if (empty($projectId)) { + $e->message = '请先选择项目'; + return $this->renderJson($e); + } + + if (empty($modelId)) { + $e->message = '请先选择型号'; + return $this->renderJson($e); + } + + $upgradeModel = UpgradeRepository::findOne(['manufacture_id' => $manufactureId, 'project_id' => $projectId, 'model_id' => $modelId, 'is_delete' => 0, 'status' => UpgradeStatus::STATUS_ON]); + if ($upgradeModel && empty($id)) { + $e->message = '该厂商该批次已经存在一个版本号为:'.$upgradeModel->version.'的发布版本,请先取消发布的版本再上传'; + return $this->renderJson($e); + } + + if ($upgradeModel && !empty($id) && $id != $upgradeModel->id) { + $e->message = '该厂商该批次已经存在一个版本号为:'.$upgradeModel->version.'的发布版本,请先取消发布的版本再上传'; + return $this->renderJson($e); + } + + $e->success = true; + $e->message = 'ok'; + return $this->renderJson($e); + } } \ No newline at end of file diff --git a/app-ht/modules/upgrade/views/upgrade/create.php b/app-ht/modules/upgrade/views/upgrade/create.php index ae210a1..f17ed0b 100644 --- a/app-ht/modules/upgrade/views/upgrade/create.php +++ b/app-ht/modules/upgrade/views/upgrade/create.php @@ -117,6 +117,7 @@ $this->params['breadcrumbs'][] = $this->title;