diff --git a/app-api/controllers/UpgradeController.php b/app-api/controllers/UpgradeController.php index d72cc9e..7123e79 100644 --- a/app-api/controllers/UpgradeController.php +++ b/app-api/controllers/UpgradeController.php @@ -82,14 +82,29 @@ class UpgradeController extends BaseController */ $ma = ManufacturerRepository::findOne(['manufacture_no' => $deviceBatchInfo[0]]); - $manufactureId = 0; + $project = ProjectRepository::findOne(['project_no' => $deviceBatchInfo[1]]); + $model = ModelRepository::findOne(['model_no' => $deviceBatchInfo[2]]); + $manufactureId = $projectId = $modelId = 0; if ($ma) { $manufactureId = $ma->id; } + if ($project) { + $projectId = $project->id; + } + if ($model) { + $modelId = $model->id; + } + if (empty($ma) || empty($project) || empty($model)) { + $e->status = 4; + $e->message = '厂商、项目、型号里面出现不在系统里面'; + return $e; + } $upgradeModel = UpgradeModel::find(); $upgradeModel->where([ 'manufacture_id' => $manufactureId, + 'project_id' => $projectId, + 'model_id' => $modelId, 'status' => UpgradeStatus::STATUS_ON, 'is_delete' => 0, 'type' => UpgradeStatus::TYPE_OTA @@ -301,14 +316,28 @@ class UpgradeController extends BaseController */ $ma = ManufacturerRepository::findOne(['manufacture_no' => $deviceBatchInfo[0]]); - $manufactureId = 0; + $project = ProjectRepository::findOne(['project_no' => $deviceBatchInfo[1]]); + $model = ModelRepository::findOne(['model_no' => $deviceBatchInfo[2]]); + $manufactureId = $projectId = $modelId = 0; if ($ma) { $manufactureId = $ma->id; } - + if ($project) { + $projectId = $project->id; + } + if ($model) { + $modelId = $model->id; + } + if (empty($ma) || empty($project) || empty($model)) { + $e->status = 4; + $e->message = '厂商、项目、型号里面出现不在系统里面'; + return $e; + } $upgradeModel = UpgradeModel::find(); $upgradeModel->where([ 'manufacture_id' => $manufactureId, + 'project_id' => $projectId, + 'model_id' => $modelId, 'status' => UpgradeStatus::STATUS_ON, 'package_name' => $packageName, 'is_delete' => 0, diff --git a/app-ht/modules/datas/views/device/export.php b/app-ht/modules/datas/views/device/export.php index c88c592..964e510 100644 --- a/app-ht/modules/datas/views/device/export.php +++ b/app-ht/modules/datas/views/device/export.php @@ -8,6 +8,7 @@ header('Cache-Control: max-age=0'); $fp = fopen('php://output', 'a'); $limit = 10000; $cnt = 0; + ?> @@ -43,7 +44,7 @@ $cnt = 0; - + diff --git a/app-ht/modules/device/controllers/DeviceController.php b/app-ht/modules/device/controllers/DeviceController.php index 0675e51..43a3ec4 100644 --- a/app-ht/modules/device/controllers/DeviceController.php +++ b/app-ht/modules/device/controllers/DeviceController.php @@ -37,6 +37,12 @@ class DeviceController extends BaseController $manufacture = $request->get('manufacture'); $deviceId = $request->get('device_id'); $status = $request->get('status'); + + $startApplyAt = $request->get('start_apply_at'); + $endApplyAt = $request->get('end_apply_at'); + $startAuthAt = $request->get('start_auth_at'); + $endAuthAt = $request->get('end_auth_at'); + $page = $request->get('page'); $where = [ 'and', @@ -63,6 +69,18 @@ class DeviceController extends BaseController if (!empty($deviceId)) { $where[] = ['like', 'a.device_id', $deviceId]; } + if ($startApplyAt) { + $where[] = ['>=', 'a.apply_at', strtotime($startApplyAt)]; + } + if ($endApplyAt) { + $where[] = ['<=', 'a.apply_at', strtotime($endApplyAt) + 86400]; + } + if ($startAuthAt) { + $where[] = ['>=', 'a.auth_at', strtotime($startAuthAt)]; + } + if ($endAuthAt) { + $where[] = ['>=', 'a.auth_at', strtotime($endAuthAt) + 86400]; + } if (isset($_GET['status']) && -1 != $status) { $where[] = ['=', 'a.status', $status]; } else { @@ -90,6 +108,10 @@ class DeviceController extends BaseController 'device_id' => $deviceId, 'production' => $production, 'manufacture' => $manufacture, + 'start_apply_at' => $startApplyAt, + 'end_apply_at' => $endApplyAt, + 'start_auth_at' => $startAuthAt, + 'end_auth_at' => $endAuthAt, 'status' => $status ]; @@ -110,6 +132,11 @@ class DeviceController extends BaseController $manufacture = $request->get('manufacture'); $deviceId = $request->get('device_id'); $status = $request->get('status'); + + $startApplyAt = $request->get('start_apply_at'); + $endApplyAt = $request->get('end_apply_at'); + $startAuthAt = $request->get('start_auth_at'); + $endAuthAt = $request->get('end_auth_at'); $page = $request->get('page'); $where = [ 'and', @@ -136,6 +163,19 @@ class DeviceController extends BaseController if (!empty($deviceId)) { $where[] = ['like', 'a.device_id', $deviceId]; } + + if ($startApplyAt) { + $where[] = ['>=', 'a.apply_at', strtotime($startApplyAt)]; + } + if ($endApplyAt) { + $where[] = ['<=', 'a.apply_at', strtotime($endApplyAt) + 86400]; + } + if ($startAuthAt) { + $where[] = ['>=', 'a.auth_at', strtotime($startAuthAt)]; + } + if ($endAuthAt) { + $where[] = ['>=', 'a.auth_at', strtotime($endAuthAt) + 86400]; + } if (isset($_GET['status']) && -1 != $status) { $where[] = ['=', 'a.status', $status]; } else { @@ -163,6 +203,10 @@ class DeviceController extends BaseController 'device_id' => $deviceId, 'production' => $production, 'manufacture' => $manufacture, + 'start_apply_at' => $startApplyAt, + 'end_apply_at' => $endApplyAt, + 'start_auth_at' => $startAuthAt, + 'end_auth_at' => $endAuthAt, 'status' => $status ]; @@ -207,7 +251,7 @@ class DeviceController extends BaseController return $this->renderJson($e); } - $batchNo = strtoupper(Device::getBatchNo($manufactureNo,$projectNo,$modelNo,$productionNo)); + $batchNo = strtoupper(Device::getBatchNo($manufactureNo, $projectNo, $modelNo, $productionNo)); $batchModel = CreateBatchRepository::findOne(['batch_no' => $batchNo]); if ($batchModel) { $e->message = '已经创建过这个批次序列号'; @@ -258,7 +302,7 @@ class DeviceController extends BaseController /** * @return string */ - public function actionSearchItem() + public function actionBatchItem() { $req = Yii::$app->request; $type = $req->post('type'); diff --git a/app-ht/modules/device/views/device/auth-fail-index.php b/app-ht/modules/device/views/device/auth-fail-index.php index d3594dc..122dcb4 100644 --- a/app-ht/modules/device/views/device/auth-fail-index.php +++ b/app-ht/modules/device/views/device/auth-fail-index.php @@ -39,19 +39,14 @@ $this->params['breadcrumbs'][] = $this->title;
- -
- -
+ -
- +
+ -
- -
diff --git a/app-ht/modules/device/views/device/createDevice.php b/app-ht/modules/device/views/device/createDevice.php index 39903ac..5dfd8ed 100644 --- a/app-ht/modules/device/views/device/createDevice.php +++ b/app-ht/modules/device/views/device/createDevice.php @@ -14,6 +14,7 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css');
@@ -21,14 +22,19 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css');
- + +
- +
@@ -36,14 +42,18 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css');
- +
- +
@@ -63,66 +73,79 @@ CssFiles::register($this, 'exts/showimg/css/showimg.css');
- + +" /> \ No newline at end of file diff --git a/app-ht/modules/upgrade/views/upgrade/edit.php b/app-ht/modules/upgrade/views/upgrade/edit.php index 92e32dd..435f11b 100644 --- a/app-ht/modules/upgrade/views/upgrade/edit.php +++ b/app-ht/modules/upgrade/views/upgrade/edit.php @@ -22,8 +22,9 @@ $this->params['breadcrumbs'][] = $this->title; padding: 6px 15px!important; margin-right: 20px; } + .combo-select{max-width: 100% !important;} - +" />
@@ -47,10 +48,27 @@ $this->params['breadcrumbs'][] = $this->title;
- + +
+ +
+
+
+
- "/> -
>
+ +
+
+
+ +
+ +
+
+
+ +
+
@@ -90,13 +108,14 @@ $this->params['breadcrumbs'][] = $this->title;
- + \ No newline at end of file diff --git a/app-ht/modules/upgrade/views/upgrade/index.php b/app-ht/modules/upgrade/views/upgrade/index.php index e0e4e08..6e7cc78 100644 --- a/app-ht/modules/upgrade/views/upgrade/index.php +++ b/app-ht/modules/upgrade/views/upgrade/index.php @@ -46,7 +46,7 @@ $this->params['breadcrumbs'][] = $this->title; - "> + "> (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP)])?>">重    置 @@ -93,7 +93,7 @@ $this->params['breadcrumbs'][] = $this->title; -
+
@@ -120,7 +120,7 @@ $this->params['breadcrumbs'][] = $this->title; - $item['id']])?>" aid="">取消发布 + 取消发布 @@ -174,5 +174,33 @@ $this->params['breadcrumbs'][] = $this->title; }); } }); + + $(".btn_auth_cancel").bind("click",function () { + if (confirm("确定要取消发布该版本吗?")){ + var data_id = $.trim($(this).attr("aid")); + if (data_id == null || data_id == ""){ + alert("丢失参数,暂时无法取消,请刷新后再试"); + return false; + } + var thiz = $(this); + $.ajax({ + type: "post", + url: "", + dataType:"json", + data: $.csrf({id:data_id}), + success:function(res){ + if(!res.success) { + alert(res.message); + } else { + var versionType = $('#versionType').val(); + window.location.href = 'index?type='+versionType; + } + }, + error:function(msg){ + //提示确认失败 + } + }); + } + }); }); \ No newline at end of file diff --git a/app-ht/modules/upgrade/views/upgrade/push-app.php b/app-ht/modules/upgrade/views/upgrade/push-app.php index 7d4289c..1d2b340 100644 --- a/app-ht/modules/upgrade/views/upgrade/push-app.php +++ b/app-ht/modules/upgrade/views/upgrade/push-app.php @@ -30,7 +30,19 @@ $this->params['breadcrumbs'][] = $this->title;
- + +
+
+
+ +
+ +
+
+
+ +
+
diff --git a/app-ht/modules/upgrade/views/upgrade/push-ota.php b/app-ht/modules/upgrade/views/upgrade/push-ota.php index 9fa2b22..db05ed9 100644 --- a/app-ht/modules/upgrade/views/upgrade/push-ota.php +++ b/app-ht/modules/upgrade/views/upgrade/push-ota.php @@ -8,7 +8,9 @@ $this->params['breadcrumbs'][] = ['label' => '版本管理', 'url' => ['/upgrade $this->params['breadcrumbs'][] = $this->title; ?> - +
@@ -33,6 +35,18 @@ $this->params['breadcrumbs'][] = $this->title;
+
+ +
+ +
+
+
+ +
+ +
+

@@ -48,22 +62,22 @@ $this->params['breadcrumbs'][] = $this->title;
- (选填) +
- +
- 增量升级 - 全量升级 + 增量升级 + 全量升级
-
- +
+
- + - +
@@ -88,6 +102,14 @@ $this->params['breadcrumbs'][] = $this->title; } }); }); + $('.package_type').click(function(e){ + var thisVal = $(this).val(); + if(2 == thisVal) { + $('.version_range').show(); + } else { + $('.version_range').hide(); + } + }) $("#save").bind("click", function () { var getUrl = ''; @@ -109,14 +131,13 @@ $this->params['breadcrumbs'][] = $this->title; alert("请选择升级方式"); return false; } - if (start_version == ""){ - alert("请填写开始版本号"); - return false; - } - if (end_version == ""){ - alert("请填写结束版本号"); - return false; + if (2 == package_type) { + if (start_version == ""){ + alert("请填写开始版本号"); + return false; + } } + var cb = $("#myFrom").validate().form(); if (!cb){ return; diff --git a/console/controllers/TestController.php b/console/controllers/TestController.php index 76a8f83..917816e 100644 --- a/console/controllers/TestController.php +++ b/console/controllers/TestController.php @@ -119,8 +119,8 @@ class TestController extends Controller public function actionCheckOtaUpdate() { //actionCheckAppVersion - $url = 'http://47.107.95.101/app-api/web/checkOtaVersion'; - //$url = 'http://kingb:8012/app-api/web/checkOtaVersion'; + //$url = 'http://47.107.95.101/app-api/web/checkOtaVersion'; + $url = 'http://kingb:8012/app-api/web/checkOtaVersion'; $params = [ 'barcode' => '0001000100010001', 'device_id' => 'DGDEVBICEID00001', @@ -128,7 +128,7 @@ class TestController extends Controller 'hardware_version' => 'V1.0.1', ]; $params = json_encode($params); - $params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}'; + //$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}'; $postResult = Http::POST($url, $params); echo $postResult; } diff --git a/domain/device/CreateBatchRepository.php b/domain/device/CreateBatchRepository.php index f6a52ec..4b8482e 100644 --- a/domain/device/CreateBatchRepository.php +++ b/domain/device/CreateBatchRepository.php @@ -33,37 +33,35 @@ class CreateBatchRepository { if ('manufacture' == $type) { $q = new Query(); - $q->select('id,manufacture_no, name'); + $q->select(['concat(id, "_", manufacture_no) as uid', 'id','manufacture_no', 'name']); $q->from('manufacture'); - $q->where('name like "%'.$keyword.'%" or manufacture_no like "%'.$keyword.'%"'); - $q->limit(20); + $q->where('id >1'); + $list = $q->all(); return $list; } elseif('project' == $type) { $q = new Query(); - $q->select('id,project_no, name'); + $q->select(['concat(id,"_", project_no) as uid', 'id','project_no', 'name']); $q->from('project'); - $q->where('name like "%'.$keyword.'%" or project_no like "%'.$keyword.'%"'); - $q->limit(20); + $q->where('id >1'); + $list = $q->all(); return $list; } elseif ('model' == $type) { $q = new Query(); - $q->select('id,model_no, name'); + $q->select(['concat(id,"_", model_no) as uid','id','model_no', 'name']); $q->from('model'); - $q->where('name like "%'.$keyword.'%" or model_no like "%'.$keyword.'%"'); - $q->limit(20); + $q->where('id >1'); $list = $q->all(); return $list; } elseif ('production' == $type) { $q = new Query(); - $q->select('id,production_no, name'); + $q->select(['concat(id,"_", production_no) as uid','id','production_no', 'name']); $q->from('production'); - $q->where('name like "%'.$keyword.'%" or production_no like "%'.$keyword.'%"'); - $q->limit(20); + $q->where('id >1'); $list = $q->all(); return $list; diff --git a/domain/upgrade/Upgrade.php b/domain/upgrade/Upgrade.php index 1b733ec..49a2fbf 100644 --- a/domain/upgrade/Upgrade.php +++ b/domain/upgrade/Upgrade.php @@ -20,20 +20,30 @@ class Upgrade static function create($item) { try { - $findUpgradeModel = UpgradeModel::findOne(['version' => $item["version"], 'manufacture_id' => $item["manufacture_id"], 'type' => $item["type"]]); + $where = [ + 'version' => $item["version"], + 'manufacture_id' => $item["manufacture_id"], + 'project_id' => $item["project_id"], + 'model_id' => $item["model_id"], + 'type' => $item["type"] + ]; + $findUpgradeModel = UpgradeModel::findOne($where); if (!empty($findUpgradeModel)) { return -1; } $upgradeModel = Yii::createObject(UpgradeModel::className()); - $upgradeModel->type = $item["type"]; // 版本类型 1. app类升级,2. OTA整包升级 - $upgradeModel->version = $item["version"]; // 版本 - $upgradeModel->manufacture_id = $item["manufacture_id"]; // 厂商编号 - $upgradeModel->path = $item["path"]; // 文件路径 - $upgradeModel->package_name = $item["package_name"]; // 安装包名称 + $upgradeModel->type = $item["type"]; // 版本类型 1. app类升级,2. OTA整包升级 + $upgradeModel->version = $item["version"]; // 版本 + $upgradeModel->manufacture_id = $item["manufacture_id"]; // 厂商编号 + $upgradeModel->project_id = $item["project_id"]; // 项目 + $upgradeModel->model_id = $item["model_id"]; // 型号 + $upgradeModel->desc = $item["desc"]; // 描述 + $upgradeModel->path = $item["path"]; // 文件路径 + $upgradeModel->package_name = $item["package_name"]; // 安装包名称 if (isset($item["device_ids"])) { $upgradeModel->device_ids = $item["指定deviceID,可以多个,多个用逗号隔开"]; // 版本 } - $upgradeModel->size = $item["size"]; // 文件大小 + $upgradeModel->size = $item["size"]; // 文件大小 $upgradeModel->file_md5 = $item["file_md5"]; // 软件包校验用的md5 $saveResult = $upgradeModel->save(); return $saveResult; @@ -66,6 +76,15 @@ class Upgrade if (isset($item['manufacture_id']) && !empty($item['manufacture_id'])) { $upgradeModel->manufacture_id = $item['manufacture_id']; } + if (isset($item['project_id']) && !empty($item['project_id'])) { + $upgradeModel->project_id = $item['project_id']; + } + if (isset($item['model_id']) && !empty($item['model_id'])) { + $upgradeModel->model_id = $item['model_id']; + } + if (isset($item['desc']) && !empty($item['desc'])) { + $upgradeModel->desc = $item['desc']; + } if (isset($item['path']) && !empty($item['path'])) { $upgradeModel->path = $item['path']; } diff --git a/environments/dev/app-ht/config/params-local.php b/environments/dev/app-ht/config/params-local.php index 04062ae..a50fc61 100644 --- a/environments/dev/app-ht/config/params-local.php +++ b/environments/dev/app-ht/config/params-local.php @@ -3,6 +3,5 @@ return [ /** * 基础 CSS JS 的路径 */ - 'assetsUrl' => 'http://localhost/jw/src/app-ht/web',// - 'supervisorUrl' =>'http://120.24.157.206:9001/', // 用于多任务分发模板消息和短信队列的Supervisor网页管理后台地址 + 'assetsUrl' => 'http://47.107.95.101/app-ht/web/', ]; diff --git a/environments/dev/common/config/main-local.php b/environments/dev/common/config/main-local.php index b8e3434..77ff301 100644 --- a/environments/dev/common/config/main-local.php +++ b/environments/dev/common/config/main-local.php @@ -1,9 +1,9 @@ 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=ota', + 'dsn' => 'mysql:host=127.0.0.1;dbname=authorization', 'username' => 'root', - 'password' => '123456', + 'password' => 'kb@2019', 'charset' => 'utf8', ]; diff --git a/environments/prod/app-api/config/main-local.php b/environments/prod/app-api/config/main-local.php index d2d3633..4f30418 100644 --- a/environments/prod/app-api/config/main-local.php +++ b/environments/prod/app-api/config/main-local.php @@ -3,7 +3,7 @@ $config = [ 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation - 'cookieValidationKey' => '', + 'cookieValidationKey' => 'YdCyYvm8eOZZsaNRa_idrGimyTbsEQ8R', ], ], ]; diff --git a/environments/prod/app-ht/config/params-local.php b/environments/prod/app-ht/config/params-local.php index bad396d..219b46c 100644 --- a/environments/prod/app-ht/config/params-local.php +++ b/environments/prod/app-ht/config/params-local.php @@ -3,5 +3,5 @@ return [ /** * 基础 CSS JS 的路径 */ - 'assetsUrl' => 'http://47.107.95.101/app-ht/web', + 'assetsUrl' => 'http://47.107.95.101/app-ht/web/', ]; \ No newline at end of file diff --git a/environments/prod/common/config/main-local.php b/environments/prod/common/config/main-local.php index ae286b8..77ff301 100644 --- a/environments/prod/common/config/main-local.php +++ b/environments/prod/common/config/main-local.php @@ -1,7 +1,7 @@ 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=authorization', + 'dsn' => 'mysql:host=127.0.0.1;dbname=authorization', 'username' => 'root', 'password' => 'kb@2019', 'charset' => 'utf8', diff --git a/environments/test/common/config/main-local.php b/environments/test/common/config/main-local.php index b821494..77ff301 100644 --- a/environments/test/common/config/main-local.php +++ b/environments/test/common/config/main-local.php @@ -1,7 +1,7 @@ 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=ota', + 'dsn' => 'mysql:host=127.0.0.1;dbname=authorization', 'username' => 'root', 'password' => 'kb@2019', 'charset' => 'utf8', -- libgit2 0.21.0