`
征途2010
  • 浏览: 243701 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
demo
/**************************************
 * 产品分类管理公共js
 * @author  lipeng
 * @date 2015-05-05
*****************************************/
/**定义全局变量*/
var ProductMgt={
	add:function(){
		$("#addForm")[0].reset();
		$('#addWindow').window('open');
	},
	doAddSubmit:function(){
		if(!$("#addForm").form('validate')){
			return;
		}
		var validation = $("#addForm").Validform(getValidformDefaultConfig());
	    validation.config({
	        beforeSubmit: function(curform) {
	        	$.prm_confirm("确认提交吗?",undefined,function(r){
	    			if('yes' == r){
	    				$().prm_show_loading();
	    				var form =  $("#addForm"); 
	    			    var options  = {
	    			    	url:ProductMgt.addUrl,  
	    			        dataType:"json",
	    			        success:function(action){
	    			    		$().prm_hide_loading(); //提交成功后去除覆盖层
	    			    		if(action.success){
	    			    			$('#addWindow').window('close');
	    			    			$("#queryTable").datagrid('load', $("#queryForm").serializeJson()); //加载数据列表
	    			    		}else{
	    			    			$('#addWindow').window('close');
	    			    			$.prm_alert(action.data.msg,undefined,false,function(){});
	    			    		}
	    			        }    
	    			    };    
	    			   form.ajaxSubmit(options);
	    			}
	    		})
		       return false;
	        }
	    })
	    validation.submitForm();
	},
	removeit:function(){
		var selected = $("#queryTable").datagrid("getChecked");
		if(selected.length<1){
			$.prm_alert("请选择需要删除的记录", "数据删除", false,function() {});
			return;
		}
		$.prm_confirm(ProductMgt.deleteTips,undefined,function(r){
			if('yes' == r){
				$.ajax({
					url: ProductMgt.deleteUrl+ProductMgt.getDeleteParams(selected),
					dataType: "json",
					type:"POST",
					success: function(res){
						if(res.success){
							$("#queryTable").datagrid('load',$("#queryForm").serializeJson());//加载数据列表
			        	}else{
			        		$.prm_alert(res.data.msg, "数据删除", false,function() {});
						}
					}
				})
			}
		});	
	},save:function(){
		endEditing();
		var rows = $('#queryTable').datagrid('getChanges');
		if(rows.length<1) {   
			$.prm_alert("没有任何需要更新的数据!", "警告", false,function() {});
	        return;
	    }
		$.ajax({
			url:ProductMgt.updateUrl,
			dataType: "json",
			type:"POST",
			data:{"list":JSON.stringify(rows)},
			success: function(res){
				if(res.success){
					$("#queryTable").datagrid('load',$("#queryForm").serializeJson());//加载数据列表
	        	}else{
	        		$.prm_alert(res.data.msg, "数据修改", false,function() {});
				}
			}
		})
	}
};

ProductMgt.openLogWindow=function(logType,value){
	var url=window.ctxPaths+"/usims/productmgt/log/businessLogList.jsp?logType="+logType+"&businessId="+value;
	url = url + "&isOldSystem=true";
	var iWidth=800; //弹出窗口的宽度;
	var iHeight=600; //弹出窗口的高度;
	var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
	var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
	window.open(url,"log","height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft); 
};

ProductMgt.logRender=function(logType,key){
	return function(value,rowData,rowIndex){
		return "<a href='javascript:void(0)' style='color:blue' onclick='ProductMgt.openLogWindow(\""+logType+"\",\""+rowData[key]+"\")'>维护记录</a>"
	};
}

/**
 * 克隆对象
 */
ProductMgt.clone=function(object1,object2){
	var result={};
	for(var o in object1){
		result[o]=object1[o];
	}
	if(object2){
		for(var o in object2){
			result[o]=object2[o];
		}
	}
	return result;
}

/**
 * 
 * @param value
 * @returns
 */
ProductMgt.splitRender=function(value){
    return ProductMgt.split(value,',');
}

/**
 * 
 * @param value
 * @returns
 */
ProductMgt.splitRenderE=function(value){
    return ProductMgt.split(value,';');
}

ProductMgt.split=function(value,prefix){
    var html="<ul style='width:100%;height:100%'>";
    if(!value||value==null){
    	return value
    }
    var values=value.split(prefix);
    for(var i=0;i<values.length;i++){
    	if(i==values.length-1){
    		html+="<li title='"+values[i]+"' style='height:40px;line-height:40px;'>"+values[i]+"</li>";
    	}else{
    		html+="<li title='"+values[i]+"' style='height:40px;line-height:40px;border-bottom: 1px solid #ededed;'>"+values[i]+"</li>";
    	}
    }
    html+="<ul>";
	return html;
}

$.extend($.fn.datagrid.methods, {
	editCell: function(jq,param){
		return jq.each(function(){
			var opts = $(this).datagrid('options');
			var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
			for(var i=0; i<fields.length; i++){
				var col = $(this).datagrid('getColumnOption', fields[i]);
				col.editor1 = col.editor;
				if (fields[i] != param.field){
					col.editor = null;
				}
			}
			$(this).datagrid('beginEdit', param.index);
			for(var i=0; i<fields.length; i++){
				var col = $(this).datagrid('getColumnOption', fields[i]);
				col.editor = col.editor1;
			}
		});
	}
});

var editIndex = undefined;
function endEditing(){
	if (editIndex == undefined){return true}
	if ($('#queryTable').datagrid('validateRow', editIndex)){
		$('#queryTable').datagrid('endEdit', editIndex);
		var remark=$('#queryTable').datagrid('getRows')[editIndex]['remark'];
		if(remark==""){
			$('#queryTable').datagrid('getRows')[editIndex]['remark']=null;
		}
		editIndex = undefined;
		return true;
	} else {
		return false;
	}
}
function onClickCell(index, field){
	if (endEditing()){
		$('#queryTable').datagrid('selectRow', index)
				.datagrid('editCell', {index:index,field:field});
		editIndex = index;
	}
}

<%
/**********************************************************************
* 产品分类管理:编码信息维护页面
* 2016-05-26 李鹏 新建
**********************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/usims/include/includejq.jsp"%>
<title>编码信息维护</title>
</head>
<body>
<div class="easyui-tabs" id="tt" style="height:auto">
	<div title="产品分类">
		 <iframe scrolling="no" frameborder="0" height="800" width="100%" srcUrl="productTypeList.jsp"></iframe>  
	</div>
	<div title="业务类型" >
		<iframe scrolling="no" frameborder="0" height="800" width="100%" srcUrl="servTypesList.jsp"></iframe>
	</div>
	<div title="业务类型代码">
		<iframe scrolling="no" frameborder="0" height="800" width="100%" srcUrl="servTypeCodeList.jsp"></iframe>
	</div>
	<div title="系统编码">
		<iframe scrolling="no" frameborder="0" height="800" width="100%" srcUrl="systemCodeList.jsp"></iframe>
	</div>
</div>
<script type="text/javascript">
$('#tt').tabs({   
    onSelect: function(){  
    	var tab = $('#tt').tabs('getSelected');  
        //获取tab的iframe对象  
        var tbIframe = tab.find("iframe:first-child");
        tbIframe.attr("src",tbIframe.attr("srcUrl"));
    }  
});  
</script>
</body>
</html>


<%
/**********************************************************************
* 产品分类管理:产品分类列表页面
* 2016-04-26 李鹏 新建
**********************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>产品分类列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/usims/include/includejq.jsp"%>
<script type="text/javascript" src="../productmgt.js"></script>
</head>
<body>
<div class="manager_wp wrap">
	<div class="manager_right" >
	<nav class="detail_nav">
            <em>您的位置</em>
            <span>:</span>
            <em>产品分类管理</em>
            <span>></span>
            <em>产品分类</em>
        </nav></nav>
	<form id="queryForm" name="queryForm" action="">
	<div class="context_layout" >
		<div class="context" >
			<fieldset>
				<legend>查询</legend>
				<table width="100%" border="0" cellspacing="5">
					<tr>
						<td class="table_right">产品分类名称:</td>
						<td>
						<input type="text" name="bdcProductCatalog.productDesc" >
						</td>
						<td class="table_right">产品分类编码:</td>
						<td>
							<input type="text"  name="bdcProductCatalog.productId"/> 
						</td>
					</tr>
					<tr>
						<td align="right" colspan="4"><a class="btn_small" id="queryBtn">查询</a> <a
							class="btn_small" id="resetBtn">清除</a> 
						</td>
					</tr>
				</table>
			</fieldset>
		</div>
	</div>
	</form>
	<div class="shadow" >
		<div style="color:red;font-weight:bold;">注:双击列表中需要修改的字段,可修改数据;删除数据时需要慎重,请与相关人员确认后再删除相关信息!" </div>
		<table id="queryTable" class="easyui-datagrid" initRoot="data.list" style="height:auto"
			data-options="
				fitColumns:true,
		    	autoHeight:true,
		 		autoWidth:true,
		 		autoScroll:true,
				pagination:true,
				pageSize:10,
				singleSelect:false,
		        pageList:[10,50,100],
				toolbar: '#tb',
				url: window.ctxPaths+'/productmgt/productType!list.action',
				onDblClickCell: onClickCell
			">
		<thead>
			<tr>
				<th data-options="width:'10',field:'detail',checkbox:true"></th>
				<th data-options="width:200,field:'productDesc',align:'center',editor:{type:'text',options:{required:true,validType:'length[0,100]'}}">产品分类名称</th>
				<th data-options="width:'100',field:'productId',align:'center'">产品分类编码</th>
				<th data-options="field:'newApproveSwitch',width:150,align:'center',
						formatter:function(value,row){
							return convertValues('productmgt_newApproveSwitch',value);
						},
						editor:{
							type:'combobox',
							options:{
								valueField:'code',
								textField:'name',
								data:constantData.productmgt_newApproveSwitch,
								required:true
							}
						}">是否需要基地复核审批</th>
				<th data-options="width:300,field:'remark',align:'center',editor:{type:'validatebox',options:{validType:'length[0,512]'}}">备注</th>
				<th data-options="width:100,field:'opateDetail',align:'center',formatter:ProductMgt.logRender('30140102','productId')">维护信息</th>
			</tr>
		</thead>
		</table>
		<div id="tb" style="height:auto">
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="ProductMgt.add()">新增</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="ProductMgt.removeit()">删除</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="ProductMgt.save()">保存</a>
		</div>
		<div id="addWindow" class="easyui-window" title="新增产品分类" data-options="modal:true,closed:true" style="width:600px;height:300px;">
	        <form method="post" action="" id="addForm">
				  <div class="content">
				    <table width="100%" border="0">
				      <tr>
				        <td width="25%">
							<span class="redtext">*</span>产品分类编码:
						</td>
						<td>
							<input type="text" name="bdcProductCatalog.productId" nullmsg="产品分类编码不能为空,必须是4位的数字组成" class="textinput" minLength="4" maxLength="4" dataType="validateMaxLength n" />
							<div class="redtext">产品分类编码不能为空,必须是4位的数字组成</div>
						</td>
				      </tr>
				      <tr>
				        <td width="25%">
							<span class="redtext">*</span>产品分类名称:
							
						</td>
						<td>
							<input type="text" name="bdcProductCatalog.productDesc" nullmsg="产品分类名称不能为空,最多50个汉字" class="textinput"  maxLength="100" dataType="validateMaxLength" />
							<div class="redtext">最多50个汉字或100个字符</div>
						</td>
				      </tr>
				      <tr>
				        <td width="25%" >
							<span class="redtext">*</span>是否需要基地复核审批:
						</td>
						<td>
							<select name="bdcProductCatalog.newApproveSwitch" id="newApproveSwitch" datatype="*" nullmsg="请选择是否需要基地复核审批!">
								<option value="">请选择</option>
								<option value="0">不需要</option>
        						<option value="1">需要</option>
							</select>
						</td>
				      </tr>
				      <tr>
				        <td width="25%">备注:
						</td>
						<td>	
							<textarea name="bdcProductCatalog.remark" rows="5"  class="width300" maxlength="512" dataType="validateMaxLength" errormsg="最多256个汉字或512个字符"></textarea>
							<div class="redtext">(最多256个汉字或512个字符)</div>
						</td>
				      </tr>
				      <tr>
				        <td class="width200">
						</td>
						<td>
							<a class="btn_small" id="submitAdd" onclick="ProductMgt.doAddSubmit()">提交</a> 
							<a class="btn_small" id="rejectBtn" onclick="$('#addWindow').window('close');">关闭</a> 
						</td>
				      </tr>
				    </table>
				</div>
			</form>
	    </div>
	</div>
	</div>
</div>
<script type="text/javascript">
$.extend(ProductMgt,{
	addUrl:window.ctxPaths+'/productmgt/productType!insert.action',
	deleteUrl:window.ctxPaths+'/productmgt/productType!delete.action?bdcProductCatalog.productId=',
	updateUrl:window.ctxPaths+'/productmgt/productType!update.action',
	deleteTips:"删除产品分类后,系统中将无法查询到该产品分类相关的所有数据,请确定是否删除?",
	getDeleteParams:function(selected){
		var params="";
		for(var i=0;i<selected.length;i++){
			params+=selected[i].productId+",";
		}
		return params;
	}
});
$(function(){
	$('#resetBtn').bind('click',function() { $('#queryForm')[0].reset();});
	 //加载信息数据列表
    $('#queryBtn').bind('click',function() {
        //查询列表
        $("#queryTable").datagrid('load', $("#queryForm").serializeJson()); //加载数据列表
    });
})
</script>
</body>
</html>
jquery-webbas
	
/**
 * 根据cookie名字取cookie的值
 */
getCookie = function (name){
    /*var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    	return null;
    }
    if ( start == -1 )
        return null;

    var end = document.cookie.indexOf( ';', len );
    if ( end == -1 )
        end = document.cookie.length;

    return unescape( document.cookie.substring( len, end ));*/
	if(name== COOKIE_DOMAIN){
		return window.p_domain;
	}
	if(name== COOKIE_TICKET){
		return window.p_ticket;
	}
}


/**
 * 获取并设置当前页面的CONTEXT_PATH,SERVLET_PATH,SESSION_ID
 */
getContextPath=function(){
    //类似request.getContextPath(),从location.pathname中获取【假定有contextpath】
    var pn=location.pathname;
    var end=pn.indexOf("/",1);
    return pn.substring(0,end);
};
CONTEXT_PATH=getContextPath();
getServletPath=function(){
    var pn=location.pathname;
    var end=pn.indexOf('/',1);
    return pn.substring(end);
};
SERVLET_PATH=getServletPath();
getSessionId=function(){
    var ckName="jsessionid";
    var arr = document.cookie.match(new RegExp("(^| )"+ckName+"=([^;]*)(;|$)"));
    if(arr != null){
        return unescape(arr[2]);
    }else{
        arr=document.cookie.match(new RegExp("(^| )"+ckName.toUpperCase()+"=([^;]*)(;|$)"));
	    if(arr != null){
	        return unescape(arr[2]);
        }else{
            return null;
        }
    }
};
SESSION_ID=getSessionId();
CONTEXT_PATH = getContextPath();






/**
 * 设置所有发起Ajax请求都必须带上的参数
 * 注意:只有通过Jquery.ajax请求的才会有此参数【Ext.data.Store缺省采用Ext.Ajax.request】
 * 这里的domain没有开头的"/"字符
 * isAjax参数用于服务器端判断请求类型(isAjax=true为ajax请求,无此参数或此参数值为false为一般请求)
 * 
 * 使用其他途径发起的请求,如果需要,请自行添加参数
 * 
 * 使用PortalClient时因为前端有可能不在portal应用中,ticket跟domain保存在cookie中
 * 需要先查看cookie,若cookie中无保存则使用SESSION_ID和CONTEXT_PATH
 * 
 */
var COOKIE_DOMAIN = 'portal_domain';
var COOKIE_TICKET = 'ticket';

getDomain = function(){
	var vDomain = getCookie(COOKIE_DOMAIN);
	if(vDomain == null){
		vDomain = DOMAIN;
	}
	if(vDomain == null || vDomain == undefined){
		vDomain = CONTEXT_PATH.substring(1);
	}
	return vDomain;
};


$.appendExtraParams = function(url){
    var vTicket = getCookie(COOKIE_TICKET);
    var vDomain = getDomain();
    if(vTicket==null) {
        vTicket = SESSION_ID;
    }
    if(url.indexOf("?")==-1){
        return url+"?ticket="+vTicket+"&domain="+vDomain+ "&token=" + tokenQuene.pop();
    }else{
        return url+"&ticket="+vTicket+"&domain="+vDomain+ "&token=" + tokenQuene.pop();
    }
};

 
 

/**
 *  对Jquery.param 方法进行扩展,增加参数值前后空格去除功能
 * @param {Object} a
 * @param {Object} traditional
 * @memberOf {TypeName} 
 * @return {TypeName} 
 */
 
 jQuery.param = function( a, traditional ) {
	var r20 = /%20/g;
	var prefix,
		s = [],
		add = function( key, value ) {
			// If value is a function, invoke it and return its value
			value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
			s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( jQuery.trim(value) );
		};

	// Set traditional to true for jQuery <= 1.3.2 behavior.
	if ( traditional === undefined ) {
		traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
	}

	// If an array was passed in, assume that it is an array of form elements.
	if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
		// Serialize the form elements
		jQuery.each( a, function() {
			add( this.name, this.value );
		});

	} else {
		// If traditional, encode the "old" way (the way 1.3.2 or older
		// did it), otherwise encode params recursively.
		for ( prefix in a ) {
			buildParams( prefix, a[ prefix ], traditional, add );
		}
	}

	// Return the resulting serialization
	return s.join( "&" ).replace( r20, "+" );
};

function buildParams( prefix, obj, traditional, add ) {
	var name,
	rbracket = /\[\]$/;
	if ( jQuery.isArray( obj ) ) {
		// Serialize array item.
		jQuery.each( obj, function( i, v ) {
			if ( traditional || rbracket.test( prefix ) ) {
				// Treat each array item as a scalar.
				add( prefix, v );

			} else {
				// Item is non-scalar (array or object), encode its numeric index.
				buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
			}
		});

	} else if ( !traditional && jQuery.type( obj ) === "object" ) {
		// Serialize object item.
		for ( name in obj ) {
			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
		}

	} else {
		// Serialize scalar item.
		add( prefix, obj );
	}
}


//对ajax方法进行扩展,此函数不能重复执行
;(function($){  
    var ajax=$.ajax;
    //认证用额外参数
    var extraParams = {ticket:(getCookie(COOKIE_TICKET)!=null?getCookie(COOKIE_TICKET):SESSION_ID),domain:getDomain(),isAjax:true,ts:new Date().getTime()};
    $.ajax=function(s){
    	//添加额外参数
		var extraPramsArray = [];
    	for(var i in extraParams){
    		extraPramsArray.push(i + '=' + extraParams[i]);
    	}
		var extraPramsStr = extraPramsArray.join("&");
    	if(s.url.indexOf("?") == -1){
    		s.url = s.url + "?" + extraPramsStr;
    	}else{
    		s.url = s.url + "&" + extraPramsStr;
    	}
    	
    	//设置为不进行缓存
    	s.cache = false;
    	
    	//扩展success方法
        var oldSucess=s.success;
        s.success=function(data, textStatus, jqXHR){
            //加入扩展代码
        	if(data.success != true && data.success !='true'){
        		var realData = data.data;
    			if(realData && realData.sessionInvalid){
					var redirectUrl = CONTEXT_PATH + "/portal/login.jsp";
					if(realData.redirectUrl){
						if(realData.redirectUrl.indexOf("/")==0){
							redirectUrl =CONTEXT_PATH +  realData.redirectUrl;	
						}else{
							redirectUrl = 	realData.redirectUrl;		
						}
					}
					var tmpUrl = redirectUrl;
					var  isFormword  =  (tmpUrl.replace(/\?.*$/,"") != window.location.pathname);
					if(isFormword){
						alert(realData.msg);
						window.top.location.href = redirectUrl;
						return;
					}
			     }else if(realData&&realData.msg&&realData.msg=='无权访问'){
			    	$.prm_confirm("该次请求无权访问,是否回到登录页面?",undefined,function(r){
			 			if('yes' == r){
			 				window.top.location.href=window.top.location.href;
			 			}
			    	})
			    	 
			     }
        	}
        	if(oldSucess){
        		oldSucess(data,textStatus,jqXHR);	
        	}
        }
        var oldError = s.error;
        s.error = function (XMLHttpRequest, textStatus, errorThrown) {
        	$().prm_hide_loading();
        	if("timeout" == textStatus || "error" == textStatus){
        		//alert("系统服务器忙,请稍候再试!");
        	}
        }
        ajax(s);  
    }  
})(jQuery); 



var TokenQuene = function(tokens){
	if(tokens == '' || tokens == null){
		this.tokenArray = new Array();
	}else{
		this.tokenArray = tokens.split(",");
	}
}

TokenQuene.prototype={
	pop:function(){
		return this.tokenArray.pop();
	}
}
var tokenQuene = new TokenQuene(window.TOKENS);
jquery-common
/** 
 * @fileoverview  卓望数码 jQuery Common Library
 * @description:封装一些jQuery公共操作方法
 * @author oCEAn Zhuang ( QQ: 153414843)
 * @version 1.0
 * @date 2013-09-18
 */
/**
 * 将form属性转化为JSON对象,支持复选框和select多选
 * @param {Object} $
 * @memberOf {TypeName} 
 * @return {TypeName} 
 */
;
(function($){
	$.fn.serializeJson = function(){
	var serializeObj = {};
	var array = this.serializeArray();
	var str = this.serialize();
	$(array).each(function(){
		if(serializeObj[this.name]){
			if($.isArray(serializeObj[this.name])){
				serializeObj[this.name].push(this.value);
			}else{
				serializeObj[this.name]=[serializeObj[this.name],this.value];
			}
		}else{
			serializeObj[this.name]=this.value;
		}
	});
	return serializeObj;
};
})(jQuery);
/**
 * 对form进行jQuery扩展,可将json数据映射到对应的表单元素里,json中的属性名需跟form表单里的元素name一致。
 * @namespace jQuery扩展封装
 * @param {json} json格式数据
 * @return void
 */
;
(function() {
	jQuery.extend(jQuery.fn, {
		json2Form: function(json) {
			var _this = this;
			jQuery.each(jQuery(_this).serializeArray(),
				function(index) {
					var name = this['name'];
					for (var a in json) {
						var key = "";
						var val = "";
						if (name.indexOf('.') != -1) {
							key = name.split('.')[0];
							var getval = name.split('.')[1];
							val = json[a][getval];
						} else {
							key = name;
							val = json[a];
						}
						if (jQuery.trim(key) == jQuery.trim(a)) {
							var eve = jQuery(_this).find("[name='" + name + "']");
							if (jQuery(eve).length > 1) {
								for (var i = 0; i < jQuery(eve).length; i++) {
									//判断单选按钮  
									if (jQuery(jQuery(eve)[i]).attr("type") == 'radio') {
										if (jQuery(jQuery(eve)[i]).val() == val) {
											jQuery(jQuery(eve)[i]).attr("checked", true);
										}
									}
								}
							} else {
								jQuery(eve).val(val);
							}
						}
					}
				});
		}
	});
})(jQuery);

$.extend({
	str2Value: function(p,str) {
		var strs = str.split('.');
		var _tt = p;
		for (var i = 0;i < strs.length; i++){
				var tmp = strs[i];
				if (tmp.indexOf('[') != -1){
					var pre = tmp.substring(0,tmp.indexOf('[')),num = tmp.substring(tmp.indexOf('[') + 1,tmp.indexOf(']'));
					if (_tt[pre][num] && typeof (_tt[pre][num]) != 'undefined'){
						_tt = _tt[pre][num];
						continue;
					}else{
						return null;
					}
				}
				if ((_tt[strs[i]]==0||_tt[strs[i]])&& typeof (_tt[strs[i]]) != 'undefined'){
					_tt = _tt[strs[i]];
					continue;
				}else{
					return null;
				}
		}
		return  _tt;
	}
});

;
(function() {
	jQuery.extend(jQuery.fn, {
		json2Form2: function(json) {
			var _this = this,tmp = json,_form = $(this).attr('id');
			if (!_form){
				_form = (new Date()).getTime();//随机生成一个ID
				$(this).attr('id',_form);
			}
			jQuery("#" + _form + " :input" ).each(function(i){
				var _name = $(this).attr('name');
				if (_name){
					var vv = $.str2Value(tmp,_name);
					if (vv){
						var _type = $(this).attr("type");
						if (_type == 'text' || _type == 'hidden'){
							$(this).val(vv);
						} else if (_type == 'radio'){
							$("#" + _form +" :input[type=radio][name='" + _name + "'][value='" + vv + "']").attr("checked","checked"); 
						} else if (_type == 'checkbox'){
							var arr = vv.split(',');
							for (var i = 0; i < arr.length ;i++){
								$("#" + _form +" :input[type=checkbox][name='" + _name + "'][value='" + arr[i] + "']").attr("checked","checked");
							}
						} 
						
					}
				}
			});
			jQuery("#" + _form + " textarea" ).each(function(i){
				var _name = $(this).attr('name');
				if (_name){
					var v = 'tmp.' + _name;
					var vv = $.str2Value(tmp,_name);
					if (vv){
						$(this).val(vv);
					}
				}
			});
			jQuery("#" + _form + " select" ).each(function(i){
				var _name = $(this).attr('name');
				if (_name){
					var vv = $.str2Value(tmp,_name);
					if (vv){
						if ($(this).attr('multiple')){
							var _ss = vv.split(',');
							for (var n = 0; n < _ss.length; n++){
								$(this).children('option[value="'+_ss[n] + '"]').attr("selected","selected");
							}
						}else{
							//if($(this).get(0).length > 0){
								$(this).val(vv);
							//}else{
								$(this).attr('_defaultValue',vv);
							//}
						}
						$(this).trigger('change');//解决firefox下通过js改变值后不触发onchange事件,这里手动触发
					}
				}
			});
		}
	});
})(jQuery);

$.extend({
	dataInput: function(elems, datas, callback) {
		var _tmp = datas;
		elems.each(function(i){
			var _name = $(this).attr('name');
			if (_name){
				var vv = $.str2Value(_tmp,_name);
				if(vv==null||vv=="null"){
					vv="";
				}
				var formatter=$(this).attr('formatter');
				if(formatter&&formatter!='null'){
					var callFromatter=eval(formatter);
					vv=callFromatter(vv);
				}
				if (vv==0||vv){
					vv = '' + vv;
					if ($(this).is('div') || $(this).is('span') || $(this).is('label') ){
						$(this).html(vv);
					}else if ($(this).is('input')){
						var _type = $(this).attr("type");
						if (_type == 'text' || _type == 'hidden'){
							$(this).val(vv);
						} else if (_type == 'radio'){
							if ($(this).val() == vv){
								$(this).attr("checked","checked")
							} 
						} else if (_type == 'checkbox'){
							var arr = vv.split(',');
							for (var i = 0; i < arr.length ;i++){
								if ($(this).val() == arr[i]){
									$(this).attr("checked","checked")
								} 
							}
						} 
					}else if ($(this).is('select')){
						//if($(this).get(0).length > 0){
							$(this).val(vv);
						//}else{
							$(this).attr('_defaultValue',vv);
						//}
						$(this).trigger('change');//解决firefox下通过js改变值后不触发onchange事件,这里手动触发
						/**var _tt = vv.split(',');
						for (var n = 0; n < _tt.length; n++ ){
							if ($(this).val() == _tt[n]){
								$(this).attr("selected","selected");
							}
						}**/
					}else if ($(this).is('textarea')){
						$(this).val(vv);
					}
					
				}
			}
		});
		if (typeof callback != 'undefined') {
			callback(datas);
		}
	}
});
$.extend({
	dataInputHtml: function(elems, datas, callback) {
		var _tmp = datas;
		elems.each(function(i){
			var _name = $(this).attr('name');
			if (_name){
				var vv = $.str2Value(_tmp,_name);
				if (vv==0||vv){
					vv = '' + vv;
					if(vv!=null && vv!=""){
				    	vv = vv.replace(/\n/g,"</br>");
				    }
					if ($(this).is('div') || $(this).is('span') || $(this).is('label') ){
						$(this).html(vv);
					}else if ($(this).is('input')){
						var _type = $(this).attr("type");
						if (_type == 'text' || _type == 'hidden'){
							$(this).val(vv);
						} else if (_type == 'radio'){
							if ($(this).val() == vv){
								$(this).attr("checked","checked")
							} 
						} else if (_type == 'checkbox'){
							var arr = vv.split(',');
							for (var i = 0; i < arr.length ;i++){
								if ($(this).val() == arr[i]){
									$(this).attr("checked","checked")
								} 
							}
						} 
					}else if ($(this).is('select')){
						//if($(this).get(0).length > 0){
							$(this).val(vv);
						//}else{
							$(this).attr('_defaultValue',vv);
						//}
						$(this).trigger('change');//解决firefox下通过js改变值后不触发onchange事件,这里手动触发
						/**var _tt = vv.split(',');
						for (var n = 0; n < _tt.length; n++ ){
							if ($(this).val() == _tt[n]){
								$(this).attr("selected","selected");
							}
						}**/
					}else if ($(this).is('textarea')){
						$(this).val(vv);
					}
					
				}
			}
		});
		if (typeof callback != 'undefined') {
			callback(datas);
		}
	}
});
$.extend({
	dataSubString: function(elems,callback) {
		elems.each(function(i){
			var subStringLength = $(this).attr('subStringLength');
			if (subStringLength){
					if ( $(this).is('span')){
						var spanText = $(this).text();
						var spanTextLength = $(this).text().replace(/[^\x00-\xff]/g, ' ').length;
						if(spanTextLength && spanTextLength > subStringLength){
						    var subStringSpanText = spanText.substring(0,subStringLength)+"...";
							$(this).text(subStringSpanText);
							$(this).attr('title',spanText);
						}
					}else if ($(this).is('input')){
						var inputVal = $(this).val();
						var inputValLength = $(this).val().replace(/[^\x00-\xff]/g, ' ').length;
						if(inputValLength && inputValLength > subStringLength){
						    var subStringInputVal = inputVal.substring(0,subStringLength)+"...";
							$(this).val(subStringInputVal);
							$(this).attr('title',inputVal);
						}
					}
			}
		});
		if (typeof callback != 'undefined') {
			callback(datas);
		}
	}
});

/**
 * 对ajax请求做了封装,统一项目的ajax请求。
 * @namespace jQuery扩展封装
 * @param {url} 请求的url地址
 * @param {params} JSON格式的参数,如{name:'abc','age':10}
 * @param {callback} 调用成功后回调函数,可不传
 * @return json数据
 */
;
$.extend({
	ajaxSubmit: function(url, params, callback) {
		jQuery.ajax({
			url: url,
			type: 'POST',
			dataType: 'json',
			data: params,
			success: function(data) {
				if (typeof callback != 'undefined') {
					callback(data);
				}
			},
			error: function() {
				alert('发生系统错误');
			},
			beforeSend: function() {
				// Handle the beforeSend event
			},
			complete: function() {
				// Handle the complete event
			}
		});
	}
});
/**
*同步提交
*/
$.extend({
	ajaxAsyncSubmit: function(url, params, callback) {
		jQuery.ajax({
			url: url,
			type: 'POST',
			dataType: 'json',
			data: params,
			async:false,
			success: function(data) {
				if (typeof callback != 'undefined') {
					callback(data);
				}
			},
			error: function() {
				alert('发生系统错误');
			},
			beforeSend: function() {
				// Handle the beforeSend event
			},
			complete: function() {
				// Handle the complete event
			}
		});
	}
});


/**
 * 对select进行jQuery扩展,select动态数据获取封装。
 * @namespace jQuery扩展select封装
 * @param {json} json格式数据
 * @return void
 */
;
(function() {
	jQuery.extend(jQuery.fn, {
		ajaxRender: function(url, config, params) { //config:{firstOption:{text:'请选择分类',value:''},keyAlias:{text:'name',value:'value'}}
			var _this = this,
				c = config || {}, keyValue = {
					text: 'name',
					value: 'value'
				};
			if (c.keyValue) {
				keyValue = c.keyValue;
			}
			$(_this).empty();
			if (c.firstOption) {
				$(_this).append('<option value="' + c.firstOption.value + '">' + c.firstOption.text + '</option>');
			}
			//var data = [{'name':'选项1','value':'值1'},{'name':'选项2','value':'值2'}];
			jQuery.ajax({
				url: url,
				type: 'GET',
				dataType: 'json',
				async:false,
				data: params,
				success: function(data) {
				    var root = c.root;
				    if(root){
				    	var arr;
						if(root.indexOf(".") > 0){
							arr =root.split(".");
						}
						data = data[arr[0]][arr[1]];
				    }
					if (data) {
						$(_this).empty();
						if (c.firstOption) {
							$(_this).append('<option value="' + c.firstOption.value + '">' + c.firstOption.text + '</option>');
						}
						for (var i = 0; i < data.length; i++) {
							$(_this).append('<option value="' + data[i][keyValue.value] + '">' + data[i][keyValue.text] + '</option>');
						}
						//增加自定义值 add by xiaoliangqing 20150408
						if (c.endOption) {
							$(_this).append('<option value="' + c.endOption.value + '">' + c.endOption.text + '</option>');
						}
						if ($(_this).attr('_defaultValue')){
							$(_this).val($(_this).attr('_defaultValue'));
							$(_this).trigger('change');//解决firefox下通过js改变值后不触发onchange事件,这里手动触发
						}
					}
				},
				error: function() {
					alert('列表数据获取发生系统错误......');
				},
				beforeSend: function() {
					// Handle the beforeSend event
				},
				complete: function() {
					// Handle the complete event
					//select下拉框选中
					if(c.selectedValue){
								$(_this).val(c.selectedValue);
							}
				}
			});
		},
		localRender:function(data, config){ //config:{firstOption:{text:'请选择分类',value:''},keyAlias:{text:'name',value:'value'}}
			var _this = this,
				c = config || {}, keyValue = {
					text: 'name',
					value: 'value'
				};
			if (c.keyValue) {
				keyValue = c.keyValue;
			}
			$(_this).empty();
			if (c.firstOption) {
				$(_this).append('<option value="' + c.firstOption.value + '">' + c.firstOption.text + '</option>');
			}
			//var data = [{'name':'选项1','value':'值1'},{'name':'选项2','value':'值2'}];
			if (data) {
				for (var i = 0; i < data.length; i++) {
					$(_this).append('<option value="' + data[i][keyValue.value] + '">' + data[i][keyValue.text] + '</option>');
				}
				if ($(_this).attr('_defaultValue')){
					$(_this).val($(_this).attr('_defaultValue'));
				}
			}
		}
	});
})(jQuery);


/**
 * 对移除和清空加了动态效果。
 * @namespace jQuery扩展移除和清空加了动态效果
 * @param {json} 
 * @return void
 */
;
(function() {
	jQuery.extend(jQuery.fn, {
		options : {
			speed : 500
		},
		fadeRemove: function(config) { 
			var _this = this;
			$.extend(_this.options, config);
			_this.fadeOut(_this.options.speed,function(){_this.remove();});
		},
		fadeEmpty: function(config) { 
			var _this = this;
			$.extend(_this.options, config);
			_this.fadeOut(_this.options.speed,function(){
				_this.empty();
				if (typeof _this.options.callback == 'function'){
					_this.options.callback();
				}
			});
		}

	});
})(jQuery);

/**
 * 浮层。
 * @namespace jQuery扩展浮层封装
 * @return void
 */
;
(function() {
	jQuery.extend(jQuery.fn, {
		_getViewPort: function(obj) {
			var viewportwidth = 0,
				viewportheight = 0;
			if (typeof window.innerWidth != 'undefined') {
				var obj = obj || window;
				viewportwidth = obj.innerWidth;
				viewportheight = obj.innerHeight;
			} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
				var obj = obj || document.documentElement;
				viewportwidth = obj.clientWidth;
				viewportheight = obj.clientHeight;
			}
			return {
				width: viewportwidth,
				height: viewportheight
			};
		},
		_calPosition: function(w, h) {
			l = (Math.max($(document).width(), $(window).width()) - w) / 2;
			t = $(window).scrollTop() + $(window).height() / 9;

			//w = this.width(),
			//h = this.height(),
			//st = document.documentElement.scrollTop,
			//sl = document.documentElement.scrollLeft,
			//vW = this._getViewPort().width,
			//vH = this._getViewPort().height,
			//l = vW / 2 - w / 2 + sl,
			//t = vH / 2 -  h / 2 + st - 240;
			/**var t = (($(window).height() / 2) - (h / 2)) -75;
			var l = (($(window).width() / 2) - (w / 2));
			if( t < 0 ) t = 0;
			if( l < 0 ) l = 0;
			
			// IE6 fix
			if( $.browser.msie && parseInt($.browser.version) <= 6 ) t = t + $(window).scrollTop();**/
			return [l, t];
		},
		_setPosition: function(C, B) {
			if (!C) {
				return false;
			}
			var lt = this._calPosition(C.width(), C.height());
			C.css({
				left: lt[0],
				top: lt[1],
				position: 'absolute',
				'z-index': 9991
			});
			var $h = Math.max($(document).height(), $(window).height()),
				$hh = $("html").height();
			//$h = Math.max($h,$hh);
			B.height($h).width('100%');
		},

		_createMask: function() {
			var divMaskId = "_maskDivId";
			if (!document.getElementById(divMaskId)) {
				$('<div id="' + divMaskId + '" style="display:none;"></div>').appendTo('body');
			}
			this._mask = $('#' + divMaskId);
			this._mask.css({
				background: '#666666',
				filter: 'alpha(opacity=60)',
				'-moz-opacity': 0.6,
				opacity: 0.6,
				position: 'absolute',
				left: 0,
				top: 0,
				'z-index': 999
			});
			$('#' + divMaskId).bgiframe();
			this._mask.show();
			return this._mask;
		},
		floatDiv: function(options) {
			var defaults = {};
			this._YQ = $.extend(defaults, options);
			var show = this._YQ.show;
			var _this = this;
			if (this._YQ && !show) {
				$(_this).slideUp(200);
				var divMaskId = "_maskDivId";
				if (document.getElementById(divMaskId)) {
					$('#' + divMaskId).hide();
				}
				return;
			}
			var mask = this._createMask();
			$(this).slideDown(200);
			this._setPosition($(this), mask);
			if (this._YQ && this._YQ.clsBtn) {
				this._YQ.clsBtn.click(function() {
					$(_this).slideUp(200);
					mask.hide();
				});
			}
		}
	});
})(jQuery);
/**
 * 对checkbox全选做简单封装。
 * @namespace jQuery扩展函数
 * @param {chkAllId} checkbox全选Id,{chkName} 被选checkbox name,
 * @return void
 */
;
$.extend({
	checkbox_chkAll: function(chkAllId, chkName,callback) {
		var checkBoxes = $("input[name=" + chkName + "]");
		$('#' + chkAllId).click(function() {
			var isCheck = $(this).attr('checked') || false;
			$.each(checkBoxes, function() {
				$(this).attr('checked', isCheck);
			});
			if (callback) callback($('#' + chkAllId),checkBoxes);
		});
		
	}
});


/**
 * 统一弹出框
 * @param {Object} $
 */
(function($) {
	$.alerts = {
		verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true, // re-centers the dialog on window resize
		overlayOpacity: .01, // transparency level of overlay
		overlayColor: '#666666', // base color of overlay
		draggable: false, // make the dialogs draggable (requires UI Draggables plugin)
		okButton: ' 确认 ', // text for the OK button
		cancelButton: ' 取消 ', // text for the Cancel button
		dialogClass: null, // if specified, this class will be applied to all dialogs

		// Public methods

		alert: function(message, title, callback) {
			if (title == null) title = 'Alert';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if (callback) callback(result);
			});
		},

		confirm: function(message, title, callback) {
			if (title == null) title = 'Confirm';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if (callback) callback(result);
			});
		},

		prompt: function(message, value, title, callback) {
			if (title == null) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if (callback) callback(result);
			});
		},

		// Private methods

		_show: function(title, msg, value, type, callback) {

			$.alerts._hide();
			$.alerts._overlay('show');

			$("BODY").append(
				'<div class="popwindow" id="popup_container">' + '<div class="popwintop">' + '<div class="poptitle" id="popup_title">我是标题</div>' + '<div class="popwinright">' + '<div class="closefenge"></div>' + '<div class="daibanright" id="popwindowclose"></div>' + '</div></div>' + '<div  class="popwinframe" id="popup_message">' + '</div></div>');

			if ($.alerts.dialogClass) $("#popup_container").addClass($.alerts.dialogClass);

			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6) ? 'absolute' : 'fixed';

			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				padding: 0,
				margin: 0
			});

			$("#popup_title").text(title);
			//$("#popup_content").addClass(type);
			//$("#popup_message").text(msg);
			//$("#popup_message").html($("#popup_message").text().replace(/\n/g, '<br />'));

			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth()
			});

			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			$("#popwindowclose").click(function() {
				$.alerts._hide();
				if (callback) {
					callback();
				};
			});
			$('#popup_message').empty();
			switch (type) {
				case 'alert':
					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr><td class="pop_center">' + msg + '</td></tr></table>').appendTo('#popup_message');
					/**$("#popup_ok").focus().keypress(function(e) {
						if (e.keyCode == 13 || e.keyCode == 27) $("#popup_ok").trigger('click');
					});**/
					break;
				case 'confirm':
					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr class="rizhiline"><td class="pop_center">' + msg + '</td></tr><tr><td style="padding-top:10px;"><p align="center"><input type="button" id="popup_ok" value="确认" class="bluebtn1" />    <input type="button" id="popup_cancel" value="取消" class="bluebtn1" /></p></td></tr></table>').appendTo('#popup_message');
					$("#popup_ok").click(function() {
						$.alerts._hide();
						if (callback) callback(true);
					});
					$("#popup_cancel").click(function() {
						$.alerts._hide();
						if (callback) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress(function(e) {
						if (e.keyCode == 13) $("#popup_ok").trigger('click');
						if (e.keyCode == 27) $("#popup_cancel").trigger('click');
					});
					break;
				case 'prompt':

					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr><td class="pop_center1"><p><img src="' + (value == 1 ? 'images/pop_right.png' : 'images/pop_wrong.png') + '" width="70" height="70" border="0"/></p><p style="line-height:50px">' + msg + '</p></td></tr></table>').appendTo('#popup_message');
					/**$("#popup_ok").click(function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if (callback) callback(val);
					});
					$("#popup_cancel").click(function() {
						$.alerts._hide();
						if (callback) callback(null);
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(e) {
						if (e.keyCode == 13) $("#popup_ok").trigger('click');
						if (e.keyCode == 27) $("#popup_cancel").trigger('click');
					});
					if (value) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();**/
					break;
			}
			$("#popup_container").fadeIn(200);

		},

		_hide: function() {
			$("#popup_container").remove();
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},

		_overlay: function(status) {
			switch (status) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						background: '#666666',
						filter: 'alpha(opacity=60)',
						'-moz-opacity': 0.6,
						opacity: 0.6,
						position: 'absolute',
						left: 0,
						top: 0,
						width: '100%',
						height: $(document).height(),
						'z-index': 1001
					});
					break;
				case 'hide':
					$("#popup_overlay").remove();
					$("#popup_container").fadeOut(200);
					break;
			}
		},

		_reposition: function() {
			//var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			//var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			var left = (Math.max($(document).width(), $(window).width()) - $("#popup_container").outerWidth()) / 2;
			var top = $(window).scrollTop() + $(window).height() / 9;
			if (top < 0) top = 0;
			if (left < 0) left = 0;

			// IE6 fix
			if ($.browser.msie && parseInt($.browser.version) <= 6) top = top + $(window).scrollTop();

			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px',
				position: 'absolute'
			});
			$("#popup_overlay").height($(document).height());
		},

		_maintainPosition: function(status) {
			if ($.alerts.repositionOnResize) {
				switch (status) {
					case true:
						$(window).bind('resize', function() {
							$.alerts._reposition();
						});
						break;
					case false:
						$(window).unbind('resize');
						break;
				}
			}
		}

	}
	// 快捷方式
	Q_Alert = function(message, callback) {

		$.alerts.alert(message, "提示", callback);
	}
	Q_Confirm = function(message, callback) {
		$.alerts.confirm(message, "提示", callback);
	}
	Q_Prompt = function(message, value, callback) {
		$.alerts.prompt(message, value, "提示", callback);
	}
	Q_Prompt_SUCC = function(message, callback) {
		$.alerts.prompt(message, 1, "提示", callback);
	}
	Q_Prompt_FAIL = function(message, callback) {
		$.alerts.prompt(message, 0, "提示", callback);
	}
})(jQuery);

//Tabs
//参数:按钮(JQ对象)[,对应的层(JQ对象),当前按钮class]
Tabs = function($bts,$divs,cls){
	this.bts = $bts;
	this.divs = $divs || $('<div />');
	this.cls = cls || 'up';
}
Tabs.prototype = {
	init: function(eventType,stopDefault){
		eventType = eventType || 'click';
		stopDefault = stopDefault || false;
		var _this = this;
		
		this.bts.bind(eventType,function(){
			var index = _this.bts.index(this);
			_this.bts.removeClass(_this.cls);
			$(this).addClass(_this.cls);
			_this.show(index, this);
			//return false;
		});
		this.bts.click(function(){
			return stopDefault;
		});
	},
	show: function(index, bt){
		this.divs.hide().eq(index).show();
		this.done(index, bt);
	},
	done: function(index, bt){
		
	}
}
/**
 * 获取url参数值。
 * @param n 为参数名
 **/
var getP = function(n) {
	var hrefstr, pos, parastr, para, tempstr;
	hrefstr = window.location.href;
	pos = hrefstr.indexOf("?");
	parastr = hrefstr.substring(pos + 1);
	para = parastr.split("&");
	tempstr = "";
	for (i = 0; i < para.length; i++) {
		tempstr = para[i];
		pos = tempstr.indexOf("=");
		if (tempstr.substring(0, pos).toLowerCase() == n.toLowerCase()) {
			return tempstr.substring(pos + 1);
		}
	}
	return '';
}

var isEndTimeGtStartTime = function(startTime,endTime){  
    var start=new Date(startTime.replace("-", "/").replace("-", "/"));  
    var end=new Date(endTime.replace("-", "/").replace("-", "/"));  
    if(end<start){  
        return false;  
    }  
    return true;  
}  


/**
 * ----------------------------------
 * prm 封装的一些公共组件和工具类
 * ----------------------------------
 */
//命名空间定义
Aspire = {
	prm:{
		SSL_SECURE_URL: ctxPaths + '/jquery/plugin/custom/css/image/s.gif'
	}
};
(function($){
	/**
	 * 为form表单添加导出功能
	 * @memberOf {TypeName} 
	 */
	$.fn.extend({
		exportData:function(setting){
			var id = new Date();
			frame = (
				jQuery("<iframe frameborder='0' width='0' height='0'/>")
				.attr({'id':id,'name':id,src:Aspire.prm.SSL_SECURE_URL}).addClass('export-hidden')
			).appendTo( document.documentElement );
			
	        //frame加载后的回调喊出
	        function cb(){
	            var response = ''
	
	           // r.argument = setting ? setting.argument : null;
	
	            try { //
	                var doc = frame.contents();
	                
	                if(doc && doc[0].body){//处理html数据
	                    response =eval('(' + doc.find('body').html() + ')'); 
	                }
	                if(doc && doc[0].XMLDocument){//处理xml数据
	                    response = doc[0].XMLDocument;
	                }else {//其他数据 当作文本来处理
	                    response = eval('(' + doc + ')');
	                }
		            }
	            catch(e) {
	                // ignore
	            }
				frame.unbind('load',cb);
				
				if(setting.callback && typeof setting.callback == "function"){
					setting.callback.call(frame,response,setting);
				}
	            //this.fireEvent("requestcomplete", this, r, o);
	
	            setTimeout(function(){frame.remove();}, 100);
	        }
	
	        frame.bind('load',cb);
	        //form.submit();
	        //拼参数
	        var p = setting.data;
            if(typeof p == "object"){
                p = $.param(p);
            }
	        //如果用自己定义的参数就不用从表单中取    
	        if(setting.data==null){
	                setting.url = setting.url || $(this).attr('action');
	                var f = $(this).serialize();
	                p = p ? (p + '&' + f) : f;
	         }	        
			//最终的url
	         setting.url += (setting.url.indexOf('?') != -1 ? '&' : '?') + '_dc=' + (new Date().getTime());
	         setting.url += (setting.url.indexOf('?') != -1 ? '&' : '?') + p;
	         setting.url += (setting.url.indexOf('?') != -1 ? '&' : '?') + "acceptContentType=html";
	         setting.url = $.appendExtraParams(setting.url);
	        frame.attr('src',setting.url);
		}
		
	})
})(jQuery);

(function() {
	jQuery.extend(jQuery.fn, {
		changePlus: function(callback) {
			if(window.navigator.userAgent.indexOf("MSIE")>=1){
				$(this).get(0).onpropertychange = callback;
			}else{
				$(this).bind('change',callback);
			}
		}
	});
})(jQuery);

//form表单ajax提交
//请求示例
/*
function test(){ 
	$('#form').importData({
		type: 'post',
		url: 'http://127.0.0.1:18080/admin/test/test.txt',
		dataType: 'json',
		success: function(data){  
			alert(data.data.list[0].baseId); 
		},  
		error: function(XmlHttpRequest, textStatus, errorThrown){  
			alert( "error");  
		}
	});
}
*/
(function() {
$.extend($.fn, {
	importData:function(config) {
		//表单
		//var $form = $('#'+config.id);
		var $form = $('#'+$(this).attr('id'));
		var form = $form[0];
		//alert(111);
		/*参数
		var opts = $.extend({}, $.ajaxSettings, {
			type: 'post',  
			url: "http://127.0.0.1:8080/test/test.txt" ,  
			dataType: 'json',
			success: function(data){  
				alert("success");  
				alert(data.data.list[0].baseId); 
			},  
			error: function(XmlHttpRequest, textStatus, errorThrown){  
				alert( "error");  
			}

		});*/
		var opts = $.extend({}, $.ajaxSettings, config);
		
		opts.url = $.appendExtraParams(opts.url);
		
		//alert(222);
		//var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++;
		var id = new Date();
		var $io = $('<iframe id="' + id + '" name="' + id + '" />');
		var io = $io[0];
		
		//目前jquery新版本已经不支持$.browser方法了
		//var op8 = $.browser.opera && window.opera.version() < 9;
		//if ($.browser.msie || op8) io.src = 'javascript:false;document.write("");';
		
		//隐藏iframe
		$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
		
		//alert(333);
		var xhr = { // mock object
			responseText: null,
			responseXML: null,
			status: 0,
			statusText: 'n/a',
			getAllResponseHeaders: function() {},
			getResponseHeader: function() {},
			setRequestHeader: function() {}
		};
		
		var g = opts.global;
		// trigger ajax global events so that activity/block indicators work like normal
		if (g && ! $.active++) $.event.trigger("ajaxStart");
		if (g) $.event.trigger("ajaxSend", [xhr, opts]);
		//alert(444);
		
		
		var cbInvoked = 0;
		var timedOut = 0;
		
		// take a breath so that pending repaints get some cpu time before the upload starts
		setTimeout(function() {
			$io.appendTo('body');
			// jQuery's event binding doesn't work for iframe events in IE
			//io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
			//alert(555);
			// make sure form attrs are set
			var encAttr = form.encoding ? 'encoding' : 'enctype';
			var t = $form.attr('target');
			$form.attr({
				target:   id,
				method:  'POST',
				encAttr: 'multipart/form-data',
				action:   opts.url
			});

			// support timout
			if (opts.timeout)
				setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
			//添加ifram加载事件
			io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
			form.submit();
			//alert(666);
			$form.attr('target', t); // reset target
		}, 10);
		
		function cb() {
			if (cbInvoked++) return;
			
			io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

			var ok = true;
			try {
				if (timedOut) throw 'timeout';
				// extract the server response from the iframe
				var data, doc;
				//alert(777);
				doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
				xhr.responseText = doc.body ? doc.body.innerHTML : null;
				xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;

				if (opts.dataType == 'json' || opts.dataType == 'script') {
					var ta = doc.getElementsByTagName('textarea')[0];
					data = ta ? ta.value : xhr.responseText;
					if (opts.dataType == 'json')
						
						//data = jQuery.parseJSON(jQuery(data).text());//可以去除<pre>标签
						data = jQuery.parseJSON(data);
						//eval("data = " + data);
						
					else
						$.globalEval(data);
				}
				else if (opts.dataType == 'xml') {
					data = xhr.responseXML;
					if (!data && xhr.responseText != null)
						data = toXml(xhr.responseText);
				}
				else {
					data = xhr.responseText;
				}
				//alert('999'+data);
			}
			catch(e){
				//alert(e.message);
				ok = false;
				//$.handleError(opts, xhr, 'error', e);
				opts.error(e);
			}

			// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
			if (ok) {
				opts.success(data, xhr.responseText, 'success');
				if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
			}
			if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
			if (g && ! --$.active) $.event.trigger("ajaxStop");
			if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');

			// clean up
			setTimeout(function() { 
				$io.remove(); 
				xhr.responseXML = null;
			}, 100);
		};
	}
	
})
})(jQuery);

jQuery.fn.limit=function(){
    //这里的div去掉的话,就可以运用li和其他元素上了,否则就只能div使用。
    this.each(function(){
		var objString = jQuery.trim($(this).text());
		var objLength = jQuery.trim($(this).text()).length;
		var num = $(this).attr("limit");
		if(num&&objLength > num){
			//这里可以设置鼠标移动上去后显示标题全文的title属性,可去掉。
			$(this).attr("title",objString);
			objString = $(this).text(objString.substring(0,num) + "...");
		}
		//如果存在该插件则初始化,反之则不初始化
		if($(this).poshytip){
			$(this).poshytip();
		}
	})
}

var ExtUtil={
	getPortal:function(){
	    if(top===self){//topest window
	        if(window.portal){
	            return portal;
	        }
	    }else{
	        var p=parent;
	        while(p){
	            if(p.portal || p.top==p.self){
	                break;
	            }else{
	                p=p.parent;
	            }
	        }
	        if(p.portal){
	            return p.portal;
	        }
	    }
	},sendUrl:function(url){
		var portal = this.getPortal();
		if(portal && portal.contMgr && url){
			if(url.indexOf('?') > 0){
				url+= "&isOldSystem=true";	
			}else{
				url+= "?systemPlaceholder=1&isOldSystem=true";	
			}
			portal.contMgr.switchContent(url,true);
		}
	},setTitle:function(title){
		var portal = this.getPortal();
		if(!portal){
			return;
		}
		portal.contMgr.getActiveTab().setTitle(title);
	},closeTab:function(){
		var portal = this.getPortal();
		if(portal && portal.contMgr){
			portal.contMgr.closeActiveTab();
		}
	}
};


/**
*同步提交
*/
$.extend({
	ajaxAsyncSubmit: function(url, params, callback) {
		jQuery.ajax({
			url: url,
			type: 'POST',
			dataType: 'json',
			data: params,
			async:false,
			success: function(data) {
				if (typeof callback != 'undefined') {
					callback(data);
				}
			},
			error: function() {
				alert('发生系统错误');
			},
			beforeSend: function() {

			},
			complete: function() {
				// Handle the complete event
			}
		});
	}
});

$.extend({
	
	addData:function(dataList,tBodyTabel){	
		var incrementHtml = ''; 
		var len = dataList.length;
		for(var i=0;i<len;i++){
			if(i==0 || i%3 ==0){
				incrementHtml +='<tr>';
			}
			incrementHtml += '<td>'+dataList[i].bizName+'</td>';
			incrementHtml += '<td>'+dataList[i].number+'</td>';
			if((i+1)==len){
				if(i%3==0){
					incrementHtml += '<td>  </td><td>  </td><td>  </td><td>  </td>';
				}
				if(i%3==1){
					
					incrementHtml += '<td>  </td><td>  </td>';
				}
			}
		    if((i+1)==len || (i+1)% 3 ==0){
		    	incrementHtml +='</tr>';
		    }

		}
		$(tBodyTabel).append(incrementHtml);	
	}
});

$.extend({
	
	addDataByYear:function(dataList,tBodyTabel){	
		var tableHeadHtml = ''; 
		var addTrHtml = '';
		var modTrHtml = '';
		var delTrHtml = '';
		var sumTrHtml = '';
		tableHeadHtml += '<tr><td width="10%" class="first">业务分类</td>';
		addTrHtml += '<tr><td>新增</td>';
		modTrHtml += '<tr><td>变更</td>';
		delTrHtml += '<tr><td>删除</td>';
		sumTrHtml += '<tr><td>合计</td>';
				var collTypes = dataList.collType.split(",");
				var addNums = dataList.addNum.split(",");
				var modNums = dataList.modNum.split(",");
				var delNums = dataList.delNum.split(",");
				//var sumNums = otherIncrementlist[i].sumNum.split(",");
				for(var j=0;j<collTypes.length;j++){
					
			    	tableHeadHtml += '<td width="9%" class="first">'+collTypes[j]+'</td>';
			    	addTrHtml +='<td>'+addNums[j]+'</td>';
			    	modTrHtml +='<td>'+modNums[j]+'</td>';
			    	delTrHtml +='<td>'+delNums[j]+'</td>';
			    	sumTrHtml +='<td>'+(parseInt(addNums[j])+parseInt(modNums[j])+parseInt(delNums[j]))+'</td>';
				}
				tableHeadHtml += '</tr>';
				addTrHtml += '</tr>';
				modTrHtml += '</tr>';
				delTrHtml += '</tr>';
				sumTrHtml += '</tr>';
			$(tBodyTabel).append(tableHeadHtml + addTrHtml + modTrHtml + delTrHtml + sumTrHtml);
	}
});

$.extend({
	
	addGprsData:function(dataList,tBodyTabel){	
		var tableHeadHtml = ''; 
		var addTrHtml = '';
		var modTrHtml = '';
		var delTrHtml = '';
		var sumTrHtml = '';
		tableHeadHtml += '<tr>';
		tableHeadHtml += '<td width="22%" class="first">业务分类</td>';
		addTrHtml += '<tr><td>新增</td>';
		modTrHtml += '<tr><td>变更</td>';
		delTrHtml += '<tr><td>删除</td>';
		sumTrHtml += '<tr><td>合计</td>';
			for(var i=0;i<dataList.length;i++){
				tableHeadHtml += '<td width="39%" class="first"><span class="charttitle">'+dataList[i].bizName+'</span></td>';
				addTrHtml +='<td>'+dataList[i].addNum+'</td>';
				modTrHtml +='<td>'+dataList[i].modNum+'</td>';
				delTrHtml +='<td>'+dataList[i].delNum+'</td>';
				var sumNum = parseInt(dataList[i].addNum)+parseInt(dataList[i].modNum)+parseInt(dataList[i].delNum);
				sumTrHtml +='<td>'+sumNum+'</td>';
				if(dataList[i].bizType=='GPRSINFO'){
					$("#gprsNumberId").html(sumNum);
				}
				if(dataList[i].bizType=='NFPAYGPRS'){
					$("#dxtfNumberId").html(sumNum);
				}
			}
			tableHeadHtml += '</tr>';
			addTrHtml += '</tr>';
			modTrHtml += '</tr>';
			delTrHtml += '</tr>';
			sumTrHtml += '</tr>';
			$(tBodyTabel).append(tableHeadHtml + addTrHtml + modTrHtml + delTrHtml + sumTrHtml);
	}
});

$.extend({
	
	addOtherData:function(dataList,tBodyTabel){	
		
			for(var i=0;i<dataList.length;i++){
				if(dataList[i].bizType=='WLANFEE'){
					$("#wlanNum").html(dataList[i].number);
				}
				if(dataList[i].bizType=='TCPARTNER'){
					$("#tcpartnerNum").html(dataList[i].number);
				}
				if(dataList[i].bizType=='TCMARKETING'){
					$("#tcmarketingNum").html(dataList[i].number);
				}
			}
	}
});

jquery-biz
/** 
 * @fileoverview  卓望数码 jQuery Common Library
 * @description:封装一些系统公用模块numbers
 * @author oCEAn Zhuang ( QQ: 153414843)
 * @version 1.0
 * @date 2013-10-30
 */

/**
 * 统一弹出框
 * @param {Object} $
 */
(function($) {
	$.alerts = {
		verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true, // re-centers the dialog on window resize
		overlayOpacity: .01, // transparency level of overlay
		overlayColor: '#666666', // base color of overlay
		draggable: false, // make the dialogs draggable (requires UI Draggables plugin)
		okButton: ' 确认 ', // text for the OK button
		cancelButton: ' 取消 ', // text for the Cancel button
		dialogClass: null, // if specified, this class will be applied to all dialogs

		// Public methods

		alert: function(message, title, callback) {
			if (title == null) title = 'Alert';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if (callback) callback(result);
			});
		},

		confirm: function(message, title, callback) {
			if (title == null) title = 'Confirm';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if (callback) callback(result);
			});
		},

		prompt: function(message, value, title, callback) {
			if (title == null) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if (callback) callback(result);
			});
		},

		// Private methods

		_show: function(title, msg, value, type, callback) {

			$.alerts._hide();
			$.alerts._overlay('show');

			$("BODY").append(
				'<div class="popwindow" id="popup_container">' + '<div class="popwintop">' + '<div class="poptitle" id="popup_title">我是标题</div>' + '<div class="popwinright">' + '<div class="closefenge"></div>' + '<div class="daibanright" id="popwindowclose"></div>' + '</div></div>' + '<div  class="popwinframe" id="popup_message">' + '</div></div>');

			if ($.alerts.dialogClass) $("#popup_container").addClass($.alerts.dialogClass);

			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6) ? 'absolute' : 'fixed';

			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				padding: 0,
				margin: 0
			});

			$("#popup_title").text(title);
			//$("#popup_content").addClass(type);
			//$("#popup_message").text(msg);
			//$("#popup_message").html($("#popup_message").text().replace(/\n/g, '<br />'));

			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth()
			});

			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			$("#popwindowclose").click(function() {
				$.alerts._hide();
				if (callback) {
					callback();
				};
			});
			$('#popup_message').empty();
			switch (type) {
				case 'alert':
					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr><td class="pop_center">' + msg + '</td></tr></table>').appendTo('#popup_message');
					/**$("#popup_ok").focus().keypress(function(e) {
						if (e.keyCode == 13 || e.keyCode == 27) $("#popup_ok").trigger('click');
					});**/
					break;
				case 'confirm':
					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr class="rizhiline"><td class="pop_center">' + msg + '</td></tr><tr><td style="padding-top:10px;"><p align="center"><input type="button" id="popup_ok" value="确认" class="bluebtn1" />    <input type="button" id="popup_cancel" value="取消" class="bluebtn1" /></p></td></tr></table>').appendTo('#popup_message');
					$("#popup_ok").click(function() {
						$.alerts._hide();
						if (callback) callback(true);
					});
					$("#popup_cancel").click(function() {
						$.alerts._hide();
						if (callback) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress(function(e) {
						if (e.keyCode == 13) $("#popup_ok").trigger('click');
						if (e.keyCode == 27) $("#popup_cancel").trigger('click');
					});
					break;
				case 'prompt':

					$('<table width="90%" border="0" cellpadding="0" cellspacing="0" class="pop_insert_table"><tr><td class="pop_center1"><p><img src="' + (value == 1 ? 'images/pop_right.png' : 'images/pop_wrong.png') + '" width="70" height="70" border="0"/></p><p style="line-height:50px">' + msg + '</p></td></tr></table>').appendTo('#popup_message');
					/**$("#popup_ok").click(function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if (callback) callback(val);
					});
					$("#popup_cancel").click(function() {
						$.alerts._hide();
						if (callback) callback(null);
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(e) {
						if (e.keyCode == 13) $("#popup_ok").trigger('click');
						if (e.keyCode == 27) $("#popup_cancel").trigger('click');
					});
					if (value) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();**/
					break;
			}
			$("#popup_container").fadeIn(200);

		},

		_hide: function() {
			$("#popup_container").remove();
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},

		_overlay: function(status) {
			switch (status) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						background: '#666666',
						filter: 'alpha(opacity=60)',
						'-moz-opacity': 0.6,
						opacity: 0.6,
						position: 'absolute',
						left: 0,
						top: 0,
						width: '100%',
						height: $(document).height(),
						'z-index': 1001
					});
					break;
				case 'hide':
					$("#popup_overlay").remove();
					$("#popup_container").fadeOut(200);
					break;
			}
		},

		_reposition: function() {
			//var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			//var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			var left = (Math.max($(document).width(), $(window).width()) - $("#popup_container").outerWidth()) / 2;
			var top = $(window).scrollTop() + $(window).height() / 9;
			if (top < 0) top = 0;
			if (left < 0) left = 0;

			// IE6 fix
			if ($.browser.msie && parseInt($.browser.version) <= 6) top = top + $(window).scrollTop();

			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px',
				position: 'absolute'
			});
			$("#popup_overlay").height($(document).height());
		},

		_maintainPosition: function(status) {
			if ($.alerts.repositionOnResize) {
				switch (status) {
					case true:
						$(window).bind('resize', function() {
							$.alerts._reposition();
						});
						break;
					case false:
						$(window).unbind('resize');
						break;
				}
			}
		}

	}
	// 快捷方式
	Q_Alert = function(message, callback) {

		$.alerts.alert(message, "提示", callback);
	}
	Q_Confirm = function(message, callback) {
		$.alerts.confirm(message, "提示", callback);
	}
	Q_Prompt = function(message, value, callback) {
		$.alerts.prompt(message, value, "提示", callback);
	}
	Q_Prompt_SUCC = function(message, callback) {
		$.alerts.prompt(message, 1, "提示", callback);
	}
	Q_Prompt_FAIL = function(message, callback) {
		$.alerts.prompt(message, 0, "提示", callback);
	}
})(jQuery);

/**
 * 所有附件上传文本框绑定change事件,当选择文件后失去焦点后会重新校验
 * add by lipeng
 */
$().ready(function() {
	$("input[type=file]").each(function(){
		$(this).live('change',function(){
			$(this).blur();
		});
	});
});

/**
 * 初始化列表,选项为最近10年。
 *
 **/
var initYearSelect = function(id) {
	var s = document.getElementById(id),
		size = 10,
		d = new Date(),
		year = d.getFullYear();
	s.length = 0;
	for (var i = size; i >= 0; i--) {
		s.options[s.length] = new Option((year - (size - i)) + '年', (year - (size - i)));
	}

};
/**
 * 提供静态方法初始化业务相关的列表。
 *
 **/
var SelectObj = {
	rendereSelect: function(id, datas) {
		var s = null;
		if (typeof(id) == 'string') {
			s = document.getElementById(id);
		} else if (typeof(id) == 'object') {
			s = id;
		}
		var len = datas.length;
		s.length = 0;
		for (var i = 0; i < len; i++) {
			s.options[s.length] = new Option(datas[i].text, datas[i].value);
		}
	},
	initApprovalType: function(sid) { //报批类型
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '报批类型1'
		}, {
			value: '2',
			text: '报批类型2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductType: function(sid) { //产品类型
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '产品类型1'
		}, {
			value: '2',
			text: '产品类型2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductSort: function(sid) { //产品分类
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '产品分类1'
		}, {
			value: '2',
			text: '产品分类2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductStatus: function(sid) { //产品状态
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '产品状态1'
		}, {
			value: '2',
			text: '产品状态2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductSupportProvince: function(sid) { //产品支撑省
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '产品支撑省1'
		}, {
			value: '2',
			text: '产品支撑省2'
		}];
		this.rendereSelect(sid, arr);
	},
	initTargetCustomer: function(sid) { //目标客户
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '目标客户1'
		}, {
			value: '2',
			text: '目标客户2'
		}];
		this.rendereSelect(sid, arr);
	},
	initCustomerService: function(sid) { //客户服务
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '客户服务1'
		}, {
			value: '2',
			text: '客户服务2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductAttr: function(sid) { //产品属性
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '产品属性1'
		}, {
			value: '2',
			text: '产品属性2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductImportant: function(sid) { //重要性
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '重要性1'
		}, {
			value: '2',
			text: '重要性2'
		}];
		this.rendereSelect(sid, arr);
	},
	initPartner: function(sid) { //合作方
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '合作方1'
		}, {
			value: '2',
			text: '合作方2'
		}];
		this.rendereSelect(sid, arr);
	},
	initModeOfOperation: function(sid) { //运营方式
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '运营方式1'
		}, {
			value: '2',
			text: '运营方式2'
		}];
		this.rendereSelect(sid, arr);
	},
	initChargingCntrolMnagement: function(sid) { //计费控制管理
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '计费控制管理1'
		}, {
			value: '2',
			text: '计费控制管理2'
		}];
		this.rendereSelect(sid, arr);
	},
	initUserDataAndOrderRelations: function(sid) { //用户数据及订购关系说明
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '用户数据及订购关系说明1'
		}, {
			value: '2',
			text: '用户数据及订购关系说明2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProductStatus: function(sid) { //用户数据及订购关系说明
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '待受理'
		}, {
			value: '2',
			text: '待初审'
		}, {
			value: '1',
			text: '待复审'
		}, {
			value: '2',
			text: '初审打回'
		}, {
			value: '1',
			text: '复审打回'
		}];
		this.rendereSelect(sid, arr);
	},
	initFeedbackChannel: function(sid) { //用户数据及订购关系说明
		var arr = [{
			value: '',
			text: '全部'
		}, {
			value: '1',
			text: '反馈渠道1'
		}, {
			value: '2',
			text: '反馈渠道2'
		}];
		this.rendereSelect(sid, arr);
	},
	initProduct: function(sid) { //用户数据及订购关系说明
		$("#productName").ajaxRender("test/requirement/productName.json", {
			keyValue: {
				text: 'productName',
				value: 'productCode'
			}
		});
	},
	initProductAndSubProduct: function(productId, subProductId) { //用户数据及订购关系说明
		var productObj = productId,
			subProductObj = subProductId;
		if (typeof productId == 'string') {
			productObj = $('#' + productId);
		}
		if (typeof subProductId == 'string') {
			subProductObj = $('#' + subProductId);
		}
		/**productObj.bind('focus', function() {
			if (subProductObj) {
				subProductObj.length = 0;
				subProductObj.options[subProductObj.length] = new Option('--请选择--', '');
			}
		})**/
		productObj.bind('change',function(){
			if($.browser.mozilla){
				alert($(this).attr('_pid'));
				if ($(this).attr('_pid')){
					$(this).attr('pid',$(this).attr('_pid'));
					$(this).attr('_pid','');
				}else{
					$(this).attr('pid','');
					subProductObj.empty();
					subProductObj.append('<option value="">--请选择--</option>');
					subProductObj.trigger('blur');
				}
				
			}else{
				subProductObj.empty();
				subProductObj.append('<option value="">--请选择--</option>');
				subProductObj.trigger('blur');
			}
			
		});
		productObj.autocomplete({
			minLength: 0,
			//source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ],
			source: function(request, response) {
				$.ajax({
					url: "test/requirement/productName.json",
					dataType: "json",
					data: {
						featureClass: "P",
						style: "full",
						maxRows: 12,
						name_startsWith: request.term
					},
					success: function(data) {
						response($.map(data, function(item) {
							return {
								label: item.productName,
								value: item.productCode
							}
						}));
					}
				});
			},
			select: function(event, ui) {
				$(this).val(ui.item.label);
				$(this).attr('pid',ui.item.value);
				$(this).attr('_pid',ui.item.value);
				if (typeof subProductObj != 'undefined') {
					var pid = $(this).attr('pid');
					if (pid){
						subProductObj.ajaxRender("test/requirement/subProductName.json?pid=" + pid, {
							firstOption: {
								text: '--请选择--',
								value: ''
							},
							keyValue: {
								text: 'productName',
								value: 'productCode'
							}
						});
					}else{
						subProductObj.empty();
						subProductObj.append('<option value="">--请选择--</option>');
					}
					//subProductObj.trigger('blur');
				}
				return false;
			}
			
		});
		/**productObj.autocomplete({
			url:"test/requirement/productName2.json",
			minChars: 0,
			onNoMatch: true,
			autoFill: true,
			showResult: function(value, data) {
				return '<span style="color:red">' + value + '</span>';
			},
			onItemSelect: function(item) {
				productObj.attr('pid',item.value);
				subProductObj.ajaxRender("test/requirement/subProductName.json",{firstOption:{text:'--请选择--',value:''},keyValue:{text:'productName',value:'productCode'}},{"suName":"1111"});
			}
			//data:[ ['apple', 1], ['apricot', 2], ['pear', 3], ['prume', 4], ['飞翔', 5], ['飞信', 6]]
		});**/
		/**productObj.bind('blur', function() {
			subProductObj.ajaxRender("test/requirement/subProductName.json", {
				firstOption: {
					text: '--请选择--',
					value: ''
				},
				keyValue: {
					text: 'productName',
					value: 'productCode'
				}
			}, {
				"suName": "1111"
			});
		})**/
		/**productObj.autocomplete({ 
			source: function(request, response) {  
            $.ajax({  
                url: "test/requirement/productName3.json",  
                data: {  
                    name: request.term  
                },  
                dataType: "json",  
                success: function(data, textStatus, jqXHR) {  
                    response($.map(data, function(item, index) {  
                        return item.label;  
                    }));  
                },
			minLength: 0
            });  
        }
		});**/
		/**productObj.autocomplete({
			
			url:'test/requirement/productName3.json',
			showResult: function(value, data) {
				return value.label;
			},
			onItemSelect: function(item) {
				
			}
		});**/
		/**
		productObj.ajaxRender("test/requirement/productName.json",{
			keyValue:{text:'productName',value:'productCode'}
		 });
		productObj.bind("change",function(){
			subProductObj.ajaxRender("test/requirement/subProductName.json",{keyValue:{text:'productName',value:'productCode'}},{"suName":"1111"});
		});
		/**$('#' + productId).bind("change",function(){
			$('#' + subProductId).ajaxRender("test/requirement/subProductName.json",{keyValue:{text:'productName',value:'productCode'}},{"suName":"1111"});
		});**/
	},
	initRequirementType: function(sid) { //用户数据及订购关系说明
		var obj = typeof(sid) == 'string' ? $('#' + sid) : sid;
		obj.ajaxRender("test/requirement/reqType.json", {
			firstOption: {
				text: '--请选择--',
				value: ''
			},
			keyValue: {
				text: 'reqTypeDesc',
				value: 'reqTypeCode'
			}
		});
	},
	initRequirementSource: function(sid) { //用户数据及订购关系说明
		var obj = typeof(sid) == 'string' ? $('#' + sid) : sid;
		obj.ajaxRender("test/requirement/reqSource.json", {
			firstOption: {
				text: '--请选择--',
				value: ''
			},
			keyValue: {
				text: 'reqSourceDesc',
				value: 'reqSourceCode'
			}
		});
	}
}
/**
 * 弹出标签式的列表选项。
 *
 **/
var TagSelectObj = function(contenterId) {
	this._contenterId = contenterId;
}
TagSelectObj.prototype = {
	_options: {
		btnName: '请选择',
		url: ''
	},
	/**_getSelectedTags: function() {
		var ids = [];
		var choiceitems = $('#' + this._contenterId).children('div:eq(1) .choiceitem');
		for (var j = 0; j < choiceitems.length; j++) {
			ids.push(choiceitems[j].attr('tagId'));
		}
	},**/
	getSelectedTags: function() {
		var result = [],
			tags = $('#' + this._contenterId + ' div.choice .item');
		$.each(tags, function() {
			var tagid = $(this).attr('tagid');
			result.push(tagid);
		});
		return result.join(',');
	},
	getTagHTML: function(contenterId, id, text) {
		return '<div class="item" id="' + contenterId + id + '" tagId="' + id + '"><div class="choiceitem">' + text + '</div><div class="closeitem1"> <a href="javascript:;" onclick="javascript:$(this).parent(\'div\').parent(\'div\').fadeRemove();$(\'#\' + $(this).parent(\'div\').parent(\'div\').attr(\'id\') + \'_cb\').attr(\'checked\',false);"></a> </div></div>';
	},
	init: function(opt) {
		var _this = this;
		$.extend(_this._options, opt);
		var divId = _this._contenterId;
		$(' <div style="float:left;"><input width="81px" type="button" style="width:81px;height:25px; line-height:25px;" class="bluebtn" value="' + _this._options.btnName + '"></div></br><div class="choice"></div><div style="clear:both"></div><div  class="popwindow" style="z-index:998;position:absolute;" id="popwindow_' + divId + '"><div class="popwintop"> 				<div class="poptitle">请选择</div> 				<div class="popwinright"> 					<div class="closefenge"></div><a class="daibanright" href="javascript:;" onclick="javascript:$(\'#popwindow_' + divId + '\').hide(200);"></a> </div></div><div class="popwinframe"></div>').appendTo('#' + this._contenterId);
		//$('<div></div><br /><div> <input type="button" width="81px" value="选择" class="bluebtn" style="width:81px;height:25px; line-height:25px;" /></div><div style="clear:both"></div><div  class="popwindow" style="z-index:998" id="popwindow_'+divId + '"><div class="popwintop"> 				<div class="poptitle">请选择</div> 				<div class="popwinright"> 					<div class="closefenge"></div><a class="daibanright" href="javascript:;" onclick="javascript:$(\'#popwindow_'+divId + '\').hide(500);"></a> </div></div><div class="popwinframe"></div>').appendTo('#' + this._contenterId);
		$('#' + divId + ' div:eq(0) :button').bind('click', function() {
			$('#popwindow_' + divId).show();
			if ($('#popwindow_' + divId).children('div.popwinframe').html() == '') {
				$.ajaxSubmit(_this._options.url, {}, function(rtn) {
					if (rtn.success) {
						var datas = rtn.data;
						var tmp = ['<div class="choice_list"><input type="checkbox" name="checkBoxAll" id="checkboxall_' + divId + '"/> 全选</div>'];
						for (var i = 0; i < datas.length; i++) {
							var width = 15;
							if (datas[i].text.length > 3 && datas[i].text.length < 8) {
								width = 30;
							} else if (datas[i].text.length >= 8) {
								width = 35;
							}
							tmp.push('<div class="choice_list" style="width:' + width + '%"><input type="checkbox" id="' + divId + datas[i].id + '_cb" name="checkbox_' + divId + '" value="' + datas[i].id + '"/> ' + datas[i].text + '</div>');
						}
						tmp.push('<div style="clear:both"></div>')
						$('#popwindow_' + divId).children('div.popwinframe').append(tmp.join(''));

						$('input[name=checkbox_' + divId + ']').bind('click', function() {
							var isCheck = $(this).attr('checked') || false;
							if (isCheck) {
								$('#' + divId + ' .choice').append(_this.getTagHTML(divId, $(this).val(), $(this).parent().text()));
								//$('<div class="choiceitem" id="' + divId + $(this).val() + '" tagId="'+ $(this).val() + '">' + $(this).parent().text() + '<div class="closeitem" style="position:relative;left:50px;"><a href="javascript:;" onclick="javascript:$(this).parent(\'div\').parent(\'div\').fadeRemove();$(\'#\' + $(this).parent(\'div\').parent(\'div\').attr(\'id\') + \'_cb\').attr(\'checked\',false);"><img src="images/closeitem.png" width="22" height="22" border="0" /></a></div></div>').appendTo(('#' + divId +' div:eq(0)'));
							} else {
								$('#' + divId + $(this).val()).fadeRemove();
							}
						});
						$.checkbox_chkAll('checkboxall_' + divId, 'checkbox_' + divId, function(allObj, selObjs) {
							var isCheck = allObj.attr('checked') || false;
							if (isCheck) {
								$.each(selObjs, function() {
									$('#' + divId + ' .choice').append(_this.getTagHTML(divId, $(this).val(), $(this).parent().text()));
									//$('<div class="choiceitem" id="' + divId + $(this).val() + '" tagId="' + $(this).val() + '">' + $(this).parent().text() + '<div class="closeitem" style="position:relative;left:50px;"><a href="javascript:;" onclick="javascript:$(this).parent(\'div\').parent(\'div\').fadeRemove();$(\'#\' + $(this).parent(\'div\').parent(\'div\').attr(\'id\') + \'_cb\').attr(\'checked\',false);"><img src="images/closeitem.png" width="22" height="22" border="0" /></a></div></div>').appendTo(('#' + divId +' div:eq(0)'));
								});
							} else {
								$('#' + divId + ' .choice').empty();
							}
						});
					}
				});
			}

		});
	}
}
/**
 * 初始化列表,选项为12月份。
 *
 **/
var initMonthSelect = function(id) {
	var s = document.getElementById(id),
		m = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
		size = m.length;
	s.length = 0;
	for (var i = 0; i < size; i++) {
		s.options[s.length] = new Option(m[i] + '月', m[i]);
	}

}

/**
 * 对Pluploader附件上传插件按照业务需求做简单封装。
 * 初始化:PlUploaderObj.init('uploadFileDiv');
 * 获取上传成功的附件ID,多个以','隔开,PlUploaderObj.getSucc();
 **/
var PlUploaderObj = function(contenterId) {
	this._contenterId = contenterId;
	this._uploadId = 'uploading_' + this._contenterId;
	this._count = 0;
	this._uploadFileBtnId = 'uploadFileBtn';
	this._attachFileIds = [];
	this._add_attachFileIds = [];
	this._del_attachFileIds = [];
	this._attachGroupId = '';
	this._hiddenId = '';
	this._uploadFinishedId = '';
	this._isInit = false;
	this.uploader = null;
	this._options = {
		btnName: '上传附件',
		btnWidth : '',
		max_file_size: '3mb',
		max_file: 1,
		addUrl: BIZCTX_PATH + '/attachment!add.action',
		mutilAddUrl : BIZCTX_PATH + '/attachment!addForMulti.action',
		delUrl: BIZCTX_PATH + '/attachment!withdraw.action',
		downloadUrl: BIZCTX_PATH + '/attachment!download.action',
		viewUrl:BIZCTX_PATH + '/attachment!view.action',
		attachGroupId : '',
		disTheme: 1,
		hiddenName : '', //附件组ID
		hiddenAttachId : '',//附件ID,多个用逗号隔开,多附件该参数不能为空
		hiddenAttr :null,
		uploadFinishedName : '',
		uploadFinishedAttr : {'uploadfinishedflag':'1','datatype':'uploadFinished','uploadfinishedignore':'uploadfinishedignore'},
		attachTypeId:'',
		isView : false,
		initData: [],
		mime_types: [{
							title: "图片文件(jpg,jpeg,gif)",
							extensions: "jpg,jpeg,gif"
						}, {
							title: "Word文件(doc,docx)",
							extensions: "doc,docx"
						},{
							title: "Pdf文件(pdf)",
							extensions: "pdf"
						}, {
							title: "Rar文件(zip,rar)",
							extensions: "zip,rar"
						}, {
							title: "Excel文件(xls,xlsx)",
							extensions: "xls,xlsx"
						}, {
							title: "PowerPoint文件(ppt,pptx)",
							extensions: "ppt,pptx"
						}]
	};
}
PlUploaderObj.prototype = {
	_disableBrowse: function(flag) { //控制上传按钮启用/禁用以及按钮样式
		var _this = this;
		_this.uploader.disableBrowse(flag);
		if (flag) {
			$('#' + _this._uploadFileBtnId).removeClass('bluebtn').addClass('graybtn');
		} else {
			$('#' + _this._uploadFileBtnId).removeClass('graybtn').addClass('bluebtn');
		}
	},
	_checkMaxSize: function() { //检查是否上传的附件总数已达到最大
		var _this = this;
		if (!_this.getSucc()){
			$('#' + _this._uploadFileBtnId).parent().show();
			//document.getElementById(_this._uploadFileBtnId).style.display = 'inline';
			//$('#' + _this._uploadFileBtnId).parent().show();
			//_this._disableBrowse(false);
			//if (!_this._isInit){
				_this._initPlUpload();
				//_this._isInit = true;
			//}
			return;
		}
		if (_this.getSucc().split(',').length < _this._options.max_file) {
			$('#' + _this._uploadFileBtnId).parent().show();
			//document.getElementById(_this._uploadFileBtnId).style.display = 'inline';
			//if (!_this._isInit){
				_this._initPlUpload();
			//	_this._isInit = true;
			//}
			//$('#' + _this._uploadFileBtnId).parent().show();
			//_this._disableBrowse(false);
		} else {
			//document.getElementById(_this._uploadFileBtnId).style.display = 'none';
			$('#' + _this._uploadFileBtnId).parent().hide();
			if (_this.uploader){
			_this.uploader.destroy();
			//_this._isInit = false;
			//$('#' + _this._uploadFileBtnId).parent().hide();
			//_this._disableBrowse(true);
			}
		}
		
	},
	_bindCloseItemEvent: function() { //绑定上传的附件关闭事件
		var _this = this;
		$('#' + this._contenterId + ' .uploading .closeitem a').bind("click",function() {
			//_this.uploader.trigger('CancelUpload');
			var o = $(this).parent('div').parent('div');
			if (o.attr('attachfileid')){
				$.ajaxSubmit(_this._options.delUrl,{'attachFileId':o.attr('attachfileid')},function(_data){
					if (_data && _data.success){
						_this._del_attachFileIds.push(o.attr('attachfileid'));
						o.fadeOut(500, function() {
							o.remove();
							_this._checkMaxSize();
							_this._initHiddenName();
							_this._initHiddenUpLoadFinishedName();
						});
					}
				});
			}else{
				o.fadeOut(500, function() {
					o.remove();
					_this._checkMaxSize();
					_this._initHiddenName();
					_this._initHiddenUpLoadFinishedName();
				});
			}
			//_this.uploader.refresh();
			//$(this).parent('div').parent('div').remove();
		});
	},
	_changeParam: function(url, name, value) {
		var newUrl = "";
		var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
		var tmp = name + "=" + value;
		if (url.match(reg) != null) {
			newUrl = url.replace(eval(reg), tmp);
		} else {
			if (url.match("[\?]")) {
				newUrl = url + "&" + tmp;
			} else {
				newUrl = url + "?" + tmp;
			}
		}
		return newUrl;
	},
	_initDatas: function() { //初始化已上传的附件信息
		var _this = this;
		var _options = _this._options;
		//if (_options.attachGroupId) {
			
			/**$.ajaxSubmit(_options.viewUrl,{'attachGroupId':_options.attachGroupId},function(_data){
				if (_data){
					for (var i = 0; i < _data.files.length; i++) {
						if (_this._options.disTheme == 2) {
							$('#' + this._contenterId).append('<div class="uploading" fileid="' + _data.files[i].fileId + '" style="width:100px;height:100px;"><img src="' + _data.files[i].fileName + '"/>' + (_this._options.isView ? '<div style="margin-top:-38px;margin-left:192px;" class="closeitem"> <a href="javascript:;"></a>':'') + ' </div></div>');
						} else {
							$('#' + this._contenterId).append('<div class="uploading" fileid="' + _data.files[i].fileId + '"><div class="uploadfile">' + _data.files[i].fileName + '</div>'+(_this._options.isView ? '<div style="margin-top:-38px;margin-left:192px;" class="closeitem"> <a href="javascript:;"></a>':'') + '</div></div>');
						}
					}
					this._bindCloseItemEvent();
				}
			});**/
			if (_options.initData.length > 0){
				for (var i = 0; i < _options.initData.length; i++) {
						$('#' + _this._contenterId).attr('attachGroupId', _options.initData[i].groupId);
						if (_options.disTheme == 2) {
							$('#' + _this._contenterId).append('<div class="uploading" attachfileid="' + _options.initData[i].fileId + '" style="width:100px;height:100px;"><div class="uploadcontent"><img src="' + _options.initData[i].fileName + '"/></div>' + (!_this._options.isView ? '<div style="margin-top:-38px;margin-left:192px;" class="closeitem"> <a href="javascript:;"></a>':'') + ' </div></div>');
						} else {
							$('#' + _this._contenterId).append('<div class="uploading" attachfileid="' + _options.initData[i].fileId + '"><div class="uploadcontent"><div class="uploadfile"><a href="'+$.appendExtraParams(_this._options.downloadUrl + "?attachFileId=" + _options.initData[i].fileId) + '" target="_blank" title="' + _options.initData[i].fileName + '">' + _options.initData[i].fileName + '</a></div></div>'+(!_this._options.isView ? '<div style="margin-top:-38px;margin-left:192px;" class="closeitem"> <a href="javascript:;"></a>':'') + '</div></div>');
						}
				 }
				_this._initHiddenName();
				_this._initHiddenUpLoadFinishedName();
				_this._bindCloseItemEvent();
				
			//}
			
		}
		_this._checkMaxSize();
	},
	_initHiddenName : function(){
		/*var name = this._options.hiddenName ? this._options.hiddenName : '';
		var id = 'hidden_' + this._contenterId;
		if (!document.getElementById(id)){
			this._hiddenId = id;
			$('#' + this._uploadFileBtnId).parent().parent().append('<input  type="hidden" '+ (this._options.hiddenName ? 'name="' + this._options.hiddenName + '"' : '') +' id="' + id + '"/>');
			if (this._options.hiddenAttr){
				for (var obj in this._options.hiddenAttr){
					$('#' + id).attr(obj,this._options.hiddenAttr[obj]);
			   }
			}
			
		}*/
		if (this._options.max_file > 1){
			$('#' + this._hiddenId).val(this.getSucc());	
			$('#' + this._attachGroupId).val(this.getGroupId());
		}else{
			if (this.getSucc()){
				$('#' + this._hiddenId).val(this.getGroupId());	
			}else{
				$('#' + this._hiddenId).val('');	
				$('#' + this._hiddenId).trigger('blur');
			}
		}
		/**if(this._options.max_file == 1){
			$('#' + id).val(this.getGroupId());	
		}else{
			$('#' + id).val(this.getGroupId() + "|" + this.getSucc());	
		}**/
		$('#' + this._contenterId).attr('attachFiles',this.getAttachFiles());
		//$('#' + this._hiddenId).trigger('blur');
	},
	_initHiddenUpLoadFinishedName : function(){
		var uploadFinishedName = this._options.uploadFinishedName ? this._options.uploadFinishedName : 'hidden_uploadFinishedName_' + this._contenterId;
		var uploadFinishedId = 'hidden_uploadFinishedId_' + this._contenterId;
		$('#' + uploadFinishedId).parent('div').remove();
		$('#' + this._uploadFileBtnId).parent().parent().append('<div><input type="hidden"'+' name="' + uploadFinishedName + '"  id="' + uploadFinishedId + '" value="uploadFinished" /></div>');
		if (this._options.uploadFinishedAttr){
				for (var obj in this._options.uploadFinishedAttr){
					$('#' + uploadFinishedId).attr(obj,this._options.uploadFinishedAttr[obj]);
			   }
			}
		$('#'+uploadFinishedId).trigger('blur');	
	},
	_addAttacheTypeParam:function(){
		var params = "attachTypeId="+this._options.attachTypeId;
		if (this._options.max_file > 1){
			params += '&attachGroupId=' + this.getGroupId() + '&attachFileIds=' + this.getSucc();
			this._uploadUrl = this._options.mutilAddUrl;
		}else{
			this._uploadUrl = this._options.addUrl;
		}
		if(this._options.addUrl.indexOf("?") == -1){
	        this._uploadUrl += "?" + params;
	    }else{
	    	this._uploadUrl += "&" + params;
	    }
	},
	_composeMimeTypes:function(){
		var _this = this;
		if(_this._options.mime_types && $.isArray(_this._options.mime_types)){//把mime_types组合到一起展示为所有文件
			var all_extensions = [];
			$.each(_this._options.mime_types, function(i,mimeTypes){
				if(mimeTypes.extensions && $.trim(mimeTypes.extensions).length > 0){
					all_extensions.push(mimeTypes.extensions);
				}
			});
			//添加到类型开头
			var all_extensionss = all_extensions.join(",");
			_this._options.mime_types.unshift({title:'所有文件(' + all_extensionss + ')',extensions:all_extensionss});
			
		}
	},
	_initPlUpload : function(){
		var _this = this;
		_this._addAttacheTypeParam();//byhaomingli
		_this.uploader = new plupload.Uploader({
			runtimes: 'gears,html5,silverlight,html4,flash',
			browse_button: _this._uploadFileBtnId, // you can pass in id...
			container: _this._contenterId, // ... or DOM Element itself
			url: _this._uploadUrl,
			multi_selection: false,
			chunk_size: '250kb',
			max_retries:0,
			//multipart:true,
			flash_swf_url: ctxPaths + '/jquery/plugin/plupload/Moxie.swf',
			silverlight_xap_url: ctxPaths + '/jquery/plugin/plupload/Moxie.xap',
			max_file_size: _this._options.max_file_size,
			filters: _this._options.mime_types,
			file_data_name:'attachment',
			headers : {'attachTypeId':_this._options.attachTypeId},
			init: {
			PostInit: function() {

			},
			FilesAdded: function(up, files) {
				$('#' + _this._uploadFileBtnId).parent().hide();
				//document.getElementById(_this._uploadFileBtnId).style.display = 'none';
				plupload.each(files, function(file) {
					//$('#' + _this._contenterId).append('<div class="uploading"><div><div class="uploadfile"><a href="javascript:;" target="_blank">' + file.name + ' (' + plupload.formatSize(file.size) + ')</a></div><span class="red">0%</span></div><div class="uploadbar"  style="width:0%"></div><div class="closeitem"> <a href="javascript:;"></a> </div></div>');
					$('#' + _this._contenterId).append('<div class="uploading"> <div class="uploadcontent"> <div class="uploadfile"><a target="_blank" href="javascript:;" title="' + file.name + '">' + file.name + '</a></div>           <div class="red uploadpercent">0%</div><div class="uploadbarbox"><div style="width: 0%;" class="uploadbar"></div></div>                         </div> <div class="closeitem"> <a href="javascript:;"></a></div></div>');
					//$('.uploading:last').attr('attachFileId', file.name);
				});
				
				/**if ($('#' + _this._contenterId).attr('attachGroupId')) {
					_this.uploader.settings.url = _this._changeParam(_this.uploader.settings.url, 'attachGroupId', $('#' + _this._contenterId).attr('attachGroupId'));
				}**/
				_this._bindCloseItemEvent();
				//up.refresh(); 
				//$('#uploadFileBtn').hide();
				//$('#uploadFileBtn2').show();
				up.refresh();
				_this.uploader.disableBrowse(true);
				_this.uploader.start();
			},
			BeforeUpload : function(up, file){
				var uploadFinishedId = 'hidden_uploadFinishedId_' + _this._contenterId;
				$('#'+uploadFinishedId).attr("uploadfinishedflag","0");
				
				//添加额外参数 ,支持分块传输,by haomingli
				if(up.settings.multipart_params == undefined){
					up.settings.multipart_params = {fileId:file.id }
				}
			},
			UploadProgress: function(up, file) {
				var _percent=file.percent>1?file.percent-1:file.percent;
				$('#' + _this._contenterId + ' .uploading .uploadcontent .uploadpercent:last').html(_percent + '%');
				$('#' + _this._contenterId + ' .uploading .uploadcontent .uploadbarbox .uploadbar:last').width(_percent+ '%');
			},
			UploadComplete: function(up, file) {
				//_this._disableBrowse(false);
				//_this._checkMaxSize();
			//$('.uploading:last').attr('fileId', file.name);
			},
			FileUploaded: function(up, file, res) {
			 var result = {'success':false};
			 var uploadFinishedId = 'hidden_uploadFinishedId_' + _this._contenterId;
			 $('#'+uploadFinishedId).attr("uploadfinishedflag","1");
			 //alert("FileUploaded1");
			 $('#'+uploadFinishedId).trigger('blur');
			 //alert("FileUploaded2");
			 	
			 if (res.response){
				try{
					result = eval(("(" + res.response + ")"));
				}catch(err){
					result = {'success':false,'data':{'msg':'发生未知错误'}};
				}
			 }
			if (result.success){
				_this._add_attachFileIds.push(result.attachFileId);
				$('#' + _this._contenterId + ' .uploading .uploadcontent .uploadpercent:last').remove();
				$('#' + _this._contenterId + ' .uploading .uploadcontent .uploadbarbox:last').remove();
				if (_this._options.disTheme == 2) {
					$('#' + _this._contenterId + ' .uploading .uploadfile :last').remove();
					$('#' + _this._contenterId + ' .uploading:last').css('width', '100px').css('height', '100px').append('<img src="'+$.appendExtraParams (_this._options.viewUrl + "?attachFileId=" + result.attachFileId + "&attachGroupId=" + result.attachGroupId) + '"/>');
				}else{
					$('#' + _this._contenterId + ' .uploading .uploadcontent .uploadfile a:last').attr('href',$.appendExtraParams (_this._options.downloadUrl + "?attachFileId=" + result.attachFileId));
				}
				$('#' + _this._contenterId + ' .uploading:last').attr('attachfileid', result.attachFileId);
				$('#' + _this._contenterId).attr('attachGroupId', result.attachGroupId);
				//$('#h_' + this._contenterId).val(result.attachGroupId + "|");
				_this._initHiddenName();
				_this._initHiddenUpLoadFinishedName();
			}else{
				alert(result.data.msg);
				$('#' + _this._contenterId +' .uploading:last').append('<div style="float:bottom"><a href="javascript:void(0)">续传</a> </div>');
			}
			
				//$('#uploadFileBtn2').hide();
			//$('#uploadFileBtn').show();
			//_this.uploader.init();
			//$('#uploadFileBtn').removeClass('graybtn').addClass('bluebtn');
			up.refresh();
			_this._bindCloseItemEvent();
			//_this._disableBrowse(false);
			_this._checkMaxSize();
			$('#' + _this._hiddenId).trigger('blur');
			if (_this.uploader)_this.uploader.disableBrowse(false);
			
			},
			ChunkUploaded:function(up, file, res){//分块文件每块上传后回调
				result = {'success':false,'data':{'msg':'未知错误'}};
				if (res.response){
					try{
						result = eval(("(" + res.response + ")"));
					}catch(err){
						result = {'success':false,'data':{'msg':'发生未知错误'}};
					}
				}
				if(result.success == false){//上传失败
					//继续上传 to
					alert(result.data.msg);
					$('#' + _this._contenterId +' .uploading:last').remove();
					up.refresh();
					_this._checkMaxSize();
					if (_this.uploader)_this.uploader.disableBrowse(false);
				}
				
			},
			Error: function(up, err) {
				if(err.message.indexOf("HTTP")>-1){
					alert("附件上传失败,请检查网络是否通畅!");
				}else{
					alert(err.message);
				}
				$('#' + _this._contenterId +' .uploading:last').append('<div style="float:bottom;margin-top:14px;"><a class="keepUpload" href="javascript:void(0)">续传</a> </div>');
				$('#' + _this._contenterId +' .uploading .keepUpload').click(function(){
					err.file.status = plupload.UPLOADING;
					up.state= plupload.UPLOADING;
					$('#' + _this._contenterId +' .uploading .keepUpload').remove();
					_this.uploader.trigger("UploadFile", err.file);
				});
				if (_this.uploader)_this.uploader.disableBrowse(false);
			}
		  }
		});
		_this.uploader.init();
	},
	init: function(ops) {
		var _this = this;
		if (typeof ops == 'object') {
			$.extend(_this._options, ops);
		}
		_this._composeMimeTypes();
		_this._uploadFileBtnId = 'uploadBtn_' + _this._contenterId;
		var name = _this._options.hiddenName ? _this._options.hiddenName : '';
		_this._hiddenId  = 'hidden_' + _this._contenterId;
		_this._attachGroupId = 'hidden_groupid_' + _this._contenterId;
		//add by xiaoliangqing on 2014/01/07 start
		var uploadFinishedName = _this._options.uploadFinishedName ? _this._options.uploadFinishedName : 'hidden_uploadFinishedName_' + _this._contenterId;
		_this._options.uploadFinishedName = uploadFinishedName;
		var uploadFinishedId = 'hidden_uploadFinishedId_' + _this._contenterId;
		_this._uploadFinishedId = uploadFinishedId;
		//add by xiaoliangqing on 2014/01/07 end
		
		$('#' + _this._contenterId).empty();
		if (_this._options.max_file > 1){
			$('<div><input type="button" id="' + _this._uploadFileBtnId + '" value="' + _this._options.btnName + '" class="bluebtn" '+(_this._options.btnWidth?'style="width:'+_this._options.btnWidth+'"':'')+'/><input type="hidden" '+ (_this._options.hiddenAttachId ? 'name="' + _this._options.hiddenAttachId + '"' : '') +' id="' + _this._hiddenId  + '"/><input type="hidden" '+ (_this._options.hiddenName ? 'name="' + _this._options.hiddenName + '"' : '') +' id="' + _this._attachGroupId  + '"/></div>').appendTo('#' + _this._contenterId);
		}else{
			$('<div><input type="button" id="' + _this._uploadFileBtnId + '" value="' + _this._options.btnName + '" class="bluebtn" '+(_this._options.btnWidth?'style="width:'+_this._options.btnWidth+'"':'')+'/><input type="hidden" '+ (_this._options.hiddenName ? 'name="' + _this._options.hiddenName + '"' : '') +' id="' + _this._hiddenId  + '"/></div>').appendTo('#' + _this._contenterId);
		}
		
		//$('<div><input type="button" id="' + _this._uploadFileBtnId + '" value="' + _this._options.btnName + '" class="bluebtn" '+(_this._options.btnWidth?'style="width:'+_this._options.btnWidth+'"':'')+'/>').appendTo('#' + _this._contenterId);
		//if (_this._options.max_file > 1){
			//$('#' + _this._contenterId).append('<input type="hidden" '+ (_this._options.hiddenAttachId ? 'name="' + _this._options.hiddenAttachId + '"' : '') +' id="' + _this._hiddenId  + '"/><input type="hidden" '+ (_this._options.hiddenName ? 'name="' + _this._options.hiddenName + '"' : '') +' id="' + _this._attachGroupId  + '"/></div>').appendTo('#' + _this._contenterId);
		//}else{
			//$('#' + _this._contenterId).append('<input type="hidden" '+ (_this._options.hiddenName ? 'name="' + _this._options.hiddenName + '"' : '') +' id="' + _this._hiddenId  + '"/></div>').appendTo('#' + _this._contenterId);
		//}
		$('<div><input  type="hidden"'+' name="' + uploadFinishedName + '"  id="' + uploadFinishedId + '" value="uploadFinished"  />').appendTo('#' + _this._contenterId);
		//$('<div><input type="button" id="' + _this._uploadFileBtnId + '" value="' + _this._options.btnName + '" class="bluebtn"><input type="hidden" '+ (_this._options.hiddenName ? 'name="' + _this._options.hiddenName + '"' : '') +' id="' + id + '"/><input type="hidden" '+' name="' + uploadFinishedName + '"  id="' + uploadFinishedId + '" value="uploadFinished"  /></div>').appendTo('#' + _this._contenterId);
		if (_this._options.hiddenAttr){
			for (var obj in this._options.hiddenAttr){
				$('#' + _this._hiddenId).attr(obj,this._options.hiddenAttr[obj]);
			}
		}
		
		//add by xiaoliangqing on 2014/01/07 start
		if (_this._options.uploadFinishedAttr){
			for (var obj in this._options.uploadFinishedAttr){
				$('#' + uploadFinishedId).attr(obj,this._options.uploadFinishedAttr[obj]);
			 }
		}
		//add by xiaoliangqing on 2014/01/07 end
		
		//$('<div style="float:left;"><a id="' + _this._uploadFileBtnId + '" class="bluebtn">' + _this._options.btnName + '<a></div>').appendTo('#' + _this._contenterId);
		
		_this._initDatas();
	},
	getGroupId: function() {
		return $('#' + this._contenterId).attr('attachGroupId')?$('#' + this._contenterId).attr('attachGroupId'):'';
	},
	getAddAttachFileIds : function(){
		return this._add_attachFileIds.join(',');
	},
	getDelAttachFileIds : function(){
		return this._del_attachFileIds.join(',');
	},
	getAttachFiles: function() {
		var succ = [];
		$('#' + this._contenterId + ' .uploading').each(function(i) {
			if ($(this).attr('attachfileid')) {
				succ.push($(this).attr('attachfileid') + "|" + $(this).find('.uploadfile a').text());
			}
		})
		return succ.join(',');
	},
	getSucc: function() {
		var succ = [];
		$('#' + this._contenterId + ' .uploading').each(function(i) {
			if ($(this).attr('attachfileid')) {
				succ.push($(this).attr('attachfileid'));
			}
		})
		return succ.join(',');
	}

}
/**
 * 解决JS中获取不到base标签href的问题
 */
var linkTo = function(url) {
	var _url = url;
	if ($.browser.msie) {
		if (document.getElementsByTagName('base') && document.getElementsByTagName('base')[0].href) {
			_url = document.getElementsByTagName('base')[0].href + url;
		}
	}
	window.location.href = _url;
}
var companyTipMsg = {
		w:{
			"n11":"限制为11位数字",
			"n":"请输入数字",
			"numbers":"请输入数字",
			"len20":"长度不能超过20个字节",
			"len30":"最大长度为30个字符",
			"zj80":"最大长度为80个字节",
			"h":"请输入汉字",
			"zj100":"最大长度为50个汉字",
			"len8":"最大长度为8个字符",
			"len6":"最大长度为6位数字",
			"len2":"最大长度为2位数字",
			"zj50":"最大长度为25个汉字",
			"len18":"最大长度为18个字符",
			"zj1000":"最大长度为500个汉字",
			"n6":"限制为6位数字",
			"len80":"长度不能超过80个字节",
			"zj160":"最大长度为80个汉字",
			"zj200":"最大长度为100个汉字",
			"zj60":"最大长度为30个汉字",
			"zj50":"最大长度为25个汉字",
			"ulogin":"申请帐号名已存在",
			"uCompanyStatus":"该公司处于审批流程中,不允许进行帐号注册",
			"rulogin":"申请帐号名已存在",
			"uemail":"Email已存在",
			"umobile":"手机号码已存在",
			"ruemail":"Email已存在",
			"rumobile":"手机号码已存在",
			"value":"请输入大写英文字母和数字",
			"pwd":"必须同时包含数字和字母",
			"len6-20":"密码长度在6-20个字符",
			"name":"只能输入汉字或字母",
			"elen30":"只能输入不超过30个字节",
			"rlen80":"不超过40个汉字,80个字节",
			"nlen20":"申请帐号名只能由英文字母、数字和中文组成,最长20位",
			"account":"申请帐号名只能由汉字、数字组成",
			"mobile":"请输入正确的手机号码"
		}
}
var getValidformDefaultConfig = function(config) {
	var _default = {
		tiptype: tipType.rightSide,
		ajaxPost: false,
		showAllError:true,
		//dragonfly:true,
		datatype: { //传入自定义datatype类型,可以是正则,也可以是函数(函数内会传入一个参数);
			"zh1-6" : /^[\u4E00-\u9FA5\uf900-\ufa2d]{1,6}$/,
			"zh1-25" : /^[\u4E00-\u9FA5\uf900-\ufa2d]{1,25}$/,
			"s1-6":/^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]{1,6}$/,
			"*1-1000":/^[\w\W]{1,1000}$/,
			"*1-18":/^[\w\W]{1,18}$/,
			"s1-50":/^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]{1,50}$/,
			"h":/^[\u4E00-\u9FFF]+$/,
			"n0-100":/^(0|[0-9][0-9]?|100)$/,
			"len6":/^\d{1,6}$/,
			"len2":/^\d{1,2}$/,
			"len18":/^.{1,18}$/,
			"g20":/^\d{20}$/,
			"100%":/^(0|[0-9][0-9]?|100)$/,
			"zj100":/^.{1,50}$/,
			"len8":/^.{1,8}$/,
			"nlen20":/^.{1,20}$/,
			"name":/^[A-Za-z\u4e00-\u9fa5]+$/,
			"pwd":/^(?=.*\d)(?=.*[A-Za-z])[0-9a-zA-Z]/,
			//"pwd":"/(?:?<!(?:[^a-zA-Z][a-zA-Z0-9])) /",
			"len6-20":/^[\w\W]{6,20}$/,
			"zj50":/^.{1,25}$/,
			"zj1000":/^.{1,500}$/,
			"n6":/^\d{6}$/,
			"len80":/^.{1,40}$/,
			"zj160":/^.{1,80}$/,
			"zj2000":/^.{1,1000}$/,
			"zj80":/^.{1,40}$/,
			"len20":/^.{1,10}$/,
			"zj200":/^.{1,100}$/,
			"zj60":/^.{1,30}$/,
			"date" : /^(\d{4})\-(\d{2})\-(\d{2})$/,
			"len30":/^.{1,30}$/,
			"len20":/^.{1,20}$/,
			"zj80":/^.{1,40}$/,
			"rlen80":/^.{1,40}$/,
			"elen30":/^.{1,30}$/,
			"account":/^[\u4e00-\u9fa5]+[0-9]+$|^[0-9]+[\u4e00-\u9fa5]+$/,
			"h":/^[\u4E00-\u9FFF]+$/,
			"value":/^[-.A-Z0-9\u4E00-\u9FFF]+$/,
			"n11":/^\d{11}$/,
			"n":/^\d+$/,
			"numbers":/^-?\d+\.?\d*$/,
			"nlen20":/^.{1,20}$/,
			"s1-80":/^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]{1,80}$/,
			"mobile":dataType.mobile,
			"ulogin":dataType.uLoginName,
			"umobile":dataType.uMobile,
			"uemail":dataType.uEmail,
			"rulogin":dataType.ruLoginName,
			"rumobile":dataType.ruMobile,
			"ruemail":dataType.ruEmail,
			"uCompanyStatus":dataType.uCompanyStatus,
			"proportion":/^(100|[0-9]?\d((\.\d)?|((\.\d\d)?)))$/,
			"phone":/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/,											
			"fax":/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/,
			"postCode":/^[0-9]\d{5}$/,
			"positiveInteger":/^[1-9]\d*$/,
			"orgCode":/^([a-zA-Z0-9]|[-]){9,10}$/,
			"scoreCode":/^((0|[0-9][0-9]?|100)|[A-Z]{1})$/,
			"email":dataType.email,
			"number100":dataType.number100,
			"bankAccount":/^[\d\-\*]*$/,
			"getIntentionBase":dataType.getIntentionBase,
			"vzhiben": /^[0-9]\d{0,5}(\.\d{0,2})?$/,
			"examScore":/^([1-9]|[0-9]((\.[1-9])|((\.[0-9][1-9])|(\.[1-9][0])))|[1-9][0-9]|[1-9][0-9]?((\.\d)?|((\.\d\d)?)))$/,
			"specialChars" : function(gets, obj, curform, regxp){//非法字符 ' " < >
				var zh = /['">\\<]/;
				if (zh.test(gets)){
					return '不能含有特殊字符 > <  \\ \' "';
				}
				return true;
			},
			"numberChars" : function(gets, obj, curform, regxp){//字母数字
				var zh = /[a-zA-Z0-9]/;
				if (zh.test(gets)){
					return '不能含有字母、数字';
				}
				return true;
			},
			"konggeChars" :  function(gets,obj,curform,regxp){
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;	
					var result = false;
					$.ajax({
						url:BIZCTX_PATH + '/authprm/findULoginReg.action',
						async:false,
						data:{'accountApply.company.creditCode':gets,'accountApply.company.cnName':curform.find('#cnName').val()},
						dataType:'json',
						success:function(data){
							if(data.success)
								{
									result=data.data.result;
								}
						}
					})
					if(result=="true")
						{
							return true;
						}
					if(result=="lengthfalse")
					{
						return '长度为18位';
					}
					if(result=="checkfalse")
					{
						return '统一代码由阿拉伯数字或大写英文字母(不使用I、O、Z、S、V)组成';
					}
					if(result=="lastfalse")
					{
						return '第18位不符合统一代码规范';
					}
					return '统一社会代码不能重复';
				
			},
			"recheck":function(gets, obj, curform, regxp){//校验重复密码,自带的在IE8下焦点有问题
				var recheckpwd = obj.attr('recheckpwd');
				if (gets && recheckpwd && gets != $('#' + recheckpwd).val()){
					return false;
				}
				return true;
			},
			"checkOrgCode":function(gets, obj, curform, regxp){//组织结构代码简单校验
				if (!gets && gets.length > 10){
					return '不是有效的组织机构代码';
				}
				return true;
			},
			"validateMaxLength" :function(gets, obj, curform, regxp) {
				if (!gets) {
					return false;
				}
				var len = 0,_len = obj.attr('maxlength');
				if (gets){
					len = gets.replace(/[^\x00-\xff]/g, '..').length;
				}
				if (_len && len > _len){
					return '长度不能超过' + _len + '个字节或'+ _len/2 + '个汉字';
				}
				return true;
			},
			"startTimeValid": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (!gets) {
					return false;
				}
				var from = obj,
					to = $('#' + obj.attr('endtimeflag'));
				if (from.val() != '' && to.val() != '' && !isEndTimeGtStartTime(from.val(), to.val())) {
					
					return false;
				}
				setTimeout(function(){to.trigger('blur');},1000);
				//to.trigger('blur');
				return true;
				//注意return可以返回true 或 false 或 字符串文字,true表示验证通过,返回字符串表示验证失败,字符串作为错误提示显示,返回false则用errmsg或默认的错误提示;
			},
			"endTimeValid": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (!gets) {
					return false;
				}
				var st = obj.attr('starttimeflag');
				if (st) {
					var from = $('#' + st),
						to = obj;
					if (from.val() != '' && to.val() != '' && !isEndTimeGtStartTime(from.val(), to.val())) {
						return false;
					}
				}
				setTimeout(function(){from.trigger('blur');},1000);
				//from.trigger('blur');
				return true;
				//注意return可以返回true 或 false 或 字符串文字,true表示验证通过,返回字符串表示验证失败,字符串作为错误提示显示,返回false则用errmsg或默认的错误提示;
			},
			"validProductName": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (obj.attr('pid') && obj.attr('pid') != '') {
					return true;
				}
				return false;
			},
			"uploadFinished": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (!gets) {
					return false;
				}
				var uploadfinishedflag = obj.attr('uploadfinishedflag');
				if (uploadfinishedflag && uploadfinishedflag == '0'){
					return '附件上传未完成,不能提交';
				}
				return true;
			},
			"maxValue": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (!gets) {
					return true;
				}
				var value = gets,
				_value = obj.attr('maxValue');
				
				if(value){
					var re =/^[1-9]+[0-9]*$/;
					if(!re.test(value)){
						return "请填入正确整数";
					}
				}
				
				if(parseInt(_value) < parseInt(value)){
					return "请输入大于"+_value+"的整数";
				}
				
				return true;
			},
			"maxNumberLength": function(gets, obj, curform, regxp) {
				//参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
				if (!gets) {
					return true;
				}
				var value = gets,
				_value = obj.attr('maxNumberLength');
				
				if(value){
					var re =/^[1-9]+[0-9]*$/;
					if(!re.test(value)){
						return "请填入正确整数";
					}
				}
				
				if(parseInt(_value) < parseInt(value)){
					return "请输入大于"+_value+"的整数";
				}
				
				return true;
			}
		}
	}
	//$.extend(validation.tipmsg.w,companyTipMsg.w);
	return typeof config == 'object' ? $.extend(_default, config) : _default;
}


/**
 * 根据常量值,select动态数据获取封装。
 * @selectId select的id
 * @constantKey 获取数据的健
 * @config 传入的参数
 * @return void
 */
function ajaxRenderConstant(selectId,constantKey, config,constats) { //config:{firstOption:{text:'请选择分类',value:''},keyAlias:{text:'name',value:'value'}}
			var _this = $("#"+selectId);
			c = config || {}, keyValue = {
				text: 'name',
				value: 'value'
			};
			if (c.keyValue) {
				keyValue = c.keyValue;
			}
			_this.empty();
			if (c.firstOption) {
				_this.append('<option value="' + c.firstOption.value + '">' + c.firstOption.text + '</option>');
			}
			var data = constantData[constantKey];
			if(constats){
				data=constats;
			}
			if (data) {
						for (var i = 0; i < data.length; i++) {
							_this.append('<option value="' + data[i][keyValue.value] + '">' + data[i][keyValue.text] + '</option>');
						}
					}
		
		    //select下拉框选中
			if(c.selectedValue){
						$(_this).val(c.selectedValue);
					}		
		
		}
		
/**
 * 解析json数据
 * @return void
 */		
function parseData(values,key,oldValues){        
      if(!(values instanceof Array) && typeof values == 'object'){

               if(oldValues == undefined){

                        oldValues = values;

               }

               for(var id in values){

                        if(typeof values[id] != 'function' && !(values[id] instanceof Array) && typeof values[id] != 'object'){

                                  if(key != undefined){

                                           oldValues[key + '.' + id] = values[id];

                                           delete values[id];

                                  }

                        }else if(typeof values[id] != 'function' && !(values[id] instanceof Array) && typeof values[id] == 'object'){

                                  var valuess = values[id];

                                  for(var idd in valuess){

                                           var newKey = id + '.' + idd;

                                           if(key != undefined){

                                                    newKey = key + '.' + id + '.' + idd;

                                           }

                                           oldValues[newKey] = valuess[idd];

                                           delete values[id];

                                           parseData(oldValues[newKey],newKey,oldValues);

                                  }

                        }

               }

      }

};

/**
 * 解析json数据put值到表单元素
 * @return void
 */	
function jsonToForm(json){
	parseData(json);
	var fields = $(".field,input");
	jQuery.each( fields, function(i, field){
		var name= $(field).attr("name");
		var value = json[name];
		if($(field).is('input')){
			$(field).val(value);
		}else{
			$(field).text(value);
		}
	      
	});
}
/**
*reset form elements
*/
function resetValue(formId){
	var _ei = $('#'+formId); 
	_ei.find('input[type=text]').val('');
	_ei.find('input[type=hidden]').val('');
	_ei.find('select').attr('value','');
	_ei.find('input[type=date]').val('');
}


/**
 * PRM 业务层封装的一些工具类和对象
 */
;
(function($){
var downLoadAttachUrl = BIZCTX_PATH + '/attachment!download.action';
$.fn.extend({
	createAttachLink:function(){
	return this.each(function( j ) {
		var attachFileId = $(this).find('span[isAttachId]').text();
		var attachName = $(this).find('span[isAttachName]').text();
		var dynamicField = $(this).find('span[isAttachName]').attr('dynamicField');
		var subStringLength =$(this).find('span[isAttachName]').attr('subStringLength');
		if($.trim(attachFileId) != '' && $.trim(attachName) != ''){
			var attachNameLength = attachName.replace(/[^\x00-\xff]/g, ' ').length;
			if(subStringLength==''||subStringLength==undefined || subStringLength==''){
				subStringLength=30;
			}
			if(dynamicField){
				var aHtml= '<span class="redtext">(修改前:<a style="color:red;" href="' + $.appendExtraParams(downLoadAttachUrl + '?attachFileId=' + attachFileId) + '" target="_blank">' + attachName + '</a>)</span>  ';
			}else{
				var aHtml= '<a  href="' + $.appendExtraParams(downLoadAttachUrl + '?attachFileId=' + attachFileId) + '" target="_blank">' + attachName + '</a>  ';
			}
			
			
			if(attachNameLength &&attachNameLength>subStringLength){
				var subStringSpanText = attachName.substring(0,subStringLength)+"...";
				if(dynamicField){
					aHtml = '<span class="redtext"><a style="color:red;" href="' + $.appendExtraParams(downLoadAttachUrl + '?attachFileId=' + attachFileId) + '" target="_blank" title="'+attachName+'">' + subStringSpanText + '</a>)</span>>  ';
				}else{
					aHtml = '<a  href="' + $.appendExtraParams(downLoadAttachUrl + '?attachFileId=' + attachFileId) + '" target="_blank" title="'+attachName+'">' + subStringSpanText + '</a>  ';
				}
				
			}
			
			$(this).empty().append(aHtml);
		}
		
	});
}
});	
	
})(jQuery);

;
(function($){
$.fn.extend({
	renderSelect:function(){
		return this.each(function( j ) {
			var size = 4,
			d = new Date(),
			year = d.getFullYear();
			$(this).empty();
			$(this).append('<option value="">请选择</option>');
			for (var i = size; i >= 0; i--) {
				$(this).append('<option value="' + ((year - (size - i))) + '">'+((year - (size - i)))+'</option>');
			}
			$(this).val('');
		});
	}
});	
})(jQuery);
/**
 * 初始化最近10年下拉列表
 * @param {Object} id
 */
var initYearSelect = function(id) {
	var s = document.getElementById(id),
		size = 4,
		d = new Date(),
		year = d.getFullYear();
	s.length = 0;
	s.options[s.length] = new Option('请选择', (year - (size - i)));
	for (var i = size; i >= 0; i--) {
		s.options[s.length] = new Option((year - (size - i)), (year - (size - i)));
	}

};

/**
 * 扩展数组的包含功能
 * @param {Object} obj
 * @memberOf {TypeName} 
 * @return {TypeName} 
 */
Array.prototype.contains = function(element) {  
    for (var i = 0; i < this.length; i++) {  
        if (this[i] == element) {  
            return true;  
        }  
    }  
    return false;  
}
;
(function($){
$.fn.extend({
	isValueDuplicate:function(){
		var arr = [];
		var flag = false;
		this.each(function( j ) {
			var v = $(this).val();
			if (arr.contains(v)){
				flag = true;
			}
			arr.push(v);
		});
		return flag;
	}
});	
})(jQuery);


//对datepicker进行扩展,增加清除功能
$(document).ready(function(){
	try{
		$( document ).tooltip();
		$('a[name="attachFileTip"]').attr('title','上传的附件只支持:图片文件(jpg,jpeg,gif),Word文件(doc,docx),Pdf文件(pdf),Rar文件(zip,rar),Excel文件(xls,xlsx),PowerPoint文件(ppt,pptx)。');
		$('a[name="attachFileTip"]').tooltip();
	}catch(err){}
});

//阻止回退键的默认行为
$(document).bind("keydown",function(e){
	if (e.which == 8 ){
		var targetNodeName = '';
		if(e.target && e.target.nodeName){
			targetNodeName =  e.target.nodeName.toLowerCase();
		}
		if((targetNodeName != 'input' && targetNodeName != 'textarea' && targetNodeName != 'password') || e.target.readOnly == true){
			return false;
		}
	  }
});

/**
 * 通过button和链接button中设置的权限属性(属性名为permCheck的格式是"[resKey,]operKey[,hidden|disable]")发起后台鉴权请求,通过后台返回的结果,对按钮或链接进行置灰和隐藏操作
 * @param {Object} url
 * @param {Object} resKey
 * @memberOf {TypeName} 
 */
;
(function( $, undefined ) {
	PermCheck=function(options){
		if(this.initialized && this.initialized === true){
			return;
		}
		this.options = options || {};
		if(this.options.url == undefined){
			this.options.url = ctxPaths+"/resAuth!pageComponentAuth.ajax";
		}
	}
	PermCheck.prototype={
		_setBehavior : function(behavior){
				//判断是原生button还是链接button
				if("button" == $(this).attr("type") || "submit" == $(this).attr("type")){
					if(behavior == 'disable'){
						$(this).attr("disabled",true);		
					 }else{
						$(this).hide();
					 }
				}else{
					var linkButton;
					if('A' == $(this).get(0).tagName){
						linkButton = $(this);
						
					}else{
						linkButton = $(this).find('a');
					}
					if(linkButton.length > 0){
						var aText = linkButton.html();
						if(behavior == 'disable'){
							$('<span>' + aText + '</span>').appendTo($(this).parent()).addClass("graybutton");
							//清除链接
							 linkButton.remove();
							 //批量审批按钮不可见 add by xiaoliangqing
							 $("#ba
pinganwanjia log4j
<?xml version="1.0" encoding="UTF-8" ?>  
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
	<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
	</appender>
	<appender name="SQL_DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/sql/debug.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="DEBUG" />
			<param name="LevelMax" value="DEBUG" />
		</filter>
	</appender>
	<appender name="SQL_INFO" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/sql/info.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="INFO" />
			<param name="LevelMax" value="INFO" />
		</filter>
	</appender>
	<appender name="SQL_ERROR" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/sql/error.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="ERROR" />
			<param name="LevelMax" value="ERROR" />
		</filter>
	</appender>
	<appender name="APPT_DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/code/debug.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="DEBUG" />
			<param name="LevelMax" value="DEBUG" />
		</filter>
	</appender>
	<appender name="APPT_INFO" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/code/info.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="INFO" />
			<param name="LevelMax" value="INFO" />
		</filter>
	</appender>
	<appender name="APPT_ERROR" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/code/error.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="ERROR" />
			<param name="LevelMax" value="ERROR" />
		</filter>
	</appender>
	<appender name="OTHER_DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/other/debug.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="DEBUG" />
			<param name="LevelMax" value="DEBUG" />
		</filter>
	</appender>
	<appender name="OTHER_INFO" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/other/info.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="INFO" />
			<param name="LevelMax" value="INFO" />
		</filter>
	</appender>
	<appender name="OTHER_ERROR" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="/tmp/log/appt/other/error.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] %l - %m%n" />
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="ERROR" />
			<param name="LevelMax" value="ERROR" />
		</filter>
	</appender>
	<logger name="com.pinganwj.clinic" additivity="false">
		<level value="DEBUG" />
		<appender-ref ref="SQL_DEBUG" />
		<appender-ref ref="SQL_INFO" />
		<appender-ref ref="SQL_ERROR" />
	</logger>
	<logger name="com.pinganwj" additivity="false">
		<level value="DEBUG" />
		<appender-ref ref="APPT_DEBUG" />
		<appender-ref ref="APPT_INFO" />
		<appender-ref ref="APPT_ERROR" />
		<appender-ref ref="STDOUT" />
	</logger>
	<logger name="kafka" additivity="true"> 
        <level value="ERROR" />
        <appender-ref ref="STDOUT" />
		<appender-ref ref="APPT_DEBUG" />
		<appender-ref ref="APPT_INFO" />
		<appender-ref ref="APPT_ERROR" />
    </logger>
	<root>
		<level value="DEBUG" />
		<appender-ref ref="OTHER_DEBUG" />
		<appender-ref ref="OTHER_INFO" />
		<appender-ref ref="OTHER_ERROR" />
		<appender-ref ref="STDOUT" />
	</root>
</log4j:configuration>  
分布式锁
package com.pinganwj.biz.appt.appointment.util;

import com.pinganwj.redis.api.RedisNXOperationService;

public class ApptRedisLock {

    private static final int DEFAULT_ACQUIRY_RESOLUTION_MILLIS = 100;

    /**
     * Lock key path.
     */
    private String lockKey;

    /**
     * 锁超时时间,防止线程在入锁以后,无限的执行等待
     */
    private int expireMsecs = 60 * 1000;

    /**
     * 锁等待时间,防止线程饥饿
     */
    private int timeoutMsecs = 10 * 1000;

    private volatile boolean locked = false;
    
    private RedisNXOperationService redisNXOperationService;

    /**
     * Detailed constructor with default acquire timeout 10000 msecs and lock expiration of 60000 msecs.
     *
     * @param lockKey lock key (ex. account:1, ...)
     */
    public ApptRedisLock(RedisNXOperationService redisNXOperationService, String lockKey) {
        this.redisNXOperationService = redisNXOperationService;
        this.lockKey = lockKey + "_appt_lock";
    }

    /**
     * Detailed constructor with default lock expiration of 60000 msecs.
     *
     */
    public ApptRedisLock(RedisNXOperationService redisNXOperationService, String lockKey, int timeoutMsecs) {
        this(redisNXOperationService, lockKey);
        this.timeoutMsecs = timeoutMsecs;
    }

    /**
     * Detailed constructor.
     *
     */
    public ApptRedisLock(RedisNXOperationService redisNXOperationService, String lockKey, int timeoutMsecs, int expireMsecs) {
        this(redisNXOperationService, lockKey, timeoutMsecs);
        this.expireMsecs = expireMsecs;
    }

    /**
     * @return lock key
     */
    public String getLockKey() {
        return lockKey;
    }

    /**
     * 获得 lock.
     * 实现思路: 主要是使用了redis 的setnx命令,缓存了锁.
     * reids缓存的key是锁的key,所有的共享, value是锁的到期时间(注意:这里把过期时间放在value了,没有时间上设置其超时时间)
     * 执行过程:
     * 1.通过setnx尝试设置某个key的值,成功(当前没有这个锁)则返回,成功获得锁
     * 2.锁已经存在则获取锁的到期时间,和当前时间比较,超时的话,则设置新的值
     *
     * @return true if lock is acquired, false acquire timeouted
     * @throws InterruptedException in case of thread interruption
     */
    public synchronized boolean lock() throws InterruptedException {
        int timeout = timeoutMsecs;
        while (timeout >= 0) {
            long expires = System.currentTimeMillis() + expireMsecs + 1;
            String expiresStr = String.valueOf(expires); //锁到期时间
            if (redisNXOperationService.setNX(lockKey, expiresStr)) {
                // lock acquired
                locked = true;
                return true;
            }

            String currentValueStr = redisNXOperationService.get(lockKey); //redis里的时间
            if (currentValueStr != null && Long.parseLong(currentValueStr) < System.currentTimeMillis()) {
                //判断是否为空,不为空的情况下,如果被其他线程设置了值,则第二个条件判断是过不去的
                // lock is expired

                String oldValueStr = redisNXOperationService.getSet(lockKey, expiresStr);
                //获取上一个锁到期时间,并设置现在的锁到期时间,
                //只有一个线程才能获取上一个线上的设置时间,因为jedis.getSet是同步的
                if (oldValueStr != null && oldValueStr.equals(currentValueStr)) {
                    //防止误删(覆盖,因为key是相同的)了他人的锁——这里达不到效果,这里值会被覆盖,但是因为什么相差了很少的时间,所以可以接受

                    //[分布式的情况下]:如过这个时候,多个线程恰好都到了这里,但是只有一个线程的设置值和当前值相同,他才有权利获取锁
                    // lock acquired
                    locked = true;
                    return true;
                }
            }
            timeout -= DEFAULT_ACQUIRY_RESOLUTION_MILLIS;

            /*
                延迟100 毫秒,  这里使用随机时间可能会好一点,可以防止饥饿进程的出现,即,当同时到达多个进程,
                只会有一个进程获得锁,其他的都用同样的频率进行尝试,后面有来了一些进行,也以同样的频率申请锁,这将可能导致前面来的锁得不到满足.
                使用随机的等待时间可以一定程度上保证公平性
             */
            Thread.sleep(DEFAULT_ACQUIRY_RESOLUTION_MILLIS);

        }
        return false;
    }


    /**
     * Acqurired lock release.
     */
    public synchronized void unlock() {
        if (locked) {
        	redisNXOperationService.delete(lockKey);
            locked = false;
        }
    }

}
模板方法设计模式
package com.pinganwj.biz.appt.message.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;
import com.pinganwj.biz.appt.appointment.service.ApptRecordService;
import com.pinganwj.biz.appt.message.util.ApptSendMessageUtils;
import com.pinganwj.biz.appt.message.util.SendWxMessage;
import com.pinganwj.biz.appt.schedule.service.ApptSchedulePamaterService;
import com.pinganwj.biz.appt.schedule.service.ApptScheduleService;
import com.pinganwj.core.base.utils.StringUtil;
import com.pinganwj.core.model.appt.constants.ApptConst;
import com.pinganwj.core.model.appt.constants.ApptParameter;
import com.pinganwj.core.model.appt.constants.ApptStatus;
import com.pinganwj.core.model.appt.db.ApptRecordMessageDto;
import com.pinganwj.core.model.websocket.constants.WebSocketConstants;
import com.pinganwj.core.model.websocket.vo.WebSocketMessageVO;
import com.pinganwj.pub.sms.util.SendMessageUtil;
import com.pinganwj.pub.uc.service.PublicUserService;
import com.pinganwj.pub.websocket.service.WebSocketOperationService;
import com.wanjia.common.json.JsonResponse;
import com.wanjia.common.kafka.KafkaSyncProducer;
import com.wanjia.sms.interior.interfaces.sms.model.req.SendSMSRequest;

/**
 * 消息发送抽象服务类
 * 主要是使用模板方法来实现过程,减少判断 
 * @author LIPENG
 *
 * @date 2017年5月20日 下午4:07:33
 *
 * @version V1.0
 */
public abstract class AbstractMessageSendService implements MessageSendService{
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private ApptScheduleService apptScheduleService;
	@Autowired
	private ApptRecordService apptRecordService;
	
	@Autowired
	private PublicUserService publicUserService;
	
	@Autowired
	protected WebSocketOperationService operationService;
	@Resource
	protected KafkaSyncProducer kafkaSyncProducer;
	
	@Autowired
	private MessageDubboService MessageDubboService;
	
	@Autowired
	protected SendWxMessage sendWxMessage;
	
	@Autowired
	protected ApptSchedulePamaterService apptSchedulePamaterService;
	
	/**
	 * sendMessage
	 */
	@Override
	public void sendMessage(ApptRecordMessageDto apptRecordInfo) {
		if(apptRecordInfo == null){
			return;
		}
		try {
			ApptConst.OPERATE_ENUM operateEnum =apptRecordInfo.getOperateType();
			Map<String, String> recordInfo=getRecordInfo(apptRecordInfo);
			//额外信息:添加支付时间
			recordInfo.put("payDateTimeStr", apptRecordInfo.getPayDateTimeStr());
			switch (operateEnum) {
			case CANCLE:						//取消
				sendCanleMessage(recordInfo);
				break;
			case CREATE:						//创建
				sendCreateApptMessage(recordInfo);
				break;
			case UPDATE:						//未确认时更新
				sendUpdateApptMssage(recordInfo);
				break;
			case CONFIRM_APPT:					//确认预约
				sendConfirmApptMessage(recordInfo);
				break;
			case CONFIRM_TREATMENT:				//确认就诊
				sendConfirmTreatmentMessage(recordInfo);
				break;
			case OVERDUR:						//过期
				sendOverDueMessage(recordInfo);
				break;
			case MISS:							//爽约
				sendMissMessage(recordInfo);
				break;
			case EVALUATE:						//评价
				sendEvalutaionMessage(recordInfo);
				break;
			case REPLY:							//回复
				sendReplyMessage(recordInfo);
				break;
			case CONFIRMED_UPDATE:				//确认后编辑
				sendConfirmApptMessage(recordInfo);
				break;
			default:
				break;
			}
		} catch (Exception e) {
			logger.error("发送消息出错",e);
		}
	}
	
	/**
	 * 发送取消预约信息
	 * 逻辑:
	 * 	1. 个人中心 :  站内信(诊所中心)、App推送、微信推送
	 *	2. 微信:   站内信(诊所中心)、App推送、微信推送
	 *	3. 客服: 站内信(诊所中心、个人)、App推送、短信(个人)
	 *	4. App: 站内信(个人)、短信(个人)、微信推送
	 *	5. 云诊所: 站内信(个人)、短信(个人)、微信推送
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendCanleMessage
	 * boolean
	 */
	protected abstract boolean sendCanleMessage(Map<String,String> recordInfo);
	
	/**
	 * 发送创建预约信息
	 * 逻辑:
	 *  普通预约和健康产品预约一致
	 *  1. 个人中心: 站内信(诊所中心、个人中心)、短信(诊所)、App推送
	 *	2. 微信: 站内信(诊所中心、个人中心)、短信(诊所、个人)、App推送
	 *	3. 客服: 站内信(诊所中心)、短信(诊所)、App推送
	 * boolean
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 */
	protected abstract boolean sendCreateApptMessage(Map<String,String> recordInfo);
	

	
	
	/****
	 * 未确认预约编辑预约信息
	 * 逻辑 
	 * 
	 *  1. 个人中心: 站内信(诊所中心、个人中心)、短信(诊所)、App推送
	 *	2. 微信 : 站内信(诊所中心、个人中心)、短信(诊所、个人)、App推送
	 *	3. 客服 : 站内信(诊所)、短信(诊所)、App推送
	 *	4. App :站内信(个人)、短信(个人)、微信推送
	 *	5. 云诊所:站内信(个人)、短信(个人)、微信推送
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendUpdateApptMssage
	 * @return
	 * boolean
	 *
	 */
	protected abstract boolean sendUpdateApptMssage(Map<String,String> recordInfo);
	
	
	/****
	 * 确认预约后编辑预约
	 * 逻辑
	 * A . 健康产品预约
	 *  1 . App :站内信(个人)、短信(个人)、微信推送
	 *	2. 云诊所:站内信(个人)、短信(个人)、微信推送
	 * B . 普通预约
	 *   1 . App:站内信(个人)、微信推送
	 *	 2. 云诊所:站内信(个人)、微信推送
	 * @Description: sendUpdateApptMssage
	 * @return
	 * boolean
	 *
	 */
	protected abstract boolean sendConfirmedUpdateApptMssage(Map<String,String> recordInfo);
	
	/**
	 * 发送确认预约信息
	 * 逻辑:
	 * 1. App : 站内信(个人)、短信(个人)、微信
	 * 2. 云诊所: 站内信(个人)、短信(个人)、微信
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendConfirmApptMessage
	 * void
	 */
	protected abstract boolean sendConfirmApptMessage(Map<String,String> recordInfo);
	
	
	
	/**
	 * 发送确认就诊信息
	 * 逻辑
	 *	1. App:站内信(个人)、短信(个人)、微信推送
	 *	2. 云诊所:站内信(个人)、短信(个人)、微信推送
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendConfirmTreatmentMessage
	 * void
	 *
	 */
	protected abstract boolean sendConfirmTreatmentMessage(Map<String,String> recordInfo);
	
	/**
	 * 过期信息发送信息
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendOverDueMessage
	 * void
	 *
	 */
	protected  boolean sendOverDueMessage(Map<String,String> recordInfo){
		return true;
	}
	
	
	/**
	 * 评价信息
	 * 逻辑:
	 * 1. 个人中心 :  站内信(诊所中心)、短信(诊所)、App推送
	 * 2. 微信:站内信(诊所中心)、短信(诊所)、App推送
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 * @Description: sendEvalutaionMessage
	 * boolean
	 *
	 */
	protected boolean sendEvalutaionMessage(Map<String,String> recordInfo){
		return false;
	}
	
	
	/**
	 * 回复信息
	 * 逻辑:
	 * 1. App : 站内信(个人)
	 * 2. 云诊所: 站内信(个人)
	 * boolean
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 *
	 */
	protected boolean sendReplyMessage(Map<String,String> recordInfo){
		return false;
	}
	
	
	/**
	 * 爽约预约信息
	 * boolean
	 * @param apptRecordInfo 
	 * @param msssageDto 
	 *
	 */
	protected boolean sendMissMessage(Map<String,String> recordInfo){
		return false;
	}
	
	/**
	 * 发送推送消息给云诊所
	 * @Description: sendWebSocketMessage
	 * @param clinicId void
	 *
	 */
	protected void sendWebSocketMessage(String clinicId){
		WebSocketMessageVO webSocketMessage=new WebSocketMessageVO();
		webSocketMessage.setSendTo(clinicId);
		webSocketMessage.setType(WebSocketConstants.MESSAGE_TYPE_APPT);
		operationService.producerMessage(this.kafkaSyncProducer, webSocketMessage);
	}
	
	protected Map<String, String> getRecordInfo(ApptRecordMessageDto apptRecordInfo){
		if(StringUtils.isNotBlank(apptRecordInfo.getApptOrderCode())){
			return apptRecordService.getApptRecordByApptOrderCode(apptRecordInfo.getApptOrderCode());
		}else if(StringUtils.isNotBlank(apptRecordInfo.getRecordId())){
			return apptRecordService.getRecordInfoByRecordId(apptRecordInfo.getRecordId());
		}
		return null;
	}
	
	protected void sendClinicNetMessage(String messageType,Map<String, String> recordInfo){
		// 会员ID
		String clinicId = StringUtil.trimObj(recordInfo.get("CLINIC_ID"));
		String apptFlag = StringUtil.trimObj(recordInfo.get("APPT_FLAG"));
		if(StringUtils.isNotBlank(clinicId)){
			Map<String, Object> message = ApptSendMessageUtils.generateMessage(recordInfo);
			message.remove("memberId");
			logger.info("sendNetMessage() 站内信params:" + JSON.toJSONString(message));
			new SendMessageUtil(MessageDubboService.getMessageService(), message, messageType, apptFlag).sendBookingMessageByThread();
		}
	}
	
	protected void sendUserNetMessage(String messageType,Map<String, String> recordInfo){
		// 会员ID
		String userId = StringUtil.trimObj(recordInfo.get("USER_ID"));
		String apptFlag = StringUtil.trimObj(recordInfo.get("APPT_FLAG"));
		if(StringUtils.isNotBlank(userId)){
			Map<String, Object> message = ApptSendMessageUtils.generateMessage(recordInfo);
			message.remove("clinicId");
			logger.info("sendNetMessage() 站内信params:" + JSON.toJSONString(message));
			new SendMessageUtil(MessageDubboService.getMessageService(), message, messageType, apptFlag).sendBookingMessageByThread();
		}
	}
	
	/**
	 * 发送管理员短信
	 * @Description: sendAdminSmsMessage
	 * @param recordInfo void
	 *
	 */
	protected void sendAdminSmsMessage(Map<String, String> recordInfo,String template){
		String clinicId = StringUtil.trimObj(recordInfo.get("CLINIC_ID"));
		//获取诊所预约手机号
		JsonResponse<List<String>>  response = MessageDubboService.getClinicInfoService().getOrderMobileByClinicId(clinicId); 
		if(response.getStatus() == JsonResponse.Status.SUCCESS){
			List<String> phontList = response.getResult(); 
			if(!CollectionUtils.isEmpty(phontList)){
				SendSMSRequest sendSMSRequest = ApptSendMessageUtils.generateSmsRequest(recordInfo, phontList.get(0), template);
				logger.info("sendAdminSmsMessage() 诊所短信params1:" + JSON.toJSONString(sendSMSRequest));
				new SendMessageUtil(MessageDubboService.getSmsClientService(), sendSMSRequest, 0).sendSmsByThread();
			}
		}
	}
	
	/**
	 * 发送用户短信
	 * @Description: sendUserSmsMessage
	 * @param recordInfo void
	 *
	 */
	protected void sendUserSmsMessage(Map<String, String> recordInfo,String template){
		String mobile_phone_number = StringUtil.trimObj(recordInfo.get("VISIT_MOBILE"));
		// 给用户发短信
		if (isSendSms(recordInfo)&&StringUtils.isNotBlank(mobile_phone_number)) {
			SendSMSRequest sendSMSRequest = ApptSendMessageUtils.generateSmsRequest(recordInfo, mobile_phone_number, template);
			logger.info("sendUserSmsMessage() 诊所短信params1:" + JSON.toJSONString(sendSMSRequest));
			new SendMessageUtil(MessageDubboService.getSmsClientService(), sendSMSRequest, 0).sendSmsByThread();
		}
	}
	
	/**
	 * 是否发送短信给用户
	 * @Description: isSendSms
	 * @param recordInfo
	 * @return boolean
	 *
	 */
	private boolean isSendSms(Map<String, String> recordInfo){
		String clinicId = StringUtil.trimObj(recordInfo.get("CLINIC_ID"));
		String apptFlag = StringUtil.trimObj(recordInfo.get("APPT_FLAG"));
		//健康产品都发
		if(ApptStatus.APPT_FLAG_PRODUCT.equals(apptFlag)){
			return true;
		}
		String isSend=apptSchedulePamaterService.getParamValueByCode(ApptParameter.ParameterCode.APPT_SMS_FLAG, clinicId);
		if(StringUtils.isBlank(isSend)){
			return true;
		}else if("2".equals(isSend)){
			logger.info("该诊所设置为不需要发送短信,clinicId:{}",clinicId);
			return false;
		}
		return true;
	}
	
}


/**
 * @author ZHANGGUANGCHAO691
 * @date 2017年5月19日 下午8:05:13
 * @version V1.0   
 */
public interface MessageSendService {

	/**  
	 * @Description: sendMessageHandle
	 * @param msssageDto
	 * @param apptRecordInfo
	 * void
	 * 
	*/
	void sendMessage(ApptRecordMessageDto apptRecordInfo);

}

/**
 * 消息发送容器,由于此处MessageSend服务是无状态的,所以使用上下文获取
 * 如果是有状态的,则需要使用简单工厂模式来获取实例化服务
 * @author LIPENG
 *
 * @date 2017年5月20日 下午5:16:28
 *
 * @version V1.0
 */
public final class MessageSendContext {

	private MessageSendContext() {
		//不允许创建实例
	}
	/**
	 * 根据来源获取对应的实现类,方便扩展
	 * @Description: getMessageSendService
	 * @param plat
	 * @return
	 * MessageSendService
	 *
	 */
	public static MessageSendService getMessageSendService(String plat){
		PLAT_ENUM platEnum=PLAT_ENUM.getPlatEnum(plat);
		if(platEnum==null){
			return ApplicationUtil.getBean("cloudPcMessageSendService");
		}
		return ApplicationUtil.getBean(platEnum.getMessageServiceName());
	}
	
}


/**
 * 微信消息发送服务
 * @author LIPENG
 *
 * @date 2017年5月20日 下午5:00:17
 *
 * @version V1.0
 */
@Service("weChatScrmMessageSendService")
public class WeChatScrmMessageSendServiceImpl extends AbstractMessageSendService implements MessageSendService{
	
	@Override
	protected boolean sendCreateApptMessage(Map<String,String> recordInfo) {
		int isNeedPay = StringUtil.trimObjDefaultInt(recordInfo.get("IS_NEED_PAY"), 0);
		int payStatus = StringUtil.trimObjDefaultInt(recordInfo.get("PAY_STATUS"), 0);
		//判断当前的预约是否需要支付,若需要支付,只有在支付成功时才会发送相关信息
		if(isNeedPay == AppointmentConstants.APPT_NEED_PAY_YES && payStatus == AppointmentConstants.APPT_PAY_STATUS_FAILURE){
			return false;
		}
		//发送站内信
		sendClinicNetMessage(ApptStatus.APPT_ADDNEWRECORD, recordInfo);
		//发送用户短信
		sendAdminSmsMessage(recordInfo,SendSMSRequest.JK160930009);
		// 发送微信消息
		sendWxMessage.sendScrmAddRegMsg(recordInfo);
		//发送推送消息给云诊所
		sendWebSocketMessage(recordInfo.get("CLINIC_ID"));
		return true;
	}

	@Override
	protected boolean sendUpdateApptMssage(Map<String,String> recordInfo) {
		//发送站内信
		sendClinicNetMessage(ApptStatus.APPT_MODIFYBOOKING, recordInfo);
		return true;
	}

	@Override
	protected boolean sendConfirmedUpdateApptMssage(Map<String,String> recordInfo) {
		//暂时不能修改
		return true;
	}
	
	@Override
	protected boolean sendCanleMessage(Map<String,String> recordInfo) {
		//发送站内信
		sendClinicNetMessage(ApptStatus.APPT_CANCELBOOKING, recordInfo);
		//发送微信消息
		sendWxMessage.sendScrmCancelRegMsg(recordInfo);
		return true;
	}

	@Override
	protected boolean sendConfirmApptMessage(Map<String,String> recordInfo) {
		//暂时无法确认
		return true;
	}

	@Override
	protected boolean sendConfirmTreatmentMessage(Map<String,String> recordInfo) {
		//暂时无法确认就诊
		return true;
	}

}

teamviewer
ID:784 656 924
密码:4641
maven配置 maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.pinganwj</groupId>
	<artifactId>pinganwj</artifactId><version>2.0.2</version>
	<packaging>pom</packaging>
	<name>pinganwj</name>
  <modules>
		<module>../pinganwj-core-base</module><!-- 核心基础包 -->
		<module>../pinganwj-core-model</module><!-- 核心对象定义包 -->
		<module>../pinganwj-core-db</module><!-- 核心数据库封装 -->
		<module>../pinganwj-api-redis</module><!-- redis dubbo接口定义 -->
		<module>../pinganwj-core-utils</module><!-- 核心工具包 -->
		<module>../pinganwj-api-operation</module><!-- 对运营平台接口定义 -->
		<module>../pinganwj-api-open</module><!-- 开放平台 dubbo接口定义 -->
		<module>../pinganwj-api-app2b</module><!-- 对B端APP接口定义 -->
		<module>../pinganwj-api-appt</module><!-- 诊前相关接口定义 包含预约、分诊、满意度、登记、健康服务产品等 对运营平台 对B端APP 对微信 -->
		<module>../pinganwj-api-wechat</module><!-- 微信对外暴露接口定义 -->
		<module>../pinganwj-api-IM</module><!-- 环信IM对外暴露接口定义 -->
		<module>../pinganwj-api-3rd</module><!-- 对第三方接口定义 对商保 对品简 对瑞美LIS 对寿险 -->
 		<module>../pinganwj-api-uc</module><!-- 用户模块暴露接口 -->
 		<module>../pinganwj-api-scrm</module><!-- 微信SCRM dubbo接口定义 -->
		<module>../pinganwj-public-service</module><!-- 公共服务,为服务层底层服务,不可依赖业务服务包 -->
		<module>../pinganwj-public-mdc-service</module><!-- 公共数据字典服务层,底层服务 -->
		<module>../pinganwj-public-log-service</module><!-- 公共日志服务层 -->
<!--  		<module>../pinganwj-apiDoc-service</module>API文档服务层 -->
		<module>../pinganwj-biz-mdc-service</module><!-- 业务数据字典服务层 -->
		<module>../pinganwj-biz-permission-service</module><!-- 业务权限服务层 -->
		<module>../pinganwj-biz-uc-service</module><!-- 业务用户服务层 -->
		<module>../pinganwj-biz-setting-service</module><!-- 业务基础设置层 -->
		<module>../pinganwj-biz-feeCI-service</module><!-- 业务收费商保相关 -->
		<module>../pinganwj-biz-feeMI-service</module><!-- 业务收费医保相关 -->
		<module>../pinganwj-biz-mec-service</module><!-- 业务体检相关 -->
		<module>../pinganwj-biz-adt-service</module><!-- 业务护士站服务层  -->
		<module>../pinganwj-biz-appt-service</module><!-- 业务预约服务层 包含预约、分诊、满意度、登记、健康服务产品等 --> 
		<module>../pinganwj-biz-crm-service</module><!-- 业务客户管理服务层   -->
		<module>../pinganwj-biz-dentist-service</module><!-- 业务齿科特殊服务层 加工 消毒  咨询 --> 
		<module>../pinganwj-biz-wms-service</module><!-- 业务库房管理服务层 -->
		<module>../pinganwj-biz-dws-service</module><!-- 业务医生工作站 -->
		<module>../pinganwj-biz-ext-service</module><!-- 业务外延服务 扩展服务 -->
		<module>../pinganwj-biz-kpiReport-service</module><!-- KPI报表 -->
		<module>../pinganwj-biz-report-service</module><!-- 统计报表 -->
		<module>../pinganwj-biz-wechat-service</module><!-- 业务微信服务  -->
 		<module>../pinganwj-wechat-utils</module><!-- 业务微信服务 -->
		<module>../pinganwj-biz-wechatAdmin-service</module><!-- 业务微信管理服务 -->
	    <module>../pinganwj-biz-admin-service</module>  <!-- 业务管理后台服务 -->
		<module>../pinganwj-biz-fee-service</module><!-- 业务收费管理服务 -->
		<module>../pinganwj-public-web-controller</module><!-- 公用contorller -->
		<module>../pinganwj-biz-scrm-service</module><!-- SCRM -->
		<module>../pinganwj-biz-IM-service</module><!-- SCRM -->
		<module>../pinganwj-combination-service</module><!-- 	服务组合服务 -->
	</modules>

	<properties>
		<jdk.verison>1.8</jdk.verison>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
		<!-- 发布版本号 -->
		<public.version.number>2.0.2</public.version.number>
		<publish.version>2.0.2</publish.version>
		<!-- 统一版本号管理 start -->
		<springframework.version>4.2.4.RELEASE</springframework.version><!-- springframework -->
		
		<log4j.version>1.2.17</log4j.version><!-- log4j -->
		<slf4j-api.version>1.7.25</slf4j-api.version><!-- slf4j -->
		<slf4j-log4j12.version>1.7.25</slf4j-log4j12.version><!-- slf4j-log4j12 -->
		
		<fastjson.version>1.2.29</fastjson.version><!-- fastjson -->
		<jackson-core.version>2.6.4</jackson-core.version><!-- jackson -->
		<jackson-databind.version>2.6.4</jackson-databind.version><!-- jackson -->
		<jackson-mapper-asl.version>1.9.13</jackson-mapper-asl.version><!-- jackson -->
		
		<aspectjrt.version>1.8.6</aspectjrt.version><!-- aop -->
		<aspectjweaver.version>1.8.6</aspectjweaver.version><!-- aop -->
		<aopalliance.version>1.0</aopalliance.version><!-- aop -->
		<druid.version>1.0.13</druid.version><!-- db -->
		<ojdbc.version>14</ojdbc.version><!-- db -->
		<mysql-connector-java.version>5.1.30</mysql-connector-java.version><!-- mysql --><!-- db -->
		<cors-filter.version>2.4</cors-filter.version><!-- cors  解决跨域问题 -->
		
		<commons-codec.version>1.9</commons-codec.version><!-- 其它 -->
		<commons-io.version>1.3.2</commons-io.version><!-- 其它 -->
		<commons-logging.version>1.2</commons-logging.version><!-- 其它 -->
		<commons-lang3.version>3.3.1</commons-lang3.version><!-- 其它 -->
		<commons-fileupload.version>1.3</commons-fileupload.version><!-- 其它 -->
		<commons-httpclient.version>3.1</commons-httpclient.version><!-- https -->
		<commons-collections.version>3.2.1</commons-collections.version>
		<commons-lang.version>2.5</commons-lang.version><!-- SSO CAS -->
		
		<httpclient.version>4.5</httpclient.version><!-- 新版本上传文件需要用到 -->
		<httpmime.version>4.5.2</httpmime.version><!-- 新版本上传文件需要用到 -->
		<httpcore.version>4.4</httpcore.version><!-- 新版本上传文件需要用到 -->
		<junit.version>4.10</junit.version>	<!--junit -->
		<pinyin4j.version>2.5.0</pinyin4j.version>
		<poi.version>3.12</poi.version>
		<jxls-core.version>1.0.6</jxls-core.version>
		<EasyXls.version>1.1.0</EasyXls.version>
		<swagger-annotations.version>1.5.13</swagger-annotations.version>
		<bcprov-jdk15on.version>1.55</bcprov-jdk15on.version>
		
		<servlet-api.version>2.5</servlet-api.version><!-- servlets -->
		<javax.servlet-api.version>3.1.0</javax.servlet-api.version><!-- servlets -->
		<jsp-api.version>2.1</jsp-api.version><!-- servlets -->
		<jstl.version>1.2</jstl.version><!-- servlets -->
		
		<mybatis.version>3.3.0</mybatis.version><!-- mybatis -->
		<mybatis-spring.version>1.2.4</mybatis-spring.version><!-- mybatis -->
		<guava.version>16.0.1</guava.version>
		<xstream.version>1.2.2</xstream.version>
		<jdom.version>1.0</jdom.version>
		<mail.version>1.4.1</mail.version>
		<dom4j.version>1.6.1</dom4j.version>
		
		<kryo.version>2.24.0</kryo.version>	<!-- kryo -->
		<kryo-serializers.version>0.26</kryo-serializers.version>	<!-- kryo -->
		<zookeeper.version>3.4.6</zookeeper.version><!-- zookeeper -->
		<zkclient.version>0.7</zkclient.version><!-- zookeeper -->
		<dubbo.version>2.8.4</dubbo.version><!-- dubbo -->
		<swagger-annotations.version>1.5.13</swagger-annotations.version><!-- swagger -->
		<pinganwj-api-redis.version>1.0</pinganwj-api-redis.version><!-- pinganwj redis -->
		<javassist.version>3.20.0-GA</javassist.version>
		<jedis.version>2.8.0</jedis.version>
		<spring-data-redis.version>1.6.4.RELEASE</spring-data-redis.version>
		<!-- wanjia 上海  shanghai -->
		<wwwcms-service-interface.version>1.0.0.RELEASE</wwwcms-service-interface.version><!-- 网站  -->
		<college-service-interface.version>1.0.0.RELEASE</college-service-interface.version><!-- 学院  -->
		<tanlent-service-interface.version>1.0.0.RELEASE</tanlent-service-interface.version><!-- 人才  -->
		<product-old-service-interface.version>1.0.0.RELEASE</product-old-service-interface.version><!-- 产品  -->
		<order-service-interface.version>1.0.0.RELEASE</order-service-interface.version><!-- 订单  -->
		<external-service-interface.version>1.0.0.RELEASE</external-service-interface.version>	<!-- 扩展  -->
		<sso-service-interface.version>1.0.0.RELEASE</sso-service-interface.version>	<!-- 单点登录  -->
		<common-service-interface.version>1.0.0.RELEASE</common-service-interface.version><!-- 通用  -->
		<clinic-service-interface.version>1.0.3.RELEASE</clinic-service-interface.version><!-- 诊所  -->
		<member-service-interface.version>1.0.0.RELEASE</member-service-interface.version><!-- 会员  -->
		<internal-interface-dubbo.version>1.0.0.RELEASE</internal-interface-dubbo.version>
		<wanjia-pay-server-dubbo.version>1.0.7.RELEASE</wanjia-pay-server-dubbo.version><!-- 支付  -->
		<cas-client-core.version>3.2.1</cas-client-core.version><!-- SSO CAS -->
		<wanjia-sso-client-jar.version>3.0.2-RELEASE</wanjia-sso-client-jar.version><!-- SSO CAS -->
		<wanjia-http-jar.version>1.0.5.RELEASE</wanjia-http-jar.version>
		<wanjia-message-service-dubbo.version>1.0.2.RELEASE</wanjia-message-service-dubbo.version>
		<wanjia-common-tools.version>1.0.5.RELEASE</wanjia-common-tools.version>
		<sms-interface-dubbo.version>1.3.1.RELEASE</sms-interface-dubbo.version><!-- kafka -->
		<wanjia-common-kafka.version>1.0.0.RELEASE</wanjia-common-kafka.version><!-- kafka -->
		<product-service-interface.version>1.0.2.RELEASE</product-service-interface.version><!--健康产品 -->
		<org.quartz.version>2.2.1</org.quartz.version><!--健康产品 -->
		
		<!-- 统一版本号管理 end -->
	</properties>

	<dependencyManagement>
	<dependencies>
		<!-- quartz -->
		<dependency>
		    <groupId>org.quartz-scheduler</groupId>
		    <artifactId>quartz</artifactId>
		    <version>${org.quartz.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.quartz-scheduler</groupId>
		    <artifactId>quartz-jobs</artifactId>
		    <version>${org.quartz.version}</version>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>${log4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4j-api.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j-log4j12.version}</version>
		</dependency>
		<!-- spring framework -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-oxm</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-redis</artifactId>
			<version>${spring-data-redis.version}</version>
		</dependency>

		<!-- fastjson -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>${fastjson.version}</version>
		</dependency>

		<!-- jackson -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>${jackson-core.version}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson-databind.version}</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-asl</artifactId>
			<version>${jackson-mapper-asl.version}</version>
		</dependency>

		<!-- aop -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>${aspectjrt.version}</version>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>${aspectjweaver.version}</version>
		</dependency>
		<dependency>
			<groupId>aopalliance</groupId>
			<artifactId>aopalliance</artifactId>
			<version>${aopalliance.version}</version>
		</dependency>

		<!-- db -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>${druid.version}</version>
		</dependency>
		<dependency>
			<groupId>ojdbc</groupId>
			<artifactId>ojdbc</artifactId>
			<version>${ojdbc.version}</version>
		</dependency>
		<!-- kafka -->
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>sms-interface-dubbo</artifactId>
			<version>${sms-interface-dubbo.version}</version>
		</dependency>
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>wanjia-common-kafka</artifactId>
			<version>${wanjia-common-kafka.version}</version>
		</dependency>
		<!-- cors -->
		<dependency>
			<groupId>com.thetransactioncompany</groupId>
			<artifactId>cors-filter</artifactId>
			<version>${cors-filter.version}</version>
		</dependency>
		<!-- 其它 -->
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
			<version>${commons-codec.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io.version}</version>
		</dependency>
		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>${commons-logging.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>${commons-lang3.version}</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>${commons-fileupload.version}</version>
		</dependency>
		<!-- test -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
		</dependency>
		<!-- https -->
		<dependency>
			<groupId>commons-httpclient</groupId>
			<artifactId>commons-httpclient</artifactId>
			<version>${commons-httpclient.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>${httpclient.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.javassist</groupId>
		    <artifactId>javassist</artifactId>
		    <version>${javassist.version}</version>
		</dependency>
		<!-- 新版本上传文件需要用到 -->
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpmime</artifactId>
			<version>${httpmime.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpcore</artifactId>
			<version>${httpcore.version}</version>
		</dependency>
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>${commons-collections.version}</version>
		</dependency>
		<dependency>
			<groupId>com.belerweb</groupId>
			<artifactId>pinyin4j</artifactId>
			<version>${pinyin4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>${poi.version}</version>
		</dependency>
		<dependency>
			<groupId>net.sf.jxls</groupId>
			<artifactId>jxls-core</artifactId>
			<version>${jxls-core.version}</version>
		</dependency>
		<dependency>
			<groupId>com.github.abel533</groupId>
			<artifactId>EasyXls</artifactId>
			<version>${EasyXls.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.bouncycastle</groupId>
  		    <artifactId>bcprov-jdk15on</artifactId>
		    <version>${bcprov-jdk15on.version}</version>
		</dependency>
		<!-- servlets -->
		<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet-api.version}</version>
            <scope>provided</scope>
        </dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>${javax.servlet-api.version}</version>
		</dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
            <scope>runtime</scope>
        </dependency>
		<!-- mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>${mybatis.version}</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>${mybatis-spring.version}</version>
		</dependency>
		<!-- mysql -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql-connector-java.version}</version>
		</dependency>
		
		<dependency>
		    <groupId>com.google.guava</groupId>
		    <artifactId>guava</artifactId>
		    <version>${guava.version}</version>
		</dependency>
		
		<dependency>
			<groupId>xstream</groupId>
			<artifactId>xstream</artifactId>
			<version>${xstream.version}</version>
		</dependency>
		<dependency>
			<groupId>jdom</groupId>
			<artifactId>jdom</artifactId>
			<version>${jdom.version}</version>
		</dependency>
		<dependency>
		    <groupId>javax.mail</groupId>
		    <artifactId>mail</artifactId>
		    <version>${mail.version}</version>
		</dependency>
		<dependency>
		    <groupId>dom4j</groupId>
		    <artifactId>dom4j</artifactId>
		    <version>${dom4j.version}</version>
		</dependency>
		<!-- kryo -->
		<dependency>
			<groupId>com.esotericsoftware.kryo</groupId>
			<artifactId>kryo</artifactId>
			<version>${kryo.version}</version>
		</dependency>
		<dependency>
			<groupId>de.javakaffee</groupId>
			<artifactId>kryo-serializers</artifactId>
			<version>${kryo-serializers.version}</version>
		</dependency>
		<!-- zookeeper -->
		<dependency>
			<groupId>org.apache.zookeeper</groupId>
			<artifactId>zookeeper</artifactId>
			<version>${zookeeper.version}</version>
		</dependency>
		<dependency>
			<groupId>com.101tec</groupId>
			<artifactId>zkclient</artifactId>
			<version>${zkclient.version}</version>
		</dependency>
<!-- 		<dependency> -->
<!--  			<groupId>com.github.sgroschupf</groupId> -->
<!--  			<artifactId>zkclient</artifactId> -->
<!--  			<version>0.1</version> -->
<!--  		</dependency> -->
		<!-- dubbo -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
			<version>${dubbo.version}</version>
		</dependency>
		<!-- swagger -->
		<dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger-annotations.version}</version>
        </dependency>
        <!-- jedis -->
        <dependency>
			<groupId>redis.clients</groupId>
			<artifactId>jedis</artifactId>
			<version>${jedis.version}</version>
		</dependency>
        
		<!-- pinganwj模块依赖包 -->
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-core-base</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-core-model</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-core-db</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-redis</artifactId>
			<version>${pinganwj-api-redis.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-core-utils</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-operation</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-app2b</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-appt</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-wechat</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-3rd</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-open</artifactId>
			<version>${publish.version}</version>
		</dependency>		
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-uc</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-scrm</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-wechatClinic</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
 			<groupId>com.pinganwj</groupId>
 			<artifactId>pinganwj-public-web-controller</artifactId>
 			<version>${publish.version}</version>
 		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-public-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-public-mdc-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-public-log-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-apiDoc-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-kpiReport-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-permission-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-report-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-uc-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-appt-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-crm-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-dentist-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-dws-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-feeMI-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-mec-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-ext-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-fee-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-feeCI-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-mdc-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-setting-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-wechat-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-IM-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-wechat-utils</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-wechatAdmin-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-admin-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-adt-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-wms-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-combination-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-biz-scrm-service</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<dependency>
			<groupId>com.pinganwj</groupId>
			<artifactId>pinganwj-api-IM</artifactId>
			<version>${publish.version}</version>
		</dependency>
		<!--<dependency>-->
			<!--<groupId>com.pinganwj</groupId>-->
			<!--<artifactId>pinganwj-api-3rd</artifactId>-->
			<!--<version>${publish.version}</version>-->
		<!--</dependency>-->
		<!--<dependency>-->
			<!--<groupId>com.pinganwj</groupId>-->
			<!--<artifactId>pinganwj-public-web-controller</artifactId>-->
			<!--<version>${publish.version}</version>-->
		<!--</dependency>-->
		<!-- wanjia 上海  shanghai                                           wanjia 上海  shanghai                wanjia 上海  shanghai  -->
		<!-- 网站  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>wwwcms-service-interface</artifactId>
		    <version>${wwwcms-service-interface.version}</version>
		</dependency>	
		<!-- 学院  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>college-service-interface</artifactId>
		    <version>${college-service-interface.version}</version>
		</dependency>
		<!-- 人才  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>tanlent-service-interface</artifactId>
		    <version>${tanlent-service-interface.version}</version>
		</dependency>
		<!-- 产品  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>product-old-service-interface</artifactId>
		    <version>${product-old-service-interface.version}</version>
		</dependency>
		<!-- 订单  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>order-service-interface</artifactId>
		    <version>${order-service-interface.version}</version>
		</dependency>
		<!-- 扩展  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>external-service-interface</artifactId>
		    <version>${external-service-interface.version}</version>
		</dependency>
		<!-- 单点登录  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>sso-service-interface</artifactId>
		    <version>${sso-service-interface.version}</version>
		</dependency>
		<!-- 通用  -->
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>common-service-interface</artifactId>
		    <version>${common-service-interface.version}</version>
		</dependency>
		<!-- 诊所  -->
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>clinic-service-interface</artifactId>
			<version>${clinic-service-interface.version}</version>
		</dependency>
		<!-- 会员  -->
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>member-service-interface</artifactId>
			<version>${member-service-interface.version}</version>
		</dependency>
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>product-service-interface</artifactId>
			<version>${product-service-interface.version}</version>
		</dependency>
		<dependency>
            <groupId>com.wanjia</groupId>
            <artifactId>internal-interface-dubbo</artifactId>
            <version>${internal-interface-dubbo.version}</version>
        </dependency>
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>wanjia-pay-server-dubbo</artifactId>
			<version>${wanjia-pay-server-dubbo.version}</version>
		</dependency>
		 <dependency>
	        <groupId>com.wanjia</groupId>
	        <artifactId>wanjia-http-jar</artifactId>
	        <version>${wanjia-http-jar.version}</version>
		</dependency>
		<!-- SSO CAS -->
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>${commons-lang.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jasig.cas.client</groupId>
			<artifactId>cas-client-core</artifactId>
			<version>${cas-client-core.version}</version>
		</dependency>
		<dependency>
			<groupId>com.wanjia</groupId>
			<artifactId>wanjia-sso-client-jar</artifactId>
			<version>${wanjia-sso-client-jar.version}</version>
		</dependency>
		
		<dependency>
		    <groupId>com.wanjia</groupId>
		    <artifactId>wanjia-message-service-dubbo</artifactId>
		    <version>${wanjia-message-service-dubbo.version}</version>
		</dependency>
		<dependency>            
            <groupId>com.wanjia</groupId>            
            <artifactId>wanjia-common-tools</artifactId>            
            <version>${wanjia-common-tools.version}</version>        
        </dependency>
          <dependency>            
           	<groupId>com.wanjia</groupId>
			<artifactId>wanjia-common</artifactId>
			<version>1.0.1.RELEASE</version>     
        </dependency>
	</dependencies>
</dependencyManagement>
    
    <dependencies>
        <!-- pinganwj 的所有公用jar包均需在这里管理,统一jar包版本,避免版本冲突问题 -->
        <!-- log -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <!-- spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>

        <!-- fastjson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>

        <!-- jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
        </dependency>

        <!-- aop -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
        </dependency>

        <!-- db -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
        </dependency>
        <!-- dubbo -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
		</dependency>
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>ojdbc</artifactId>
        </dependency>
        <!-- cors -->
        <dependency>
            <groupId>com.thetransactioncompany</groupId>
            <artifactId>cors-filter</artifactId>
        </dependency>

        <!-- 其它 -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>
        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
    </dependencies>
	<!-- 私服 -->
	<distributionManagement>
		<repository>
			<id>releases</id>
			<url>http://172.20.51.24:8081/nexus/content/repositories/releases</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<url>http://172.20.51.24:8081/nexus/content/repositories/snapshots</url>
			<uniqueVersion>false</uniqueVersion>
		</snapshotRepository>
	</distributionManagement>

	<build>
		<finalName>${project.artifactId}-${project.version}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
			<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                     <threshold>High</threshold>
                     <effort>Default</effort>
                     <findbugsXmlOutput>true</findbugsXmlOutput>
                     <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                     <xmlOutput>true</xmlOutput>
                     <formats><format>html</format></formats>
                     <findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
                </configuration>
             </plugin>
<!-- 			<plugin> -->
<!-- 				<groupId>org.apache.maven.plugins</groupId> -->
<!-- 				<artifactId>maven-source-plugin</artifactId> -->
<!-- 				<version>3.0.1</version> -->
<!-- 				<executions> -->
<!-- 					<execution> -->
<!-- 						<id>attach-sources</id> -->
<!-- 						<goals> -->
<!-- 							<goal>jar-no-fork</goal> -->
<!-- 						</goals> -->
<!-- 					</execution> -->
<!-- 				</executions> -->
<!-- 			</plugin> -->
			<plugin>
				<groupId>org.eclipse.m2e</groupId>
				<artifactId>lifecycle-mapping</artifactId>
				<version>1.0.0</version>
				<configuration>
					<lifecycleMappingMetadata>
						<pluginExecutions>
							<!-- copy-dependency plugin -->
							<pluginExecution>
								<pluginExecutionFilter>
									<groupId>org.apache.maven.plugins</groupId>
									<artifactId>maven-dependency-plugin</artifactId>
									<versionRange>[1.0.0,)</versionRange>
									<goals>
										<goal>copy-dependencies</goal>
									</goals>
								</pluginExecutionFilter>
								<action>
									<ignore />
								</action>
							</pluginExecution>

							<!-- mybatis-generator-plugin -->
							<pluginExecution>
								<pluginExecutionFilter>
									<groupId>org.mybatis.generator</groupId>
									<artifactId>mybatis-generator-maven-plugin</artifactId>
									<versionRange>[1.3.2,)</versionRange>
									<goals>
										<goal>generate</goal>
									</goals>
								</pluginExecutionFilter>
								<action>
									<ignore />
								</action>
							</pluginExecution>
						</pluginExecutions>
					</lifecycleMappingMetadata>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<reporting>
        <plugins>
               <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>findbugs-maven-plugin</artifactId>
                      <version>3.0.1</version>
                      <configuration>
                      <xmlOutput>true</xmlOutput>
                      <!-- Optional directoryto put findbugs xdoc xml report -->
                      <!--<xmlOutputDirectory>target/site</xmlOutputDirectory>-->
                      <findbugsXmlOutput>true</findbugsXmlOutput>
                      <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                      </configuration>
               </plugin>
        </plugins>
	</reporting>
	<profiles>
		<profile>
			<id>debug</id>
			<properties>
				<env>debug</env>
				<!-- 发布版本号 -->
                <publish.version>${public.version.number}-SNAPSHOT</publish.version>
			</properties>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
		</profile>
		<profile>
			<id>develop</id>
			<properties>
				<env>develop</env>
		        <!-- 发布版本号 -->
		        <publish.version>${public.version.number}-SNAPSHOT</publish.version>
			</properties>
		</profile>
		<profile>
			<id>test</id>
			<properties>
				<env>test</env>
			</properties>
		</profile>
		<profile>
			<id>stg</id>
			<properties>
				<env>stg</env>
			</properties>
		</profile>
		<profile>
			<id>product</id>
			<properties>
				<env>product</env>
			</properties>
		</profile>
		
		<!-- 供上海使用 -->
		<profile>
            <id>develop-sh</id>
            <properties>
                <env>develop</env>
            </properties>
            <!-- 上海私服 -->
            <distributionManagement>
                <repository>
                    <id>releases</id>
                    <url>http://172.19.21.213:8080/nexus/content/repositories/releases</url>
                </repository>
                <snapshotRepository>
                    <id>snapshots</id>
                    <url>http://172.19.21.213:8080/nexus/content/repositories/snapshots</url>
                    <uniqueVersion>false</uniqueVersion>
                </snapshotRepository>
            </distributionManagement>
        </profile>
	</profiles>
</project>
log4j日志封装类 log4j
package com.aspire.common.log;

/**
 * <p>Title: TimeSizeRollingFileAppender</p>
 * <p>Description: it record the log in a file and roll based on size and time strategy
 * within a time period, it rolls by size,pass the span,mark the old one by time
 * </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Aspire Technologies</p>
 * @author yanfeng
 * @version 1.0
 * history
 * created at 8/5/2003
 * updated at 24/5/2003, lay the sequence mark number behind "bak"
 * revised at 12/6/2003 add uniform of file seperator
 * @CheckItem@ BUGXXX-yanfeng-20030909 revise the repeateable renaming file problem while rolling over time
 * @CheckItem@ OPT-yanfeng-20030909 remove file existence check while logging
 * @CheckItem@ OPT-yanfeng-20030909 move file existence check from setFile(p1,p2,p3,p4) to setFile(file)
 * @CheckItem@ BUG-yanfeng-20031126 backup all the size-backup file when time roller.
 * @CheckItem@ REQ-liuyufeng-20040325 添加放置Log在Server目录下功能
 */

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.helpers.CountingQuietWriter;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.spi.ErrorCode;
import org.apache.log4j.spi.LoggingEvent;
import com.aspire.misc.infrastruct.PublicUtilit;

public class TimeSizeRollingFileAppender extends FileAppender implements
    ErrorCode{

    /**
     The default maximum file size is 10MB.
     */
    protected long maxFileSize = 10 * 1024 * 1024;

    /**
       There is one backup file by default.
     */
    protected int maxBackupIndex = 1;

    protected int logInServer = 0;

    static final int LOG_IN_SERVER = 1;

    static final int NOT_LOG_IN_SERVER = 0;

    // The code assumes that the following constants are in a increasing
    // sequence.
    static final int TOP_OF_TROUBLE = -1;

    static final int TOP_OF_MINUTE = 0;

    static final int TOP_OF_HOUR = 1;

    static final int HALF_DAY = 2;

    static final int TOP_OF_DAY = 3;

    static final int TOP_OF_WEEK = 4;

    static final int TOP_OF_MONTH = 5;

    /**
       The date pattern. By default, the pattern is set to
       "'.'yyyy-MM-dd" meaning daily rollover.
     */
    private String datePattern = "'.'yyyy-MM-dd";

    /**
       The log file will be renamed to the value of the
       scheduledFilename variable when the next interval is entered. For
       example, if the rollover period is one hour, the log file will be
       renamed to the value of "scheduledFilename" at the beginning of
       the next hour.
       The precise time when a rollover occurs depends on logging
       activity.
     */
    private String scheduledFilename;

    /**
       The next time we estimate a rollover should occur. */
    private long nextCheck = System.currentTimeMillis() - 1;

    Date now = new Date();

    SimpleDateFormat sdf;

    RollingCalendar rc = new RollingCalendar();

    int checkPeriod = TOP_OF_TROUBLE;

    // The gmtTimeZone is used only in computeCheckPeriod() method.
    static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");

    private File currFile;

    /**
       The default constructor does nothing. */
    public TimeSizeRollingFileAppender(){
    }

    /**
      Instantiate a <code>TimeSizeRollingFileAppender</code> and open the
      file designated by <code>filename</code>. The opened filename will
      become the ouput destination for this appender.
     */
    public TimeSizeRollingFileAppender(Layout layout,String filename,
                                       String datePattern) throws IOException{
        super(layout,filename,true);
        this.datePattern = datePattern;
        activateOptions();
    }

    /**
       The <b>DatePattern</b> takes a string in the same format as
       expected by {@link SimpleDateFormat}. This options determines the
       rollover schedule.
     */
    public void setDatePattern(String pattern){
        datePattern = pattern;
    }

    /** Returns the value of the <b>DatePattern</b> option. */
    public String getDatePattern(){
        return datePattern;
    }

    /**
       Returns the value of the <b>MaxBackupIndex</b> option.
     */
    public int getMaxBackupIndex(){
        return maxBackupIndex;
    }

    /**
       Get the maximum size that the output file is allowed to reach
       before being rolled over to backup files.
       @since 1.1
     */
    public long getMaximumFileSize(){
        return maxFileSize;
    }

    public void setLogInServer(int server){
        logInServer = server;
    }

    public void setFile(String file){
        // Trim spaces from both ends. The users probably does not want
        // trailing spaces in file names.
        String val = file.trim();
        String tmpfileName = val.replace('/',LogConstants.FILE_SEP.charAt(0));
        /*        if (!tmpfileName.startsWith(LogConstants.FILE_SEP))
                    {
                    tmpfileName=LogConstants.FILE_SEP+tmpfileName;
                    }
         */
        //判断文件名是否绝对路径,如果绝对路径则logInServer不生效
        if(tmpfileName != null){
            if(tmpfileName.startsWith("/")){
                logInServer = NOT_LOG_IN_SERVER;
            } else if(tmpfileName.indexOf(":") != -1){
                logInServer = NOT_LOG_IN_SERVER;
            }
        }
        //判断是否需要打印在Server目录下
        if(logInServer == LOG_IN_SERVER){
            String weblogicPath = PublicUtilit.getUserDir() +
                                  PublicUtilit.getFileSeparator() +
                                  PublicUtilit.getWeblogicName();
            tmpfileName = weblogicPath + PublicUtilit.getFileSeparator() +
                          tmpfileName;
        }

        fileName = tmpfileName;
        //create non-exist path
        LogLog.debug("fileName:" + tmpfileName);

        int index = fileName.lastIndexOf(LogConstants.FILE_SEP);
        if(index > 0){
            String sPath = fileName.substring(0,index);
            File path = new File(sPath);
            if(!path.exists()){
                path.mkdirs();
            }
        }

        LogLog.debug("File set:" + fileName);
    }

    public synchronized void setFile(String pFileName,boolean append,
                                     boolean bufferedIO,int bufferSize) throws
        IOException{
        try{
            reset();
            this.fileName = pFileName;
            LogLog.debug("setFile called: " + fileName + ", " + append);
            // It does not make sense to have immediate flush and bufferedIO.
            if(bufferedIO){
                setImmediateFlush(false);
            }

            Writer fw = createWriter(new FileOutputStream(fileName,append));
            if(bufferedIO){
                fw = new BufferedWriter(fw,bufferSize);
            }
            this.setQWForFiles(fw);
            this.fileAppend = append;
            this.bufferedIO = bufferedIO;
            this.bufferSize = bufferSize;
            writeHeader();

            if(append){
                currFile = new File(fileName);
                ((CountingQuietWriter)qw).setCount(currFile.length());
            }
            LogLog.debug("setFile ended");
        } catch(IOException e){
            //@CheckItem@ SELFBUG-yanfeng-20030716 创建日志文件失败,可能是权限不够
            errorHandler.error("Create log File error",e,FILE_OPEN_FAILURE);
        }
    }

    public void activateOptions(){
        super.activateOptions();
        if(datePattern != null && fileName != null){
            now.setTime(System.currentTimeMillis());
            sdf = new SimpleDateFormat(datePattern);
            int type = computeCheckPeriod();
            printPeriodicity(type);
            rc.setType(type);
            currFile = new File(fileName);
            scheduledFilename = fileName +
                                sdf.format(new Date(currFile.lastModified()));
            LogLog.debug("scheduledFilename generated:" + scheduledFilename);
        } else{
            LogLog.error(
                "Either File or DatePattern options are not set for appender [" +
                name + "].");
        }
    }

    /**
      Set the maximum number of backup files to keep around.
      <p>The <b>MaxBackupIndex</b> option determines how many backup
      files are kept before the oldest is erased. This option takes
      a positive integer value. If set to zero, then there will be no
      backup files and the log file will be truncated when it reaches
      <code>MaxFileSize</code>.
     */
    public void setMaxBackupIndex(int maxBackups){
        this.maxBackupIndex = maxBackups;
    }

    /**
         Set the maximum size that the output file is allowed to reach
         before being rolled over to backup files.
         <p>In configuration files, the <b>MaxFileSize</b> option takes an
         long integer in the range 0 - 2^63. You can specify the value
         with the suffixes "KB", "MB" or "GB" so that the integer is
         interpreted being expressed respectively in kilobytes, megabytes
         or gigabytes. For example, the value "10KB" will be interpreted
         as 10240.
     */
    public void setMaxFileSize(String value){
        maxFileSize = OptionConverter.toFileSize(value,maxFileSize + 1);
        //maxFileSize=value;
    }

    public void setMaximumFileSize(long value){
        //maxFileSize=OptionConverter.toFileSize(value,maxFileSize+1);
        maxFileSize = value;
    }

    protected void setQWForFiles(Writer writer){
        this.qw = new CountingQuietWriter(writer,errorHandler);
    }

    void printPeriodicity(int type){
        switch(type){
            case TOP_OF_MINUTE:
                LogLog.debug("Appender [" + name +
                             "] to be rolled every minute.");
                break;
            case TOP_OF_HOUR:
                LogLog.debug("Appender [" + name +
                             "] to be rolled on top of every hour.");
                break;
            case HALF_DAY:
                LogLog.debug("Appender [" + name +
                             "] to be rolled at midday and midnight.");
                break;
            case TOP_OF_DAY:
                LogLog.debug("Appender [" + name +
                             "] to be rolled at midnight.");
                break;
            case TOP_OF_WEEK:
                LogLog.debug("Appender [" + name +
                             "] to be rolled at start of week.");
                break;
            case TOP_OF_MONTH:
                LogLog.debug("Appender [" + name +
                             "] to be rolled at start of every month.");
                break;
            default:
                LogLog.warn("Unknown periodicity for appender [" + name + "].");
        }
    }

    // This method computes the roll over period by looping over the
    // periods, starting with the shortest, and stopping when the r0 is
    // different from from r1, where r0 is the epoch formatted according
    // the datePattern (supplied by the user) and r1 is the
    // epoch+nextMillis(i) formatted according to datePattern. All date
    // formatting is done in GMT and not local format because the test
    // logic is based on comparisons relative to 1970-01-01 00:00:00
    // GMT (the epoch).

    int computeCheckPeriod(){
        RollingCalendar rollingCalendar = new RollingCalendar(gmtTimeZone,
                                                              Locale.ENGLISH);
        // set sate to 1970-01-01 00:00:00 GMT
        Date epoch = new Date(0);
        if(datePattern != null){
            for(int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++){
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
                    datePattern);
                simpleDateFormat.setTimeZone(gmtTimeZone); // do all date formatting in GMT
                String r0 = simpleDateFormat.format(epoch);
                rollingCalendar.setType(i);
                Date next = new Date(rollingCalendar.getNextCheckMillis(epoch));
                String r1 = simpleDateFormat.format(next);
                LogLog.debug("Type = " + i + ", r0 = " + r0 + ", r1 = " + r1);
                if(r0 != null && r1 != null && !r0.equals(r1)){
                    return i;
                }
            }
        }
        return TOP_OF_TROUBLE; // Deliberately head for trouble...
    }

    /**
       Rollover the current file to a new file.
     */
    public void rollOverForTime() throws IOException{

        /* Compute filename, but only if datePattern is specified */
        if(datePattern == null){
            errorHandler.error("Missing DatePattern option in rollOver().");
            return;
        }

        String datedFilename = fileName + sdf.format(now);
        LogLog.debug("datedFilename:" + datedFilename);
        // It is too early to roll over because we are still within the
        // bounds of the current interval. Rollover will occur once the
        // next interval is reached.
        if(scheduledFilename.equals(datedFilename)){
            return;
        }

        // close current file, and rename it to datedFilename
        this.closeFile();

        File target = new File(scheduledFilename +
                               LogConstants.LOG_BACKUP_SUFFIX);
        if(target.exists()){
            target.delete();
        }

        File file = new File(fileName);
        for(int i = 1; i <= maxBackupIndex; i++){ //roll for all size-backup files
            String before = fileName + "." + i;
            File files = new File(before);
            String after = scheduledFilename + "." + i +
                           LogConstants.LOG_BACKUP_SUFFIX;
            File targets = new File(after);
            if(targets.exists()){
                targets.delete();
            }
            if(files.exists()){ //only backup existed one
                boolean result = files.renameTo(targets);
                if(result){
                    LogLog.debug(before + " -> " + after);
                } else{
                    LogLog.error("Failed to rename [" + before + "] to [" +
                                 after + "].");
                }
            }
        }

        //rename current writting file is necessary
        boolean result = file.renameTo(target);
        if(result){
            LogLog.debug(fileName + " -> " + scheduledFilename);
        } else{
            LogLog.error("Failed to rename [" + fileName + "] to [" +
                         scheduledFilename + "].");
        }

        try{
            // This will also close the file. This is OK since multiple
            // close operations are safe.
            this.setFile(fileName,false,this.bufferedIO,this.bufferSize);
        } catch(IOException e){
            errorHandler.error("setFile(" + fileName + ", false) call failed.");
        }
        scheduledFilename = datedFilename;
        LogLog.debug("scheduledFilename after roll:" + scheduledFilename);
    }

    /**
       Implements the usual roll over behaviour.
       <p>If <code>MaxBackupIndex</code> is positive, then files
       {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
       are renamed to {<code>File.2</code>, ...,
       <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
       renamed <code>File.1</code> and closed. A new <code>File</code> is
       created to receive further log output.
       <p>If <code>MaxBackupIndex</code> is equal to zero, then the
       <code>File</code> is truncated with no backup files created.
     */
    public void rollOverForSize(){ // synchronization not necessary since doAppend is alreasy synched
        File target;
        File file;

        LogLog.debug("rolling over count=" + ((CountingQuietWriter)qw).getCount());
        LogLog.debug("maxBackupIndex=" + maxBackupIndex);
        // If maxBackups <= 0, then there is no file renaming to be done.
        if(maxBackupIndex > 0){
            // Delete the oldest file, to keep Windows happy.
            file = new File(fileName + '.' + maxBackupIndex);
            if(file.exists()){
                file.delete();

                // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
            }
            for(int i = maxBackupIndex - 1; i >= 1; i--){
                file = new File(fileName + "." + i);
                if(file.exists()){
                    target = new File(fileName + '.' + (i + 1));
                    LogLog.debug("Renaming file " + file + " to " + target);
                    file.renameTo(target);
                }
            }

            // Rename fileName to fileName.1
            target = new File(fileName + "." + 1);

            this.closeFile(); // keep windows happy.

            file = new File(fileName);
            LogLog.debug("Renaming file " + file + " to " + target);
            file.renameTo(target);
        }

        try{
            // This will also close the file. This is OK since multiple
            // close operations are safe.
            this.setFile(fileName,false,bufferedIO,bufferSize);
        } catch(IOException e){
            LogLog.error("setFile(" + fileName + ", false) call failed.",e);
        }
    }

    /**
     * This method differentiates TimeSizeRollingFileAppender from its
     * super class.
     *
     * <p>Before actually logging, this method will check whether it is
     * time to do a rollover. If it is, it will schedule the next
     * rollover time and then rollover.
     * */
    protected void subAppend(LoggingEvent event){
        if((fileName != null) &&
           ((CountingQuietWriter)qw).getCount() >= maxFileSize){
            rollOverForSize();
        }
        long n = System.currentTimeMillis();
        if(n >= nextCheck){
            now.setTime(n);
            nextCheck = rc.getNextCheckMillis(now);
            try{
                rollOverForTime();
            } catch(IOException ioe){
                LogLog.error("rollOver() failed.",ioe);
            }
        }
        //@CheckItem@ OPT-yanfeng-20030909 remove file exist check while logging for better effencience
        super.subAppend(event);
    }
}

/**
 *  RollingCalendar is a helper class to TimeSizeRollingFileAppender.
 *  Given a periodicity type and the current time, it computes the
 *  start of the next interval.
 * */
class RollingCalendar extends GregorianCalendar{

    int type = TimeSizeRollingFileAppender.TOP_OF_TROUBLE;

    RollingCalendar(){
        super();
    }

    RollingCalendar(TimeZone tz,Locale locale){
        super(tz,locale);
    }

    void setType(int type){
        this.type = type;
    }

    public long getNextCheckMillis(Date now){
        return getNextCheckDate(now).getTime();
    }

    public Date getNextCheckDate(Date now){
        this.setTime(now);

        switch(type){
            case TimeSizeRollingFileAppender.TOP_OF_MINUTE:
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                this.add(Calendar.MINUTE,1);
                break;
            case TimeSizeRollingFileAppender.TOP_OF_HOUR:
                this.set(Calendar.MINUTE,0);
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                this.add(Calendar.HOUR_OF_DAY,1);
                break;
            case TimeSizeRollingFileAppender.HALF_DAY:
                this.set(Calendar.MINUTE,0);
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                int hour = get(Calendar.HOUR_OF_DAY);
                if(hour < 12){
                    this.set(Calendar.HOUR_OF_DAY,12);
                } else{
                    this.set(Calendar.HOUR_OF_DAY,0);
                    this.add(Calendar.DAY_OF_MONTH,1);
                }
                break;
            case TimeSizeRollingFileAppender.TOP_OF_DAY:
                this.set(Calendar.HOUR_OF_DAY,0);
                this.set(Calendar.MINUTE,0);
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                this.add(Calendar.DATE,1);
                break;
            case TimeSizeRollingFileAppender.TOP_OF_WEEK:
                this.set(Calendar.DAY_OF_WEEK,getFirstDayOfWeek());
                this.set(Calendar.HOUR_OF_DAY,0);
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                this.add(Calendar.WEEK_OF_YEAR,1);
                break;
            case TimeSizeRollingFileAppender.TOP_OF_MONTH:
                this.set(Calendar.DATE,1);
                this.set(Calendar.HOUR_OF_DAY,0);
                this.set(Calendar.SECOND,0);
                this.set(Calendar.MILLISECOND,0);
                this.add(Calendar.MONTH,1);
                break;
            default:
                throw new IllegalStateException("Unknown periodicity type.");
        }
        return getTime();
    }
}
job列表 job,list
 /**
     * 列表出Job对象
     * 
     * @return
     */
    public ActionForward listSimsJobs(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
        logger.debug("列表出Job对象 listSimsJobs");
        List<SimsJob> jobList = null;
        try {
            jobList=new ArrayList<SimsJob>();
            Scheduler scheduler = (Scheduler) BeanLocator.getBeanInstance("bdcscheduler");
            // 通过调度器对象scheduler获取所有触发器组名称数组TriggerGroupNames
            String[] triggerGroups = scheduler.getTriggerGroupNames();
            
            for (int i = 0; i < triggerGroups.length; i++) {// 遍历每个触发器组名数组,得到每组所有触发器
                String groupName = triggerGroups[i];
                // 根据触发器组名获得该组所有触发器名称数组
                String[] triggerNames = scheduler.getTriggerNames(groupName);
                
                for (int j = 0; j < triggerNames.length; j++) {// 遍历每个触发器名数组,得到当前组所有触发器
                    SimsJob tForm = new SimsJob();
                    String triggerName = triggerNames[j];
                    Trigger trigger=scheduler.getTrigger(triggerName, groupName);;
                    if(trigger instanceof CronTrigger){
                        // 根据触发器名称获得触发器对象
                        CronTrigger ctrigger = (CronTrigger) trigger;
                        tForm.setTriggerCronExpression(ctrigger.getCronExpression());
                    }else{
                        continue;
                    }
                    // 对每个触发器对象TriggerDTO设属性值
                    tForm.setDesc(trigger.getDescription());
                    tForm.setGroup(trigger.getJobGroup());
                    tForm.setName(trigger.getJobName());
                    tForm.setTriggerGroup(trigger.getGroup());
                    tForm.setTriggerName(trigger.getName());
                    jobList.add(tForm);
                    
                }
            }
            String jobName = (String) request.getParameter("jobName");
            if (StringUtils.isNotBlank(jobName)) {
                Iterator<SimsJob> iterator = jobList.iterator();
                while (iterator.hasNext()) {
                    SimsJob job = iterator.next();
                    if (!job.getName().toLowerCase().contains(jobName.toLowerCase())) {
                        iterator.remove();
                    }
                }
            }
        } catch (Exception e) {
            logger.error("列表出Job对象 listSimsJobs 出错", e);
            e.printStackTrace();
        }
        request.setAttribute("jobList", jobList);
        return mapping.findForward("list");
    }
    

package com.aspire.sims.uspc.process.bdcjob.pojo;

import java.util.Map;

/**
 * SimsJobPojo
 * @author niepenghe
 *
 */
public class SimsJob {
	private String name;
	private String group;
	private String jobClass;
	private String serviceName;
	private Map paraMap;
	private String desc;
	private String volatility;
	private String durability;
	private String recover;
	
	private String triggerName;
	private String triggerGroup;
	private String triggerCronExpression;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGroup() {
		return group;
	}
	public void setGroup(String group) {
		this.group = group;
	}
	public String getJobClass() {
		return jobClass;
	}
	public void setJobClass(String jobClass) {
		this.jobClass = jobClass;
	}
	public String getVolatility() {
		return volatility;
	}
	public void setVolatility(String volatility) {
		this.volatility = volatility;
	}
	public String getDurability() {
		return durability;
	}
	public void setDurability(String durability) {
		this.durability = durability;
	}
	public String getRecover() {
		return recover;
	}
	public void setRecover(String recover) {
		this.recover = recover;
	}
	public String getTriggerName() {
		return triggerName;
	}
	public void setTriggerName(String triggerName) {
		this.triggerName = triggerName;
	}
	public String getTriggerGroup() {
		return triggerGroup;
	}
	public void setTriggerGroup(String triggerGroup) {
		this.triggerGroup = triggerGroup;
	}
	public String getTriggerCronExpression() {
		return triggerCronExpression;
	}
	public void setTriggerCronExpression(String triggerCronExpression) {
		this.triggerCronExpression = triggerCronExpression;
	}
	public Map getParaMap() {
		return paraMap;
	}
	public void setParaMap(Map paraMap) {
		this.paraMap = paraMap;
	}
	
	public String getParaValue(String key){
		return (String)paraMap.get(key);
	}
	public String getServiceName() {
		return serviceName;
	}
	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
}
jobutils quartz、运行一次
package com.aspire.sims.uspc.process.bdcjob.util;

import java.lang.reflect.Constructor;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.quartz.CronTrigger;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerListener;

import com.aspire.component.monitor4job.listener.MonitorTriggerListener;
import com.aspire.sims.rtplt.component.springhelper.BeanLocator;
import com.aspire.sims.uspc.process.bdcjob.pojo.SimsJob;

/**
 * name:JobUtils
 * <p>
 * </p>
 * 
 * @author:lipeng
 * @data:2014-12-30 上午11:24:46
 * @version 1.0
 */
public class JobUtils {
    
    private static final Logger logger = Logger.getLogger(JobUtils.class);
    
    public static void runJob(String jobName) {
        logger.debug("执行选择的Job对象 doRunSimsJob runName:" + jobName);
        try {
            // 执行一下JOB
            Scheduler scheduler = (Scheduler) BeanLocator.getBeanInstance("bdcscheduler");
            SimsJob simsJob = null;
            boolean existFlag = false;
            if (jobName != null && !"".equals(jobName)) {
                // 通过调度器对象scheduler获取所有触发器组名称数组TriggerGroupNames
                String[] triggerGroups = scheduler.getTriggerGroupNames();
                
                for (int i = 0; i < triggerGroups.length; i++) {// 遍历每个触发器组名数组,得到每组所有触发器
                    String groupName = triggerGroups[i];
                    // 根据触发器组名获得该组所有触发器名称数组
                    String[] triggerNames = scheduler.getTriggerNames(groupName);
                    for (int j = 0; j < triggerNames.length; j++) {// 遍历每个触发器名数组,得到当前组所有触发器
                        if (existFlag) {
                            break;
                        }
                        simsJob = new SimsJob();
                        String triggerName = triggerNames[j];
                        // 根据触发器名称获得触发器对象
                        CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerName, groupName);
                        if (jobName.equals(trigger.getJobName())) {
                            // 对每个触发器对象TriggerDTO设属性值
                            simsJob.setDesc(trigger.getDescription());
                            simsJob.setGroup(trigger.getJobGroup());
                            simsJob.setName(trigger.getJobName());
                            JobDetail jobdetail=scheduler.getJobDetail(trigger.getJobName(), trigger.getJobGroup());
                            simsJob.setJobClass(jobdetail.getJobClass().getName());
                            simsJob.setParaMap(jobdetail.getJobDataMap());
                            simsJob.setTriggerGroup(trigger.getGroup());
                            simsJob.setTriggerName(trigger.getName());
                            simsJob.setTriggerCronExpression(trigger.getCronExpression());
                            existFlag = true;
                        }
                        
                    }
                    if (existFlag) {
                        break;
                    }
                }
            }
            if (existFlag) {
                Class clazz=Class.forName(simsJob.getJobClass());
                // 实例化控制的Job
                Constructor constructor = clazz.getConstructor();
                Job job = (Job) constructor.newInstance();
                TriggerListener myListener = new MonitorTriggerListener();
                scheduler.addGlobalTriggerListener(myListener);
                JobDetail jobDetail = new JobDetail(simsJob.getName(), Scheduler.DEFAULT_GROUP, job.getClass());
                JobDataMap jobDataMap = new JobDataMap();
                jobDataMap.putAll(simsJob.getParaMap());
                jobDetail.setJobDataMap(jobDataMap);
                Trigger trigger =
                    new SimpleTrigger(simsJob.getTriggerName(), Scheduler.DEFAULT_GROUP, new Date(), null, 0, 0L);
                scheduler.scheduleJob(jobDetail, trigger);
                scheduler.start();
                logger.error("执行选择的Job对象:" + simsJob.getName() + "已经开始执行,稍后请检查数据!");
            } else {
                logger.error("执行选择的Job对象出错:该Job不存在于Job配置文件中,请确认Job 名称是否正确!");
            }
        } catch (Exception e) {
            logger.error("doRunSimsJob 执行选择的Job对象出错", e);
            e.printStackTrace();
        }
    }
}
日志初始化
package com.aspire.sims.uspc.platform.log;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.xml.DOMConfigurator;

import com.aspire.sims.uspc.platform.util.ConfigContext;
import com.aspire.sims.uspc.platform.util.RunTimeUtil;

/**
 * <p>
 * Title: LogInitServlet.java
 * </p>
 * <p>
 * Description: 定义日志的初始化servlet
 * </p>
 * <p>
 * Copyright: Copyright (c) 2007
 * </p>
 * <p>
 * Company: aspire
 * </p>
 * 
 * @author cuizhongshan
 * @version 2.0.0 version author date description
 *          ------------------------------------------------------------------
 */
public class LogInitServlet extends HttpServlet {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -2192309888111920733L;

	/**
	 * 初始化方法,获得配置文件,初始化
	 */
	public void init(ServletConfig cfg) throws javax.servlet.ServletException {
		String userDir = RunTimeUtil.getUserDir();
		String logRootPath = userDir + File.separator + "log";
		TimeSizeRollingFileAppender.setLogRootPath(logRootPath);
		// 日志配置路径
		String logPath = cfg.getInitParameter("log_path");
		if ((logPath == null) || ("".equals(logPath))) {
			logPath = "log";
		}
		// 日志配置文件
		String logFile = cfg.getInitParameter("log_file");
		if ((logFile == null) || ("".equals(logFile))) {
			logFile = "log4j.xml";
		}
		// 获得配置文件
		String configFile = ConfigContext.getFullConfigPath(logPath, logFile);
		System.out.println("获得日志配置文件为:" + configFile);
		// 加载XML配置文件(每半小时扫描一次配置文件,如果有更新,自动加载)
		DOMConfigurator.configureAndWatch(configFile, 30 * 60 * 1000);
		System.out.println("初始化日志组件成功");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.sendError(HttpServletResponse.SC_FORBIDDEN);
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.sendError(HttpServletResponse.SC_FORBIDDEN);
	}

}
日志
package com.aspire.sims.uspc.platform.log;

/**
 * <p>Title: TimeSizeRollingFileAppender</p>
 * <p>Description: it record the log in a file and roll based on size and time strategy
 * within a time period, it rolls by size,pass the span,mark the old one by time
 * </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Aspire Technologies</p>
 * @author yanfeng
 * @version 1.0
 * history
 * created at 8/5/2003
 * updated at 24/5/2003, lay the sequence mark number behind "bak"
 * revised at 12/6/2003 add uniform of file seperator
 * @CheckItem@ BUGXXX-yanfeng-20030909 revise the repeateable renaming file problem while rolling over time
 * @CheckItem@ OPT-yanfeng-20030909 remove file existence check while logging
 * @CheckItem@ OPT-yanfeng-20030909 move file existence check from setFile(p1,p2,p3,p4) to setFile(file)
 * @CheckItem@ BUG-yanfeng-20031126 backup all the size-backup file when time roller.
 * @CheckItem@ REQ-liuyufeng-20040325 添加放置Log在Server目录下功能
 * @CheckItem@ REQ-cuizhongshan-20071017 根据sims_omr要求修改,删除LogConstants和PublicUtilit引用
 */

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.helpers.CountingQuietWriter;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.spi.ErrorCode;
import org.apache.log4j.spi.LoggingEvent;

public class TimeSizeRollingFileAppender extends FileAppender implements
		ErrorCode {
	/** * 备份文件后缀名 */
	private static String BACKUP_SUFFIX = ".bak";
	/** * log文件根路径 */
	private static String LOG_ROOT_PATH = ".";

	/**
	 * 设置log文件根路径.
	 * 
	 * @param logRootPath
	 *            根路径
	 */
	public static void setLogRootPath(String logRootPath) {
		LOG_ROOT_PATH = logRootPath;
	}

	/**
	 * 返回log文件根路径.
	 */
	public static String getLogRootPath() {
		return LOG_ROOT_PATH;
	}

	/**
	 * The default maximum file size is 10MB.
	 */
	protected long maxFileSize = 10 * 1024 * 1024;

	/**
	 * There is one backup file by default.
	 */
	protected int maxBackupIndex = 1;

	// The code assumes that the following constants are in a increasing
	// sequence.
	static final int TOP_OF_TROUBLE = -1;

	static final int TOP_OF_MINUTE = 0;

	static final int TOP_OF_HOUR = 1;

	static final int HALF_DAY = 2;

	static final int TOP_OF_DAY = 3;

	static final int TOP_OF_WEEK = 4;

	static final int TOP_OF_MONTH = 5;

	/**
	 * The date pattern. By default, the pattern is set to "'.'yyyy-MM-dd"
	 * meaning daily rollover.
	 */
	private String datePattern = "'.'yyyy-MM-dd";

	/**
	 * The log file will be renamed to the value of the scheduledFilename
	 * variable when the next interval is entered. For example, if the rollover
	 * period is one hour, the log file will be renamed to the value of
	 * "scheduledFilename" at the beginning of the next hour. The precise time
	 * when a rollover occurs depends on logging activity.
	 */
	private String scheduledFilename;

	/**
	 * The next time we estimate a rollover should occur.
	 */
	private long nextCheck = System.currentTimeMillis() - 1;

	Date now = new Date();

	SimpleDateFormat sdf;

	RollingCalendar rc = new RollingCalendar();

	int checkPeriod = TOP_OF_TROUBLE;

	// The gmtTimeZone is used only in computeCheckPeriod() method.
	static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");

	private File currFile;

	/**
	 * The default constructor does nothing.
	 */
	public TimeSizeRollingFileAppender() {
	}

	/**
	 * Instantiate a <code>TimeSizeRollingFileAppender</code> and open the
	 * file designated by <code>filename</code>. The opened filename will
	 * become the ouput destination for this appender.
	 */
	public TimeSizeRollingFileAppender(Layout layout, String filename,
			String datePattern) throws IOException {
		super(layout, filename, true);
		this.datePattern = datePattern;
		activateOptions();
	}

	/**
	 * The <b>DatePattern</b> takes a string in the same format as expected by
	 * {@link SimpleDateFormat}. This options determines the rollover schedule.
	 */
	public void setDatePattern(String pattern) {
		datePattern = pattern;
	}

	/** Returns the value of the <b>DatePattern</b> option. */
	public String getDatePattern() {
		return datePattern;
	}

	/**
	 * Returns the value of the <b>MaxBackupIndex</b> option.
	 */
	public int getMaxBackupIndex() {
		return maxBackupIndex;
	}

	/**
	 * Get the maximum size that the output file is allowed to reach before
	 * being rolled over to backup files.
	 * 
	 * @since 1.1
	 */
	public long getMaximumFileSize() {
		return maxFileSize;
	}

	public void setFile(String file) {
		// Trim spaces from both ends. The users probably does not want
		// trailing spaces in file names.
		String val = file.trim();
		String tmpfileName = val.replace('/', File.separatorChar);

		// log根目录+相对路径=实际日志文件名
		fileName = getLogRootPath() + File.separator + tmpfileName;

		// create non-exist path
		LogLog.debug("fileName:" + fileName);

		int index = fileName.lastIndexOf(File.separatorChar);
		if (index > 0) {
			String sPath = fileName.substring(0, index);
			File path = new File(sPath);
			if (!path.exists()) {
				path.mkdirs();
			}
		}

		LogLog.debug("File set:" + fileName);
	}

	public synchronized void setFile(String pFileName, boolean append,
			boolean bufferedIO, int bufferSize) throws IOException {
		try {
			reset();
			this.fileName = pFileName;
			LogLog.debug("setFile called: " + fileName + ", " + append);
			// It does not make sense to have immediate flush and bufferedIO.
			if (bufferedIO) {
				setImmediateFlush(false);
			}

			Writer fw = createWriter(new FileOutputStream(fileName, append));
			if (bufferedIO) {
				fw = new BufferedWriter(fw, bufferSize);
			}
			this.setQWForFiles(fw);
			this.fileAppend = append;
			this.bufferedIO = bufferedIO;
			this.bufferSize = bufferSize;
			writeHeader();

			if (append) {
				currFile = new File(fileName);
				((CountingQuietWriter) qw).setCount(currFile.length());
			}
			LogLog.debug("setFile ended");
		} catch (IOException e) {
			// @CheckItem@ SELFBUG-yanfeng-20030716 创建日志文件失败,可能是权限不够
			errorHandler.error("Create log File error", e, FILE_OPEN_FAILURE);
		}
	}

	public void activateOptions() {
		super.activateOptions();
		if (datePattern != null && fileName != null) {
			now.setTime(System.currentTimeMillis());
			sdf = new SimpleDateFormat(datePattern);
			int type = computeCheckPeriod();
			printPeriodicity(type);
			rc.setType(type);
			currFile = new File(fileName);
			scheduledFilename = fileName
					+ sdf.format(new Date(currFile.lastModified()));
			LogLog.debug("scheduledFilename generated:" + scheduledFilename);
		} else {
			LogLog
					.error("Either File or DatePattern options are not set for appender ["
							+ name + "].");
		}
	}

	/**
	 * Set the maximum number of backup files to keep around.
	 * <p>
	 * The <b>MaxBackupIndex</b> option determines how many backup files are
	 * kept before the oldest is erased. This option takes a positive integer
	 * value. If set to zero, then there will be no backup files and the log
	 * file will be truncated when it reaches <code>MaxFileSize</code>.
	 */
	public void setMaxBackupIndex(int maxBackups) {
		this.maxBackupIndex = maxBackups;
	}

	/**
	 * Set the maximum size that the output file is allowed to reach before
	 * being rolled over to backup files.
	 * <p>
	 * In configuration files, the <b>MaxFileSize</b> option takes an long
	 * integer in the range 0 - 2^63. You can specify the value with the
	 * suffixes "KB", "MB" or "GB" so that the integer is interpreted being
	 * expressed respectively in kilobytes, megabytes or gigabytes. For example,
	 * the value "10KB" will be interpreted as 10240.
	 */
	public void setMaxFileSize(String value) {
		maxFileSize = OptionConverter.toFileSize(value, maxFileSize + 1);
		// maxFileSize=value;
	}

	public void setMaximumFileSize(long value) {
		// maxFileSize=OptionConverter.toFileSize(value,maxFileSize+1);
		maxFileSize = value;
	}

	protected void setQWForFiles(Writer writer) {
		this.qw = new CountingQuietWriter(writer, errorHandler);
	}

	void printPeriodicity(int type) {
		switch (type) {
		case TOP_OF_MINUTE:
			LogLog.debug("Appender [" + name + "] to be rolled every minute.");
			break;
		case TOP_OF_HOUR:
			LogLog.debug("Appender [" + name
					+ "] to be rolled on top of every hour.");
			break;
		case HALF_DAY:
			LogLog.debug("Appender [" + name
					+ "] to be rolled at midday and midnight.");
			break;
		case TOP_OF_DAY:
			LogLog.debug("Appender [" + name + "] to be rolled at midnight.");
			break;
		case TOP_OF_WEEK:
			LogLog.debug("Appender [" + name
					+ "] to be rolled at start of week.");
			break;
		case TOP_OF_MONTH:
			LogLog.debug("Appender [" + name
					+ "] to be rolled at start of every month.");
			break;
		default:
			LogLog.warn("Unknown periodicity for appender [" + name + "].");
		}
	}

	// This method computes the roll over period by looping over the
	// periods, starting with the shortest, and stopping when the r0 is
	// different from from r1, where r0 is the epoch formatted according
	// the datePattern (supplied by the user) and r1 is the
	// epoch+nextMillis(i) formatted according to datePattern. All date
	// formatting is done in GMT and not local format because the test
	// logic is based on comparisons relative to 1970-01-01 00:00:00
	// GMT (the epoch).

	int computeCheckPeriod() {
		RollingCalendar rollingCalendar = new RollingCalendar(gmtTimeZone,
				Locale.ENGLISH);
		// set sate to 1970-01-01 00:00:00 GMT
		Date epoch = new Date(0);
		if (datePattern != null) {
			for (int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++) {
				SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
						datePattern);
				simpleDateFormat.setTimeZone(gmtTimeZone); // do all date
				// formatting in GMT
				String r0 = simpleDateFormat.format(epoch);
				rollingCalendar.setType(i);
				Date next = new Date(rollingCalendar.getNextCheckMillis(epoch));
				String r1 = simpleDateFormat.format(next);
				LogLog.debug("Type = " + i + ", r0 = " + r0 + ", r1 = " + r1);
				if (r0 != null && r1 != null && !r0.equals(r1)) {
					return i;
				}
			}
		}
		return TOP_OF_TROUBLE; // Deliberately head for trouble...
	}

	/**
	 * Rollover the current file to a new file.
	 */
	public void rollOverForTime() throws IOException {

		/* Compute filename, but only if datePattern is specified */
		if (datePattern == null) {
			errorHandler.error("Missing DatePattern option in rollOver().");
			return;
		}

		String datedFilename = fileName + sdf.format(now);
		LogLog.debug("datedFilename:" + datedFilename);
		// It is too early to roll over because we are still within the
		// bounds of the current interval. Rollover will occur once the
		// next interval is reached.
		if (scheduledFilename.equals(datedFilename)) {
			return;
		}

		// close current file, and rename it to datedFilename
		this.closeFile();

		File target = new File(scheduledFilename + BACKUP_SUFFIX);
		if (target.exists()) {
			target.delete();
		}

		File file = new File(fileName);
		for (int i = 1; i <= maxBackupIndex; i++) { // roll for all size-backup
			// files
			String before = fileName + "." + i;
			File files = new File(before);
			String after = scheduledFilename + "." + i + BACKUP_SUFFIX;
			File targets = new File(after);
			if (targets.exists()) {
				targets.delete();
			}
			if (files.exists()) { // only backup existed one
				boolean result = files.renameTo(targets);
				if (result) {
					LogLog.debug(before + " -> " + after);
				} else {
					LogLog.error("Failed to rename [" + before + "] to ["
							+ after + "].");
				}
			}
		}

		// rename current writting file is necessary
		boolean result = file.renameTo(target);
		if (result) {
			LogLog.debug(fileName + " -> " + scheduledFilename);
		} else {
			LogLog.error("Failed to rename [" + fileName + "] to ["
					+ scheduledFilename + "].");
		}

		try {
			// This will also close the file. This is OK since multiple
			// close operations are safe.
			this.setFile(fileName, false, this.bufferedIO, this.bufferSize);
		} catch (IOException e) {
			errorHandler.error("setFile(" + fileName + ", false) call failed.");
		}
		scheduledFilename = datedFilename;
		LogLog.debug("scheduledFilename after roll:" + scheduledFilename);
	}

	/**
	 * Implements the usual roll over behaviour.
	 * <p>
	 * If <code>MaxBackupIndex</code> is positive, then files {<code>File.1</code>,
	 * ..., <code>File.MaxBackupIndex -1</code>} are renamed to {<code>File.2</code>,
	 * ..., <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code>
	 * is renamed <code>File.1</code> and closed. A new <code>File</code> is
	 * created to receive further log output.
	 * <p>
	 * If <code>MaxBackupIndex</code> is equal to zero, then the
	 * <code>File</code> is truncated with no backup files created.
	 */
	public void rollOverForSize() { // synchronization not necessary since
		// doAppend is alreasy synched
		File target;
		File file;

		LogLog.debug("rolling over count="
				+ ((CountingQuietWriter) qw).getCount());
		LogLog.debug("maxBackupIndex=" + maxBackupIndex);
		// If maxBackups <= 0, then there is no file renaming to be done.
		if (maxBackupIndex > 0) {
			// Delete the oldest file, to keep Windows happy.
			file = new File(fileName + '.' + maxBackupIndex);
			if (file.exists()) {
				file.delete();

				// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex,
				// ..., 3, 2}
			}
			for (int i = maxBackupIndex - 1; i >= 1; i--) {
				file = new File(fileName + "." + i);
				if (file.exists()) {
					target = new File(fileName + '.' + (i + 1));
					LogLog.debug("Renaming file " + file + " to " + target);
					file.renameTo(target);
				}
			}

			// Rename fileName to fileName.1
			target = new File(fileName + "." + 1);

			this.closeFile(); // keep windows happy.

			file = new File(fileName);
			LogLog.debug("Renaming file " + file + " to " + target);
			file.renameTo(target);
		}

		try {
			// This will also close the file. This is OK since multiple
			// close operations are safe.
			this.setFile(fileName, false, bufferedIO, bufferSize);
		} catch (IOException e) {
			LogLog.error("setFile(" + fileName + ", false) call failed.", e);
		}
	}

	/**
	 * This method differentiates TimeSizeRollingFileAppender from its super
	 * class.
	 * 
	 * <p>
	 * Before actually logging, this method will check whether it is time to do
	 * a rollover. If it is, it will schedule the next rollover time and then
	 * rollover.
	 */
	protected void subAppend(LoggingEvent event) {
		if ((fileName != null)
				&& ((CountingQuietWriter) qw).getCount() >= maxFileSize) {
			rollOverForSize();
		}
		long n = System.currentTimeMillis();
		if (n >= nextCheck) {
			now.setTime(n);
			nextCheck = rc.getNextCheckMillis(now);
			try {
				rollOverForTime();
			} catch (IOException ioe) {
				LogLog.error("rollOver() failed.", ioe);
			}
		}
		// @CheckItem@ OPT-yanfeng-20030909 remove file exist check while
		// logging for better effencience
		super.subAppend(event);
	}
}

/**
 * RollingCalendar is a helper class to TimeSizeRollingFileAppender. Given a
 * periodicity type and the current time, it computes the start of the next
 * interval.
 */
class RollingCalendar extends GregorianCalendar {
	/**
	 * serialVersionUID.
	 */
	private static final long serialVersionUID = 2238807139240434580L;

	int type = TimeSizeRollingFileAppender.TOP_OF_TROUBLE;

	RollingCalendar() {
		super();
	}

	RollingCalendar(TimeZone tz, Locale locale) {
		super(tz, locale);
	}

	void setType(int type) {
		this.type = type;
	}

	public long getNextCheckMillis(Date now) {
		return getNextCheckDate(now).getTime();
	}

	public Date getNextCheckDate(Date now) {
		this.setTime(now);

		switch (type) {
		case TimeSizeRollingFileAppender.TOP_OF_MINUTE:
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			this.add(Calendar.MINUTE, 1);
			break;
		case TimeSizeRollingFileAppender.TOP_OF_HOUR:
			this.set(Calendar.MINUTE, 0);
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			this.add(Calendar.HOUR_OF_DAY, 1);
			break;
		case TimeSizeRollingFileAppender.HALF_DAY:
			this.set(Calendar.MINUTE, 0);
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			int hour = get(Calendar.HOUR_OF_DAY);
			if (hour < 12) {
				this.set(Calendar.HOUR_OF_DAY, 12);
			} else {
				this.set(Calendar.HOUR_OF_DAY, 0);
				this.add(Calendar.DAY_OF_MONTH, 1);
			}
			break;
		case TimeSizeRollingFileAppender.TOP_OF_DAY:
			this.set(Calendar.HOUR_OF_DAY, 0);
			this.set(Calendar.MINUTE, 0);
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			this.add(Calendar.DATE, 1);
			break;
		case TimeSizeRollingFileAppender.TOP_OF_WEEK:
			this.set(Calendar.DAY_OF_WEEK, getFirstDayOfWeek());
			this.set(Calendar.HOUR_OF_DAY, 0);
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			this.add(Calendar.WEEK_OF_YEAR, 1);
			break;
		case TimeSizeRollingFileAppender.TOP_OF_MONTH:
			this.set(Calendar.DATE, 1);
			this.set(Calendar.HOUR_OF_DAY, 0);
			this.set(Calendar.SECOND, 0);
			this.set(Calendar.MILLISECOND, 0);
			this.add(Calendar.MONTH, 1);
			break;
		default:
			throw new IllegalStateException("Unknown periodicity type.");
		}
		return getTime();
	}

}
加载指定目录下的jar 加载jar,classloader
package com.whty.onest;

import java.io.File;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;

public final class ClassLoaderUtil
{
  private static Method addURL = initAddMethod();

  private static URLClassLoader system = (URLClassLoader)ClassLoader.getSystemClassLoader();

  private static final Method initAddMethod()
  {
    try
    {
      Method add = URLClassLoader.class
        .getDeclaredMethod("addURL", new Class[] { URL.class });
      add.setAccessible(true);
      return add;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }

  private static final void loopFiles(File file, List<File> files)
  {
    if (file.isDirectory()) {
      File[] tmps = file.listFiles();
      for (File tmp : tmps) {
        loopFiles(tmp, files);
      }
    }
    else if ((file.getAbsolutePath().endsWith(".jar")) || (file.getAbsolutePath().endsWith(".zip"))) {
      files.add(file);
    }
  }

  public static final void loadJarFile(File file)
  {
    try
    {
      addURL.invoke(system, new Object[] { file.toURI().toURL() });
      System.out.println("加载JAR包:" + file.getAbsolutePath());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static final void loadJarPath(String path)
  {
    List files = new ArrayList();
    File lib = new File(path);
    loopFiles(lib, files);
    for (File file : files)
      loadJarFile(file);
  }
}
oracle 新增dblink dblink,oracle
create database link ps_dblink connect to uspc_ps identified by uspc_ps using '10.1.5.12:1522/ora10g';
drop database link ps_dblink
select SEQ_sms_id.nextval from dual;

insert into sms_send@ps_dblink 
select SEQ_sms_id.nextval@ps_dblink,CLIENT_ID, DESTINATION, CONTENT, MESSAGE_ID, t.last_send_date, DEAL_TIMES, STATUS, CREATE_TIME , EXPECTED_SEND_DATE, t.iscrypt, ERROR_CODE, ERROR_MESSAGE,SOURCE 
   from sms_send t where t.destination = (select config_value from uspc_sys_config where config_name = 'DATA_RECEIVE_NOTIFY_MOBILES');
   select SEQ_sms_id.nextval from dual
   
   select * from sms_send@ps_dblink m where m.DESTINATION='13823649821'
mongodb帮助类 mongodb,dao
/* 
 * @(#)MongoBaseDao.java 2013-5-21
 * Copyright (c) 2013 TianYu Technologies, Inc. All rights reserved.   
 * 
 * This software is the confidential and proprietary information of   
 * TianYu Technologies. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with TianYu Technologies.   
 *   
 */
package com.whty.eop.cms.common.mongo;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;

import com.component.page.Pagination;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.whty.eop.cms.common.base.BaseDomain;
import com.whty.eop.cms.common.domain.LogVO;
import com.whty.eop.cms.common.util.DateUtils;
import com.whty.eop.cms.content.domain.Cms_Content;
import com.whty.eop.cms.content.domain.Cms_Content_His;

/**
 * <p> Title: EOP_CMS </p>
 * <p> Description: 
 * 该类主要是得到Spring-mongo数据访问层接口,同时编写对Mongo操作的公用方法
 *  </p>
 * 
 * @author WF
 * @version 2.0 2013-5-21
 * 
 * Modification History: Date Author Version Description
 * ------------------------------------------------------------------
 * 
 */
@Component("mongoBaseDao")
public class MongoBaseDao {
	/**
	 * logger
	 */
	protected static final Logger logger = Logger.getLogger(MongoBaseDao.class);

	/**
	 * Spring-Mongo 访问接口
	 */
	@Resource
	public MongoOperations mongoOperations;

	/**
	 * 根据键值查找 单个数据
	 * 
	 * @param keyName
	 *            字段名称
	 * @param keyValue
	 *            字段对应值
	 * @return entityClass 实体类
	 * @throws Exception
	 */
	public <T> T findObjByKeyAndValue(String keyName, String keyValue, Class<T> entityClass) {
		return mongoOperations.findOne(query(where(keyName).is(keyValue)), entityClass);
	}

	/**
	 * 根据键值查询数据集合
	 * 
	 * @param <T>
	 * @param keyName
	 *            字段名称
	 * @param keyValue
	 *            字段对应值
	 * @param entityClass
	 *            实体类
	 * @return
	 */
	public <T> List<T> listObjByKeyAndValue(String keyName, String keyValue, Class<T> entityClass) {
		return mongoOperations.find(query(where(keyName).is(keyValue)), entityClass);
	}

	/**
	 * 单条数据的插入
	 * 
	 * @param tclass
	 *            实体class类
	 * @param o
	 */
	public <T extends BaseDomain> void insert(T o) {
		// 创建时间
		Date date = new Date();
		o.setCreateTime(date);
		o.setUpdateTime(date);
		o.setCreateTimeStr(DateUtils.dateToStrLong(date));
		o.setUpdateTimeStr(DateUtils.dateToStrLong(date));
		mongoOperations.insert(o);
	}

	/**
	 * 数据集合报错
	 * 
	 * @param objects
	 *            数据集合
	 */
	public <T> void insertAll(Collection<? extends Object> objects) {
		mongoOperations.insertAll(objects);
	}

	/**
	 * 单条数据的保存,类似于Hibernate的saveOrupdate
	 * 
	 * @param tclass
	 *            实体class类
	 * @param o
	 * 
	 */
	public <T extends BaseDomain> void save(T o) {
		Date date = new Date();
		o.setCreateTime(date);
		o.setUpdateTime(date);
		o.setCreateTimeStr(DateUtils.dateToStrLong(date));
		o.setUpdateTimeStr(DateUtils.dateToStrLong(date));
		mongoOperations.save(o);
	}

	public <T extends BaseDomain> void update(String coll, T o, DBObject query) {
		Date date = new Date();
		o.setUpdateTime(date);
		o.setUpdateTimeStr(DateUtils.dateToStrLong(date));
		DBObject obj = new BasicDBObject();
		mongoOperations.getConverter().write(o, obj);
		mongoOperations.getCollection(coll).update(query, obj);
	}

	/**
	 * 通过条件查询更新数据
	 * 
	 * @param query
	 * @param update
	 * @return
	 */
	public void update(Query query, Update update, Class<?> clazz) {
		Date date = new Date();
		update.set("updateTime", date);
		update.set("updateTimeStr", DateUtils.dateToStrLong(date));
		mongoOperations.upsert(query, update, clazz);
	}
	
	/**
	 * 通过条件查询更新数据
	 * 
	 * @param query
	 * @param update
	 * @return
	 */
	public void logDelete(String operate,DBObject query,String userName) {
		LogVO vo=LogVO.getLogVO();
		vo.setQuery(query.toString());
		vo.setOperateUserName(userName);
		mongoOperations.insert(vo);
	}
	
	/**
	 * 通过条件查询更新数据
	 * 
	 * @param query
	 * @param update
	 * @return
	 */
	public void logDelete(String operate,List<Cms_Content> contents,String userName) {
		List<Cms_Content_His> contents_his = new ArrayList<Cms_Content_His>();
		if(contents != null){
			for(Cms_Content content : contents){
				Cms_Content_His his = new Cms_Content_His();
				BeanUtils.copyProperties(content, his);
				his.setDelDate(DateUtils.getStringDate());
				his.setDelUsername(userName);
				contents_his.add(his);
			}
		}

		mongoOperations.insertAll(contents_his);
	}
	
	/**
	 * @desc 通用查询记录集
	 * @date 2013-6-27
	 * @author xiongxiaofei
	 *         List<T>
	 * @param query
	 * @param clazz
	 * @return
	 */
	public <T> List<T> findPaginationSort(Class<T> clazz, Query query, Pagination<T> pagination) {

		List<T> resultList = null;
		if (pagination != null) {
			Long count = this.count(query, clazz); // 获取查询的内容总数
			int currentPage = pagination.getCurrentPage(); // 当前页码
			int pageNum = pagination.getCount(); // 每页条数
			long tempNum=count/pageNum;
			tempNum=count%pageNum>0?(tempNum+1):tempNum;
			if(tempNum<currentPage){
				currentPage=Integer.parseInt(String.valueOf(tempNum));
				pagination.setCurrentPage(currentPage);
			}
			query.skip((currentPage - 1) * pageNum);
			query.limit(pageNum);
			pagination.setTotalCount(count.intValue());
			resultList = this.mongoOperations.find(query, clazz); // 分页查询
			pagination.setPageResult(resultList);
		} else {
			resultList = this.mongoOperations.find(query, clazz);
		}
		return resultList;
	}

	/**
	 * @desc 查询记录集
	 * @date 2013-6-27
	 * @author xiongxiaofei
	 *         List<T>
	 * @param bean
	 *            普通JavaBean对象
	 * @param clazz
	 * @return
	 */
	public <T> List<T> find(Object bean, Class<T> clazz, Pagination<T> pagination) {
		Query query = convertToQuery(bean);
		return find(query, clazz, pagination);
	}

	/**
	 * @desc 查询记录集
	 * @date 2013-6-27
	 * @author xiongxiaofei
	 *         List<T>
	 * @param query
	 * @param clazz
	 * @return
	 */
	public <T> List<T> find(Query query, Class<T> clazz, Pagination<T> pagination) {
		List<T> resultList = null;
		if (pagination != null) {
			Long count = this.count(query, clazz); // 获取查询的内容总数
			int currentPage = pagination.getCurrentPage(); // 当前页码
			int pageNum = pagination.getCount(); // 每页条数
			long tempNum=count/pageNum;
			tempNum=count%pageNum>0?(tempNum+1):tempNum;
			if(tempNum<currentPage){
				currentPage=Integer.parseInt(String.valueOf(tempNum));
				pagination.setCurrentPage(currentPage);
			}
			query.skip((currentPage - 1) * pageNum);
			query.limit(pageNum);
			pagination.setTotalCount(count.intValue());
			resultList = this.mongoOperations.find(query, clazz); // 分页查询
			pagination.setPageResult(resultList);
		} else {
			resultList = this.mongoOperations.find(query, clazz);
		}
		return resultList;
	}

	/**
	 * @desc 普通JavaBean对象转换成Query对象
	 * @date 2013-6-27
	 * @author xiongxiaofei
	 *         Query
	 * @param bean
	 * @return
	 */
	protected Query convertToQuery(Object bean) {
		Query query = null;
		Criteria criteria = null;
		Class<?> clazz = bean.getClass();
		Field[] fields = clazz.getDeclaredFields();
		Boolean flag = false; // 标记Criteria对象是否已创建(false=没创建,true=已创建)
		for (int i = 0; i < fields.length; i++) {
			try {
				Field field = fields[i];
				String fieldName = field.getName();
				if (fieldName.equals("serialVersionUID")) {
					continue;
				}
				String getMethodName = "get" + String.valueOf(fieldName.charAt(0)).toUpperCase()
						+ fieldName.substring(1);
				Method getMethod = clazz.getMethod(getMethodName, new Class<?>[] {});
				if (!getMethod.isAccessible()) {
					getMethod.setAccessible(true);
				}
				Object value = getMethod.invoke(bean, new Object[] {});

				if (value != null) {
					if (!flag) {
						criteria = Criteria.where(fieldName).is(value);
						flag = true;
					} else {
						criteria = criteria.and(fieldName).is(value);
					}
				}
			} catch (Exception ex) {
				logger.error(ex.getMessage(), ex);
				continue;
			}
		}
		query = Query.query(criteria);
		return query;
	}

	/**
	 * 计算数量
	 * 
	 * @param <T>
	 * @param query
	 * @param clazz
	 * @return
	 */
	public <T> long count(Query query, Class<T> clazz) {
		// count 后期需要缓存
		return mongoOperations.count(query, clazz);
	}

	/**
	 * 根据条件删除数据
	 * 
	 * @param <T>
	 * @param query
	 * @param clazz
	 * @return
	 */
	public <T> void delete(Query query, Class<T> clazz) {
		mongoOperations.remove(query, clazz);
	}

	/**
	 * 根据字段名和删除条件
	 * 
	 * @param <T>
	 * @param delKey
	 *            字段
	 * @param delVal
	 *            删除条件,要是唯一条件才能调用此方法
	 * @param clazz
	 */
	public <T> void deleteByKeyAndVal(String delKey, String delVal, Class<T> clazz) {
		mongoOperations.remove(query(where(delKey).is(delVal)), clazz);
	}

	public MongoOperations getMongoOperations() {
		return mongoOperations;
	}

	public void setMongoOperations(MongoOperations mongoOperations) {
		this.mongoOperations = mongoOperations;
	}

}
linux ftp权限设置 linux,ftp
useradd ftp031
passwd ftp031
groupadd ftp031
usermod -G ftp031 ftp031
mkdir ${dir}/031/
chgrp -R ftp031 ${dir}/031
chmod -R 775 ${dir}/031
mongodb后台辅助命令 mongodb,遍历
var count=1;
db.cms_Content.find().forEach(function(x) {
	if(x.audit&&x.audit.experts){
		var ss=db.auditBatch.findOne({"contents":x.contentId});
		print(count++);
		if(ss&&ss.batchName){
		db.cms_Content.update({"contentId":x.contentId},{"$set":{"batchName":ss.batchName}});
		}
	}
});

db.cms_Content.count({"userId":"444333f107624489bae28140d1970bbc"})
var curse=db.cms_Content.find();
db.cms_Category.find().forEach(function(x) { db.cms_Content.update({"levelColumnId":x.categoryId},{"$set":{"textbook_list":x.categoryNamePath}},false,true);});

db.cms_Content.find({"userId":"444333f107624489bae28140d1970bbc"}).forEach(function(x) {
	if(x.title&&x.fileName){
		print(x.contentId);
		db.cms_Content.update({"contentId":x.contentId},{"$set":{"title":x.fileName}});
	}
})

db.cms_Content.update({"userId":"444333f107624489bae28140d1970bbc"},{"$set":{"status":"final_pass"}},false,true);
db.cms_Content.update({"status":{"$in":["tech_pass","experts_on","experts_pass","experts_deny"]}},{"$set":{"audit":{},"status":"tech_pass"}},false,true);

//更新审核信息
var count=1;
db.cms_Content.find().forEach(function(x) {
	if(x.audit&&x.audit.planExpertsName){
		var audit=x.audit;
		var expertNames=[];
		print(count++);
		var names=audit.planExpertsName.split(",");
		if(audit.expertCheckReason){
		var reason=audit.expertCheckReason.split("#!#");
		var users=audit.expertCheckUser.split(",");
		var usersId=audit.expertCheckUserId.split(",");
		var result=audit.expertCheckResult.split(",");
		for(var i=0;i<users.length;i++){
			var mm={"expertId":usersId[i],"expertName":users[i],"reason":reason[i],"result":result[i]};
			expertNames.push(mm);
		}
		}
		if(expertNames.length<audit.planExpertsId.length){
			for(var l=0;l<audit.planExpertsId.length;l++){
				if(!audit.expertCheckUserId||audit.expertCheckUserId.indexOf(audit.planExpertsId[l])<=-1){
					var mm1={"expertId":audit.planExpertsId[l],"expertName":names[l],"reason":"","result":""};
					expertNames.push(mm1);
				}
				
			}
		}
		audit.finalCheckUser=audit.finalCheckUser?audit.finalCheckUser:"";
		audit.finalCheckReason=audit.finalCheckUser?audit.finalCheckReason:"";
		audit.isSelect=audit.isSelect?audit.isSelect:"0";
		var ss={"experts":expertNames,"finalCheckUser":audit.finalCheckUser,"finalCheckReason":audit.finalCheckReason,"isSelect":audit.isSelect};
		db.cms_Content.update({"contentId":x.contentId},{"$set":{"audit":ss}});
	}
});
mongodb集群部署命令 mongodb、集群部署
/////////////////////////////////////////
/*  203 **/

./mongod -configsvr -port 20000 -dbpath /mongodb/mongodb-linux-x86_64-2.4.3/data/config -logpath /mongodb/mongodb-linux-x86_64-2.4.3/data/config.log -logappend -fork

./mongos -configdb 192.168.1.203:20000,192.168.1.207:20000,192.168.1.207:20001 -port 30000 -chunkSize 5 -logpath /mongodb/mongodb-linux-x86_64-2.4.3/data/mongos.log -logappend -fork



./mongod -shardsvr -replSet shard1 -port 27017 -dbpath /mongodb/mongodb-linux-x86_64-2.4.3/data/shard11 -oplogSize 100 -logpath /mongodb/mongodb-linux-x86_64-2.4.3/data/shard11/shard11.log -logappend -fork


/*  207 **/

./mongod -configsvr -port 20000 -dbpath /opt/mongodb/mongodb-linux-x86_64-2.4.3/data/config -logpath /opt/mongodb/mongodb-linux-x86_64-2.4.3/data/config.log -logappend -fork

./mongos -configdb 10.8.10.143:20000,10.8.10.150:20000,10.8.10.150:20001 -port 30000 -chunkSize 5 -logpath /opt/mongodb/mongodb-linux-x86_64-2.4.3/data/mongos.log -logappend -fork



./mongod -shardsvr -replSet shard2 -port 27017 -dbpath /opt/mongodb/mongodb-linux-x86_64-2.4.3/data/shard21 -oplogSize 100 -logpath /opt/mongodb/mongodb-linux-x86_64-2.4.3/data/shard21/shard71.log -logappend -fork


/*  集群配置 **/
config = {_id: 'shard3',members: [{_id:0, host: '10.8.10.150:27018'}]}
rs.initiate(config);

db.runCommand( { enablesharding : "tycms" } );


db.runCommand( { addshard : "shard1/10.8.10.143:27017",name:"s1",maxsize:20480} );

db.runCommand( {addshard : "shard2/10.8.10.150:27017",name:"s2",maxsize:20480} );
db.runCommand( {addshard : "shard3/10.8.10.150:27018",name:"s3",maxsize:20480} );


for (var i = 1; i <= 200000; i++) db.c1.save({id:i,value1:"1234567890",value2:"1234567890"})
for (var i = 1; i <= 3000; i++) db.c2.save({id:i,value1:"1234567890",value2:"1234567890"})

db.runCommand( { shardcollection : "tycms.cms_Content",key : {contentId: 1} } )

./mongod -dbpath /mongodb/mongodb-linux-x86_64-2.4.3/data -logpath /mongodb/mongodb-linux-x86_64-2.4.3/data/config.log 
将GBK转化为UTF-8 gbk;utf-8
package com.code.pd;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

import org.apache.commons.io.IOUtils;

/**
 * 
 * 
 *
 * @author  李鹏
 * @since   1.0
 * @version 2013-10-24 李鹏
 */
public class GbkToUtf {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		GbkToUtf.readfile("D:\\workspace\\JavaUtils\\src\\com\\code\\common");
	}

	public static void readfile(String filePath) {
		try {
			File file = new File(filePath);
			if (!file.isDirectory()) {
				transferCharset(file);
			} else if (file.isDirectory()) {
				System.out.println("文件夹");
				String[] filelist = file.list();
				for (int i = 0; i < filelist.length; i++) {
					File readfile = new File(filePath + "\\" + filelist[i]);
					if (!readfile.isDirectory()) {
							transferCharset(readfile);
					} else if (readfile.isDirectory()) {
						if(!"excel,jdbc,nosql,spring".contains( filelist[i])){
							readfile(filePath + "\\" + filelist[i]);
						}
					}
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public static void transferCharset(File file){
		try {
			String charset=codeString(file);
			if("GBK".equals(codeString(file))){
				System.out.println(file.getAbsolutePath()+"------------"+charset);
				String content = getFileContentWithCharsetName(file, "GBK");
				saveFileWithCharsetName(file, "UTF-8", content);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	public static void saveFileWithCharsetName(File file, String charsetName, String content)
			throws Exception {
		FileOutputStream fileOut = new FileOutputStream(file);
		// CharsetDecoder
		OutputStreamWriter outWrite = new OutputStreamWriter(fileOut, Charset.forName(charsetName));
		outWrite.write(content);
		outWrite.close();
	}
	
	/**
	 * 判断文件的编码格式
	 * @param fileName :file
	 * @return 文件编码格式
	 * @throws Exception
	 */
	public static String codeString(File fileName) throws Exception{
		BufferedInputStream bin = new BufferedInputStream(
		new FileInputStream(fileName));
		int p = (bin.read() << 8) + bin.read();
		String code = null;
		
		switch (p) {
			case 0xefbb:
				code = "UTF-8";
				break;
			case 0xfffe:
				code = "Unicode";
				break;
			case 0xfeff:
				code = "UTF-16BE";
				break;
			default:
				code = "GBK";
		}
		IOUtils.closeQuietly(bin);
		return code;
	}

	public static String getFileContentWithCharsetName(File file, String charsetName)
			throws Exception {
		FileInputStream fileIn = new FileInputStream(file);
		// CharsetDecoder
		InputStreamReader inRead = new InputStreamReader(fileIn, Charset.forName(charsetName));
		int size = (int) (file.length());
		char[] chs = new char[size];
		inRead.read(chs);
		String str = new String(chs).trim();
		inRead.close();
		return str;
	}
}
时间格式化常用方法 java,date
    /**
     * 时间转字符串
     * 
     * @param time 时间类型
     * @return 字符串
     */
    public static String getTimestampToString(Timestamp time) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return objSimpleDate.format(time);
    }
    
    /**
     * 时间转字符串当天的0时
     * 
     * @param time 时间
     * @return 字符
     */
    public static String getDateToStringMin(Date time) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        return objSimpleDate.format(time);
    }
    
    /**
     * 时间转字符串当天的23时59份59秒
     * 
     * @param time 时间
     * @return 字符
     */
    public static String getDateToStringMax(Date time) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
        return objSimpleDate.format(time);
    }
    
    /**
     * 时间转字符串,可以指定样式的转换时间
     * 
     * @param time 时间
     * @param strPattern 格式
     * @return 字符
     */
    public static String getTimestampToString(Timestamp time, String strPattern) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat(strPattern);
        return objSimpleDate.format(time);
    }
    
    /**
     * 时间转字符串,可以指定样式的转换时间
     * 
     * @param time 时间
     * @return 字符
     */
    public static String timestampToString(Timestamp time) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return objSimpleDate.format(time);
    }
    
    /**
     * 时间转字符串,可以指定样式
     * 
     * @param objDate 时间
     * @param strPattern 格式
     * @return 字符
     */
    public static String getDateToString(Date objDate, String strPattern) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat(strPattern);
        return objSimpleDate.format(objDate);
    }
    
    /**
     * 时间转字符串
     * 
     * @param objDate 时间
     * @return 字符
     */
    public static String getDateToString(Date objDate) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return objSimpleDate.format(objDate);
    }
    
    /**
     * 字符串转时间
     * 
     * @param strTtime 字符
     * @return 时间格式
     */
    public static Date getStringToDate(String strTtime) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date objDate = null;
        try {
            objDate = objSimpleDate.parse(strTtime);
        } catch (ParseException e) {
            LOGGER.error("字符串转时间异" + e);
        }
        return objDate;
    }
    
    /**
     * 字符串转时间
     * 
     * @param strTtime 字符
     * @return 时间格式
     */
    public static Timestamp getStringToTimestamp(String strTtime) {
        SimpleDateFormat objSimpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date objDate = null;
        try {
            objDate = objSimpleDate.parse(strTtime);
        } catch (ParseException e) {
            LOGGER.error("字符串转时间异" + e);
            return null;
        }
        return new Timestamp(objDate.getTime());
    }
    
    /**
     * 获取uuid
     * 
     * @return 唯一标识
     */
    public static String getUUID() {
        return UUID.randomUUID().toString();
    }
    
    /**
     * 返回当前时间
     * 
     * @return 当前时间
     */
    public static Timestamp getCurrentTime() {
        return new Timestamp(new Date().getTime());
    }
    
    /**
     * 处理double的精度
     * 
     * @param dParam
     * @param iScale
     * @return double
     */
    public static double getDoubleToPattern(double dParam, int iScale) {
        double dParamValue = 0.0D;
        try {
            BigDecimal objB = new BigDecimal(dParam);
            dParamValue = objB.setScale(iScale, BigDecimal.ROUND_HALF_UP).doubleValue();
        } catch (Exception e) {
            LOGGER.error("处理double精度异常", e);
            return dParam;
        }
        
        return dParamValue;
    }
    
    /**
     * 处理当前时间为yyyy-MM-dd HH:mm:s0的格式
     * 
     * @param objDate
     * @return Date
     */
    public static String getCurrentDate(Date objDate) {
        String strDate = CommonUtils.getDateToString(objDate, "yyyy-MM-dd HH:mm:ss");
        strDate = strDate.subSequence(0, 18) + "0";
        return strDate;
    }
    
    /**
     * 数据精度转换方法
     * 
     * @param dOringal 原始数值
     * @param iParam 被出的参数
     * @param iScale 保留的精度
     * @return double 计算结果
     */
    public static double transferData(double dOringal, double iParam, int iScale) {
        dOringal = dOringal / iParam;
        // 保留指定小数位
        dOringal = getDoubleToPattern(dOringal, iScale);
        return dOringal;
    }
    
    /**
     * 数据统一格式化方法,因为从TOP平台的封装,从数据库中查询出0.36类型的数据,Java中返回是.36 使用该方法统一将数据格式化为0.00格式。
     * 
     * @param number 需格式化的数据
     * @param pattern 模式 两位小数是"0.00" 三位小数是"0.000"
     * @return 返回格式化后字符串形式的数据
     */
    public static String formate(String number, String pattern) {
        String value = "";
        if (StringUtils.isEmpty(number) || StringUtils.isEmpty(pattern)) {
            value = "";
        } else {
            // 返回一个新的 double 值,该值被初始化为用指定 String 表示的值,这与 Double 类的 valueOf 方法一样。
            double temp = Double.parseDouble(number);
            // 创建一个DecimalFormat实例
            DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
            // 将给定的模式应用于此 Format 对象
            df.applyPattern(pattern);
            value = df.format(temp);
        }
        return value;
    }
    
    /**
     * 获得两个时间的时间差,天为单位
     * 
     * @param beginTime 开始时间字符
     * @param endTime 结束时间字符
     * @param format 格式
     * @return 时间差
     */
    public static Long getStringTimeDiff(String beginTime, String endTime, String format, char interval) {
        long division = 0;
        switch (interval) {
            // 秒
            case 's':
                division = 1000;
                break;
            // 分
            case 'n':
                division = 60 * 1000;
                break;
            // 时
            case 'h':
                division = 60 * 60 * 1000;
                break;
            // 天
            case 'd':
                division = 24 * 60 * 60 * 1000;
                break;
            // 周
            case 'w':
                division = 7 * 24 * 60 * 60 * 1000;
                break;
        }
        
        SimpleDateFormat objSimpleDate = new SimpleDateFormat(format);
        Long diff = null;
        if (division != 0) {
            try {
                diff = (objSimpleDate.parse(endTime).getTime() - objSimpleDate.parse(beginTime).getTime()) / division;
            } catch (ParseException e) {
                LOGGER.error("字符串转时间异" + e);
            }
        }
        return diff;
    }
js 帮助类 js, 常用
/**
 * author 李鹏
 * 2011-11-22
 * 操作轨迹js库
 */


/**
 * 将时间类型转化为字符串
 */
 function timeToString(date){
 	if(date&&Date.parse(date) != Date.parse(date)){
	    var year = date.year+1900;
	    var month = (date.month+1)<10?"0"+(date.month+1):(date.month+1);
	    var day = (date.date)<10?"0"+(date.date):(date.date);
	    var hours = (date.hours)<10?"0"+(date.hours):(date.hours);
	    var minutes = (date.minutes)<10?"0"+(date.minutes):(date.minutes);
	    var seconds = (date.seconds)<10?"0"+(date.seconds):(date.seconds);
	    return  year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
 	}
 }
/**
 * 获取鼠标位置
 */
function mousePosition(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop - document.body.clientTop
	};
}

/**
 *  获取页面中元素位置
 */
function GetAbsoluteLocation(element)
{
    if ( arguments.length != 1 || element == null )
    {
        return null;
    }
    var offsetTop = element.offsetTop;
    var offsetLeft = element.offsetLeft;
    var offsetWidth = element.offsetWidth;
    var offsetHeight = element.offsetHeight;
    while( element = element.offsetParent )
    {
        offsetTop += element.offsetTop;
        offsetLeft += element.offsetLeft;
    }
    return { absoluteTop: offsetTop, absoluteLeft: offsetLeft,
        offsetWidth: offsetWidth, offsetHeight: offsetHeight };
}


/**
功能:锁定表头行,表头滚动到页面顶部之后就自动锁定在顶部了。
      如果表格宽度是根据百分比决定的,在页面大小改变时可以自动调整表头宽度。
使用方法:var lth = new LockTableHead('tableId');
在IE 6上通过测试。
*/

function LockTableHead(tableId,divId)
{
	var tops, left;
	var nt;
	var t = document.getElementById(tableId);
	if(nt)
		nt.style.display = 'none';
    this._Resize = _Resize;
    if (t){
        nt = t.cloneNode(true);
        for(var i = nt.rows.length - 1;  i > 0; i--)
        {
            nt.deleteRow(i);
        }
        document.getElementById(divId).appendChild(nt);
        _Resize();
    }

    function _Scroll(){
        window.status = top;
        if (document.body.scrollTop >= top)
        {
            nt.style.top = document.body.scrollTop;
        } else{
            nt.style.top = tops + 'px';
        }
    }

    function _Resize(){
    	if(nt){
	        nt.style.width = t.offsetWidth + 'px';
	        nt.style.position = 'absolute';
	        nt.style.height = "";

	        tops = t.offsetTop;
	        left = t.offsetLeft;

	        var t2 = t;
	        while(t2.offsetParent)
	        {
	            t2 = t2.offsetParent;
	            tops += t2.offsetTop;
	            left += t2.offsetLeft;
	        }
	        nt.style.left = left;
	        _Scroll();
	        nt.style.zIndex = 100;
    	}
    }

    function clearAll(){
    	top=null;
    	left=null;
        nt=null;
    }
    this.clearAll=clearAll;
    this._Scroll=_Scroll;
    this.tops=tops;
    this.left=left;
    this.nt=nt;
}
Global site tag (gtag.js) - Google Analytics