天天看點

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

input 、multiple選擇多張圖檔時,需要删除其中的一張圖檔怎麼做,大家都知道 input 中的檔案是不能删除和更改的,隻能清空,這裡我的做法是 定義一個對象儲存器把需要的檔案存在儲存器中 formData,背景不從Input中讀取,從對象存儲器中擷取檔案,一組圖檔使用一個儲存器中formData,存儲器中的 key 我們用檔案名加Input的ID 拼接,而後取出圖檔的key 也用Input的ID;删除圖檔也是同一個key; 上傳所有的圖檔時,用ajax 需要異步操作與背景互動,背景根據 key 擷取所有圖檔,圖檔最終儲存在阿裡oss對象儲存伺服器上,資料庫寫入圖檔上傳後傳回的URL位址;

(ajax用async: false同步後,(确認框)無法關閉【使用者會誤認為程式卡死狀态】,确認框需要等待所有的ajax代碼依次執行結束才會關閉,是以這裡需要把ajax改為異步,自己通過其它技術實作同步,使用者點确認按鈕後确認框會馬上關閉!)

【 

ajax同步技術:

1、  var someAjaxDfd = $.Deferred(); 

2、  var its_promise = $.when( someAjaxDfd );

3、【 someAjaxDfd.resolve();   放對應的ajax 執行結束的代碼中 】

4、  its_promise.done(function () {

         【對應的ajax執行結束後會執行這裡面的代碼】

        });

ajax 同步圖:

someAjaxDfd.resolve();   放對應的ajax 執行結束的代碼中;

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

效果:

添加圖檔:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

删除其中一張圖檔:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

重複圖檔提示:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

單圖檔預覽:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

 确認框:

(ajax 如不做異步,這個框點選确認後會一直存在直到ajax都執行完畢,使用者點選後會誤認為程式卡死)

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

上傳圖檔元件樣式:

D:\Project\lvmsm\src\main\webapp\assets\upjs\css\index.css

<link href="/assets/upjs/css/index.css" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" type="text/css" rel="stylesheet"/>

/*上傳圖檔插件的樣式*/
.img-box{
	margin-top: 40px;
}
.img-box .up-p{
	margin-bottom: 20px;
	font-size: 16px;
	color: #555;
}
.z_photo{
	padding: 18px;
	border:2px dashed #E7E6E6;
	/*padding: 18px;*/
}
.z_photo .z_file{
	position: relative;
}
.z_file  .file{
	width: 100%;
	height: 100%;
	opacity: 0;
	position: absolute;
	top: 0px;
	left: 0px;
	z-index: 100;
}
.z_photo .up-section{
	position: relative;
	margin-right: 20px;
	margin-bottom: 20px;
}
.up-section .close-upimg{
	position: absolute;
	top: 6px;
	right: 8px;
	display: none;
	z-index: 10;
}
.up-section .up-span{
	/*display: block;*/
	width: 100%;
	height: 100%;
	visibility: hidden;
	position: absolute;
	top: 0px;
	left: 0px;
	z-index: 9;
	background: rgba(0,0,0,.5);
}
.up-section:hover{
	border: 2px solid #f15134;
}
.up-section:hover .close-upimg{

	display: block;
}
.up-section:hover .up-span{
	/*選擇中圖檔變黑*/
	/*visibility: visible;*/
}
.z_photo .up-img{
	display: block;
	width: 100%;
	height: 100%;
}
.loading{
    border: 1px solid #D1D1D1;
	background:url(../img/loading.gif) no-repeat center;
}
.up-opcity{
	opacity: 0;
}
.img-name-p{
	display: none;
}
.upimg-div .up-section {
    width: 190px;
    height: 180px;
}
.img-box .upimg-div .z_file {
    width: 190px;
    height: 180px;
}
.z_file .add-img {
    display: block;
    width: 190px;
    height: 180px;
}
/*遮罩層樣式*/
.mask{
	z-index: 1000;
	display: none;
	position: fixed;
	top: 0px;
	left: 0px;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,.4);
}
.mask .mask-content{
	 width: 500px;
	 position: absolute;
	 top: 50%;
	 left: 50%;
	 margin-left: -250px;
	 margin-top: -80px;
	 background: white;
	 height: 160px;
	 text-align: center;
}
.mask .mask-content .del-p{
	color: #555;
	height: 94px;
	line-height: 94px;
	font-size: 18px;
	border-bottom: 1px solid #D1D1D1;
}
.mask-content .check-p{
	height: 66px;
	line-height: 66px;
	position: absolute;
	bottom: 0px;
	left: 0px;
	width: 100%;
}
.mask-content .check-p span{
	width: 49%;
	display:inline-block;
	text-align: center;
	color:#d4361d ;
	font-size: 18px;
}
.check-p .del-com{
	border-right: 1px solid #D1D1D1;
}
           
<link href="/assets/upjs/css/common.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  type="text/css" rel="stylesheet"/>      
* {
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	/* Firefox */
	-webkit-box-sizing: border-box;
	/* Safari */
}
.up-section .type-upimg{
	display: none;
}
::-ms-clear,::-ms-reveal{display:none;}
textarea{
	outline: none;
	line-height: 14px;
	padding-left: 4px;
	padding-top: 4px;
	border: 1px solid #ccc;
	color: #444;
	font-size: 14px;
	outline: none;
	text-align: left;
}
.overflow{
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
button{
	outline: none;
	border: 0px;
	font-family: "微軟雅黑", "PingFang SC", "arial, helvetica, sans-serif";
}
input{
	font-family: "微軟雅黑", "PingFang SC", "arial, helvetica, sans-serif";
	outline: none;
}
a {
	outline: none;
}
a,button{cursor:pointer;} 

/*body {
	background: #f4f4f4;
	font-size: 14px;
	font-family: "微軟雅黑", "PingFang SC", "arial, helvetica, sans-serif";
}*/
.clear {
	clear: both;
}
.full{
	width: 1210px;
	min-width: 1210px;
	margin: 0 auto;
}
.full-big{
	width: 1340px;
	min-width: 1340px;
	margin: 0 auto;
}
.img-full{
	display: block;
	width: 100%;
}
::-webkit-input-placeholder {
	color: #777;
	font-size: 14px;
}
:-moz-placeholder {
	/* Firefox 18- */
	color: #777;
	font-size: 14px;
}
::-moz-placeholder {
	/* Firefox 19+ */
	color: #777;
	font-size: 14px;
}
:-ms-input-placeholder {
	color:#777;
	font-size: 14px;
}
/* ====clear float====== */
/*nav a:visited{color: rgb(65,65,65);}
aside a:visited{color: rgb(65,65,65);}*/
.fl {
	float: left;
}
.fr {
	float: right;
}
.clear:after {
	content: '';
	display: block;
	clear: both;
}
/* reset */
.pic img{display: none;}
i,
p,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
br,
em,
dl,
dd,
li,
ul,
ol,
td,
th,
pre,
form,
body,
input,
strong,
textarea,
select,figcaption,figure{
	margin: 0;
	padding: 0;
}
em {
	font-style: normal
}
li {
	list-style: none
}
a {
	text-decoration: none;
}
img {
	border: none;
	
}
table {
	border-collapse: collapse;
}
textarea {
	resize: none;
	overflow: auto;
}
a,button{cursor:pointer;} 
           

圖檔增删 與背景互動js:

assets/js/gm/add-GasCylinderCheckInfoAjaxfileupload.js

/*===========================================首頁證書檢視===================================================*/
$(document).ready(function() {


});
//多圖檔檢視
function showImg(urls) {
  var  url = "";
    if(null != urls && 0 < urls.length) {
        $("#showImg").val(urls);
        var url = urls.split(',');

    }
    if(null != url && url != ""){
        popWin.showWin("1300","590","檢視證書",url);
    }else{
        DJMask.msg("未擷取到資料請檢查!");
    }

}

//單圖檔檢視
function showImgD(url) {

    if(null != url && url != ""){
        popWinD.showWin("600","590","檢視證書",url);
    }else{
        DJMask.msg("未擷取到資料請檢查!");
    }

}
/*function ass() {
    popWin.showWin("800","600","通用的iframe彈層插件","http://www.jq22.com");
}*/
/*-------------------------------------------------上傳圖檔,圖檔顯示js,控制5張圖檔------------------------------------------------------------------------*/
//取資料
/*産品合格證*/
/*對應圖檔上傳input的ID*/
var fu1="productqualifyurlFile1";
/*圖檔儲存器*/
var formData = new FormData();
var formData1 = new FormData();

/*(品質證明書)*/
/*對應圖檔上傳input的ID*/
var fuA="qualitycertificateurlFile2";
/*圖檔儲存器*/
var formDataA = new FormData();
var formDataA1 = new FormData();

/*(使用說明書)*/
/*對應圖檔上傳input的ID*/
var fuB="instructionmanualurlFile2";
/*圖檔儲存器*/
var formDataB = new FormData();
var formDataB1 = new FormData();

/*(檢驗報告)*/
/*對應圖檔上傳input的ID*/
var fuC="inspectereporturlFile2"
/*圖檔儲存器*/
var formDataC = new FormData();
var formDataC1 = new FormData();

/*(日常檢驗記錄)*/
/*對應圖檔上傳input的ID*/
var fuD="dailyinspectrecordurlFile2";
/*圖檔儲存器*/
var formDataD = new FormData();
var formDataD1 = new FormData();


$(function () {
    var delParent;
    var idFile;
    var defaults = {
        fileType: ["jpg", "png", "bmp", "jpeg", "JPG","PNG"],   // 上傳檔案的類型

        fileSize: 1024 * 1024 * 10                  // 上傳檔案的大小 10M
    };
    /*點選圖檔的文本框*/
    $("table").delegate(".file", "change", function () {

       /*擷取對應圖檔上傳input的ID*/
        idFile = $(this).attr("id")+"";
        /*擷取對應圖檔集*/
        var file = document.getElementById(idFile);
        var imgContainer = $(this).parents(".z_photo"); //存放圖檔的父親元素

        var fileList = file.files; //擷取的圖檔檔案

        console.log(fileList + "======filelist=====");
        var input = $(this).parent();//文本框的父親元素
        var imgArr = [];

        //周遊得到的圖檔檔案

        var numUp = imgContainer.find(".up-section").length;
        var totalNum = numUp + fileList.length;  //總的數量
        if (fileList.length > 5 || totalNum > 5) {
          //一次選擇上傳超過5個 或者是已經上傳和這次上傳的到的總數也不可以超過5個
            DJMask.msg("上傳圖檔數目不可以超過5個,請重新選擇!");
        }
        else if (numUp < 5) {
            fileList = validateUp(fileList);
            for (var i = 0; i < fileList.length; i++) {
                var imgUrl = window.URL.createObjectURL(fileList[i]);
                imgArr.push(imgUrl);
             
                var $section = $("<section class='up-section fl loading'>");
                imgContainer.prepend($section);
                var $span = $("<span class='up-span'>");
                $span.appendTo($section);

             /*   删除圖檔*/
          var $img0 = $("<img class='close-upimg'>").on("click", function (event) {

                    event.preventDefault();
                    event.stopPropagation();
                    $(".works-mask").show();
                    delParent = $(this).parent();

              var numUp = delParent.siblings().length;
              if (numUp < 6) {
                  delParent.parent().find(".z_file").show();
              }
              /* 擷取删除圖檔的圖檔名*/  
              var fileName =$(this).parent().children(".img-name-p").text();
                /* 擷取删除圖檔的input的ID*/  
              var idFile1 = $(this).parent(). nextAll(".z_file").children(".file").attr("id")+"";

      /* 判斷删除圖檔的input的ID是哪一組圖檔,對應操作對應的圖檔儲存器!*/          
                  if(idFile1 == fu1){
                  formData.delete((fileName+idFile1));
                  formData.delete(idFile1);
                  formData1.delete(idFile1);
                  var i = formData.entries();
                  while(item = i.next()){
                      if(item.done) break;
                      //因為對象裡存儲多個類型的圖檔,需要區分圖檔單獨增删
                      if(item.value[0] != idFile1){
                       //将需要的圖檔中轉一下,直接放formData這個裡可能會死循序
                          formData1.append(idFile1,item.value[1]);
                      }
                  }
                  //周遊中轉存儲器formDataA中的圖檔
                  var y = formData1.entries();
                  while(item1 = y.next()){
                      if(item1.done) break;
                          //加入formData存儲器中,key為input的ID
                          formData.append(idFile1,item1.value[1]);
                  }
                  delParent.remove();
              }else if(idFile1 == fuA){
                  formDataA.delete((fileName+idFile1));
                  formDataA.delete(idFile1);
                  formDataA1.delete(idFile1);
                  var i = formDataA.entries();
                  while(item = i.next()){
                      if(item.done) break;
                      //因為對象裡存儲多個類型的圖檔,需要區分圖檔單獨增删
                      if(item.value[0] != idFile1){
                         //将需要的圖檔中轉一下,直接放formDataA這個裡可能會死循序
                          formDataA1.append(idFile1,item.value[1]);
                      }
                  }

                  var y = formDataA1.entries();
                  while(item1 = y.next()){
                      if(item1.done) break;
                          formDataA.append(idFile1,item1.value[1]);
                  }
                  delParent.remove();
              }else if(idFile1 == fuB){
                  formDataB.delete((fileName+idFile1));
                  formDataB.delete(idFile1);
                  formDataB1.delete(idFile1);
                  var i = formDataB.entries();
                  while(item = i.next()){
                      if(item.done) break;
                      //因為對象裡存儲多個類型的圖檔,需要區分圖檔單獨增删
                      if(item.value[0] != idFile1){
                          formDataB1.append(idFile1,item.value[1]);
                      }
                  }

                  var y = formDataB1.entries();
                  while(item1 = y.next()){
                      if(item1.done) break;
                          formDataB.append(idFile1,item1.value[1]);
                  }
                  delParent.remove();
              }else if(idFile1 == fuC){
                  formDataC.delete((fileName+idFile1));
                  formDataC.delete(idFile1);
                  formDataC1.delete(idFile1);
                  var i = formDataC.entries();
                  while(item = i.next()){
                      if(item.done) break;
                      //因為對象裡存儲多個類型的圖檔,需要區分圖檔單獨增删
                      if((item.value[0]+"") != idFile1){
                          formDataC1.append(idFile1,item.value[1]);
                      }
                  }

                  var y = formDataC1.entries();
                  while(item1 = y.next()){
                      if(item1.done) break;
                          formDataC.append(idFile1,item1.value[1]);
                  }
                  delParent.remove();
              }else if(idFile1 == fuD){
                  formDataD.delete((fileName+idFile1));
                  formDataD.delete(idFile1);
                  formDataD1.delete(idFile1);
                  var i = formDataD.entries();
                  while(item = i.next()){
                      if(item.done) break;
                      //因為對象裡存儲多個類型的圖檔,需要區分圖檔單獨增删
                      if((item.value[0]+"") != idFile1){
                          formDataD1.append(idFile1,item.value[1]);

                      }

                  }

                  var y = formDataD1.entries();
                  while(item1 = y.next()){
                      if(item1.done) break;
                          formDataD.append(idFile1,item1.value[1]);
                  }

                  delParent.remove();
              }

                });

                /*删除圖檔按鈕*/
                $img0.attr({"src":"/assets//upjs/img/a7.png"}).appendTo($section);
                /*單張圖檔預覽*/
                var $img = $("<a href=\"javascript:showImgD('"+imgArr[i]+"')\"><img class='up-img up-opcity' src='"+imgArr[i]+"'></a>");
                /*var $img = $("<img class='up-img up-opcity' >");*/
                $img.attr("src", imgArr[i]);
                $img.appendTo($section);
                var $p = $("<p class='img-name-p'>");
                $p.html(fileList[i].name).appendTo($section);
                var $input = $("<input id='taglocation' name='taglocation' value='' type='hidden'>");
                $input.appendTo($section);
                var $input2 = $("<input id='tags' name='tags' value='' type='hidden'/>");
                $input2.appendTo($section);

            }
        }




        setTimeout(function () {
            $(".up-section").removeClass("loading");
            $(".up-img").removeClass("up-opcity");
        }, 450);
        numUp = imgContainer.find(".up-section").length;
        if (numUp >= 5) {
            $(this).parent().hide();
        }

    });


    $(".z_photo").delegate(".close-upimg", "click", function () {
        $(".works-mask").show();
        delParent = $(this).parent();
    });

    $(".wsdel-ok").click(function () {
        $(".works-mask").hide();
        var numUp = delParent.siblings().length;
        if (numUp < 6) {
            delParent.parent().find(".z_file").show();
        }

        delParent.remove();

    });

    $(".wsdel-no").click(function () {
        $(".works-mask").hide();
    });



    function validateUp(files) {

        var arrFiles = [];//替換的檔案數組

        for (var i = 0, file; file = files[i]; i++) {
            //擷取檔案上傳的字尾名

            var newStr = file.name.split("").reverse().join("");
            if (newStr.split(".")[0] != null) {
                var type = newStr.split(".")[0].split("").reverse().join("");
                console.log(type + "===type===");
                if (jQuery.inArray(type, defaults.fileType) > -1) {
                    // 類型符合,可以上傳
                    if (file.size >= defaults.fileSize) {
                        DJMask.msg(file.size);
                        DJMask.msg('您這個"' + file.name + '"檔案大小過大');
                    
                    } else {

                        // 在這裡需要判斷目前所有檔案中
                        //判斷 增加的圖檔是哪個input 的ID,把圖檔加入對應的圖檔儲存器中
                        if(idFile == fu1){
                           //判斷 圖檔儲存器中是否已存在該圖檔,如果存在就不加入,并給與提示;
                            if( !formData.has((file.name+idFile))) {
                                formData.append((file.name + idFile), file);
                                formData.append(idFile, file);
                                arrFiles.push(file);
                            }else{
                                DJMask.msg("檔案不能重複上傳!");
                            }

                        }else if(idFile == fuA){
                            if( !formDataA.has((file.name+idFile))) {
                                formDataA.append((file.name + idFile), file);
                                formDataA.append(idFile, file);
                                arrFiles.push(file);
                            }else{
                                DJMask.msg("檔案不能重複上傳!");
                            }
                        }else if(idFile == fuB){
                            if( !formDataB.has((file.name+idFile))) {
                                formDataB.append((file.name + idFile), file);
                                formDataB.append(idFile, file);
                                arrFiles.push(file);
                            }else{
                                DJMask.msg("檔案不能重複上傳!");
                            }
                        }else if(idFile == fuC){
                                if( !formDataC.has((file.name+idFile))) {
                            formDataC.append((file.name+idFile),file);
                            formDataC.append(idFile,file);
                                    arrFiles.push(file);
                                }else{
                                    DJMask.msg("檔案不能重複上傳!");
                                }
                        }else if(idFile == fuD){
                                if( !formDataD.has((file.name+idFile))) {
                            formDataD.append((file.name+idFile),file);
                            formDataD.append(idFile,file);
                              arrFiles.push(file);
                                }else{
                                    DJMask.msg("檔案不能重複上傳!");
                                }
                        }
                    }
                } else {
                    
                    DJMask.msg('您這個"' + file.name + '"上傳類型不符合');
                }
            } else {
               
                DJMask.msg('您這個"' + file.name + '"沒有類型, 無法識别');
            }
        }
        return arrFiles;
    }

})

/*================================================實作資料庫圖檔上傳==================================================================*/



/*産品合格證*/
function ProductqualifyurlFileUpload(someAjaxDfd) {
    /*産品合格證*/
    $.ajax({
        url: "/config/create-AllGasCylinderCheckInfoFileurlFileUpload",
        type: "POST",
        dataType: 'json',
        processData: false,
        contentType: false,
        data: formData,
        /*async: false,*/
        success: function(data){
            if (data.resultCode == 200) {
                $("#productqualifyurl").val(data.fieldString);
            }
            if (data.resultCode == 505) {
                DJMask.msg("請圖檔上傳失敗");
            }
            someAjaxDfd.resolve();
        },
        error: function () {
        }
    });

}



/*品質證書*/
 function qualitycertificateurlFileUpload(ajax1Dfd) {
    /*品質證書*/
     $.ajax({
         url: "/config/create-AllGasCylinderCheckInfoQualitycertificateurlFileUpload",
         type: "POST",
         dataType: 'json',
         processData: false,
         contentType: false,
         data: formDataA,
         /*async: false,*/
         success: function(data){
             if (data.resultCode == 200) {
                 $("#qualitycertificateurl").val(data.fieldString);
             }
             if(data.resultCode == 505){
                 DJMask.msg("請圖檔上傳失敗");
             }
             ajax1Dfd.resolve();
         },
         error: function () {
         }
     });


}


/* 使用說明書*/
function instructionmanualurlFileUpload(ajax3Dfd) {
    $.ajax({
        url: "/config/create-AllGasCylinderCheckInfoInstructionmanualurlUpload",
        type: "POST",
        dataType: 'json',
        processData: false,
        contentType: false,
        data: formDataB,
        /*async: false,*/
        success: function(data){
            if (data.resultCode == 200) {
                $("#instructionmanualurl").val(data.fieldString);
            }
            if(data.resultCode == 505){
                DJMask.msg("請圖檔上傳失敗");
            }
            ajax3Dfd.resolve();
        },
        error: function () {
        }
    });

}
/* 檢驗報告*/
function InspectereporturlUpload(ajax4Dfd) {
    /*===================================== */
    $.ajax({
        url: "/config/create-AllGasCylinderCheckInspectereporturlUpload",
        type: "POST",
        dataType: 'json',
        processData: false,
        contentType: false,
        data: formDataC,
       /* async: false,*/
        success: function(data){
            if (data.resultCode == 200) {
                $("#inspectereporturl").val(data.fieldString);
            }
            if(data.resultCode == 505){
                DJMask.msg("請圖檔上傳失敗");
            }
            ajax4Dfd.resolve();
        },
        error: function () {
        }
    });


}
/*  日常檢驗記錄*/
function DailyinspectrecordurlUpload(ajax5Dfd) {

    $.ajax({
        url: "/config/create-AllGasCylinderCheckDailyinspectrecordurlUpload",
        type: "POST",
        dataType: 'json',
        processData: false,
        contentType: false,
        data: formDataD,
        /*async: false,*/
        success: function(data){
            if (data.resultCode == 200) {
                $("#dailyinspectrecordurl").val(data.fieldString);
            }
            if(data.resultCode == 505){
                DJMask.msg("請圖檔上傳失敗");
            }
            ajax5Dfd.resolve();
        },
        error: function () {
        }
    });

}




/*==================================上傳圖檔(産品合格證url)=首頁上傳圖檔,更新資料庫============================================================*/
function productqualifyurlUploadImage1(id, i) {
    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);
    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("productqualifyurlFile" + i + "").files;
    var f = document.getElementById("productqualifyurlFile" + i + "").value;
    if ((files.length-0) == 0) {
        DJMask.msg("請上傳圖檔");
        return false;
    }else if( 5 < (files.length-0)  ){
        DJMask.msg("圖檔不能超過5張!");
        return false;
    } else {
        if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
            DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
            return false;
        }
    }

    DJMask.msg("請稍等正在處理!");
    $.ajaxFileUpload({
        url: "/config/add-GasCylinderCheckInfoProductqualifyurlUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
        /*data: {'id': id},*/
        fileElementId: 'productqualifyurlFile' + i,
        dataType: "json",
        success: function (data) {
            if (200 == data.resultCode) {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            } else {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                DJMask.msg(data.failDesc);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            }

        }
    });


}
/*==================================上傳圖檔(品質證明書url)=首頁上傳圖檔,更新資料庫============================================================*/
function qualitycertificateurlUploadImage1(id, i) {
    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);
    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("qualitycertificateurlFile" + i + "").files;
    var f = document.getElementById("qualitycertificateurlFile" + i + "").value;
    if ((files.length-0) == 0) {
        DJMask.msg("請上傳圖檔");
        return false;
    }else if( 5 < (files.length-0)  ){
        DJMask.msg("圖檔不能超過5張!");
        return false;
    } else {
        if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
            DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
            return false;
        }
    }

    DJMask.msg("請稍等正在處理!");
    $.ajaxFileUpload({
        url: "/config/add-GasCylinderCheckInfoQualitycertificateurlUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
        /*data: {'id': id},*/
        fileElementId: 'qualitycertificateurlFile' + i,
        dataType: "json",
        success: function (data) {
            if (200 == data.resultCode) {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            } else {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                DJMask.msg(data.failDesc);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            }

        }
    });


}
/*==================================上傳圖檔(品質說明書)=首頁上傳圖檔,更新資料庫============================================================*/
function qualityspecifyurlUploadImage1(id, i) {
    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);
    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("qualityspecifyurlFile" + i + "").files;
    var f = document.getElementById("qualityspecifyurlFile" + i + "").value;
    if ((files.length-0) == 0) {
        DJMask.msg("請上傳圖檔");
        return false;
    }else if( 5 < (files.length-0)  ){
        DJMask.msg("圖檔不能超過5張!");
        return false;
    } else {
        if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
            DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
            return false;
        }
    }

    DJMask.msg("請稍等正在處理!");
    $.ajaxFileUpload({
        url: "/config/add-GasCylinderCheckInfoQualityspecifyurlUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
        /*data: {'id': id},*/
        fileElementId: 'qualityspecifyurlFile' + i,
        dataType: "json",
        success: function (data) {
            if (200 == data.resultCode) {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            } else {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                DJMask.msg(data.failDesc);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            }

        }
    });


}
/*==================================上傳圖檔(使用說明書url)=首頁上傳圖檔,更新資料庫============================================================*/
function instructionmanualurlUploadImage1(id, i) {
    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);
    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("instructionmanualurlFile" + i + "").files;
    var f = document.getElementById("instructionmanualurlFile" + i + "").value;
    if ((files.length-0) == 0) {
        DJMask.msg("請上傳圖檔");
        return false;
    }else if( 5 < (files.length-0)  ){
        DJMask.msg("圖檔不能超過5張!");
        return false;
    } else {
        if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
            DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
            return false;
        }
    }

    DJMask.msg("請稍等正在處理!");
    $.ajaxFileUpload({
        url: "/config/add-GasCylinderCheckInfoInstructionmanualurlUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
        /*data: {'id': id},*/
        fileElementId: 'instructionmanualurlFile' + i,
        dataType: "json",
        success: function (data) {
            if (200 == data.resultCode) {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            } else {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                DJMask.msg(data.failDesc);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            }

        }
    });


}

