Commit e546ab15a18ae1bdfa4ab32596c2a069e30d89a3
1 parent
fd360fdb
Exists in
master
app-ht
1. A 版本管理添加条件筛选
Showing
4 changed files
with
56 additions
and
18 deletions
Show diff stats
.gitignore
app-api/web/.gitignore
app-ht/modules/upgrade/controllers/UpgradeController.php
... | ... | @@ -45,6 +45,9 @@ class UpgradeController extends BaseController |
45 | 45 | $endTime = $request->get('endTime'); |
46 | 46 | $status = $request->get('status'); |
47 | 47 | $version = $request->get('version'); |
48 | + $manufacture_name = $request->get('manufacture_name'); | |
49 | + $project_name = $request->get('project_name'); | |
50 | + $model_name = $request->get('model_name'); | |
48 | 51 | $dataType = !empty($request->get('type')) ? $request->get('type') : UpgradeStatus::TYPE_APP; |
49 | 52 | |
50 | 53 | $gets = [ |
... | ... | @@ -53,9 +56,25 @@ class UpgradeController extends BaseController |
53 | 56 | 'status' => $status, |
54 | 57 | 'version' => $version, |
55 | 58 | 'type' => $dataType, |
59 | + 'manufacture_name' => $manufacture_name, | |
60 | + 'project_name' => $project_name, | |
61 | + 'model_name' => $model_name | |
56 | 62 | ]; |
57 | 63 | |
58 | 64 | $where = ['and']; |
65 | + if ($manufacture_name) { | |
66 | + $where[] = ['or', ['like','mf.name', $manufacture_name], ['like','mf.manufacture_no', $manufacture_name]]; | |
67 | + } | |
68 | + | |
69 | + if ($project_name) { | |
70 | + $where[] = ['or', ['like','pro.name', $project_name], ['like','pro.project_no', $project_name]]; | |
71 | + } | |
72 | + | |
73 | + if ($model_name) { | |
74 | + $where[] = ['or', ['like','mo.name', $model_name], ['like','mo.model_no', $model_name]]; | |
75 | + } | |
76 | + | |
77 | + | |
59 | 78 | if ($creatTime) { |
60 | 79 | $creatTime = strtotime($creatTime); |
61 | 80 | $where[] = ['>=', 'u.pushed_at', $creatTime]; |
... | ... | @@ -408,7 +427,7 @@ class UpgradeController extends BaseController |
408 | 427 | */ |
409 | 428 | public function actionUploadFile() |
410 | 429 | { |
411 | - header("Expires: Mon, 26 Jul 2020 05:00:00 GMT"); | |
430 | + header("Expires: Mon, 26 Jul 2030 05:00:00 GMT"); | |
412 | 431 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
413 | 432 | header("Content-type: text/html; charset=utf-8"); |
414 | 433 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
... | ... | @@ -432,11 +451,11 @@ class UpgradeController extends BaseController |
432 | 451 | // Uncomment this one to fake upload time |
433 | 452 | usleep(5000); |
434 | 453 | // Settings |
435 | - $upload = dirname(dirname(dirname(__DIR__))) . "/web/upload"; | |
436 | - $savePath = 'web/upload/packages/package_' . date("Ymd"); | |
454 | + $upload = Yii::getAlias('@app/api') . "/web/upload"; | |
455 | + $savePath = 'web/upload/packages/package_' . date("Ym"); | |
437 | 456 | $assetsUrl = Yii::$app->params['assetsUrl']; |
438 | - $targetDir = $upload . '/packages/file_material_tmp/' . Yii::$app->user->id; //存放分片临时目录 | |
439 | - $uploadDir = $upload . '/packages/package_' . date("Ymd"); | |
457 | + $targetDir = $upload . '/packages/file_material_tmp'; //存放分片临时目录 | |
458 | + $uploadDir = $upload . '/packages/package_' . date("Ym"); | |
440 | 459 | |
441 | 460 | $cleanupTargetDir = true; // Remove old files |
442 | 461 | $maxFileAge = 5 * 3600; // Temp file age in seconds |
... | ... | @@ -517,8 +536,10 @@ class UpgradeController extends BaseController |
517 | 536 | |
518 | 537 | if ($done) { |
519 | 538 | $pathInfo = pathinfo($fileName); |
520 | - $hashStr = substr(md5($pathInfo['basename']),8,16); | |
521 | - $hashName = time() . $hashStr . '.' .$pathInfo['extension']; | |
539 | + $hashStr = substr(md5(time().mt_rand(000000, 999999)), 8, 16); | |
540 | + $fName = str_replace(' ', '', $pathInfo['basename']); | |
541 | + $filenameArr = explode('.', $fName); | |
542 | + $hashName = $filenameArr[0] .'_'. $hashStr . '.' .$pathInfo['extension']; | |
522 | 543 | $uploadPath = $uploadDir . "/" .$hashName; |
523 | 544 | $saveUploadPath = $savePath . "/" . $hashName; |
524 | 545 | if (!$out = fopen($uploadPath, "wb")) { |
... | ... | @@ -540,7 +561,7 @@ class UpgradeController extends BaseController |
540 | 561 | } |
541 | 562 | fclose($out); |
542 | 563 | |
543 | - $savePath = self::getFilePath(Yii::$app->user->id, $hashName); | |
564 | + $savePath = self::getFilePath($hashName, Yii::$app->user->id); | |
544 | 565 | |
545 | 566 | $response = [ |
546 | 567 | 'success' => true, |
... | ... | @@ -593,7 +614,7 @@ class UpgradeController extends BaseController |
593 | 614 | $e->message = "该版本不存在"; |
594 | 615 | return $this->renderJson($e); |
595 | 616 | } |
596 | - $uploadPath = Yii::getAlias('@app/ht') . "/" . $upgradeModel->upload_path; | |
617 | + $uploadPath = Yii::getAlias('@app/api') . "/" . $upgradeModel->upload_path; | |
597 | 618 | if (!file_exists($uploadPath)) { |
598 | 619 | $e->message = "该版本ECS文件不存在"; |
599 | 620 | return $this->renderJson($e); |
... | ... | @@ -740,14 +761,13 @@ class UpgradeController extends BaseController |
740 | 761 | } |
741 | 762 | |
742 | 763 | /** |
743 | - * 获取文件存储路径: bind_apply/20170509/[userId]/文件名 | |
744 | - * @param $userId | |
764 | + * 获取文件存储路径: bind_apply/201705//文件名 | |
745 | 765 | * @param $suffix 文件后缀 |
746 | 766 | * @return string |
747 | 767 | */ |
748 | - public static function getFilePath($userId, $filename) | |
768 | + public static function getFilePath( $filename, $userId) | |
749 | 769 | { |
750 | - $basePath = "upgrade_packages/" . date("Ymd") . '/' . $userId; | |
770 | + $basePath = "upgrade_packages/" . date("Ym"); | |
751 | 771 | $savePath = $basePath . '/' . $filename; |
752 | 772 | return $savePath; |
753 | 773 | } | ... | ... |
app-ht/modules/upgrade/views/upgrade/index.php
... | ... | @@ -24,20 +24,34 @@ $this->params['breadcrumbs'][] = $this->title; |
24 | 24 | <table width="100%" class="table"> |
25 | 25 | <tbody> |
26 | 26 | <tr > |
27 | - <td width="10%" class="text-right">APP版本号</td> | |
27 | + <td width="10%" class="text-right">厂商:</td> | |
28 | 28 | <td width="20%" class="text-left"> |
29 | - <input type="text" class="form-control" name="version" placeholder="输入APP版本号" value="<?php if (!empty($gets['version'])){ echo $gets['version']; } ?>"> | |
29 | + <input type="text" class="form-control" name="manufacture_name" placeholder="厂商关键字" value="<?php if (!empty($gets['manufacture_name'])){ echo $gets['manufacture_name']; } ?>"> | |
30 | + </td> | |
31 | + <td width="10%" class="text-right">项目:</td> | |
32 | + <td width="20%" class="text-left"> | |
33 | + <input type="text" class="form-control" name="project_name" placeholder="项目关键字" value="<?php if (!empty($gets['project_name'])){ echo $gets['project_name']; } ?>"> | |
30 | 34 | </td> |
31 | - <td width="10%" class="text-right">发布状态:</td> | |
35 | + <td width="10%" class="text-right">型号:</td> | |
32 | 36 | <td width="20%" class="text-left"> |
37 | + <input type="text" class="form-control" name="model_name" placeholder="型号关键字" value="<?php if (!empty($gets['model_name'])){ echo $gets['model_name']; } ?>"> | |
38 | + </td> | |
39 | + </tr> | |
40 | + <tr > | |
41 | + <td class="text-right">APP版本号</td> | |
42 | + <td class="text-left"> | |
43 | + <input type="text" class="form-control" name="version" placeholder="输入APP版本号" value="<?php if (!empty($gets['version'])){ echo $gets['version']; } ?>"> | |
44 | + </td> | |
45 | + <td class="text-right">发布状态:</td> | |
46 | + <td class="text-left"> | |
33 | 47 | <select class="form-control" id="status" name="status"> |
34 | 48 | <option>全部</option> |
35 | 49 | <option value="-1" <?php if (isset($gets['status']) && $gets['status'] == -1){ echo "selected"; } ?>>未发布</option> |
36 | 50 | <option value="1" <?php if (isset($gets['status']) && $gets['status'] == 1){ echo "selected"; } ?>>已发布</option> |
37 | 51 | </select> |
38 | 52 | </td> |
39 | - <td width="10%" class="text-right">发布时间:</td> | |
40 | - <td width="20%" class="text-left"> | |
53 | + <td class="text-right">发布时间:</td> | |
54 | + <td class="text-left"> | |
41 | 55 | <div class="form-inline"> |
42 | 56 | <input type="date" class="form-control" style="width: 150px;" name="creatTime" placeholder="起" value="<?php if (!empty($gets['creatTime'])){ echo $gets['creatTime']; } ?>"> - |
43 | 57 | <input type="date" class="form-control" style="width: 150px;" name="endTime" placeholder="止" value="<?php if (!empty($gets['endTime'])){ echo $gets['endTime']; } ?>"> | ... | ... |