/** 一页的数据数量 */
int size = 20;
/** 超始页,一般是1 */
int first = 1;
/** 当前页 */
int curr = 1;
/** 最后页,总页数 */
int last = 1;
/** 总条数 */
int total = 0;
/** 数据超始索引 */
int start = 0;
/** 数据结束索引 */
int finish = 0;
#2 户藉常量
这里的结构是枚举类型 enum(num, desc)
LOCAL_CITY(1, "本市城镇"),
LOCAL_VILLAGE(2, "本市农村"),
NONLOCAL_CITY(3, "外地城镇"),
NONLOCAL_VILLAGE(4, "外地农村");
#3 基数类型
数值 | 代表基数 |
---|---|
1 | 自定义 |
2 | 最低工资 |
3 | 实际工资 ( 暂不支持 ) |
建议使用 SockJS客户端.
/he/ws/new/conn
前端公共JS代码
var webSocketSrv, ws_session_id="", curr_uri, ws_uri="/he/ws/new/conn";
/**
* 使用WebSocket
* @param websocket_uri
* @param openFunc
* @param msgFunc
*/
function useWebSocket(websocket_uri, openFunc, msgFunc) {
if (webSocketSrv && webSocketSrv.readyState == 1) { // open=1, closed=3
ws_close();
}
curr_uri = (undefined != websocket_uri && "" != websocket_uri) ? websocket_uri : ws_uri;
webSocketSrv = new SockJS(curr_uri);
if (undefined == openFunc) {
webSocketSrv.onopen = function () {
ws_opened(false);
};
} else {
webSocketSrv.onopen = openFunc;
}
if (undefined == msgFunc) {
webSocketSrv.onmessage = function (evt) {
var data = JSON.parse(evt.data);
if ("WS_DONE" == data.p) {
webSocketSrv.close();
clearInterval(ws_interval);
}
}
} else {
webSocketSrv.onmessage = msgFunc;
}
webSocketSrv.onerror = function (evt) {
webSocketSrv.close();
notice("WS因异常已关闭:"+evt.data, 8000);
};
}
/**
* 在WebSocket的 onopen, onmessage事件中调用.
* data : JS的JSON对象.
*/
var ws_interval, auto_conn=false, openFunc, msgFunc;
function ws_opened(autoConn) {
wsSessionId();
clearInterval(ws_interval);
notice("WS连接成功", 1);
auto_conn = autoConn;
if (!auto_conn) {
return;
}
openFunc = webSocketSrv.onopen;
msgFunc = webSocketSrv.onmessage;
ws_interval = window.setInterval(function () {
if (webSocketSrv && webSocketSrv.readyState != 1) { // open=1
notice("WS连接已关闭, 自动尝试重连");
if (auto_conn == false) {
clearInterval(ws_interval);
} else {
useWebSocket(curr_uri, openFunc, msgFunc);
}
}
}, 5000);
}
function ws_close() {
webSocketSrv.close();
clearInterval(ws_interval);
auto_conn = false;
}
/**
* 当只需要用到WS的消息展示,不发送消息时.
* 手动获取得到WebSocket的SessionID, 发到其它接口进行消息推送
*/
function wsSessionId() {
if (webSocketSrv) {
var url = webSocketSrv._transport.url;
var uri = url.substring(url.indexOf(curr_uri)+curr_uri.length+1, url.length);
ws_session_id = uri.substring(uri.indexOf("/")+1, uri.indexOf("/")+9);
console.log("ws_id="+ws_session_id);
return ws_session_id;
}
return "";
}
调用
useWebSocket("", function () { // onopen
ws_opened(true);
var data = {
p: "sync_wdsb_sbuser",
msg: ""
};
webSocketSrv.send(JSON.stringify(data));
}, function (evt) { // onmessage
var data = JSON.parse(evt.data);
$("#wsModal").modal({ backdrop: 'static', keyboard: false });
$("#wsBody").prepend("<p>"+data.msg+"</p>");
if (data.p == "WS_DONE") {
ws_close();
}
}
);
协议号 | 描述 |
---|---|
WS_ID | 成功打开连接,直接推送此协议消息 |
WS_MSG | 普通的消息 |
WS_DONE | 成功处理,WebSocket使用结束. |
{
"p": "WS_MSG",
"msg": "员工的五险一金方案不存在,已经终止修改。"
}
第一个参数名: num, 第二个参数名: desc
PRE_PAY(1, "待付款"),
PAY_OK(2, "完成付款"),
APPLYING(3, "正在申报中"),
OK(4, "参缴成功"),
FAIL(5, "参缴不成功"),
REFUNDED(11, "已全额退款"),
ASK_REFUND(15, "用户申请退款"),
WXYJ_DOC(30, "存档中(不可更改)"),
WXYJ_GEN(31, "系统生成"),
WXYJ_PROXY(32, "代缴生成"),
WXYJ_CONFIRM(36, "代缴确认"),
WXYJ_PROXYING(40, "代缴中"), // 然后接下状态:APPLYING(3, "正在申报中")、OK(4, "完成参保") 或 FAIL(5, "参保不成功"),
WXYJ_PROXYED(44, "代缴完成")
enum(int num, String desc)
INC_C_DEC_C(0, "增当月、减当月")
INC_C_DEC_N(1, "增当月、减下月")
INC_N_DEC_N(2, "增下月、减下月")
enum(int num, String desc)
LOCAL_CITY(1, "本市城镇"),
LOCAL_VILLAGE(2, "本市农村"),
NONLOCAL_CITY(3, "外地城镇"),
NONLOCAL_VILLAGE(4, "外地农村");
enum(int num, String desc)
INC(1, "增员"),
NORMAL(5, "在保"),
DEC(8, "减员"),
REPAY(11, "补缴") // 补缴数据不区分增员还是在保.