/*==================================================================================================================================================*/

/*==================================上傳圖檔(檢驗報告)=首頁上傳圖檔,更新資料庫============================================================*/



function inspectereporturlUploadImage1(id, i) {
    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);
    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("inspectereporturlFile" + i + "").files;
    var f = document.getElementById("inspectereporturlFile" + i + "").value;
        if ((files.length-0) == 0) {
            DJMask.msg("請上傳圖檔");
            return false;
        }else if( 5 < (files.length-0)  ){
            DJMask.msg("圖檔不能超過5張!");
            return false;
        } else {
            if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
                DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                return false;
            }
        }

    DJMask.msg("請稍等正在處理!");
        $.ajaxFileUpload({
            url: "/config/add-GasCylinderCheckInfoInspectereporturlUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
            /*data: {'id': id},*/
            fileElementId: 'inspectereporturlFile' + i,
            dataType: "json",
            success: function (data) {
                if (200 == data.resultCode) {
                    setTimeout(function(){
                        DJMask.msg(data.failDesc);
                    },1500);
                    setTimeout(function(){
                        ajax1Dfd.resolve();
                    },3000);
                    its_promise.done(function(){
                        getAllpage();
                    });
                } else {
                    setTimeout(function(){
                        DJMask.msg(data.failDesc);
                    },1500);
                    DJMask.msg(data.failDesc);
                    setTimeout(function(){
                        ajax1Dfd.resolve();
                    },3000);
                    its_promise.done(function(){
                        getAllpage();
                    });
                }

            }
        });


}

/*==================================上傳圖檔(日常檢驗記錄)首頁上傳圖檔,更新資料庫=============================================================*/
function dailyinspectrecordurlUploadImage1(id, i) {

    var ajax1Dfd = $.Deferred();
    var its_promise = $.when(ajax1Dfd);

    $("#gasCylinderCheckInfoId").val(id);
    var files = document.getElementById("dailyinspectrecordurlFile" + i + "").files;
    var f = document.getElementById("dailyinspectrecordurlFile" + i + "").value;
    if ((files.length-0) == 0) {
        DJMask.msg("請上傳圖檔");
        return false;
    }else if(5 < (files.length-0) ){
        DJMask.msg("圖檔不能超過5張!");
        return false;
    } else {
        if (f != null && !/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f)) {
            DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
            return false;
        }
    }
    /*    var id = $("#id").val();*/
    DJMask.msg("請稍等正在處理!");

    $.ajaxFileUpload({
        url: "/config/add-GasCylinderCheckInfoDailyinspectrecordurlFileUpload1?gasCylinderCheckInfoId=" + id + "&ii=" + i,
        /*data: {'id': id},*/
        fileElementId: 'dailyinspectrecordurlFile' + i,
        dataType: "json",
        success: function (data) {
            if (200 == data.resultCode) {
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });

            } else {
                DJMask.msg(data.failDesc);
                setTimeout(function(){
                    DJMask.msg(data.failDesc);
                },1500);
                setTimeout(function(){
                    ajax1Dfd.resolve();
                },3000);
                its_promise.done(function(){
                    getAllpage();
                });
            }
            /*    $("#certificateURL5").attr("src", data);
                $("#dailyinspectrecordurl").val(data);*/
            /* var data2 = data.split("?");*/
     /*       $("#loading").toggle();*/
        }
    });
}





           

 直接把 formData 指派個ajax的data,背景後根據key 名接收;

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

背景用 CommonsMultipartFile集合對應傳過來的名字來接收資料;

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

圖檔增加删除頁面與使用者互動 js 操作:

assets/js/gm/air_parameter_add.js

/*=====================菜單定位=========================*/

$(".c-nav .ed").find("li").eq(1).addClass("cur")
$(".c-nav .ed").find("li").eq(1).find(".abx").eq(8).addClass("cur")


/*=================日期=============================*/
//日期正常用法
laydate.render({
    elem: '#testdate'
});



/*=============================氣瓶id查詢,查詢氣瓶位置編号======================================*/
/*function SelsceGasCylinderpositionnum() {
    /!*下拉選擇氣瓶編号時,從value擷取氣瓶id*!/
    var gasCylinderId = $("#num").val();
    $.ajax({
        type: 'post',
        dataType: "json",
        /!*contentType: "application/json; charset=utf-8",*!/
        url: "/config/showAdd-GasCylinderCheckInfoTwo",
        data: {"gasCylinderId": gasCylinderId},
        success: function (data) {
            if (data.resultCode == 200) {
                if (0 < data.list.length) {
                    $("#positionnum").val(data.list[0].positionnum);
                    $("#GasCylinderNum").val(data.list[0].num);

                } else {
                    DJMask.msg("無氣瓶資料");
                }
            }
            if (data.resultCode == 505) {
                $("#messageValue").val(data.failDesc);
                $("#btn3").click();
            }
        }, error: function () {
            $("#messageValue").val("擷取車牌異常!");
            $("#btn3").click();

        }
    });

}*/

/*=============================氣瓶編号查詢氣瓶位置編号和車牌号======================================*/
$(function () {
    SelsceGasCylinderpositionnum1();
});
function SelsceGasCylinderpositionnum1() {
    //先清除所有
    $("#cph").val("");
    $("#positionnum").val("");
    $("#num").val("");
    $("#GasCylinderNum").val("");
    /*(産品合格證)*/
    $("#certificateURL1").attr("src", "");
    $("#productqualifyurl").val("");

    /*(品質說明書qualityspecifyurl)*/
    $("#certificateURL").attr("src", "");
    $("#manufacturingsupervisioninsurl").val("");
    /*(品質證明書)*/
    $("#certificateURL2").attr("src", "");
    $("#qualitycertificateurl").val("");
    /*(使用說明書)*/
    $("#certificateURL6").attr("src", "");
    $("#instructionmanualurl").val("");


    /*(檢驗報告)*/
    $("#certificateURL4").attr("src", "");
    $("#inspectereporturl").val("");
    /*(日常檢驗記錄)*/
    $("#certificateURL5").attr("src", "");
    $("#dailyinspectrecordurl").val("");

    $("#gasCylinderCheckInfoId").val("");

    /*(産品合格證)*/
    $("#productqualifyurldurlHtml").html("");
    /*(品質證書)*/
    $("#qualitycertificateurlHtml").html("");
    /*(品質說明書)*/
    $("#manufacturingsupervisioninsurlHtml").html("");
    /*(使用說明書)*/
    $("#instructionmanualurlHtml").html("");
    /*(檢驗報告)*/
    $("#inspectereporturldurlHtml").html("");
    /*(日常檢驗記錄)*/
    $("#dailyinspectrecordurlHtml").html("");


    var loadingX = $("#loadingX").val();

    var num = $("#num1").val();
    if (null == num || 0 == num.length) {
        DJMask.msg("請輸入氣瓶編号!");
        return;
    }

    $.ajax({
        type: 'post',
        dataType: "json",
        /*contentType: "application/json; charset=utf-8",*/
        url: "/config/SelsceGasCylinderpositionnum1",
        data: {"num": num},
        success: function (data) {
            if (data.resultCode == 200) {
                if (0 < data.list.length) {
                    $("#cph").val(data.list[0].vehicle.cph);
                    $("#positionnum").val(data.list[0].gasCylinder.positionnum);
                    $("#num").val(data.list[0].gasCylinder.id);
                    $("#GasCylinderNum").val(data.list[0].gasCylinder.num);

                    if (null != data.list[0].gasCylinderCheckInfo) {
                        /*原産品合格證*/
                        if (null != data.list[0].gasCylinderCheckInfo.productqualifyurl && 0 <  data.list[0].gasCylinderCheckInfo.productqualifyurl.length) {
                            $("#productqualifyurl").val(data.list[0].gasCylinderCheckInfo.productqualifyurl);
                        }
                        /*原品質證書*/
                            if (null != data.list[0].gasCylinderCheckInfo.qualitycertificateurl && 0 <  data.list[0].gasCylinderCheckInfo.qualitycertificateurl.length) {
                                $("#qualitycertificateurl").val(data.list[0].gasCylinderCheckInfo.qualitycertificateurl);
                            }
                        /*原品質說明書*/
                          /*  if (null != data.list[0].gasCylinderCheckInfo.qualityspecifyurl && 0 < data.list[0].gasCylinderCheckInfo.qualityspecifyurl.length) {
                                $("#manufacturingsupervisioninsurl").val(data.list[0].gasCylinderCheckInfo.qualityspecifyurl);

                            }*/

                        /*原使用說明書*/
                            if (null != data.list[0].gasCylinderCheckInfo.instructionmanualurl && 0 < data.list[0].gasCylinderCheckInfo.instructionmanualurl.length) {
                                $("#instructionmanualurl").val(data.list[0].gasCylinderCheckInfo.instructionmanualurl);
                            }

                    }
                    /*産品合格證*/
                        td1 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            " <p class=\"up-p\">産品合格證:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"productqualifyurlFile1\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";

                        /*(品質證明書)*/
                        td2 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            "<p class=\"up-p\">品質證書:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"qualitycertificateurlFile2\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";
                        /*(品質說明書)*/
                       /* td3 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            "<p class=\"up-p\">品質說明書:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"manufacturingSupervisIoninsurFile2\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";*/
                        /*(使用說明書)*/
                        td4 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            " <p class=\"up-p\">使用說明書:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"instructionmanualurlFile2\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";

                        /*(檢驗報告)*/
                        td5 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            "<p class=\"up-p\">檢驗報告:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"inspectereporturlFile2\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";

                        /*(日常檢驗記錄)*/
                        td6 =
                            "<div class=\"img-box full\">" +
                            "<section class=\" img-section\">" +
                            "<p class=\"up-p\">日常檢驗記錄:<span class=\"up-span\">最多可以上傳5張圖檔</span></p>" +
                            "<div class=\"z_photo upimg-div clear\" >" +
                            "<section class=\"z_file fl\">" +
                            "<img src=\"/assets/upjs/img/a11.png\" class=\"add-img\">" +
                            "<input type=\"file\" name=\"file\" id=\"dailyinspectrecordurlFile2\" class=\"file\" value=\"\" accept=\"image/jpg,image/jpeg,image/png,image/bmp\" multiple />" +
                            "</section>" +
                            "</div>" +
                            "</section>" +
                            "</div>";

                        /*新增必須isfirsttest 寫1*/
                        $("#isfirsttest").val(1);
                        /*産品合格證*/
                        $("#productqualifyurldurlHtml").html(td1);
                        /*品質證書*/
                        $("#qualitycertificateurlHtml").html(td2);
                        /*/!*品質說明書*!/
                        $("#manufacturingsupervisioninsurlHtml").html(td3);*/
                        /*使用說明書*/
                        $("#instructionmanualurlHtml").html(td4);
                        /*檢驗報告*/
                        $("#inspectereporturldurlHtml").html(td5);
                        /*日常檢驗記錄*/
                        $("#dailyinspectrecordurlHtml").html(td6);


                 /*   }
*/

                } else {
                    DJMask.msg(data.failDesc);
                }
            }
            if (data.resultCode == 505) {
                DJMask.msg(data.failDesc);

            }
        }, error: function () {
            DJMask.msg(data.failDesc);


        }
    });

}

