2018年3月9日 星期五

62進位 使用 Bigintger 轉 10進制 轉回 62進制

public String getNextsubDocNum(String docnum) throws Exception {
String[] evnval = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c",
"d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z" }; // MAPPING   << 
String jonstr62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // 對應 文字的數字

String rexStr = "^[\\w]+$"; // 驗證 字串 是否 是數字 與 英文

if (!Pattern.matches(rexStr, docnum)) {
return "0-ERROR FORMATE"; // 若不是指定的格式 則回傳
}

BigInteger bei_chu_shu = new BigInteger("0");
for (int i = 0; i < docnum.length(); i++) {
int cop = (docnum.length() - i) - 1; // 次方
int log = jonstr62.indexOf(docnum.charAt(i)); // 位數值
BigInteger id = new BigInteger("62").pow(cop);// 62進制 N 次方
bei_chu_shu = bei_chu_shu.add(new BigInteger(String.valueOf(log)).multiply(id)); // 算出 10進制
}

bei_chu_shu = bei_chu_shu.add(BigInteger.ONE); // 下一個值 +1
BigInteger chu_shu = new BigInteger("62"); // 準備 62進制
BigInteger yu = BigInteger.ZERO; //

String shang = "";// 商
String sum = "";// 最後顯示的結果

while (!bei_chu_shu.equals(BigInteger.ZERO)) {
yu = bei_chu_shu.divide(chu_shu);// 餘數=被除數 / 除數
shang = String.valueOf(yu.subtract(yu.subtract(bei_chu_shu.mod(chu_shu))));// 餘數
bei_chu_shu = yu;// 讓下次迴圈的 被除數= 目前的 餘數
sum = evnval[Integer.valueOf(shang)] + sum;// 答案
}

return sum;

2018年2月6日 星期二

關於 使用JQUERY FILE UPLOAD 一次submit 上傳

 <!-- Fonts -->
<link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="../css/manage.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet" href="../css/style.css">
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
<link rel="stylesheet" href="../css/jquery.fileupload.css">
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="../js/vendor/jquery.ui.widget.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="https://blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="https://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"></script>
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="../js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="../js/jquery.fileupload.js"></script>
<script src="../js/jquery.fileupload.js"></script>
<!-- The File Upload processing plugin -->
<script src="../js/jquery.fileupload-process.js"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="../js/jquery.fileupload-image.js"></script>
<!-- The File Upload audio preview plugin -->
<script src="../js/jquery.fileupload-audio.js"></script>
<!-- The File Upload video preview plugin -->
<script src="../js/jquery.fileupload-video.js"></script>
<!-- The File Upload validation plugin -->
<script src="../js/jquery.fileupload-validate.js"></script>

 var filesList = new Array();
       $(function () {
           $('#fileupload').fileupload({
               autoUpload: false
           }).on('fileuploadadd', function (e, data) {
               data.context = $('<div/><br/>', { class: 'thumbnail pull-left' }).appendTo('#files');
               $.each(data.files, function (index, file) {
                   filesList.push(data.files[index]);
                   console.log("Added: " + data.files[index].name);
                   var node = $('<p/>').append($('<span/>').text(file.name).data(data));
                   node.appendTo(data.context);
               });
           }).on('fileuploadprocessalways', function (e, data) {
               var index = data.index,
                   file = data.files[index],
                   node = $(data.context.children()[index]);
               if (file.preview) {
                   node.prepend('<br>').prepend(file.preview);
               }
               if (file.error) {
                   node.append('<br>').append($('<span class="text-danger"/>').text(file.error));
               }
           }).prop('disabled', !$.support.fileInput)
               .parent().addClass($.support.fileInput ? undefined : 'disabled');
           
           $("#uploadform").submit(function(event) {
               if (filesList.length > 0) {
                   console.log("multi file submit");
                   event.preventDefault();
                   $('#fileupload').fileupload('send', {files: filesList})
                       .success(function (result, textStatus, jqXHR) { console.log('success'); })
                       .error(function (jqXHR, textStatus, errorThrown) { console.log('error'); })
                       .complete(function (result, textStatus, jqXHR) { 
                           console.log('complete: ' + JSON.stringify(result));
                           // window.location='back to view-page after submit?'
                       });
               } else {
                   console.log("plain default form submit");
               }
           });
       });

