Commit fcfbddb937ddf5cc727a4ff4de5538ab1e9e8f08

Authored by xu
1 parent 9394a543
Exists in master

app-ht

1. F 上传文件到 OSS拆开来处理
app-ht/modules/upgrade/controllers/UpgradeController.php
... ... @@ -593,7 +593,7 @@ class UpgradeController extends BaseController
593 593 $e->message = "该版本不存在";
594 594 return $this->renderJson($e);
595 595 }
596   - $uploadPath = dirname(dirname(dirname(__DIR__))) . "/" . $upgradeModel->upload_path;
  596 + $uploadPath = Yii::getAlias('@app/ht') . "/" . $upgradeModel->upload_path;
597 597 if (!file_exists($uploadPath)) {
598 598 $e->message = "该版本ECS文件不存在";
599 599 return $this->renderJson($e);
... ... @@ -605,6 +605,7 @@ class UpgradeController extends BaseController
605 605 $upgradeModel->save();
606 606 $e->success = true;
607 607 $e->message = "同步OSS成功";
  608 +
608 609 return $this->renderJson($e);
609 610 } catch (\Exception $ex) {
610 611 $e->message = "同步OSS异常:" . $ex->getMessage();
... ...
app-ht/modules/upgrade/views/upgrade/create.php
... ... @@ -231,7 +231,7 @@ $this->params['breadcrumbs'][] = $this->title;
231 231 '</div>').appendTo( $li ).find('.progress-bar');
232 232 }
233 233  
234   - $li.find('p.state').text('上传中, 文件会先上传到缓存再传到远程服务器,600M大概是12分钟左右,请耐心等待');
  234 + $li.find('p.state').text('上传中, 请耐心等待');
235 235  
236 236 $percent.css( 'width', percentage * 100 + '%' );
237 237 });
... ...
app-ht/modules/upgrade/views/upgrade/edit.php
... ... @@ -43,13 +43,13 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
43 43 APP版本号
44 44 <?php } ?>:</label>
45 45 <div class="col-sm-4 text-left">
46   - <input type="text" value="<?= (isset($info["version"]) ? $info["version"] : "") ?>" name="version" placeholder="请填写APP版本号" style="margin-top: -6px;" class="form-control"">
  46 + <input type="text" value="<?= (isset($info["version"]) ? $info["version"] : "") ?>" name="version" id="version" placeholder="请填写APP版本号" style="margin-top: -6px;" class="form-control"">
47 47 </div>
48 48 </div>
49 49 <div class="form-group col-sm-12">
50 50 <label for="skillName" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>安装包名称:</label>
51 51 <div class="col-sm-4 text-left">
52   - <input type="text" value="<?= (isset($info["package_name"]) ? $info["package_name"] : "") ?>" name="package_name" placeholder="请填写安装包名称" style="margin-top: -6px;" class="form-control"">
  52 + <input type="text" value="<?= (isset($info["package_name"]) ? $info["package_name"] : "") ?>" name="package_name" id="package_name" placeholder="请填写安装包名称" style="margin-top: -6px;" class="form-control"">
53 53 </div>
54 54 </div>
55 55 <div class="form-group col-sm-12">
... ... @@ -222,7 +222,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
222 222 '</div>').appendTo( $li ).find('.progress-bar');
223 223 }
224 224  
225   - $li.find('p.state').text('上传中, 文件会先上传到缓存再传到远程服务器,600M大概是12分钟左右,请耐心等待');
  225 + $li.find('p.state').text('上传中,请耐心等待');
226 226  
227 227 $percent.css( 'width', percentage * 100 + '%' );
228 228 });
... ... @@ -257,7 +257,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
257 257 var project = $('#project').val();
258 258 var model = $('#model').val();
259 259 var type = $('#type').val();
260   - $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model, id: $('#uid').val(), 'type':type}, function(res){
  260 + var package_name = $('#package_name').val();
  261 + var version = $('#version').val();
  262 + $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model, id: $('#uid').val(), 'type':type, package_name:package_name, version:version}, function(res){
261 263 if (res.success) {
262 264 if (that.hasClass('disabled')) {
263 265 return false;
... ...
app-ht/modules/upgrade/views/upgrade/index.php
... ... @@ -194,7 +194,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
194 194 });
195 195  
196 196 $(".btn_auth_cancel").bind("click",function () {
197   - if (confirm("确定要取消发布该版本吗?")){
  197 + if (confirm("确定要取消发布该版本吗?")) {
198 198 var data_id = $.trim($(this).attr("aid"));
199 199 if (data_id == null || data_id == ""){
200 200 alert("丢失参数,暂时无法取消,请刷新后再试");
... ... @@ -220,9 +220,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
220 220 });
221 221 }
222 222 });
223   -
224 223 $(".btn_upload_oss").bind("click",function () {
225   - if (confirm("确定要同步该版本文件到OSS吗?")){
  224 + if (confirm("确定要同步该版本文件到OSS吗?600M大概需要7分钟左右。")){
226 225 var data_id = $.trim($(this).attr("aid"));
227 226 if (data_id == null || data_id == ""){
228 227 alert("丢失参数,暂时无法取消,请刷新后再试");
... ... @@ -230,14 +229,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
230 229 }
231 230 var thiz = $(this);
232 231 thiz.text("同步中…");
  232 + $('#upload-mark').remove();
  233 + $('body').append('<div id="upload-mark" style="width:100%;height:100%;position:fixed;top:0;left:0;background: rgba(0,0,0,0.4)"></div>');
233 234 var loding = $.loading();
234 235 loding.show();
  236 +
235 237 $.ajax({
236 238 type: "post",
237 239 url: "<?=Url::toRoute('upgrade/push-oss')?>",
238 240 dataType:"json",
239 241 data: $.csrf({upgrade_id:data_id}),
240 242 success:function(res){
  243 + $('#upload-mark').remove();
241 244 loding.hide();
242 245 loding = null;
243 246 if(!res.success) {
... ...
domain/upgrade/Upgrade.php
... ... @@ -89,6 +89,7 @@ class Upgrade
89 89 return -1;
90 90 }
91 91 }
  92 + $oldUploadPath = $upgradeModel->upload_path;
92 93 if (isset($item['version']) && !empty($item['version'])) {
93 94 $upgradeModel->version = $item['version'];
94 95 }
... ... @@ -109,6 +110,9 @@ class Upgrade
109 110 }
110 111 if (isset($item['upload_path']) && !empty($item['upload_path'])) {
111 112 $upgradeModel->upload_path = $item['upload_path'];
  113 + if ($oldUploadPath != $item['upload_path']) {
  114 + $upgradeModel->oss_upload_status = UpgradeStatus::OSS_UPLOAD_WAIT;
  115 + }
112 116 }
113 117 if (isset($item['focuse']) && !empty($item['focuse'])) {
114 118 $upgradeModel->focuse = $item['focuse'];
... ...