/*=============================添加======================================*/
function go() {
    $("#btn1").click();
}

/*================================================彈出框 =========================================================*/
$(function () {
    /* 添加提示框和js邏輯!*/
    $("#btn1").click(function () {
        var cph = $("#cph").val();
        /*這個num,是氣瓶id*/
        var num = $("#num").val();
        /*檢驗日期*/
        var firsttestdate = $("#testdate").val();
        /*檢驗機關*/
        var firsttestunit = $("#testunit").val();
        /*檢驗結果*/
        var firsttestresult = $("#testresult").val();
        if ( 0 == firsttestdate.length
            ) {
            DJMask.msg("請輸入檢驗日期!");
            return;
        }
        if (0 == firsttestunit.length
            ) {
            DJMask.msg("請輸入檢驗機關!");
            return;
        }
        if ( 0 == firsttestresult.length) {
            DJMask.msg("請輸入檢驗結果!");
            return;
        }
        /*================圖檔上傳獲得圖檔id=================*/
        /*===============先上傳圖檔=========================*/


        var f1 = document.getElementById("productqualifyurlFile1").value;
        var f2 = document.getElementById("qualitycertificateurlFile2").value;
      /*  var f3 = document.getElementById("manufacturingSupervisIoninsurFile2").value;*/
        var f4 = document.getElementById("instructionmanualurlFile2").value;
        var f5 = document.getElementById("inspectereporturlFile2").value;
        var f6 = document.getElementById("dailyinspectrecordurlFile2").value;

        //判斷圖檔是否已經上傳

        /*=============ajax圖檔上傳===========================*/
        var txt = "确定為車牌号: " + cph + " 添加定檢資訊?";
        var option = {
            title: "添加定檢資訊",
            btn: parseInt("0011", 2),
            onOk: function () {
                console.log("确認啦");
                DJMask.msg("正在處理請稍等!");
                DJMask.show();
                var someAjaxDfd = $.Deferred();
                var ajax1Dfd = $.Deferred();
                var ajax2Dfd = $.Deferred();
                var ajax3Dfd = $.Deferred();
                var ajax4Dfd = $.Deferred();
                var ajax5Dfd = $.Deferred();
                var ajaxtime = $.Deferred();
                // 傳回這個延遲對象的Promise
                /*産品合格證*/
                var its_promise = $.when(someAjaxDfd);
                /*品質證書*/
                var its_promise1 = $.when(ajax1Dfd);
                /* 品質說明書*/
                var its_promise2 = $.when(ajax2Dfd);
                /* 使用說明書*/
                var its_promise3 = $.when(ajax3Dfd);
                /* 檢驗報告*/
                var its_promise4 = $.when(ajax4Dfd);
                /* 日常檢驗記錄*/
                var its_promise5 = $.when(ajax5Dfd);

                /* 添加資料*/
                var its_promiseTime = $.when(ajaxtime);


                 /* 記錄使用者總共上傳多少組圖檔*/
                var FF = 0;

                /* 記錄ajax 上傳完成了多少組圖檔*/
                var x = 0;
                /*======================新方法=================================*/

                if (null != f1 && f1 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f1)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /*産品合格證*/
                    ProductqualifyurlFileUpload(someAjaxDfd);

                    its_promise.done(function () {
                        x++;
                    });
                }
                if (null != f2 && f2 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f2)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /*品質證書*/
                    qualitycertificateurlFileUpload(ajax1Dfd);
                    its_promise1.done(function () {
                        x++;

                    });
                }
                /* 品質說明書*/
               /*if (null != f3 && f3 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f3)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /!* 品質說明書*!/
                    ManufacturingSupervisionInsurFileUpload(ajax2Dfd);
                    its_promise2.done(function () {
                        x++;

                    });
                }*/
                if (null != f4 && f4 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f4)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /* 使用說明書*/
                    instructionmanualurlFileUpload(ajax3Dfd);
                    its_promise3.done(function () {

                        x++;
                    });
                }
                if (null != f5 && f5 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f5)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /* 檢驗報告*/
                    InspectereporturlUpload(ajax4Dfd);
                    its_promise4.done(function () {

                        x++;
                    });
                }
                if (null != f6 && f6 != ""){
                    if ((!/\.(|jpg|jpeg|png|JPG|PNG)$/.test(f6)) ) {
                        DJMask.msg("圖檔類型必須是.jpeg,jpg,png中的一種");
                        return false;
                    }
                    FF++;
                    /*  日常檢驗記錄*/
                    DailyinspectrecordurlUpload(ajax5Dfd);
                    its_promise5.done(function () {

                        x++;
                    });

                }

                var time = setInterval(function () {
                    if(FF == x){
                        ajaxtime.resolve();
                        clearTimeout(time);
                        console.log("時間停")
                    }
                    console.log("時間輪")
                },5000);

                        its_promiseTime.done(function () {
                            /*定檢資訊資料寫入*/
                            createGasCylinderchkInfo(cph);
                       });
            }
        }

        window.wxc.xcConfirm(txt, "custom", option);
    });

    /* 添加氣瓶定檢資訊*/
    function createGasCylinderchkInfo(cph) {
        var productqualifyurl = $("#productqualifyurl").val();
        var qualitycertificateurl = $("#qualitycertificateurl").val();
        var manufacturingsupervisioninsurl = $("#manufacturingsupervisioninsurl").val();
        var instructionmanualurl = $("#instructionmanualurl").val();
        var inspectereporturl = $("#inspectereporturl").val();
        var dailyinspectrecordurl = $("#dailyinspectrecordurl").val();
        var num = $("#num").val();
        var GasCylinderNum = $("#GasCylinderNum").val();
        var positionnum = $("#positionnum").val();
        var orderByClause = $("#orderByClause").val();
        var isfirsttest = $("#isfirsttest").val();
        var testdate = $("#testdate").val();
        var testunit = $("#testunit").val();
        var testresult = $("#testresult").val();

        console.log("确認啦");
        $.ajax({
            type: "POST",
            dataType: "json",
            async:false,
            url: "/config/add-GasCylinderCheckInfo",//url
            data: {
                "productqualifyurl": productqualifyurl,
                "qualitycertificateurl": qualitycertificateurl,
                "manufacturingsupervisioninsurl": manufacturingsupervisioninsurl,
                "instructionmanualurl": instructionmanualurl,
                "inspectereporturl": inspectereporturl,
                "dailyinspectrecordurl": dailyinspectrecordurl,
                "num": num,
                "cph": cph,
                "GasCylinderNum": GasCylinderNum,
                "positionnum": positionnum,
                "orderByClause": orderByClause,
                "isfirsttest": isfirsttest,
                "testdate": testdate,
                "testunit": testunit,
                "testresult": testresult
            },

            success: function (data) {
                DJMask.hide();
                console.log("ajax:" + data);
                if (data.resultCode == 200) {

                    $("#messageValue").val(data.failDesc);
                    $("#btn2").click();

                }
                if (data.resultCode == 505) {
                    $("#messageValue").val(data.failDesc);
                    $("#btn3").click();
                }
                ;
            },
            error: function () {

                $("#messageValue").val("系統異常操作不成功!\n");
                $("#btn3").click();
            }
        });

    }

    /* 成功提示*/
    $("#btn2").click(function () {
        var txt = $("#messageValue").val();
        var option = {
            title: "添加定檢資訊",
            btn: parseInt("0012", 2),
            onOk: function () {
                window.history.go(-1);
            }
        }
        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.success, option);
    });
    /* 錯誤提示!*/
    $("#btn3").click(function () {
        var txt = $("#messageValue").val();
        var option = {
            title: "添加定檢資訊",
            btn: parseInt("0012", 2),
            onOk: function () {
            }
        }
        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error, option);
    });
});
           

觸發圖檔上傳操作的 click function:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

關鍵點說明:

js中定義了兩個變量 FF 與 X,分别記錄使用者總共上傳多少組圖檔與記錄ajax 上傳完成了多少組圖檔,

通過setInterval每5秒輪詢使用者總共上傳圖檔組數量與ajax上傳完成了多少組圖檔數量, 若FF 的數量

與 X 的數量一緻相等即表示圖檔上傳完成,獲得了圖檔儲存URL,可執行下步資料寫入操作;

定義變量 FF 與 X :

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

setInterval輪詢對比兩個變量的值,直到兩變量值相等為止:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

FF與X數值相等時通知下一步資料寫人操作:

多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果:

頁面:

<%@ page language="java" pageEncoding="UTF-8"
         contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta name="author" content=""/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <link rel="icon" type="image/x-icon" href="/assets/i/favicon.ico" target="_blank" rel="external nofollow" />
    <link rel="stylesheet" href="/assets/newPageJs/css/reset.css" target="_blank" rel="external nofollow" >
    <link rel="stylesheet" href="/assets/newPageJs/css/style.css" target="_blank" rel="external nofollow" >

    <script src="/assets/newPageJs/js/jQuery.js"></script>
    <script type="text/javascript" src="/assets/showImg/js/popwin.js"></script>
</head>
<body>

<!--nave-->
<jsp:include page="../common/newMenu.jsp"></jsp:include>

<!--header-->
<jsp:include page="../common/newTop.jsp"></jsp:include>
<!--main-->
<div class="over-auto">
    <form class="am-form am-form-horizontal" action="##" method="post"
          id="stuForm">
        <input id="gasCylinderCheckInfoId" name="gasCylinderCheckInfoId"
               type="hidden" value="">
        <%--第一次添加為1,第二次添加為0--%>
        <input id="isfirsttest" name="isfirsttest" type="hidden" value="">
        <%--産品合格證--%>
        <input type="hidden" id="productqualifyurl" name="productqualifyurl"
               value="">
        <%--品質證書--%>
        <input type="hidden" id="qualitycertificateurl" name="productqualifyurl"
               value="">
        <%--品質說明書--%>
        <input type="hidden" id="manufacturingsupervisioninsurl"
               name="productqualifyurl" value="">
        <%--使用說明書--%>
        <input type="hidden" id="instructionmanualurl" name="productqualifyurl"
               value="">
        <%--檢驗報告--%>
        <input type="hidden" id="inspectereporturl" name="productqualifyurl"
               value="">
        <%--日常檢驗記錄--%>
        <input type="hidden" id="dailyinspectrecordurl" name="productqualifyurl"
               value="">
        <input id="loadingX" name="loadingX" type="hidden"
               value="${pageContext.request.contextPath}/assets/img/loading.gif">
        <div class="m-main">
            <div class="f-cb">
                <div class="m-title">添加定檢資訊</div>
                <a href="javascript:history.go(-1);" target="_blank" rel="external nofollow"  class="return fr">傳回</a>
                <a href="javascript:go()" target="_blank" rel="external nofollow"  type="button" class="modify fr"><img
                        src="/assets/newPageJs/img/a8.svg"
                        alt=""/>送出</a>
            </div>
            <div class="kk-box">
                <div class="box-one">


                    <div class="s-title">基礎資訊</div>
                    <table id="tabe">
                        <%-- ======--%>
                        <tr>
                            <td class="w320">
                                <div class="same-bx mar-fr">
                                    <%--擷取的氣瓶編号--%>
                                    <input name="GasCylinderNum"
                                           id="GasCylinderNum" type="hidden">
                                    <%--這裡了的num存放氣瓶id--%>
                                    <input name="num" id="num" type="hidden">
                                    <div class="te">氣瓶編号</div>
                                    <input class="pt hover" name="num1"
                                           id="num1" value=""
                                           onblur="SelsceGasCylinderpositionnum1()"
                                           type="text"><span style="color:red;margin-left: 2px">*</span>
                                    <%--<select class="select hover" id="num" name="num"
                                            onchange="SelsceGasCylinderpositionnum();">

                                    </select> 按車牌号查詢氣瓶資訊 --%>
                                </div>
                            </td>
                            <td>
                                <div class="same-bx mar-fr">
                                    <div class="te">氣瓶位置編号</div>
                                    <input class="pt hover" name="positionnum"
                                           id="positionnum" value=""
                                           readonly="readonly" type="text">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="same-bx mar-fr">
                                    <div class="te">車牌号</div>
                                    <%--<input class="pt hover" name="cph" id="cph" value="" onblur="SelectVehicleByCph()"
                                           type="text"> 按車牌号查詢氣瓶資訊 --%>
                                    <input class="pt hover" name="cph" id="cph"
                                           value=""
                                           readonly="readonly" type="text">
                                </div>
                            </td>
                            <td>

                            </td>
                        </tr>

                        <%--================--%>
                    </table>
                </div>
                <div class="box-one">
                    <div class="s-title">檢驗資訊</div>
                    <table>
                        <tr>
                            <td class="w320">
                                <div class="same-bx mar-fr">
                                    <div class="te">檢驗日期</div>
                                    <input type="text"
                                           class="layui-input pt hover day"
                                           name="testdate"
                                           id="testdate" value="" lay-key="1">
                                    <span style="color:red;margin-left: 2px">*</span>
                                </div>
                            </td>
                            <td>
                                <div class="same-bx mar-fr">
                                    <div class="te">檢驗機關</div>
                                    <input class="pt hover" name="testunit"
                                           id="testunit" type="text">
                                    <span style="color:red;margin-left: 2px">*</span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="same-bx mar-fr">
                                    <div class="te">檢驗結果</div>
                                    <select class="select1 hover"
                                            id="testresult" name="testresult">
                                        <option value="">請選擇</option>
                                        <option value="合格">合格</option>
                                        <option value="不合格">不合格</option>
                                    </select>
                                    <span style="color:red;margin-left: 2px">*</span>
                                </div>
                            </td>
                            <td>

                            </td>
                        </tr>
                    </table>

                    <table>
                        <tr>
                            <%--産品合格證--%>
                            <%-- <td id="productqualifyurldurlHtml">--%>
                            <td id="productqualifyurldurlHtml">

                                <%--    <div class="img-box full">
                                        <section class=" img-section">
                                            <p class="up-p">産品合格證:<span class="up-span">最多可以上傳5張圖檔</span></p>
                                            <div class="z_photo upimg-div clear" >
                                                <section class="z_file fl">
                                                    <img src="/assets/upjs/img/a11.png" class="add-img">
                                                    <input type="file" name="file" id="productqualifyurlFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                                </section>
                                            </div>
                                        </section>
                                    </div>--%>
                                <%--            <aside class="mask works-mask">
                                                <div class="mask-content">
                                                    <p class="del-p">您确定要删除作品圖檔嗎?</p>
                                                    <p class="check-p"><span class="del-com wsdel-ok">确定</span><span class="wsdel-no">取消</span></p>
                                                </div>
                                            </aside>--%>

                            </td>
                            <%--<td id="qualitycertificateurlHtml">--%>
                            <td>

                            </td>
                        </tr>
                        <tr>
                            <%--品質證明書--%>
                            <td id="qualitycertificateurlHtml">
                                <%--<td id="manufacturingsupervisioninsurlHtml">--%>
                                <%--   <div class="img-box full">
                                          <section class=" img-section">
                                              <p class="up-p">品質證書:<span class="up-span">最多可以上傳5張圖檔</span></p>
                                              <div class="z_photo upimg-div clear" >
                                                  <section class="z_file fl">
                                                      <img src="/assets/upjs/img/a11.png" class="add-img">
                                                      <input type="file" name="file" id="qualitycertificateurlFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                                  </section>
                                              </div>
                                          </section>
                                      </div>--%>
                            </td>
                            <td>
                                <%--<td id="instructionmanualurlHtml">--%>
                            </td>
                        </tr>
                        <tr>
                            <%--品質說明書--%>
                            <td id="manufacturingsupervisioninsurlHtml">
                                <%--  <div class="img-box full">
                                      <section class=" img-section">
                                          <p class="up-p">品質說明書:<span class="up-span">最多可以上傳5張圖檔,馬上上傳</span></p>
                                          <div class="z_photo upimg-div clear" >
                                              <section class="z_file fl">
                                                  <img src="/assets/upjs/img/a11.png" class="add-img">
                                                  <input type="file" name="file" id="manufacturingSupervisIoninsurFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                              </section>
                                          </div>
                                      </section>
                                  </div>--%>
                            </td>
                            <td>

                            </td>
                        </tr>

                        <tr>
                            <%--使用說明書--%>
                            <td id="instructionmanualurlHtml">
                                <%--<td id="inspectereporturldurlHtml">--%>
                                <%--    <div class="img-box full">
                                        <section class=" img-section">
                                            <p class="up-p">使用說明書:<span class="up-span">最多可以上傳5張圖檔,馬上上傳</span></p>
                                            <div class="z_photo upimg-div clear" >
                                                <section class="z_file fl">
                                                    <img src="/assets/upjs/img/a11.png" class="add-img">
                                                    <input type="file" name="file" id="instructionmanualurlFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                                </section>
                                            </div>
                                        </section>
                                    </div>--%>
                            </td>
                            <td>
                                <%-- <td id="dailyinspectrecordurlHtml">--%>

                            </td>
                        </tr>
                        <tr>
                            <%--檢驗報告--%>
                            <td id="inspectereporturldurlHtml">
                                <%--  <div class="img-box full">
                                      <section class=" img-section">
                                          <p class="up-p">檢驗報告:<span class="up-span">最多可以上傳5張圖檔,馬上上傳</span></p>
                                          <div class="z_photo upimg-div clear" >
                                              <section class="z_file fl">
                                                  <img src="/assets/upjs/img/a11.png" class="add-img">
                                                  <input type="file" name="file" id="inspectereporturlFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                              </section>
                                          </div>
                                      </section>
                                  </div>--%>
                            </td>
                            <td>

                            </td>
                        </tr>
                        <tr>
                            <%--日常檢驗記錄--%>
                            <td id="dailyinspectrecordurlHtml"><%--
                                <div class="img-box full">
                                    <section class=" img-section">
                                        <p class="up-p">日常檢驗記錄:<span class="up-span">最多可以上傳5張圖檔,馬上上傳</span></p>
                                        <div class="z_photo upimg-div clear" >
                                            <section class="z_file fl">
                                                <img src="/assets/upjs/img/a11.png" class="add-img">
                                                <input type="file" name="file" id="dailyinspectrecordurlFile1" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                                            </section>
                                        </div>
                                    </section>
                                </div>--%>
                            </td>
                            <td>

                            </td>
                        </tr>

                        <tr>
                            <%--========這個沒用但去掉會對圖檔上傳樣式造成影響=========--%>
                            <td class="w320">
                                <div class="same-bx mar-fr">
                                    <div class="te"></div>
                                    <input type="hidden" class="" name=""
                                           id="" value="" lay-key="1">
                                </div>
                            </td>
                            <td>

                            </td>
                        </tr>

                    </table>
                </div>
                <div class="box-one">

                </div>
            </div>

        </div>

    </form>