<form id="uploadform" method="POST" enctype="multipart/form-data">
 <span class="btn btn-success fileinput-button"> 
 <i class="glyphicon glyphicon-plus"></i> 
 <span>增加檔案</span> 
 <input id="fileupload" type="file" name="files" multiple="multiple">
 </span>
</form 

2018年1月28日 星期日

關於 Spring 多筆上傳

HTML <form id="id" name="name" method="POST" enctype="multipart/form-data" > <input multiple="multiple" name="file" type="file" /> // </form> JAVA
import org.springframework.web.multipart.MultipartFile; 
import org.springframework.web.multipart.MultipartHttpServletRequest;

@RequestMapping(value = "/url/name", method = RequestMethod.POST)
public ModelAndView modthName(HttpServletRequest request, HttpServletResponse response,
@RequestParam String htmval) throws Exception {

MultipartHttpServletRequest reqfile = (MultipartHttpServletRequest) request;
List<MultipartFile> files = reqfile.getFiles("file");


}

2018年1月25日 星期四

關於 HTML EDIT Trumbowyg 的使用

官方網站
   HTML 元件 
   
        <script src="自訂位置/trumbowyg.min.js"></script> //主要的功能
        <script src="自訂位置/plugins/upload/trumbowyg.cleanpaste.min.js"></script> //乾淨的黏貼功能 
        <script src="自訂位置/plugins/upload/trumbowyg.pasteimage.min.js"></script> //貼上圖片功能 
        <script src="自訂位置/langs/zh_tw.min.js"></script> //在地化元件
        <body>
        <div id="htmEdit"></div>
   簡單的文件 自訂化

$('#htmEdit').trumbowyg(
   {
    lang : 'zh_tw', //設定繁體中文 需要另外引入 /TrumbowygHtmlEditorSrc/langs/zh_tw.min.js.....
    btns : [
      [ 'undo', 'redo' ], // 設定按鈕 
      [ 'formatting' ],
      [ 'strong', 'em', 'del' ],
      [ 'superscript', 'subscript' ],
      [ 'link' ],
      [ 'insertImage' ],
      [ 'justifyLeft', 'justifyCenter', 'justifyRight',
        'justifyFull' ],
      [ 'unorderedList', 'orderedList' ],
      [ 'horizontalRule' ], [ 'removeformat' ],
      [ 'fullscreen' ] ]
   //Focus on editor: tbwfocus 焦點  
   //Blur on editor: tbwblur 離開 焦點  
   }).on('tbwinit', function() { // 若是修改 內文 的update 使用 INIT EVENT
  //Keep 當前輸入的值 。  
  $('#htmEdit').trumbowyg('html', '${vo.content}'); //有資料 則顯示 
 });


2018年1月16日 星期二

關於 Jqery Ajax 參數 簡單說明

  

   $.ajax({
         url: "", //網址
         type: 'POST', // 預設為 get
         data: null, // 傳送檔案 
         async: false, //是否為同步
         cache: false, //是否可暫存
         dataType : "json", //回傳 檔案 型別
         contentType: false, // 設定使用原定的傳輸協定
         processData: false, // 傳送檔案是否為序列化資料
         success: function (data) { // 成功時
          alert(data.XXX);
          
         },
         error : function(jqXHR, textStatus, errorThrown) { //發生錯誤時
                alert("發生錯誤:" + errorThrown);
         },
          beforeSend:function(){ //送出前
        //alert('show londing');
  },
  complete:function(){//完成後 不管有無錯誤
       //alert('unshow londing');
  }

});

2016年8月21日 星期日

關於 PL SQL if 的結構

關於PLSQL  if 的結構
if v_var is not null and v_var = 'b' then 
 s_var := 1;
elsif v_var is not null and  v_var = 'c' then
s_var := 2;  else 
 s_var := 3; 
end if;

2016年8月15日 星期一

關於 oracle sql 的遞迴查詢

各個常常會愈到階層關係比如










這時候 可以使用 查詢
 

 -- 向上查詢階層
   select * from org o 
   start with o.id = 123
   connect by o.id = prior o.parent_id;

--  向下查詢階層
   select * from org o 
   start with o.id = 123
   connect by prior o.id = o.parent_id;