</div>
<%--====================================================遮罩========================================================--%>
<input type="hidden" id="messageValue" name="messageValue" value="">
<input type="hidden" id="createVehgroupId" name="createVehgroupId" value="">
<input type="hidden" id="value" name="value" value="">
<input type="hidden" id="id1" name="id1" value="">
<input type="hidden" id="vehId" name="vehId" value="">
<input type="hidden" id="num1" name="num1" value="">

<input class="sgBtn" id="btn4" type="hidden" value="彈窗4(自定義)">
<input class="sgBtn" id="btn5" type="hidden" value="彈窗5(自定義)">
<input class="sgBtn" id="btn7" type="hidden" value="彈窗7(自定義)">

<input class="sgBtn" id="btn1" type="hidden" value="彈窗1(自定義)">
<input class="sgBtn" id="btn2" type="hidden" value="彈窗2(自定義)">
<input class="sgBtn" id="btn3" type="hidden" value="彈窗3(自定義)">


<<%--script src="/assets/js/system/DJMask.js"></script>
<link rel="stylesheet" type="text/css" href="/assets/css/xcConfirm.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" />
<script src="/assets/js/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
<script src="/assets/js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
    .sgBtn{width: 135px; height: 35px; line-height: 35px; margin-left: 10px; margin-top: 10px; text-align: center; background-color: #0095D9; color: #FFFFFF; float: left; border-radius: 5px;}
</style>
<link href="/assets/css/index.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  rel="stylesheet"/>
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>--%>
<script src="/assets/js/system/DJMask.js"></script>
<link rel="stylesheet" type="text/css" href="/assets/css/xcConfirm.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" />
<script src="/assets/js/jquery-1.9.1.js" type="text/javascript"
        charset="utf-8"></script>
<script src="/assets/js/xcConfirm.js" type="text/javascript"
        charset="utf-8"></script>
<style type="text/css">
    .sgBtn {
        width: 135px;
        height: 35px;
        line-height: 35px;
        margin-left: 10px;
        margin-top: 10px;
        text-align: center;
        background-color: #0095D9;
        color: #FFFFFF;
        float: left;
        border-radius: 5px;
    }
</style>
<%--<link href="/assets/css/index.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  rel="stylesheet"/>--%>
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="/assets/js/jquery-DJMask.2.1.1.js"
        charset="UTF-8"></script>

<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/amazeui.min.js"></script>

<%--<script src="/assets/js/laydate/laydate.js"></script>--%>
<!-- 日期js改成你的路徑 -->
<script src="${pageContext.request.contextPath}/assets/newPageJs/js/laydate/laydate.js"></script>
<%--<script src="/assets/js/app.js"></script>--%>

</body>

<script src="/assets/newPageJs/js/main.js"></script>
<script src="/assets/js/gm/air_parameter_add.js"></script>

<%--圖檔上傳--%>
<link href="/assets/upjs/css/common.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  type="text/css" rel="stylesheet"/>
<link href="/assets/upjs/css/index.css" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  type="text/css" rel="stylesheet"/>
<%--<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>--%>
<%--<script src="/assets/upjs/js/imgUp.js"></script>--%>
<%--上傳--%>
<script src="/assets/js/gm/add-GasCylinderCheckInfoAjaxfileupload.js"></script>
<script src="/assets/js/ajaxfileupload.js"></script>


</html>
           

單圖檔預覽js:

assets/showImg/js/popwin.js

var popWin = {
    scrolling: 'no',
    //是否顯示滾動條 no,yes,auto

int: function() {
        this.mouseClose();
        this.closeMask();
        //this.mouseDown();

    },

showWin: function(width, height, title, src) {
        var iframeHeight = height - 52;
        var marginLeft = width / 2;
        var marginTop = height / 2;
        var inntHtml = '';
        inntHtml += '<div id="mask" style="width:100%; height:100%; position:fixed; top:0; left:0; z-index:1999;background:#cccccc; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity:0.5;"></div>'
        inntHtml += '<div id="maskTop" style="width: ' + width + 'px; height: ' + height + 'px; border: #999999 1px solid; background: #fff; color: #333; position: fixed; top: 50%; left: 50%; margin-left: -' + marginLeft + 'px; margin-top: -' + marginTop + 'px; z-index: 2999; filter: progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4); -moz-box-shadow: 2px 2px 10px #909090; -webkit-box-shadow: 2px 2px 10px #909090; box-shadow: 2px 2px 10px #909090;">'
        inntHtml += '<div id="maskTitle" style="height: 50px; line-height: 50px; font-family: Microsoft Yahei; font-size: 20px; color: #333333; padding-left: 20px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAyCAYAAABlG0p9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABvSURBVEhL1cq5DcAwDENR7T+sL9lOOoUbkCoCwwKewOJbiGe+31BkwgeDM18YgrPhxuBs4CkS4cQQZMKFwd0R+gzFJaFjcD+EfXgoMuHA4O4Iew/FJWHD4BJhwxDoYcNTIKwY3NGwYggQFgxODEt8xO1/6P+HHxEAAAAASUVORK5CYII=); border-bottom: 1px solid #999999; position: relative;">'
        inntHtml += '' + title + ''
        inntHtml += '<div id="popWinClose" style="width: 28px; height: 28px; cursor: pointer; position: absolute; top: -12px; right: -9px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJeSURBVEhLvZbPq2lRFMf9B4bSTTIxZiBSMlCI9ycoKX+Bod7w/il3YIL4NyhFmYmBKD2Sp0ix3vqes/e529n74t33Op9astevr3PO2tvxvcLtdquzfbAtyAV8IlYX6d+DG7yxvbP9Fr2fglxR8ybavAYX/GD7Jfr8NahFD9HuMZz4U9Q5jEYjqlarFA6HiVPuDD7EkOMGvTjna9xi8/mcstmsJvKVIRc1Kl+K4haIHItut0t+v9/Y+JGhBrUq6M2xT9iBAXGeGQrY/U+miqI3NNhvw4t3EbNuyXeuzG3ood5eaLDfhhfO6JueWbPZtGKFQkGLNRoN2u/3FI/HtRh6SaDBPkusLnzWpMlkaRC7XC5WfLVaUTqddmKVSoVOp5MVG4/HlEql7mph6vRCC4IfYm2Nt7vAzW63o2KxSLVaja7Xq/DatFotrR49JdCCoHNcmfZZPp+n9XotMmxwVVwnVjbD4ZAikYhWj54SaN1dgjtZWiaToe12K7J0JpOJUUyaykuCsFwuR8fjUWR+slgsKBAIGGukqbwsiGdmElwul5RIJIw10lReEsQ0ns9nkaVzOBys226qhak8HRrsM7ktJLPZjDabjVjZYLBKpZJWrw0NfzzcFvj1KtPp1HpmsVjM2iIq/X5fqzdti4cbHycINjUYDAYUCoWcGA4BHAag1+tRMBi8q4VpGx/wl4dHWzKZpHa7TdFoVIuVy2XqdDrGSTUebYAXnh/e3v49AXZ49wcs4YB3rxgStyjApGG8TfsUPsTUaZQ8FZPgFrB585oo4QLvXoTdcIP/9Krv8/0BDUSOirKWU6wAAAAASUVORK5CYII=);"></div>'
        inntHtml += '</div>'
    for(var i = 0; i < src.length; i++){
            if(src[i] != ""){
                /*inntHtml +=  "<img src=\"" + src[i] + "\" onclick=\"lookProductqualifyurl('"+src[i]+"');\" class=\"add-img\" style=\"list-style:none;margin:8.5px;width: 420px;height: 400px; \">";*/
                inntHtml +=  "<img src=\"" + src[i] + "\" onclick=\"showImgD('"+src[i]+"');\" class=\"add-img\" style=\"list-style:none;margin:8.5px;width: 300px;height: 250px; \">";
            }

    }

    /*inntHtml += '<iframe width="' + width + '" height="' + iframeHeight + '" frame scrolling="' + this.scrolling + '" src="' + url + '"></iframe>';*/

        $("body").append(inntHtml);
        this.int();


    },

mouseClose: function() {
        $("#popWinClose").on('mouseenter', 
        function() {
            $(this).css("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJwSURBVEhLvZbLSiNBFIb7DVyKiIgb17oQRRAXgor6CIIIeQKXMksfxYUbFbMZRh0Yb6ODMgEddCVmoWkRLzFekukxfay/+lRbqSqTVob+4CyqzuVPV59TaS8JYRhmhM0Ly5MB9tiX4fDPIQq0CpsT9sC1G4JYzmnlMskQCRPCrrnOh0EuanC5+ojAL5wXc5/LUW5qitba2ynreTWGPfgQY4JaXNaNKfZ0dkY7g4OWyHuGWOTovCuKI+AYib+8TF+bmpyF6xlykKuD2iwTITbQIPE7Q4Kr2EdMF0VtaLCcFJxjnzySzzyZaaihHy80WE4Kxq3vemcns7PStzsyYvn+zMxQUCzSRne35UMtBTSUWIb3ZKeZSRCrBoH0lwsF2u7vj32/JyepWi5L3/3hIW319dXkwvTuhRYE53kt29tMMAlub2lvdJRy09MUVqu8G3GxsGDlo6YCWhCMryvXnO0OD1PF9zkiQj5VGPIqonhwQOsdHVY+aiqgVfMIZrCy7YEBCm5uOMqmdHTkFFOmk0gQ9nNoiF4eHznyjed8nr41NztzlOkkFsQ7cwmWz89ps6fHmaNMJ5Gg7MZKhaNs/pVK8thduTCdhk2DOVNjoXg6PaW/V1e8ikBj7Y2NWflW06BVee0cC/x6nYfjY/nOfnR1yRHRucxmrXzXWNQdfNwgGGpwt79Pa21tsQ+XAC4D4K+s0GpLS00uzBp8vm3qXm1bvb1UWFyk752dlu/X+Dj5S0vOTnVebUAsUr+80/17AmIjvT9ghXCk94mhMEUBOg3t7ZpT7MGnd6OioZgCRyAsnc9EhUhI70PYRBT4T5/6nvcKYG1hElXAZggAAAAASUVORK5CYII=)");

        });

        $("#popWinClose").on('mouseleave', 
        function() {
            $(this).css("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJeSURBVEhLvZbPq2lRFMf9B4bSTTIxZiBSMlCI9ycoKX+Bod7w/il3YIL4NyhFmYmBKD2Sp0ix3vqes/e529n74t33Op9astevr3PO2tvxvcLtdquzfbAtyAV8IlYX6d+DG7yxvbP9Fr2fglxR8ybavAYX/GD7Jfr8NahFD9HuMZz4U9Q5jEYjqlarFA6HiVPuDD7EkOMGvTjna9xi8/mcstmsJvKVIRc1Kl+K4haIHItut0t+v9/Y+JGhBrUq6M2xT9iBAXGeGQrY/U+miqI3NNhvw4t3EbNuyXeuzG3ood5eaLDfhhfO6JueWbPZtGKFQkGLNRoN2u/3FI/HtRh6SaDBPkusLnzWpMlkaRC7XC5WfLVaUTqddmKVSoVOp5MVG4/HlEql7mph6vRCC4IfYm2Nt7vAzW63o2KxSLVaja7Xq/DatFotrR49JdCCoHNcmfZZPp+n9XotMmxwVVwnVjbD4ZAikYhWj54SaN1dgjtZWiaToe12K7J0JpOJUUyaykuCsFwuR8fjUWR+slgsKBAIGGukqbwsiGdmElwul5RIJIw10lReEsQ0ns9nkaVzOBys226qhak8HRrsM7ktJLPZjDabjVjZYLBKpZJWrw0NfzzcFvj1KtPp1HpmsVjM2iIq/X5fqzdti4cbHycINjUYDAYUCoWcGA4BHAag1+tRMBi8q4VpGx/wl4dHWzKZpHa7TdFoVIuVy2XqdDrGSTUebYAXnh/e3v49AXZ49wcs4YB3rxgStyjApGG8TfsUPsTUaZQ8FZPgFrB585oo4QLvXoTdcIP/9Krv8/0BDUSOirKWU6wAAAAASUVORK5CYII=)");

        });

    },

closeMask: function() {
        $("#popWinClose").on('click', 
        function() {
            $("#mask,#maskTop").fadeOut(function() {
                $(this).remove();

            });

        });

    }

/*mouseDown : function(){
		var dragging = false;
		var iX, iY;
		//var elmen = $("div#maskTop");
		$("#maskTop").on('mousedown' , function(e){
			dragging = true;
                iX = e.clientX - this.offsetLeft;
                iY = e.clientY - this.offsetTop;
                this.setCapture && this.setCapture();
                return false;
		});
		document.onmousemove = function(e) {
                if (dragging) {
                var e = e || window.event;
                var oX = e.clientX - iX;
                var oY = e.clientY - iY;
                $("#maskTop").css({"left":oX + "px", "top":oY + "px"});
                return false;
                }
            };
            $(document).mouseup(function(e) {
                dragging = false;
                $("#maskTop")[0].releaseCapture();
                e.cancelBubble = true;
            })
	},*/

};

/*單圖檔檢視*/
var popWinD = {
    scrolling: 'no',
    //是否顯示滾動條 no,yes,auto

    int: function() {
        this.mouseClose();
        this.closeMask();
        //this.mouseDown();

    },

    showWin: function(width, height, title, src) {
        var iframeHeight = height - 52;
        var marginLeft = width / 2;
        var marginTop = height / 2;
        var inntHtml = '';

        inntHtml += '<div id="mask1" style="width:100%; height:100%; position:fixed; top:0; left:0; z-index:3500;background:#cccccc; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity:0.5;"></div>'
        inntHtml += '<div id="maskTop1" style="width: ' + width + 'px; height: ' + height + 'px; border: #999999 1px solid; background: #fff; color: #333; position: fixed; top: 50%; left: 50%; margin-left: -' + marginLeft + 'px; margin-top: -' + marginTop + 'px; z-index: 3600; filter: progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4); -moz-box-shadow: 2px 2px 10px #909090; -webkit-box-shadow: 2px 2px 10px #909090; box-shadow: 2px 2px 10px #909090;">'
        inntHtml += '<div id="maskTitle1" style="height: 50px; line-height: 50px; font-family: Microsoft Yahei; font-size: 20px; color: #333333; padding-left: 20px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAyCAYAAABlG0p9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABvSURBVEhL1cq5DcAwDENR7T+sL9lOOoUbkCoCwwKewOJbiGe+31BkwgeDM18YgrPhxuBs4CkS4cQQZMKFwd0R+gzFJaFjcD+EfXgoMuHA4O4Iew/FJWHD4BJhwxDoYcNTIKwY3NGwYggQFgxODEt8xO1/6P+HHxEAAAAASUVORK5CYII=); border-bottom: 1px solid #999999; position: relative;">'
        inntHtml += '' + title + ''
        inntHtml += '<div id="popWinClose1" style="width: 28px; height: 28px; cursor: pointer; position: absolute; top: -12px; right: -9px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJeSURBVEhLvZbPq2lRFMf9B4bSTTIxZiBSMlCI9ycoKX+Bod7w/il3YIL4NyhFmYmBKD2Sp0ix3vqes/e529n74t33Op9astevr3PO2tvxvcLtdquzfbAtyAV8IlYX6d+DG7yxvbP9Fr2fglxR8ybavAYX/GD7Jfr8NahFD9HuMZz4U9Q5jEYjqlarFA6HiVPuDD7EkOMGvTjna9xi8/mcstmsJvKVIRc1Kl+K4haIHItut0t+v9/Y+JGhBrUq6M2xT9iBAXGeGQrY/U+miqI3NNhvw4t3EbNuyXeuzG3ood5eaLDfhhfO6JueWbPZtGKFQkGLNRoN2u/3FI/HtRh6SaDBPkusLnzWpMlkaRC7XC5WfLVaUTqddmKVSoVOp5MVG4/HlEql7mph6vRCC4IfYm2Nt7vAzW63o2KxSLVaja7Xq/DatFotrR49JdCCoHNcmfZZPp+n9XotMmxwVVwnVjbD4ZAikYhWj54SaN1dgjtZWiaToe12K7J0JpOJUUyaykuCsFwuR8fjUWR+slgsKBAIGGukqbwsiGdmElwul5RIJIw10lReEsQ0ns9nkaVzOBys226qhak8HRrsM7ktJLPZjDabjVjZYLBKpZJWrw0NfzzcFvj1KtPp1HpmsVjM2iIq/X5fqzdti4cbHycINjUYDAYUCoWcGA4BHAag1+tRMBi8q4VpGx/wl4dHWzKZpHa7TdFoVIuVy2XqdDrGSTUebYAXnh/e3v49AXZ49wcs4YB3rxgStyjApGG8TfsUPsTUaZQ8FZPgFrB585oo4QLvXoTdcIP/9Krv8/0BDUSOirKWU6wAAAAASUVORK5CYII=);"></div>'
        inntHtml += '</div>'
        /*inntHtml +=' <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">'
        inntHtml +=' <div id="innerdiv" style="position:absolute;">'*/

            if(src != ""){
                inntHtml +=  "<img src=\"" + src + "\"  class=\"add-img\" style=\"list-style:none;margin:8.5px;width: 580px;height: 524px; \">";
            }
        /*inntHtml += '</div>'
        inntHtml += '</div>'*/
        /*inntHtml += '<iframe width="' + width + '" height="' + iframeHeight + '" frame scrolling="' + this.scrolling + '" src="' + src[i] + '"></iframe>';*/

        $("body").append(inntHtml);
        this.int();


    },

    mouseClose: function() {
        $("#popWinClose1").on('mouseenter',
            function() {
                $(this).css("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJwSURBVEhLvZbLSiNBFIb7DVyKiIgb17oQRRAXgor6CIIIeQKXMksfxYUbFbMZRh0Yb6ODMgEddCVmoWkRLzFekukxfay/+lRbqSqTVob+4CyqzuVPV59TaS8JYRhmhM0Ly5MB9tiX4fDPIQq0CpsT9sC1G4JYzmnlMskQCRPCrrnOh0EuanC5+ojAL5wXc5/LUW5qitba2ynreTWGPfgQY4JaXNaNKfZ0dkY7g4OWyHuGWOTovCuKI+AYib+8TF+bmpyF6xlykKuD2iwTITbQIPE7Q4Kr2EdMF0VtaLCcFJxjnzySzzyZaaihHy80WE4Kxq3vemcns7PStzsyYvn+zMxQUCzSRne35UMtBTSUWIb3ZKeZSRCrBoH0lwsF2u7vj32/JyepWi5L3/3hIW319dXkwvTuhRYE53kt29tMMAlub2lvdJRy09MUVqu8G3GxsGDlo6YCWhCMryvXnO0OD1PF9zkiQj5VGPIqonhwQOsdHVY+aiqgVfMIZrCy7YEBCm5uOMqmdHTkFFOmk0gQ9nNoiF4eHznyjed8nr41NztzlOkkFsQ7cwmWz89ps6fHmaNMJ5Gg7MZKhaNs/pVK8thduTCdhk2DOVNjoXg6PaW/V1e8ikBj7Y2NWflW06BVee0cC/x6nYfjY/nOfnR1yRHRucxmrXzXWNQdfNwgGGpwt79Pa21tsQ+XAC4D4K+s0GpLS00uzBp8vm3qXm1bvb1UWFyk752dlu/X+Dj5S0vOTnVebUAsUr+80/17AmIjvT9ghXCk94mhMEUBOg3t7ZpT7MGnd6OioZgCRyAsnc9EhUhI70PYRBT4T5/6nvcKYG1hElXAZggAAAAASUVORK5CYII=)");

            });

        $("#popWinClose1").on('mouseleave',
            function() {
                $(this).css("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJeSURBVEhLvZbPq2lRFMf9B4bSTTIxZiBSMlCI9ycoKX+Bod7w/il3YIL4NyhFmYmBKD2Sp0ix3vqes/e529n74t33Op9astevr3PO2tvxvcLtdquzfbAtyAV8IlYX6d+DG7yxvbP9Fr2fglxR8ybavAYX/GD7Jfr8NahFD9HuMZz4U9Q5jEYjqlarFA6HiVPuDD7EkOMGvTjna9xi8/mcstmsJvKVIRc1Kl+K4haIHItut0t+v9/Y+JGhBrUq6M2xT9iBAXGeGQrY/U+miqI3NNhvw4t3EbNuyXeuzG3ood5eaLDfhhfO6JueWbPZtGKFQkGLNRoN2u/3FI/HtRh6SaDBPkusLnzWpMlkaRC7XC5WfLVaUTqddmKVSoVOp5MVG4/HlEql7mph6vRCC4IfYm2Nt7vAzW63o2KxSLVaja7Xq/DatFotrR49JdCCoHNcmfZZPp+n9XotMmxwVVwnVjbD4ZAikYhWj54SaN1dgjtZWiaToe12K7J0JpOJUUyaykuCsFwuR8fjUWR+slgsKBAIGGukqbwsiGdmElwul5RIJIw10lReEsQ0ns9nkaVzOBys226qhak8HRrsM7ktJLPZjDabjVjZYLBKpZJWrw0NfzzcFvj1KtPp1HpmsVjM2iIq/X5fqzdti4cbHycINjUYDAYUCoWcGA4BHAag1+tRMBi8q4VpGx/wl4dHWzKZpHa7TdFoVIuVy2XqdDrGSTUebYAXnh/e3v49AXZ49wcs4YB3rxgStyjApGG8TfsUPsTUaZQ8FZPgFrB585oo4QLvXoTdcIP/9Krv8/0BDUSOirKWU6wAAAAASUVORK5CYII=)");

            });

    },

    closeMask: function() {
        $("#popWinClose1").on('click',
            function() {
                $("#mask1,#maskTop1").fadeOut(function() {
                    $(this).remove();

                });

            });

    }

    /*mouseDown : function(){
            var dragging = false;
            var iX, iY;
            //var elmen = $("div#maskTop");
            $("#maskTop").on('mousedown' , function(e){
                dragging = true;
                    iX = e.clientX - this.offsetLeft;
                    iY = e.clientY - this.offsetTop;
                    this.setCapture && this.setCapture();
                    return false;
            });
            document.onmousemove = function(e) {
                    if (dragging) {
                    var e = e || window.event;
                    var oX = e.clientX - iX;
                    var oY = e.clientY - iY;
                    $("#maskTop").css({"left":oX + "px", "top":oY + "px"});
                    return false;
                    }
                };
                $(document).mouseup(function(e) {
                    dragging = false;
                    $("#maskTop")[0].releaseCapture();
                    e.cancelBubble = true;
                })
        },*/

};
           

DJMask彈出提示框js:

assets/js/jquery-DJMask.2.1.1.js

/**DJMask.js
 * author:Mo
 * updateTime:2016/12/17
 * */
DJMask={
			common:{//公共配置
				windowW:$(window).width(),//浏覽器視窗寬度
				windowH:$(window).height(),//浏覽器視窗高度	
				closeCssAnimate:function(){//關閉X的動畫效果
					$("[class*=-close]").css({
							"transition":"all 0.4s ease-in-out",
							"-webkit-transition":"all 0.4s ease-in-out",
							"-ms-transition":"all 0.4s ease-in-out"
					}).hover(function(){
						$(this).css({
							"color":"#ff0000",
							"transform":"rotate(360deg)",
							"-webkit-transform":"rotate(360deg)",
							"-ms-transform":"rotate(360deg)"
						});
					},function(){
						$(this).css({
							"color":"#666",
							"transform":"rotate(0deg)",
							"-webkit-transform":"rotate(0deg)",
							"-ms-transform":"rotate(0deg)"
						});
					})
				}
			},
			maskBackgroundCss:function(){
				var css={//遮罩的黑色透明背景樣式
						"background":"#000000",						
						"opacity":"0.5",
						"-moz-opacity":"0.5",
						"-webkit-opacity":"0.5",
						"filter":"alpha(opacity=50)",
						"width":"100%",
						"height":document.body.scrollHeight,//文檔的高度
						"position": "absolute",
						"top": "0px",
						"left": "0px",
						"z-index": "100",
						"display":"none"
					};
				return css;
			},
			init:function(){//初始化				
								var maskHtml='<div id="dj-mask"></div>';								
								$(maskHtml).appendTo("body");
								djMaskDomLoaded=$("#dj-mask");
								djMaskDomLoaded.css(this.maskBackgroundCss());
				},
			show:function(){//展示遮罩
				this.init();
				djMaskDomLoaded.show();
			},
			hide:function(){//關閉遮罩
				djMaskDomLoaded.remove();
			},	
			loadingCss:function(){
				this.show();
				var loadingBoxCenterCss={
					"position":"absolute",
					"left":"50%",
					"top":"50%",
					"height":"20px",
					"width":"100px",
					"margin-top":"-10px",
					"margin-left":"-50px",
					"z-index":"999999999"
				};
				var objectClass={
					"width":"20px",
					"height":"20px",
					"background-color":"#FFF",
					"-moz-border-radius":"50% 50% 50% 50%",
					"-webkit-border-radius":"50% 50% 50% 50%",
					"border-radius":"50% 50% 50% 50%",
					"margin-right":"20px",
					"margin-bottom":"20px",
					"position":"absolute"
				};
				var objectOneCss={
					"-webkit-animation":"object 2s linear infinite",
					"-ms-animation":"object 2s linear infinite",
		 			"animation":"object 2s linear infinite"
				};
				var objectTwoCss={
					"-webkit-animation": "object 2s linear infinite -.4s",
					"-ms-animation":"object 2s linear infinite -.4s",
					"animation":"object 2s linear infinite -.4s"
				};
				var objectThreeCss={
					"-webkit-animation": "object 2s linear infinite -.8s",
					"-ms-animation": "object 2s linear infinite -.8s",
					"animation": "object 2s linear infinite -.8s"
				};
				var objectFourCss={
					"-webkit-animation": "object 2s linear infinite -1.2s",
					"-ms-animation": "object 2s linear infinite -1.2s",
					"animation": "object 2s linear infinite -1.2s",
				};
				var objectFiveCss={
					"-webkit-animation": "object 2s linear infinite -1.6s",
					"-ms-animation": "object 2s linear infinite -1.6s",
					"animation":"object 2s linear infinite -1.6s"
				};
				var keyframesObj='0% { left: 100px; top:0}'+
							  	 '80% { left: 0; top:0;}'+
							  	 '85% { left: 0; top: -20px; width: 20px; height: 20px;}'+
							  	 '90% { width: 40px; height: 15px; }'+
							  	 '95% { left: 100px; top: -20px; width: 20px; height: 20px;}'+
							  	 '100% { left: 100px; top:0; }';
				document.styleSheets.item(0).insertRule('@-webkit-keyframes object{0% { left: 100px; top:0}80% { left: 0; top:0;}85% { left: 0; top: -20px; width: 20px; height: 20px;}90% { width: 40px; height: 15px; }95% { left: 100px; top: -20px; width: 20px; height: 20px;}100% { left: 100px; top:0; }}',0); 
				document.styleSheets.item(0).insertRule('@keyframes object{0% { left: 100px; top:0}80% { left: 0; top:0;}85% { left: 0; top: -20px; width: 20px; height: 20px;}90% { width: 40px; height: 15px; }95% { left: 100px; top: -20px; width: 20px; height: 20px;}100% { left: 100px; top:0; }	}',0); 
				var html='<div id="dj-mask-loadingBoxCenter">'+
						 '<div class="object" id="objectOne"></div>'+
						 '<div class="object" id="objectTwo" style="left:20px;"></div>'+
						 '<div class="object" id="objectThree" style="left:40px;"></div>'+
						 '<div class="object" id="objectFour" style="left:60px;"></div>'+
						 '<div class="object" id="objectFive" style="left:80px;"></div>'
						 '</div>';
				$(html).css(loadingBoxCenterCss).appendTo("body").children(".object").css(objectClass);
				$("#objectOne").css(objectOneCss);
				$("#objectTwo").css(objectTwoCss);
				$("#objectThree").css(objectThreeCss);
				$("#objectFour").css(objectFourCss);
				$("#objectFive").css(objectFiveCss);
			},
			loading:function(option){//加載中...
				if(option=="close"){
					this.hide();
					$("#dj-mask-loadingBoxCenter").remove();
				}
				else{										
					this.loadingCss();
				}
			},
			closeAll:function(){				
					$("[class^=dj-mask-]").remove();
					$("[id^=dj-mask]").remove();			
			},
			msg:function(message){//消息提示
				if(message==undefined||message=="") return false;
				var msgDom='<div class="dj-msg-number-'+Math.floor(Math.random()*1000000)+'"></div>';					
				$(msgDom).css({
					"overflow":"hidden",
					"background":"rgba(0,0,0,.5)",
					"border-radius":"4px",
					"position": "fixed",
					"top":$(window).height()/2.5+"px",
					"left":$(window).width()/2+"px",	
					"padding":"15px",
					"color":"#fff",
					"z-index":"999999",
					"display":"none",
					"max-width":"200px",
					"word-break":"break-all"
				}).appendTo("body").html(message);
				var msgDomLoaded=$("."+$(msgDom).attr("class"));//擷取設定樣式後的msg元素
				msgDomLoaded.css({//消息居中
					"margin-left":"-"+msgDomLoaded.width()/2+"px",
					"margin-top":"-"+msgDomLoaded.height()/2+"px",
				}).fadeIn();
				setTimeout(function(){
					$("."+$(msgDom).attr("class")).remove();
				},1500);
			},
			alertMask:function(){//彈框遮罩
				var alertMaskHtml='<div id="dj-mask-alert"></div>';								
				$(alertMaskHtml).appendTo("body");
				alertMaskDomLoaded=$("#dj-mask-alert");
				alertMaskDomLoaded.css($.extend(this.maskBackgroundCss(),{"z-index":"200"}));
			},
			alert:function(message,callback){//彈框提醒				
				if(message==""||message==undefined) return false;
				this.alertMask();
				alertMaskDomLoaded.show(); 
				var alertDom='<div class="dj-mask-alert-'+Math.floor(Math.random()*1000000)+'"></div>';
				$(alertDom).css({
					"width":"200px",
					"overflow":"hidden",
					"border":"1px solid #ddd",					
					"z-index":"300",
					"background":"#fff",
					"border-radius":"4px",
					"position": "fixed",
					"top":$(window).height()/2.5+"px",
					"left":$(window).width()/2+"px",	
				}).appendTo("body");
				var alertDomLoaded=$("."+$(alertDom).attr("class"));
				alertDomLoaded.css({
					"margin-left":"-"+alertDomLoaded.width()/2+"px",
					"margin-top":"-"+alertDomLoaded.height()/2+"px",
				})
				.append('<div style="height:30px;border-bottom:1px solid #ddd;line-height:30px;padding-left:10px;font-size:14px;color:#666;background:#ebebeb">提示<a style="float:right;margin-right:10px;cursor:pointer;color:#666;font-size:15px;" class="dj-alert-close">X</a></div>')
				.append('<div style="font-size:13px;color:#333;padding:10px;overflow:hidden;word-break:break-all" class="dj-alert-content"></div>')
				.append('<a style="display:block;width:50px;height:25px;line-height:25px;text-align:center;border-radius:4px;background:#428bca;color:#fff;cursor:pointer;float:right;margin:5px;padding:0" class="dj-alert-ok">确定</a>');
				this.common.closeCssAnimate();
				$(".dj-alert-content").html(message);
				$(".dj-alert-close").click(function(){//關閉視窗
					alertDomLoaded.remove();
					alertMaskDomLoaded.remove();
				});
				$(".dj-alert-ok").click(function(){
					if(callback)  callback();//有回調函數執行函數内容
					alertDomLoaded.remove();
					alertMaskDomLoaded.remove();
				});
			},
			openMask:function(){//自定義彈窗遮罩				
				var openMaskHtml='<div id="dj-mask-open"></div>';								
				$(openMaskHtml).appendTo("body");
				openMaskDomLoaded=$("#dj-mask-open");
				openMaskDomLoaded.css($.extend(this.maskBackgroundCss(),{"z-index":"150"}));
			},
			open:function(options,callback){//自定義彈窗内容
				var config={
					width:"400px",
					height:"300px",
					title:"提示",
					content:"<div>loading.......</div>"
				},
				me=$.extend(config, options);
				this.openMask();
				openMaskDomLoaded.show();
				var contentDom='<div class="dj-mask-content-'+Math.floor(Math.random()*1000000)+'"></div>';
				$(contentDom).css({
					"width":me.width,
					"height":me.height,
					"overflow":"hidden",
					"border":"1px solid #ddd",					
					"z-index":"150",
					"background":"#fff",
					"border-radius":"4px",
					"position": "fixed",
					"top":$(window).height()/2.5+"px",
					"left":$(window).width()/2+"px",		
				}).appendTo("body");
				var contentDomLoaded=$("."+$(contentDom).attr("class"));
				contentDomLoaded.css({
					"margin-left":"-"+contentDomLoaded.width()/2+"px",
					"margin-top":"-"+contentDomLoaded.height()/2+"px",
				})
				.append('<div style="height:30px;border-bottom:1px solid #ddd;line-height:30px;padding-left:10px;font-size:14px;color:#666;background:#ebebeb">'+me.title+'<a style="float:right;margin-right:10px;cursor:pointer;color:#666;font-size:15px;" class="dj-content-close">X</a></div>')
				.append('<div style="font-size:13px;color:#333;padding:10px;overflow:hidden;word-break:break-all" class="dj-content-content"></div>');
				this.common.closeCssAnimate();
				$(".dj-content-content").html(me.content);
				$(".dj-content-close").click(function(){//關閉視窗
					if(callback) callback();//有回調函數執行函數内容
					contentDomLoaded.remove();
					openMaskDomLoaded.remove();					
				});
			},
			doAjaxMthod:(function(){//定義完立即執行	,ajax遮罩添加	
					var mss = {};
					var ajaxStart_default = mss.ajaxStart_default = function() {						
						DJMask.loading();
					};
					var ajaxStop_default = mss.ajaxStop_default = function() {
						DJMask.loading("close");
					};
					$(document).ajaxStart(ajaxStart_default); // 預設的ajax執行前處理
					$(document).ajaxStop(ajaxStop_default); // 預設的ajax執行完畢處理
			}())
		};
           

确認彈出框:

<link rel="stylesheet" type="text/css" href="/assets/css/xcConfirm.css" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" />

/*垂直居中*/
.verticalAlign{ vertical-align:middle; display:inline-block; height:100%; margin-left:-1px;}

.xcConfirm .xc_layer{position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #666666; opacity: 0.5; z-index: 2147000000;}
.xcConfirm .popBox{position: fixed; left: 50%; top: 50%; background-color: #ffffff; z-index: 2147000001; width: 500px; height: 250px; margin-left: -285px; margin-top: -150px; border-radius: 5px; font-weight: bold; color: #535e66;}
.xcConfirm .popBox .ttBox{height: 20px; line-height: 30px; padding: 14px 30px; border-bottom: solid 1px #eef0f1;}
.xcConfirm .popBox .ttBox .tt{font-size: 18px; display: block; float: left; height: 30px; position: relative;}
.xcConfirm .popBox .ttBox .clsBtn{display: block; cursor: pointer; width: 12px; height: 12px; position: absolute; top: 22px; right: 30px; background: url(../img/icons.png) -48px -96px no-repeat;}
.xcConfirm .popBox .txtBox{margin: 40px 100px; height: 100px; overflow: hidden;}
.xcConfirm .popBox .txtBox .bigIcon{float: left; margin-right: 20px; width: 48px; height: 48px; background-image: url(../img/icons.png); background-repeat: no-repeat; background-position: 48px 0;}
.xcConfirm .popBox .txtBox p{ height: 84px; margin-top: 16px; line-height: 26px; overflow-x: hidden; overflow-y: auto;}
.xcConfirm .popBox .txtBox p input{width: 364px; height: 30px; border: solid 1px #eef0f1; font-size: 18px; margin-top: 6px;}
.xcConfirm .popBox .btnArea{border-top: solid 1px #eef0f1;}
.xcConfirm .popBox .btnGroup{float: right;}
.xcConfirm .popBox .btnGroup .sgBtn{margin-top: -25px; margin-right: 12px;}
.xcConfirm .popBox .sgBtn{display: block; cursor: pointer; float: left; width: 95px; height: 35px; line-height: 35px; text-align: center; color: #FFFFFF; border-radius: 5px;}
.xcConfirm .popBox .sgBtn.ok{background-color: #0095d9; color: #FFFFFF;}
.xcConfirm .popBox .sgBtn.cancel{background-color: #546a79; color: #FFFFFF;}
           

 assets/js/xcConfirm.js

/*
 * 使用說明:
 * window.wxc.Pop(popHtml, [type], [options])
 * popHtml:html字元串
 * type:window.wxc.xcConfirm.typeEnum集合中的元素
 * options:擴充對象
 * 用法:
 * 1. window.wxc.xcConfirm("我是彈窗<span>lalala</span>");
 * 2. window.wxc.xcConfirm("成功","success");
 * 3. window.wxc.xcConfirm("請輸入","input",{onOk:function(){}})
 * 4. window.wxc.xcConfirm("自定義",{title:"自定義"})
 */
(function($){
	window.wxc = window.wxc || {};
	window.wxc.xcConfirm = function(popHtml, type, options) {
	    var btnType = window.wxc.xcConfirm.btnEnum;
		var eventType = window.wxc.xcConfirm.eventEnum;
		var popType = {
			info: {
				title: "資訊",
				icon: "0 0",//藍色i
				btn: btnType.ok
			},
			success: {
				title: "成功",
				icon: "0 -48px",//綠色對勾
				btn: btnType.ok
			},
			error: {
				title: "錯誤",
				icon: "-48px -48px",//紅色叉
				btn: btnType.ok
			},
			confirm: {
				title: "提示",
				icon: "-48px 0",//黃色問号
				btn: btnType.okcancel
			},
			warning: {
				title: "警告",
				icon: "0 -96px",//黃色歎号
				btn: btnType.okcancel
			},
			input: {
				title: "輸入",
				icon: "",
				btn: btnType.ok
			},
			custom: {
				title: "",
				icon: "",
				btn: btnType.ok
			}
		};
		var itype = type ? type instanceof Object ? type : popType[type] || {} : {};//格式化輸入的參數:彈窗類型
		var config = $.extend(true, {
			//屬性
			title: "", //自定義的标題
			icon: "", //圖示
			btn: btnType.ok, //按鈕,預設單按鈕
			//事件
			onOk: $.noop,//點選确定的按鈕回調
			onCancel: $.noop,//點選取消的按鈕回調
			onClose: $.noop//彈窗關閉的回調,傳回觸發事件
		}, itype, options);
		
		var $txt = $("<p>").html(popHtml);//彈窗文本dom
		var $tt = $("<span>").addClass("tt").text(config.title);//标題
		var icon = config.icon;
		var $icon = icon ? $("<div>").addClass("bigIcon").css("backgroundPosition",icon) : "";
		var btn = config.btn;//按鈕組生成參數
		
		var popId = creatPopId();//彈窗索引
		
		var $box = $("<div>").addClass("xcConfirm");//彈窗插件容器
		var $layer = $("<div>").addClass("xc_layer");//遮罩層
		var $popBox = $("<div>").addClass("popBox");//彈窗盒子
		var $ttBox = $("<div>").addClass("ttBox");//彈窗頂部區域
		var $txtBox = $("<div>").addClass("txtBox");//彈窗内容主體區
		var $btnArea = $("<div>").addClass("btnArea");//按鈕區域
		
		var $ok = $("<a>").addClass("sgBtn").addClass("ok").text("确定");//确定按鈕
		var $cancel = $("<a>").addClass("sgBtn").addClass("cancel").text("取消");//取消按鈕
		var $input = $("<input>").addClass("inputBox");//輸入框
		var $clsBtn = $("<a>").addClass("clsBtn");//關閉按鈕
		
		//建立按鈕映射關系
		var btns = {
			ok: $ok,
			cancel: $cancel
		};
		
		init();
		
		function init(){
			//處理特殊類型input
			if(popType["input"] === itype){
				$txt.append($input);
			}
			
			creatDom();
			bind();
		}
		
		function creatDom(){
			$popBox.append(
				$ttBox.append(
					$clsBtn
				).append(
					$tt
				)
			).append(
				$txtBox.append($icon).append($txt)
			).append(
				$btnArea.append(creatBtnGroup(btn))
			);
			$box.attr("id", popId).append($layer).append($popBox);
			$("body").append($box);
		}
		
		function bind(){
			//點選确認按鈕
			$ok.click(doOk);
			
			//Enter鍵觸發确認按鈕事件
			$(window).bind("keydown", function(e){
				if(e.keyCode == 13) {
					if($("#" + popId).length == 1){
						doOk();
					}
				}
			});
			
			//點選取消按鈕
			$cancel.click(doCancel);
			
			//點選關閉按鈕
			$clsBtn.click(doClose);
		}

		//确認按鈕事件
		function doOk(){
			var $o = $(this);
			var v = $.trim($input.val());
			if ($input.is(":visible"))
		        config.onOk(v);
		    else
		        config.onOk();
			$("#" + popId).remove(); 
			config.onClose(eventType.ok);
		}
		
		//取消按鈕事件
		function doCancel(){
			var $o = $(this);
			config.onCancel();
			$("#" + popId).remove(); 
			config.onClose(eventType.cancel);
		}
		
		//關閉按鈕事件
		function doClose(){
			$("#" + popId).remove();
			config.onClose(eventType.close);
			$(window).unbind("keydown");
		}
		
		//生成按鈕組
		function creatBtnGroup(tp){
			var $bgp = $("<div>").addClass("btnGroup");
			$.each(btns, function(i, n){
				if( btnType[i] == (tp & btnType[i]) ){
					$bgp.append(n);
				}
			});
			return $bgp;
		}

		//重生popId,防止id重複
		function creatPopId(){
			var i = "pop_" + (new Date()).getTime()+parseInt(Math.random()*100000);//彈窗索引
			if($("#" + i).length > 0){
				return creatPopId();
			}else{
				return i;
			}
		}
	};
	
	//按鈕類型
	window.wxc.xcConfirm.btnEnum = {
		ok: parseInt("0001",2), //确定按鈕
		cancel: parseInt("0010",2), //取消按鈕
		okcancel: parseInt("0011",2) //确定&&取消
	};
	
	//觸發事件類型
	window.wxc.xcConfirm.eventEnum = {
		ok: 1,
		cancel: 2,
		close: 3
	};
	
	//彈窗類型
	window.wxc.xcConfirm.typeEnum = {
		info: "info",
		success: "success",
		error:"error",
		confirm: "confirm",
		warning: "warning",
		input: "input",
		custom: "custom"
	};

})(jQuery);
           

背景:

package com.tc.lvmsm.controller.gm;

import com.tc.common.bean.cm.CmService;
import com.tc.common.log.BaseController;
import com.tc.common.log.ModuleLogger;
import com.tc.common.log.ModuleLoggerFactory;

import com.tc.common.page.Page;
import com.tc.common.pic.OSSUploadUtil;
import com.tc.lvmsm.serv.itf.GasCylinderCheckInfoService;
import com.tc.lvmsm.serv.itf.GasService;
import com.tc.lvmsm.vo.cm.VehicleAndGasCylinderAndGasCylinderCheckInfo;
import com.tc.lvmsm.vo.gm.*;
import com.tc.lvmsm.vo.vm.Vehicle;
import com.tc.lvmsm.vo.vm.VehicleExample;
import com.tc.util.DateUtils;
import com.tc.util.ExcelUtil;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;

/**
 * <p>
 * <p>
 * FileName: GasCylinderCheckInfoController
 * Author:    蘇凱
 * Date:     2018/3/22 19:08
 * Description: 氣瓶定檢資訊Controller
 *
 */
@Controller
public class GasCylinderCheckInfoController
{
    /**
     * 配置管理、Service層各子產品接口bean
     */
    @Autowired
    private CmService cmServiceFactory;
    /**
     * 氣瓶管理、氣瓶定檢service
     */
    @Autowired
    private GasCylinderCheckInfoService gasCylinderCheckInfoService;
    /**
     * 配置管理 氣瓶service
     */
    @Autowired
    private GasService gasService;
    /**
     * 獲得日志句柄
     */
    private ModuleLogger logger = ModuleLoggerFactory
            .getDefinedLogger("GM\\GasCylinderCheckInfoController ");

    /**
     * Description: 查詢所有資料+分頁(ajax WEB-INF/jsp/gm/air_test_info.jsp);
    
    
     *
     * @param cph       車輛條件做查詢條件
    
    
     * @param num       氣瓶編号
     * @param pageNow   查詢目前第幾頁的資料
     * @param pageSize1 顯示每頁多少條資料
    
    
     * @return page
     */
    @RequestMapping(value = "/config/show-GasCylinderCheckInfo", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Page showAllGasCylinderCheckInfo(HttpServletRequest request,
            Integer pageNow, Integer pageSize1, String cph, String num,
            String positionnum, String firsttestdate1, String firsttestdate2,
            String orderByClause)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/show-GasCylinderCheckInfo ";
        // 建立分頁對象
        Page page = null;
        try
        {
            // 排序 預設id
            if (null == orderByClause || 0 == orderByClause.length())
            {
                orderByClause = "testdate DESC";
            }
            // 轉換positionnum查詢條件
            if (null != positionnum && "氣瓶已解除安裝!".equals(positionnum.trim()))
            {
                positionnum = "待配置氣瓶!";
            }
            if (null != positionnum && "氣瓶已解除安裝".equals(positionnum.trim()))
            {
                positionnum = "待配置氣瓶!";
            }
            // 建立氣瓶定檢資訊的List容器
            List<GasCylinderCheckInfo> gasCylinderCheckInfos = new ArrayList<GasCylinderCheckInfo>();
            // 如果頁面有傳入氣瓶參數做查詢條件,需要擷取車隊ID
            List<Integer> vehicleIds = new ArrayList<Integer>();
            // 擷取氣瓶id
            List<Integer> GasCylinderIds = new ArrayList<Integer>();
            // 存放關聯資料的集合

            List<VehicleAndGasCylinderAndGasCylinderCheckInfo> vehicleAndGasCylinderAndGasCylinderCheckInfos = new ArrayList<VehicleAndGasCylinderAndGasCylinderCheckInfo>();
            // 通過車輛查條件查詢資料

            if ((null != cph && 0 < cph.trim().length()))
            {
                VehicleExample vehicleExample = new VehicleExample();
                VehicleExample.Criteria vehicleExampleCriteria = vehicleExample
                        .createCriteria();
                // 車牌号

                vehicleExampleCriteria.andCphLike("%" +cph.trim()+ "%");

                List<Vehicle> vehicles = cmServiceFactory.getVmVehicleService()
                        .selectByExample(CALLER, vehicleExample);
                if (0 < vehicles.size())
                {
                    for (int j = 0; j < vehicles.size(); j++)
                    {
                        // 通過車輛條件擷取到已配置氣瓶的車輛id(車輛id放容器中用做擷取氣瓶資訊的條件)
                        vehicleIds.add(vehicles.get(j).getId().intValue());
                    }
                }
                else
                {
                    vehicleIds.add(0);
                }
            }
            // 頁面有傳入氣瓶編号或氣瓶位置編号做查詢條件

            // 建立氣瓶查詢條件
            if ((null != num && 0 < num.trim().length())
                    || (null != positionnum && 0 < positionnum.trim().length())
                    || (0 < vehicleIds.size()))
            {
                GasCylinderExample gasCylinderExample = new GasCylinderExample();
                GasCylinderExample.Criteria criteria2 = gasCylinderExample
                        .createCriteria();
                // 氣瓶編号num
                if (null != num && 0 < num.trim().length())
                {
                    criteria2.andNumLike("%" +num.trim()+ "%");
                }
                // 氣瓶位置編号positionnum
                if (null != positionnum && 0 < positionnum.trim().length())
                {
                    criteria2.andPositionnumEqualTo(positionnum.trim());
                }
                // 通過車輛id擷取已經配置的配置資訊

                if (0 < vehicleIds.size())
                {
                    List<Long> vehicleIdsL = new ArrayList<Long>();
                    for (int i = 0; i < vehicleIds.size(); i++)
                    {
                        vehicleIdsL.add(vehicleIds.get(i).longValue());
                    }
                    if (0 < vehicleIdsL.size())
                    {
                        criteria2.andVehidIn(vehicleIdsL);
                    }
                }
                // 必須顯示已安裝的氣瓶,排除(Vehid= -1狀态 為未安裝的氣瓶)
                long i = -1;
                /* criteria2.andVehidNotEqualTo(i); */ // 如果隻需要顯示已配置車輛的氣瓶資訊,把這條注釋打開即可
                List<GasCylinder> gasCylinders = gasService
                        .selectByExample(CALLER, gasCylinderExample);
                if (0 < gasCylinders.size())
                {
                    for (int j = 0; j < gasCylinders.size(); j++)
                    {
                        GasCylinderIds.add(gasCylinders.get(j).getId());
                    }
                }
                else
                {
                    GasCylinder gasCylinder = new GasCylinder();
                    gasCylinder.setNum("無氣瓶資訊");
                    // 當氣瓶編号未查詢到資料時,頁面不應當有資料,是以這邊的車輛ID集合中寫入0;

                    GasCylinderIds.add(0);
                }
            }

            // 構造氣瓶定檢查詢條件
            GasCylinderCheckInfoExample gasCylinderCheckInfoExample = new GasCylinderCheckInfoExample();
            GasCylinderCheckInfoExample.Criteria criteria2 = gasCylinderCheckInfoExample
                    .createCriteria();
            if (0 < GasCylinderIds.size())
            {
                criteria2.andGascylinderidIn(GasCylinderIds);
            }
            // 按日期查詢

            if (null != firsttestdate1 && 0 < firsttestdate1.length())
            {
                criteria2.andTestdateEqualTo(firsttestdate1);
            }

            int i1 = gasCylinderCheckInfoService.countByExample(CALLER,
                    gasCylinderCheckInfoExample);
            if (null != pageNow)
            {
                page = new Page(i1, pageNow);
                if (null != pageSize1)
                {
                    page.setPageSize(pageSize1);
                }

                gasCylinderCheckInfos = gasCylinderCheckInfoService
                        .selectGasCylinderCheckInfoeByExampleNoUrlList(CALLER,
                                page.getStartPos(), page.getPageSize(),
                                gasCylinderCheckInfoExample, orderByClause);

                if (0 < gasCylinderCheckInfos.size())
                {
                    for (int i = 0; i < gasCylinderCheckInfos.size(); i++)
                    {
                        VehicleAndGasCylinderAndGasCylinderCheckInfo vehicleAndGasCylinderAndGasCylinderCheckInfo = getVehicleAndGasCylinderAndGasCylinderCheckInfo(
                                CALLER, request,
                                vehicleAndGasCylinderAndGasCylinderCheckInfos,
                                gasCylinderCheckInfos, cph, i);
                        vehicleAndGasCylinderAndGasCylinderCheckInfos.add(
                                vehicleAndGasCylinderAndGasCylinderCheckInfo);
                    }
                }
                else
                {
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "查詢", 0, 1, "未找到氣瓶定檢資料!" + CALLER);
                }
            }
            else
            {
                page = new Page(i1, 1);
                if (null != pageSize1)
                {
                    page.setPageSize(pageSize1);
                }
                gasCylinderCheckInfos = gasCylinderCheckInfoService
                        .selectGasCylinderCheckInfoeByExample(CALLER,
                                page.getStartPos(), page.getPageSize(),
                                gasCylinderCheckInfoExample, orderByClause);
                if (0 < gasCylinderCheckInfos.size())
                {
                    for (int i = 0; i < gasCylinderCheckInfos.size(); i++)
                    {
                        
                        VehicleAndGasCylinderAndGasCylinderCheckInfo vehicleAndGasCylinderAndGasCylinderCheckInfo = getVehicleAndGasCylinderAndGasCylinderCheckInfo(
                                CALLER, request,
                                vehicleAndGasCylinderAndGasCylinderCheckInfos,
                                gasCylinderCheckInfos, cph, i);
                        vehicleAndGasCylinderAndGasCylinderCheckInfos.add(
                                vehicleAndGasCylinderAndGasCylinderCheckInfo);
                    }
                }
                else
                {
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "查詢", 0, 1, "未找到氣瓶定檢資料!" + CALLER);
                }
            }
            page.setList(vehicleAndGasCylinderAndGasCylinderCheckInfos);
            page.setResultCode(200);
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "查詢", 1, 1, "" + CALLER);
        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "查詢", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }
    }

    /**
     * Description: 查詢資料(修改詳情[擷取圖檔])
    
    
     *
     * @param gasCylinderCheckInfoId 氣瓶定檢id
     * @return Page
     */
    @RequestMapping(value = "/config/showAdd-GasCylinderCheckInfoBytsByGasCylinderCheckInfoId", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Page GasCylinderCheckInfoBytsByGasCylinderCheckInfoId(
            HttpServletRequest request, Integer gasCylinderCheckInfoId)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_GasCylinderCheckInfoBytsByGasCylinderCheckInfoId";
        Page page = new Page();
        try
        {
            GasCylinderCheckInfo gasCylinderCheckInfo = gasCylinderCheckInfoService
                    .selectByPrimaryKey(CALLER, gasCylinderCheckInfoId);
            if (null != gasCylinderCheckInfo)
            {
                page.setResultCode(200);
                page.getList().add(gasCylinderCheckInfo);
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "氣瓶定檢詳情", 1, 1, "顯示圖檔!" + CALLER);
            }
            else
            {
                page.setResultCode(505);
                page.setFailDesc("未擷取到定檢資訊!");
            }

        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "氣瓶定檢詳情", 0, 1, "顯示圖檔!" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;

        }

    }

    ;

    /**
     * Description: 查詢資料(修改詳情)
     *
     * @param gasCylinderCheckInfoId 氣瓶定檢id
     * @return String ("/gm/air_parameter_g")
     */
    @RequestMapping(value = "/config/Update-GasCylinderCheckInfo", produces = "application/json;charset=UTF-8")
    public String showGasCylinderCheckInfo(HttpServletRequest request,
            Integer gasCylinderCheckInfoId)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/Update-GasCylinderCheckInfo ";
        try
        {
            // 建立(車輛 氣瓶 氣瓶定檢資訊 )對象

            VehicleAndGasCylinderAndGasCylinderCheckInfo vehicleAndGasCylinderAndGasCylinderCheckInfo = new VehicleAndGasCylinderAndGasCylinderCheckInfo();
            if (null != gasCylinderCheckInfoId && 0 < gasCylinderCheckInfoId)
            {
                GasCylinderCheckInfo gasCylinderCheckInfo = gasCylinderCheckInfoService
                        .selectByPrimaryKey(CALLER, gasCylinderCheckInfoId);
                /*
                 * GasCylinderCheckInfo gasCylinderCheckInfo =
                 * gasCylinderCheckInfoService.
                 * getPictureDataByGasCylinderCheckInfo(CALLER,
                 * gasCylinderCheckInfo1);
                 */
                if (null != gasCylinderCheckInfo)
                {
                    vehicleAndGasCylinderAndGasCylinderCheckInfo
                            .setGasCylinderCheckInfo(gasCylinderCheckInfo);
                    GasCylinder gasCylinder = gasService.selectByPrimaryKey(
                            CALLER, gasCylinderCheckInfo.getGascylinderid());
                    if (null != gasCylinder)
                    {
                        vehicleAndGasCylinderAndGasCylinderCheckInfo
                                .setGasCylinder(gasCylinder);
                        Vehicle vehicle = cmServiceFactory.getVmVehicleService()
                                .selectByPrimaryKey(CALLER,
                                        gasCylinder.getVehid().intValue());
                        if (null != vehicle)
                        {
                            vehicleAndGasCylinderAndGasCylinderCheckInfo
                                    .setVehicle(vehicle);
                        }
                        else
                        {
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "氣瓶定檢詳情", 0, 1,
                                    "從資料庫中未擷取到車輛資訊" + CALLER);
                            logger.writeLog(logger.LOG_LEVEL_ERROR,
                                    "" + CALLER);
                        }
                    }
                    else
                    {
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "氣瓶定檢詳情", 0, 1,
                                "從資料庫中未擷取到氣瓶定檢資訊" + CALLER);
                        logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
                    }
                }
                else
                {
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "氣瓶定檢詳情", 0, 1, "從資料庫中未擷取到氣瓶資訊" + CALLER);
                    logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
                }

                request.setAttribute(
                        "vehicleAndGasCylinderAndGasCylinderCheckInfo",
                        vehicleAndGasCylinderAndGasCylinderCheckInfo);

                logger.writeLog(logger.LOG_LEVEL_DEBUG,
                        logger.getExitMethodHint());
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "氣瓶定檢詳情", 1, 1, "" + CALLER);
            }
            else
            {
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "氣瓶定檢詳情", 0, 1, "未接收到氣瓶定檢參數id" + CALLER);
                logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            }
        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "氣瓶定檢詳情", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return "/gm/air_parameter_g";
            /* return "/gm/Update-GasCylinderCheckInfo"; */
        }

    }

    /**
     * Description:添加氣瓶定檢資訊(ajax WEB-INF/jsp/gm/add-GasCylinderCheckInfo.jsp);
    
    
     *
     * @param gasCylinderCheckInfo           氣瓶定檢對象
     * @param gasCylinderId                  氣瓶id
     * @param cph                            車輛牌照
     * @param GasCylinderNum                 氣瓶編碼
     * @param positionnum                    氣瓶位置編号
     * @param manufacturingsupervisioninsurl 品質說明書URL
     * @param orderByClause                  字段排序
     * @return page
     */
    @RequestMapping(value = "/config/add-GasCylinderCheckInfo", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Page addGasCylinderCheckInfo(HttpServletRequest request,
            GasCylinderCheckInfo gasCylinderCheckInfo,
            @RequestParam("num") Integer gasCylinderId, String cph,
            String GasCylinderNum, String positionnum,
            String manufacturingsupervisioninsurl, String orderByClause)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfo ";
        Integer a = gasCylinderId;
        Page page = new Page();

        try
        {
            // 排序 預設id
            if (null == orderByClause || 0 == orderByClause.length())
            {
                orderByClause = "ID DESC";
            }
            if (null != manufacturingsupervisioninsurl
                    && 0 < manufacturingsupervisioninsurl.length())
            {
                gasCylinderCheckInfo
                        .setQualityspecifyurl(manufacturingsupervisioninsurl);
            }
            page = gasCylinderCheckInfoService.addGasCylinderCheckInfo(CALLER,
                    request, gasCylinderCheckInfo, gasCylinderId, cph,
                    GasCylinderNum, positionnum, orderByClause);
        }
        catch (Exception e)
        {
            page.setResultCode(502);
            page.setFailDesc("請檢查!");
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "添加定檢資訊", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

    /**
     * Description:修改氣瓶定檢資訊;
    
    
     *
     * @param gasCylinderCheckInfo           氣瓶定檢資訊
     * @param cph                            車輛牌照
     * @param positionnum                    氣瓶位置編号
     * @param num                            氣瓶編号
     * @param manufacturingsupervisioninsurl 品質說明書URL
     * @param orderByClause                  字段排序
     * @return page
     */
    @RequestMapping(value = "/config/Update-GasCylinderCheckInfoT", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Page updateGasCylinderCheckInfo(HttpServletRequest request,
            GasCylinderCheckInfo gasCylinderCheckInfo, String cph, String num,
            String positionnum, String manufacturingsupervisioninsurl,
            String orderByClause)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/Update-GasCylinderCheckInfoT ";
        Page page = new Page();
        // 排序 預設id
        if (null == orderByClause || 0 == orderByClause.length())
        {
            orderByClause = "ID DESC";
        }
        try
        {
            if (null != manufacturingsupervisioninsurl
                    && 0 < manufacturingsupervisioninsurl.length())
            {
                gasCylinderCheckInfo
                        .setQualityspecifyurl(manufacturingsupervisioninsurl);
            }
            page = gasCylinderCheckInfoService.updateGasCylinderCheckInfo(
                    CALLER, request, gasCylinderCheckInfo, cph, num,
                    positionnum, orderByClause);
            /*
             * page =
             * gasCylinderCheckInfoService.addGasCylinderCheckInfo(CALLER,
             * request, gasCylinderCheckInfo, gasCylinderId, cph,
             * GasCylinderNum, positionnum);
             */
        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "修改氣瓶定檢資訊", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

    /**
     * Description:删除氣瓶定檢資訊;
    
    
     *
     * @param id 氣瓶定檢資訊id
     * @return page
     */
    @RequestMapping(value = "/config/delete-GasCylinderCheckInfo", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Page deleteGasCylinderCheckInfo(HttpServletRequest request,
            Integer id)
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/delete-GasCylinderCheckInfo";
        Page page = new Page();
        try
        {
            if (null != id && 0 < id)
            {
                int i = 0;
                /*
                 * gasCylinderCheckInfoService.
                 * deletePictureDataByGasCylinderCheckInfo(CALLER,id);
                 */
                i = gasCylinderCheckInfoService.deleteByPrimaryKey(CALLER, id);
                if (0 < i)
                {
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "修改氣瓶定檢資訊/删除氣瓶定檢資訊", 1, 1,
                            "氣瓶定檢資訊删除失敗,請檢查資料庫" + CALLER);
                    page.setResultCode(200);
                    page.setFailDesc("氣瓶定檢資訊删除成功!");

                }
                else
                {
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "修改氣瓶定檢資訊/删除氣瓶定檢資訊", 0, 1,
                            "氣瓶定檢資訊删除失敗,請檢查資料庫" + CALLER);
                    page.setResultCode(505);
                    page.setFailDesc("氣瓶定檢資訊删除失敗!");
                    return page;
                }

            }
            else
            {
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "修改氣瓶定檢資訊/删除氣瓶定檢資訊", 0, 1,
                        "氣瓶定檢資訊删除失敗,未擷取到頁面傳來的氣瓶定檢id參數!" + CALLER);
                page.setResultCode(505);
                page.setFailDesc("氣瓶定檢資訊删除失敗!");
                return page;
            }

        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "修改氣瓶定檢資訊/删除氣瓶定檢資訊", 0, 1, "系統異常删除氣瓶定檢資訊失敗!" + CALLER);
            page.setResultCode(505);
            page.setFailDesc("系統異常删除氣瓶定檢資訊失敗!");
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);

        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }


    //==============================檔案上傳======================================
    /**
     * 産品合格證檔案上傳
     */
    @RequestMapping(value = "/config/create-AllGasCylinderCheckInfoFileurlFileUpload", method = RequestMethod.POST)
    @ResponseBody
    public Page AllGasCylinderCheckInfoProductqualifyurlFileUpload(
            @RequestParam("productqualifyurlFile1") List<CommonsMultipartFile> files,
            HttpServletRequest request) throws IOException
    {
        String CALLER = "GasCylinderCheckInfoController_/config/create-AllGasCylinderCheckInfoFileurlFileUpload ";
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        System.out.println(url);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";

                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                        }
                    }
                }
                if (null != urls && 0 < urls.length())
                {
                    page.setFieldString(urls);
                    page.setFailDesc("圖檔上傳成功!");
                    page.setResultCode(200);
                }
            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "增加氣瓶定檢資訊/檔案上傳", 0, 1, "系統異常檔案上傳失敗!" + CALLER);
        }
        finally
        {
            return page;
        }
    }

    /**
     *品質證書檔案上傳
     */
    @RequestMapping(value = "/config/create-AllGasCylinderCheckInfoQualitycertificateurlFileUpload", method = RequestMethod.POST)
    @ResponseBody
    public Page AllGasCylinderCheckInfoQualitycertificateurlFileUpload(
            @RequestParam("qualitycertificateurlFile2") List<CommonsMultipartFile> files,
            HttpServletRequest request) throws IOException
    {
        String CALLER = "GasCylinderCheckInfoController_/config/create-AllGasCylinderCheckInfoFileurlFileUpload ";
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        System.out.println(url);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";

                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                        }
                    }
                }
                if (null != urls && 0 < urls.length())
                {
                    page.setFieldString(urls);
                    page.setFailDesc("圖檔上傳成功!");
                    page.setResultCode(200);
                }
            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "增加氣瓶定檢資訊/檔案上傳", 0, 1, "系統異常檔案上傳失敗!" + CALLER);
        }
        finally
        {
            return page;
        }
    }


 /**
 * 使用說明書檔案上傳
 */
@RequestMapping(value = "/config/create-AllGasCylinderCheckInfoInstructionmanualurlUpload", method = RequestMethod.POST)
@ResponseBody
public Page AllGasCylinderCheckInfoInstructionmanualurlFileUpload(
        @RequestParam("instructionmanualurlFile2") List<CommonsMultipartFile> files,
        HttpServletRequest request) throws IOException
{
    String CALLER = "GasCylinderCheckInfoController_/config/create-AllGasCylinderCheckInfoFileurlFileUpload ";
    String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
    String fileName = "";
    String fileType = "";
    Page page = new Page();
    String urls = "";
    try
    {
        if (null != files && 0 < files.size())
        {
            for (int i = 0; i < files.size(); i++)
            {
                if (!files.get(i).isEmpty())
                {
                    // 檔案儲存路徑
                    CommonsMultipartFile file = (CommonsMultipartFile) files
                            .get(i);
                    fileName = file.getOriginalFilename();
                    if (null != fileName && 0 < fileName.length())
                    {
                        fileType = fileName
                                .substring(fileName.lastIndexOf(".") + 1);
                    }
                    String url = OSSUploadUtil.uploadFile(file, fileType);
                    System.out.println(url);
                    if (null != url && 0 < url.length())
                    {
                        urls += url + ",";

                    }
                    else
                    {
                        page.setFailDesc("圖檔上傳不成功!");
                        page.setResultCode(505);
                    }
                }
            }
            if (null != urls && 0 < urls.length())
            {
                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);
            }
        }
        else
        {
            page.setFailDesc("未擷取到檔案資訊!");
            page.setResultCode(505);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
        BaseController.saveLog(
                SecurityUtils.getSubject().getPrincipals().toString(),
                startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                "增加氣瓶定檢資訊/檔案上傳", 0, 1, "系統異常檔案上傳失敗!" + CALLER);
    }
    finally
    {
        return page;
    }
}

    /**
     * 檢驗報告檔案上傳
     */
    @RequestMapping(value = "/config/create-AllGasCylinderCheckInspectereporturlUpload", method = RequestMethod.POST)
    @ResponseBody
    public Page AllGasCylinderCheckInspectereporturlFileUpload(
            @RequestParam("inspectereporturlFile2") List<CommonsMultipartFile> files,
            HttpServletRequest request) throws IOException
    {
        String CALLER = "GasCylinderCheckInfoController_/config/create-AllGasCylinderCheckInfoFileurlFileUpload ";
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        System.out.println(url);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";

                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                        }
                    }
                }
                if (null != urls && 0 < urls.length())
                {
                    page.setFieldString(urls);
                    page.setFailDesc("圖檔上傳成功!");
                    page.setResultCode(200);
                }
            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "增加氣瓶定檢資訊/檔案上傳", 0, 1, "系統異常檔案上傳失敗!" + CALLER);
        }
        finally
        {
            return page;
        }
    }

    /**
     * 日常檢驗記錄檔案上傳
     */
    @RequestMapping(value = "/config/create-AllGasCylinderCheckDailyinspectrecordurlUpload", method = RequestMethod.POST)
    @ResponseBody
    public Page AllGasCylinderCheckDailyinspectrecordurlFileUpload(
            @RequestParam("dailyinspectrecordurlFile2") List<CommonsMultipartFile> files,
            HttpServletRequest request) throws IOException
    {
        String CALLER = "GasCylinderCheckInfoController_/config/create-AllGasCylinderCheckInfoFileurlFileUpload ";
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        System.out.println(url);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";

                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                        }
                    }
                }
                if (null != urls && 0 < urls.length())
                {
                    page.setFieldString(urls);
                    page.setFailDesc("圖檔上傳成功!");
                    page.setResultCode(200);
                }
            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "增加氣瓶定檢資訊/檔案上傳", 0, 1, "系統異常檔案上傳失敗!" + CALLER);
        }
        finally
        {
            return page;
        }
    }
    /**
     * Description:氣瓶定檢查詢分頁
     *
     * @param vehicleAndGasCylinderAndGasCylinderCheckInfos (車輛、氣瓶、氣瓶定檢資訊)封裝對象
    
     * @param gasCylinderCheckInfos                         (氣瓶定檢資訊集合)
    
    
     * @param cph                                           車牌号
    
    
     * @param i                                             周遊索引
     * @param
     */
    public VehicleAndGasCylinderAndGasCylinderCheckInfo getVehicleAndGasCylinderAndGasCylinderCheckInfo(
            String CALLER, HttpServletRequest request,
            List<VehicleAndGasCylinderAndGasCylinderCheckInfo> vehicleAndGasCylinderAndGasCylinderCheckInfos,
            List<GasCylinderCheckInfo> gasCylinderCheckInfos, String cph, int i)
            throws Exception
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        VehicleAndGasCylinderAndGasCylinderCheckInfo vehicleAndGasCylinderAndGasCylinderCheckInfo = new VehicleAndGasCylinderAndGasCylinderCheckInfo();
        vehicleAndGasCylinderAndGasCylinderCheckInfo
                .setGasCylinderCheckInfo(gasCylinderCheckInfos.get(i));
        if (null != gasCylinderCheckInfos.get(i).getGascylinderid()
                && 0 < gasCylinderCheckInfos.get(i).getGascylinderid())
        {
            // 擷取氣瓶資訊
            GasCylinderExample gasCylinderExample = new GasCylinderExample();
            GasCylinderExample.Criteria criteria1 = gasCylinderExample
                    .createCriteria();
            criteria1.andIdEqualTo(
                    gasCylinderCheckInfos.get(i).getGascylinderid());
            List<GasCylinder> gasCylinders = gasService.selectByExample(CALLER,
                    gasCylinderExample);
            if (0 < gasCylinders.size())
            {
                vehicleAndGasCylinderAndGasCylinderCheckInfo
                        .setGasCylinder(gasCylinders.get(0));
                // 擷取車輛資訊
                VehicleExample vehicleExample = new VehicleExample();
                VehicleExample.Criteria criteria = vehicleExample
                        .createCriteria();
                if (null != gasCylinders.get(0).getVehid()
                        && 0 < gasCylinders.get(0).getVehid())
                {
                    criteria.andIdEqualTo(
                            gasCylinders.get(0).getVehid().intValue());
                }
                else
                {
                    criteria.andIdEqualTo(0);
                }

                List<Vehicle> vehicles = cmServiceFactory.getVmVehicleService()
                        .selectByExample(CALLER, vehicleExample);
                if (0 < vehicles.size())
                {
                    for (int j = 0; j < vehicles.size(); j++)
                    {
                        vehicleAndGasCylinderAndGasCylinderCheckInfo
                                .setVehicle(vehicles.get(0));
                        logger.writeLog(logger.LOG_LEVEL_DEBUG,
                                logger.getExitMethodHint());
                    }
                }
                else
                {
                    Vehicle vehicle = new Vehicle();
                    vehicle.setCph("無");
                    vehicle.setOwnno("無");
                    vehicleAndGasCylinderAndGasCylinderCheckInfo
                            .setVehicle(vehicle);
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "查詢", 0, 1, "未找到車輛資料" + CALLER);
                }

            }
            else
            {
                GasCylinder gasCylinder = new GasCylinder();
                gasCylinder.setNum("-1");
                gasCylinder.setPositionnum("-1");
                vehicleAndGasCylinderAndGasCylinderCheckInfo
                        .setGasCylinder(gasCylinder);
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "查詢", 0, 1, "未找到氣瓶資料" + CALLER);
            }
        }
        return vehicleAndGasCylinderAndGasCylinderCheckInfo;
    }

    /**
     * Description: 檔案下載下傳功能
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/down")
    public void down(HttpServletRequest request, HttpServletResponse response)
            throws Exception
    {
        // 模拟檔案,myfile.txt為需要下載下傳的檔案
        String fileName = request.getSession().getServletContext()
                .getRealPath("upload") + "/myfile.txt";
        // 擷取輸入流

        InputStream bis = new BufferedInputStream(
                new FileInputStream(new File(fileName)));
        // 假如以中文名下載下傳的話
        String filename = "下載下傳檔案.txt";
        // 轉碼,免得檔案名中文亂碼
        filename = URLEncoder.encode(filename, "UTF-8");
        // 設定檔案下載下傳頭

        response.addHeader("Content-Disposition",
                "attachment;filename=" + filename);
        // 1.設定檔案ContentType類型,這樣設定,會自動判斷下載下傳檔案類型

        response.setContentType("multipart/form-data");
        BufferedOutputStream out = new BufferedOutputStream(
                response.getOutputStream());
        int len = 0;
        while ((len = bis.read()) != -1)
        {
            out.write(len);
            out.flush();
        }
        out.close();
    }

    /**
     * Description: 導出檔案(WEB-INF/jsp/gm/air_test_info.jsp)
    
    
     *
     * @param cph 車輛條件做查詢條件
    
    
     * @param num 氣瓶編号
     * @return String null
     */
    @RequestMapping(value = "/config/export-GasCylinderCheckInfoExcel", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String exportAllGasCylinderCheckInfoExcel(HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "cph", required = false) String cph,
            @RequestParam(value = "num", required = false) String num,
            @RequestParam(value = "positionnum", required = false) String positionnum,
            @RequestParam(value = "firsttestdate1", required = false) String firsttestdate1,
            @RequestParam(value = "firsttestdate2", required = false) String firsttestdate2,
            @RequestParam(value = "orderByClause", required = false) String orderByClause)
    {
        String fileName = "氣瓶定檢";
        // 排序 預設id
        if (null == orderByClause || 0 == orderByClause.length())
        {
            orderByClause = "testdate DESC";
        }
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/export-GasCylinderCheckInfoExcel ";
        // 建立分頁對象
        Page page = new Page();
        // 建立氣瓶定檢資訊的List容器
        List<GasCylinderCheckInfo> gasCylinderCheckInfos = new ArrayList<GasCylinderCheckInfo>();
        try
        {
            request.setCharacterEncoding("utf-8");
            // 如果頁面有傳入氣瓶參數做查詢條件,需要擷取車隊ID
            List<Integer> vehicleIds = new ArrayList<Integer>();
            // 擷取氣瓶id
            List<Integer> GasCylinderIds = new ArrayList<Integer>();
            // 存放關聯資料的集合

            List<VehicleAndGasCylinderAndGasCylinderCheckInfo> vehicleAndGasCylinderAndGasCylinderCheckInfos = new ArrayList<VehicleAndGasCylinderAndGasCylinderCheckInfo>();
            // 通過車輛查條件查詢資料

            if ((null != cph && 0 < cph.trim().length()))
            {
                /* cph = new String(cph.getBytes("iso8859-1"),"utf-8"); */
                cph = URLDecoder.decode(cph, "UTF-8");
                VehicleExample vehicleExample = new VehicleExample();
                VehicleExample.Criteria vehicleExampleCriteria = vehicleExample
                        .createCriteria();
                // 車牌号

                vehicleExampleCriteria.andCphEqualTo(cph.trim());
                List<Vehicle> vehicles = cmServiceFactory.getVmVehicleService()
                        .selectByExample(CALLER, vehicleExample);
                if (0 < vehicles.size())
                {
                    for (int j = 0; j < vehicles.size(); j++)
                    {
                        // 通過車輛條件擷取到已配置氣瓶的車輛id(車輛id放容器中用做擷取氣瓶資訊的條件)
                        vehicleIds.add(vehicles.get(j).getId().intValue());
                    }
                }
                else
                {
                    vehicleIds.add(0);
                }
            }
            /*
             * =================================================================
             */
            // 頁面有傳入氣瓶編号或氣瓶位置編号做查詢條件

            // 建立氣瓶查詢條件
            if ((null != num && 0 < num.trim().length())
                    || (null != positionnum && 0 < positionnum.trim().length())
                    || (0 < vehicleIds.size()))
            {
                GasCylinderExample gasCylinderExample = new GasCylinderExample();
                GasCylinderExample.Criteria criteria2 = gasCylinderExample
                        .createCriteria();
                // 氣瓶編号num
                if (null != num && 0 < num.trim().length())
                {
                    criteria2.andNumEqualTo(num.trim());
                }
                // 氣瓶位置編号positionnum
                if (null != positionnum && 0 < positionnum.trim().length())
                {
                    /*
                     * positionnum = new String(
                     * positionnum.getBytes("iso8859-1"),"utf-8");
                     */
                    criteria2.andPositionnumEqualTo(positionnum.trim());
                }
                // 通過車輛id擷取已經配置的配置資訊

                if (0 < vehicleIds.size())
                {
                    List<Long> vehicleIdsL = new ArrayList<Long>();
                    for (int i = 0; i < vehicleIds.size(); i++)
                    {
                        vehicleIdsL.add(vehicleIds.get(i).longValue());
                    }
                    if (0 < vehicleIdsL.size())
                    {
                        criteria2.andVehidIn(vehicleIdsL);
                    }
                }
                // 必須顯示已安裝的氣瓶,排除(Vehid= -1狀态 為未安裝的氣瓶)
                long i = -1;
                /* criteria2.andVehidNotEqualTo(i); */
                List<GasCylinder> gasCylinders = gasService
                        .selectByExample(CALLER, gasCylinderExample);
                if (0 < gasCylinders.size())
                {
                    for (int j = 0; j < gasCylinders.size(); j++)
                    {
                        GasCylinderIds.add(gasCylinders.get(j).getId());
                    }
                }
                else
                {
                    GasCylinder gasCylinder = new GasCylinder();
                    gasCylinder.setNum("無氣瓶資訊");
                    // 當氣瓶編号未查詢到資料時,頁面不應當有資料,是以這邊的車輛ID集合中寫入0;

                    GasCylinderIds.add(0);
                }
            }
            /*
             * =================================================================
             */
            // 構造氣瓶定檢查詢條件
            GasCylinderCheckInfoExample gasCylinderCheckInfoExample = new GasCylinderCheckInfoExample();
            GasCylinderCheckInfoExample.Criteria criteria2 = gasCylinderCheckInfoExample
                    .createCriteria();
            if (0 < GasCylinderIds.size())
            {
                criteria2.andGascylinderidIn(GasCylinderIds);
            }
            // 按日期查詢

            if (null != firsttestdate1 && 0 < firsttestdate1.length())
            {
                criteria2.andTestdateEqualTo(firsttestdate1);
            }
            /*
             * if(null != firsttestdate1 && 0 < firsttestdate1.length() && null
             * != firsttestdate2 && 0 < firsttestdate2.length()){
             * criteria2.andFirsttestdateBetween(firsttestdate1,firsttestdate2);
             * } if((null != firsttestdate1 && 0 < firsttestdate1.length()) &&
             * (null == firsttestdate2 || 0 == firsttestdate2.length())){
             * criteria2.andFirsttestdateEqualTo(firsttestdate1); } if((null !=
             * firsttestdate2 && 0 < firsttestdate2.length()) && (null ==
             * firsttestdate1 || 0 == firsttestdate1.length())){
             * criteria2.andFirsttestdateEqualTo(firsttestdate2); }
             */
            gasCylinderCheckInfos = gasCylinderCheckInfoService.selectByExample(
                    CALLER, gasCylinderCheckInfoExample, orderByClause);
            if (0 < gasCylinderCheckInfos.size())
            {
                for (int i = 0; i < gasCylinderCheckInfos.size(); i++)
                {
                    VehicleAndGasCylinderAndGasCylinderCheckInfo vehicleAndGasCylinderAndGasCylinderCheckInfo = getVehicleAndGasCylinderAndGasCylinderCheckInfo(
                            CALLER, request,
                            vehicleAndGasCylinderAndGasCylinderCheckInfos,
                            gasCylinderCheckInfos, cph, i);
                    vehicleAndGasCylinderAndGasCylinderCheckInfos
                            .add(vehicleAndGasCylinderAndGasCylinderCheckInfo);
                }
                /*
                 * ============================================Excel導出==========
                 */
                // 建立存放需要導出資料的map容器
                Map<String, Object> vehicleAndGasCylinderAndGasCylinderCheckInfopMap = new HashMap<String, Object>();
                // 建立存放map的list容器
                List<Map<String, Object>> vehicleAndVehGroupsList = new ArrayList<Map<String, Object>>();
                vehicleAndGasCylinderAndGasCylinderCheckInfopMap
                        .put("sheetName", "sheet1");
                vehicleAndVehGroupsList
                        .add(vehicleAndGasCylinderAndGasCylinderCheckInfopMap);
                if (0 < vehicleAndGasCylinderAndGasCylinderCheckInfos.size())
                {
                    // 導出方法
                    excelOut(request, response, fileName,
                            vehicleAndGasCylinderAndGasCylinderCheckInfos,
                            vehicleAndVehGroupsList);
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("未獲得資料!");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "導出", 0, 1, "未獲得資料!" + CALLER);
                }
            }
            else
            {
                BaseController.saveLog(
                        SecurityUtils.getSubject().getPrincipals().toString(),
                        startTime,
                        DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                        BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                        "導出", 0, 1, "未找到氣瓶定檢資料!" + CALLER);
            }
            page.setResultCode(200);
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "導出", 1, 1, "" + CALLER);
        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "導出", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return null;
        }
    }

    // excel導出
    private void excelOut(HttpServletRequest request,
            HttpServletResponse response, String fileName,
            List<VehicleAndGasCylinderAndGasCylinderCheckInfo> vehicleAndGasCylinderAndGasCylinderCheckInfos,
            List<Map<String, Object>> vehicleAndVehGroupsList)
            throws IOException
    {
        Map<String, Object> vehicleAndGasCylinderAndGasCylinderCheckInfopMap;
        for (int i = 0; i < vehicleAndGasCylinderAndGasCylinderCheckInfos
                .size(); i++)
        {
            vehicleAndGasCylinderAndGasCylinderCheckInfopMap = new HashMap<String, Object>();
            vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put("cph",
                    vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i)
                            .getVehicle().getCph()); // 車牌号

            vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put("num",
                    vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i)
                            .getGasCylinder().getNum()); // 氣瓶編号
            if ("待配置氣瓶!".equals(vehicleAndGasCylinderAndGasCylinderCheckInfos
                    .get(i).getGasCylinder().getPositionnum()))
            {
                vehicleAndGasCylinderAndGasCylinderCheckInfopMap
                        .put("positionnum", "氣瓶已經解除安裝!"); // 氣瓶位置編号
            }
            else
            {
                vehicleAndGasCylinderAndGasCylinderCheckInfopMap
                        .put("positionnum",
                                vehicleAndGasCylinderAndGasCylinderCheckInfos
                                        .get(i).getGasCylinder()
                                        .getPositionnum()); // 氣瓶位置編号
            }

            vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put("testdate",
                    vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i)
                            .getGasCylinderCheckInfo().getTestdate()); // 首次檢驗日期

            vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put("testunit",
                    vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i)
                            .getGasCylinderCheckInfo().getTestunit()); // 首次檢驗機關

            vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put("testresult",
                    vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i)
                            .getGasCylinderCheckInfo().getTestresult()); // 首次檢驗結果

            /*
             * vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put(
             * "recenttestdate",
             * vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i).
             * getGasCylinderCheckInfo().getRecenttestdate()); //最近檢驗日期
             * 
             * 
             * vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put(
             * "recentinspectunit",
             * vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i).
             * getGasCylinderCheckInfo().getRecentinspectunit()); //最近檢驗機關
             *
             *
             * 
             * 
             * vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put(
             * "recentinspectresult",
             * vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i).
             * getGasCylinderCheckInfo().getRecentinspectresult()); //最近檢驗結果
             * 
             * 
             */
            /*
             * vehicleAndGasCylinderAndGasCylinderCheckInfopMap.put(
             * "nexttesttime",
             * vehicleAndGasCylinderAndGasCylinderCheckInfos.get(i).
             * getGasCylinderCheckInfo().getNexttesttime()); //下次定檢日期
             */
            vehicleAndVehGroupsList
                    .add(vehicleAndGasCylinderAndGasCylinderCheckInfopMap);

        }
        String[][] columnNames =
        {
                {},
                { "車牌号", "氣瓶編号", "位置編号", "檢驗日期", "檢驗機關", "檢驗結果" } }; // 列名
        String[] keys =
        { "cph", "num", "positionnum", "testdate", "testunit", "testresult" }; // map中的key
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        ExcelUtil.createWorkBook(vehicleAndVehGroupsList, keys, columnNames)
                .write(os);
        ExcelUtil.inputExcel(request, response, fileName, os);
    }


    /*=================首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔==================================*/
    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(産品合格證url)
     * 此圖檔儲存後需要,将其它同氣瓶編号的氣瓶資訊一并同步成同一圖檔;
     * @return page
     * @throws IOException
     * @RequestParam("productqualifyurlFile") CommonsMultipartFile file
     */
    @RequestMapping(value = "/config/add-GasCylinderCheckInfoProductqualifyurlUpload1", method = RequestMethod.POST)
    @ResponseBody
    public Page GasCylinderCheckInfoProductqualifyurlUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {

        /*
         * =====================================================================
         */
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfoProductqualifyurlUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo.setProductqualifyurl(urls.toString());
                        int i = gasCylinderCheckInfoService.updateImageByPrimaryKeySelective(CALLER,
                                gasCylinderCheckInfo);

                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(檢驗報告)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }


    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(品質證明書url)
     *
     * @return page
     * @throws IOException
     * @RequestParam("qualitycertificateurlFile") CommonsMultipartFile file
     */

    @RequestMapping(value = "/config/add-GasCylinderCheckInfoQualitycertificateurlUpload1", method = RequestMethod.POST)
    @ResponseBody
    public Page GasCylinderCheckInfoQualitycertificateurlUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {

        /*
         * =====================================================================
         */
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfoQualitycertificateurlUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo
                                .setQualitycertificateurl(urls.toString());
                        int i = gasCylinderCheckInfoService.updateImageByPrimaryKeySelective(CALLER,
                                gasCylinderCheckInfo);
                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(檢驗報告)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(品質說明書)
     *
     * @return page
     * @throws IOException
     * @RequestParam("qualityspecifyurlFile") CommonsMultipartFile file
     */

    @RequestMapping(value = "/config/add-GasCylinderCheckInfoQualityspecifyurlUpload1", method = RequestMethod.POST)
    @ResponseBody
    public Page GasCylinderCheckInfoQualityspecifyurlUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {

        /*
         * =====================================================================
         */
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfoQualityspecifyurlUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo
                                .setQualityspecifyurl(urls.toString());
                        int i = gasCylinderCheckInfoService.updateImageByPrimaryKeySelective(CALLER,
                                gasCylinderCheckInfo);
                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(檢驗報告)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(使用說明書url)
     *
     * @return page
     * @throws IOException
     * @RequestParam("instructionmanualurlFile") CommonsMultipartFile file
     */
    @RequestMapping(value = "/config/add-GasCylinderCheckInfoInstructionmanualurlUpload1", method = RequestMethod.POST)
    @ResponseBody

    public Page GasCylinderCheckInfoInstructionmanualurlUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {

        /*
         * =====================================================================
         */
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfoInstructionmanualurlUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo
                                .setInstructionmanualurl(urls.toString());
                        int i = gasCylinderCheckInfoService.updateImageByPrimaryKeySelective(CALLER,
                                gasCylinderCheckInfo);
                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(檢驗報告)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }


    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(檢驗報告)
     *
     * @return page
     * @throws IOException
     * @RequestParam("inspectereporturlFile") CommonsMultipartFile file
     */
    @RequestMapping(value = "/config/add-GasCylinderCheckInfoInspectereporturlUpload1", method = RequestMethod.POST)
    @ResponseBody
    public Page GasCylinderCheckInfoInspectereporturlUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {

        /*
         * =====================================================================
         */
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_/config/add-GasCylinderCheckInfoInspectereporturlUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {
            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo
                                .setInspectereporturl(urls.toString());
                        int i = gasCylinderCheckInfoService
                                .updateByPrimaryKeySelective(CALLER,
                                        gasCylinderCheckInfo);
                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(檢驗報告)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

    /**
     * Description:首頁檔案上傳功能(上傳完圖檔直接将URL更新數到據庫)、上傳圖檔(日常檢驗記錄)
     * @return page
     * @throws IOException
     * @RequestParam("dailyinspectrecordurlFile") CommonsMultipartFile file
     */
    @RequestMapping(value = "/config/add-GasCylinderCheckInfoDailyinspectrecordurlFileUpload1", method = RequestMethod.POST)
    @ResponseBody
    public Page GasCylinderCheckInfoDailyinspectrecordurlFileUpload1(
            @RequestParam("file") List<CommonsMultipartFile> files,
            HttpServletRequest request, Integer gasCylinderCheckInfoId,
            Integer ii) throws IOException
    {
        String startTime = DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss");
        String CALLER = "GasCylinderCheckInfoController_GasCylinderCheckInfoDailyinspectrecordurlFileUpload1 ";
        String fileName = "";
        String fileType = "";
        Page page = new Page();
        String urls = "";
        try
        {

            if (null != files && 0 < files.size())
            {
                for (int i = 0; i < files.size(); i++)
                {
                    if (!files.get(i).isEmpty())
                    {
                        // 檔案儲存路徑
                        CommonsMultipartFile file = (CommonsMultipartFile) files
                                .get(i);
                        fileName = file.getOriginalFilename();
                        if (null != fileName && 0 < fileName.length())
                        {
                            fileType = fileName
                                    .substring(fileName.lastIndexOf(".") + 1);
                        }
                        String url = OSSUploadUtil.uploadFile(file, fileType);
                        if (null != url && 0 < url.length())
                        {
                            urls += url + ",";
                            System.out.println(url);
                        }
                        else
                        {
                            page.setFailDesc("圖檔上傳不成功!");
                            page.setResultCode(505);
                            return page;
                        }
                    }
                }
                if (null != gasCylinderCheckInfoId
                        && 0 < gasCylinderCheckInfoId)
                {
                    if (null != urls && 0 < urls.length())
                    {
                        GasCylinderCheckInfo gasCylinderCheckInfo = new GasCylinderCheckInfo();
                        gasCylinderCheckInfo.setId(gasCylinderCheckInfoId);
                        gasCylinderCheckInfo
                                .setDailyinspectrecordurl(urls.toString());
                        int i = gasCylinderCheckInfoService
                                .updateByPrimaryKeySelective(CALLER,
                                        gasCylinderCheckInfo);
                        if (0 < i)
                        {
                            page.setResultCode(200);
                            page.setFailDesc("上傳成功!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳(日常檢驗記錄)", 1, 1,
                                    "" + CALLER);
                        }
                        else
                        {
                            page.setResultCode(505);
                            page.setFailDesc("上傳失敗!");
                            BaseController.saveLog(
                                    SecurityUtils.getSubject().getPrincipals()
                                            .toString(),
                                    startTime,
                                    DateUtils.getCurrentDate(
                                            "yyyy-MM-dd HH:mm:ss"),
                                    BaseController.getRequestIp(request),
                                    "氣瓶資訊", "氣瓶定檢資訊", "點選上傳", 0, 1,
                                    "上傳失敗!" + CALLER);
                        }
                    }
                    else
                    {
                        page.setResultCode(505);
                        page.setFailDesc("上傳失敗,未傳回檔案路徑!");
                        BaseController.saveLog(
                                SecurityUtils.getSubject().getPrincipals()
                                        .toString(),
                                startTime,
                                DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                                BaseController.getRequestIp(request), "氣瓶資訊",
                                "氣瓶定檢資訊", "點選上傳", 0, 1, "未傳回檔案路徑" + CALLER);
                    }
                }
                else
                {
                    page.setResultCode(505);
                    page.setFailDesc("上傳失敗,未獲得氣瓶定檢id");
                    BaseController.saveLog(
                            SecurityUtils.getSubject().getPrincipals()
                                    .toString(),
                            startTime,
                            DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                            BaseController.getRequestIp(request), "氣瓶資訊",
                            "氣瓶定檢資訊", "點選上傳", 0, 1, "未獲得氣瓶定檢id" + CALLER);
                }

                page.setFieldString(urls);
                page.setFailDesc("圖檔上傳成功!");
                page.setResultCode(200);

            }
            else
            {
                page.setFailDesc("未擷取到檔案資訊!");
                page.setResultCode(505);
            }

        }
        catch (Exception e)
        {
            BaseController.saveLog(
                    SecurityUtils.getSubject().getPrincipals().toString(),
                    startTime, DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
                    BaseController.getRequestIp(request), "氣瓶資訊", "氣瓶定檢資訊",
                    "點選上傳", 0, 1, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR, "" + CALLER);
            logger.writeLog(logger.LOG_LEVEL_ERROR,
                    logger.getExceptionMethodHint(), e);
        }
        finally
        {
            logger.writeLog(logger.LOG_LEVEL_DEBUG, logger.getExitMethodHint());
            return page;
        }

    }

}
           
多組input檔案,每組 multiple選擇多張圖檔上傳可增删其中任意一張圖檔,用formData對象實作;(ajax做異步,自己做延時同步)【 】效果: