common.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html;charset=UTF-8">
  5. <style type="text/css">
  6. <!--
  7. @import url(md.css);
  8. -->
  9. </style>
  10. </head>
  11. <body>
  12. <h2>通用</h2>
  13. <div id="page"></div>
  14. <h1>1 分页</h1>
  15. <pre><code>/** 一页的数据数量 */
  16. int size = 20;
  17. /** 超始页,一般是1 */
  18. int first = 1;
  19. /** 当前页 */
  20. int curr = 1;
  21. /** 最后页,总页数 */
  22. int last = 1;
  23. /** 总条数 */
  24. int total = 0;
  25. /** 数据超始索引 */
  26. int start = 0;
  27. /** 数据结束索引 */
  28. int finish = 0;
  29. </code></pre>
  30. <div id="hukou"></div>
  31. <h1>2 户藉常量</h1>
  32. <p>这里的结构是枚举类型 <code>enum(num, desc)</code></p>
  33. <pre><code>LOCAL_CITY(1, &quot;本市城镇&quot;),
  34. LOCAL_VILLAGE(2, &quot;本市农村&quot;),
  35. NONLOCAL_CITY(3, &quot;外地城镇&quot;),
  36. NONLOCAL_VILLAGE(4, &quot;外地农村&quot;);
  37. </code></pre>
  38. <div id="radix"></div>
  39. <h1>3 基数类型</h1>
  40. <table><thead>
  41. <tr>
  42. <th align="left">数值</th>
  43. <th align="left">代表基数</th>
  44. </tr>
  45. </thead><tbody>
  46. <tr>
  47. <td align="left">1</td>
  48. <td align="left">自定义</td>
  49. </tr>
  50. <tr>
  51. <td align="left">2</td>
  52. <td align="left">最低工资</td>
  53. </tr>
  54. <tr>
  55. <td align="left">3</td>
  56. <td align="left">实际工资 ( 暂不支持 )</td>
  57. </tr>
  58. </tbody></table>
  59. <div id="ws"></div>
  60. <h1>4 WebSocket</h1>
  61. <h3>请求连接</h3>
  62. <p>建议使用 <a href="https://github.com/sockjs/sockjs-client" target="_blank">SockJS客户端</a>.</p>
  63. <h5>URI</h5>
  64. <pre><code>/he/ws/new/conn
  65. </code></pre>
  66. <ul>
  67. <li><p>前端公共JS代码</p>
  68. <pre><code>var webSocketSrv, ws_session_id=&quot;&quot;, curr_uri, ws_uri=&quot;/he/ws/new/conn&quot;;
  69. /**
  70. * 使用WebSocket
  71. * @param websocket_uri
  72. * @param openFunc
  73. * @param msgFunc
  74. */
  75. function useWebSocket(websocket_uri, openFunc, msgFunc) {
  76. if (webSocketSrv &amp;&amp; webSocketSrv.readyState == 1) { // open=1, closed=3
  77. ws_close();
  78. }
  79. curr_uri = (undefined != websocket_uri &amp;&amp; &quot;&quot; != websocket_uri) ? websocket_uri : ws_uri;
  80. webSocketSrv = new SockJS(curr_uri);
  81. if (undefined == openFunc) {
  82. webSocketSrv.onopen = function () {
  83. ws_opened(false);
  84. };
  85. } else {
  86. webSocketSrv.onopen = openFunc;
  87. }
  88. if (undefined == msgFunc) {
  89. webSocketSrv.onmessage = function (evt) {
  90. var data = JSON.parse(evt.data);
  91. if (&quot;WS_DONE&quot; == data.p) {
  92. webSocketSrv.close();
  93. clearInterval(ws_interval);
  94. }
  95. }
  96. } else {
  97. webSocketSrv.onmessage = msgFunc;
  98. }
  99. webSocketSrv.onerror = function (evt) {
  100. webSocketSrv.close();
  101. notice(&quot;WS因异常已关闭:&quot;+evt.data, 8000);
  102. };
  103. }
  104. /**
  105. * 在WebSocket的 onopen, onmessage事件中调用.
  106. * data : JS的JSON对象.
  107. */
  108. var ws_interval, auto_conn=false, openFunc, msgFunc;
  109. function ws_opened(autoConn) {
  110. wsSessionId();
  111. clearInterval(ws_interval);
  112. notice(&quot;WS连接成功&quot;, 1);
  113. auto_conn = autoConn;
  114. if (!auto_conn) {
  115. return;
  116. }
  117. openFunc = webSocketSrv.onopen;
  118. msgFunc = webSocketSrv.onmessage;
  119. ws_interval = window.setInterval(function () {
  120. if (webSocketSrv &amp;&amp; webSocketSrv.readyState != 1) { // open=1
  121. notice(&quot;WS连接已关闭, 自动尝试重连&quot;);
  122. if (auto_conn == false) {
  123. clearInterval(ws_interval);
  124. } else {
  125. useWebSocket(curr_uri, openFunc, msgFunc);
  126. }
  127. }
  128. }, 5000);
  129. }
  130. function ws_close() {
  131. webSocketSrv.close();
  132. clearInterval(ws_interval);
  133. auto_conn = false;
  134. }
  135. /**
  136. * 当只需要用到WS的消息展示,不发送消息时.
  137. * 手动获取得到WebSocket的SessionID, 发到其它接口进行消息推送
  138. */
  139. function wsSessionId() {
  140. if (webSocketSrv) {
  141. var url = webSocketSrv._transport.url;
  142. var uri = url.substring(url.indexOf(curr_uri)+curr_uri.length+1, url.length);
  143. ws_session_id = uri.substring(uri.indexOf(&quot;/&quot;)+1, uri.indexOf(&quot;/&quot;)+9);
  144. console.log(&quot;ws_id=&quot;+ws_session_id);
  145. return ws_session_id;
  146. }
  147. return &quot;&quot;;
  148. }
  149. </code></pre></li>
  150. <li><p>调用</p>
  151. <pre><code>useWebSocket(&quot;&quot;, function () { // onopen
  152. ws_opened(true);
  153. var data = {
  154. p: &quot;sync_wdsb_sbuser&quot;,
  155. msg: &quot;&quot;
  156. };
  157. webSocketSrv.send(JSON.stringify(data));
  158. }, function (evt) { // onmessage
  159. var data = JSON.parse(evt.data);
  160. $(&quot;#wsModal&quot;).modal({ backdrop: &#39;static&#39;, keyboard: false });
  161. $(&quot;#wsBody&quot;).prepend(&quot;&lt;p&gt;&quot;+data.msg+&quot;&lt;/p&gt;&quot;);
  162. if (data.p == &quot;WS_DONE&quot;) {
  163. ws_close();
  164. }
  165. }
  166. );
  167. </code></pre></li>
  168. </ul>
  169. <h3>协议</h3>
  170. <table><thead>
  171. <tr>
  172. <th align="left">协议号</th>
  173. <th align="left">描述</th>
  174. </tr>
  175. </thead><tbody>
  176. <tr>
  177. <td align="left">WS_ID</td>
  178. <td align="left">成功打开连接,直接推送此协议消息</td>
  179. </tr>
  180. <tr>
  181. <td align="left">WS_MSG</td>
  182. <td align="left">普通的消息</td>
  183. </tr>
  184. <tr>
  185. <td align="left">WS_DONE</td>
  186. <td align="left">成功处理,WebSocket使用结束.</td>
  187. </tr>
  188. </tbody></table>
  189. <h3>响应的协议消息结构</h3>
  190. <ul>
  191. <li>p 协议号</li>
  192. <li>msg 协议内容体</li>
  193. </ul>
  194. <pre><code class="json">{<span class="attribute">
  195. "p</span>": <span class="value"><span class="string">"WS_MSG"</span></span>,<span class="attribute">
  196. "msg</span>": <span class="value"><span class="string">"员工的五险一金方案不存在,已经终止修改。"
  197. }
  198. </span></span></code></pre>
  199. <hr>
  200. <h1 id="wxyj_status"> 5 社保数据状态 </h1>
  201. <blockquote>
  202. <p>第一个参数名: num, 第二个参数名: desc</p>
  203. </blockquote>
  204. <pre><code>PRE_PAY(1, &quot;待付款&quot;),
  205. PAY_OK(2, &quot;完成付款&quot;),
  206. APPLYING(3, &quot;正在申报中&quot;),
  207. OK(4, &quot;参缴成功&quot;),
  208. FAIL(5, &quot;参缴不成功&quot;),
  209. REFUNDED(11, &quot;已全额退款&quot;),
  210. ASK_REFUND(15, &quot;用户申请退款&quot;),
  211. WXYJ_DOC(30, &quot;存档中(不可更改)&quot;),
  212. WXYJ_GEN(31, &quot;系统生成&quot;),
  213. WXYJ_PROXY(32, &quot;代缴生成&quot;),
  214. WXYJ_CONFIRM(36, &quot;代缴确认&quot;),
  215. WXYJ_PROXYING(40, &quot;代缴中&quot;), // 然后接下状态:APPLYING(3, &quot;正在申报中&quot;)、OK(4, &quot;完成参保&quot;) 或 FAIL(5, &quot;参保不成功&quot;),
  216. WXYJ_PROXYED(44, &quot;代缴完成&quot;)
  217. </code></pre>
  218. <hr>
  219. <h1 id="opt">6 操作规则</h1>
  220. <pre><code>enum(int num, String desc)
  221. INC_C_DEC_C(0, &quot;增当月、减当月&quot;)
  222. INC_C_DEC_N(1, &quot;增当月、减下月&quot;)
  223. INC_N_DEC_N(2, &quot;增下月、减下月&quot;)
  224. </code></pre>
  225. <hr>
  226. <h1 id="hukou">7 户藉常量</h1>
  227. <pre><code>enum(int num, String desc)
  228. LOCAL_CITY(1, &quot;本市城镇&quot;),
  229. LOCAL_VILLAGE(2, &quot;本市农村&quot;),
  230. NONLOCAL_CITY(3, &quot;外地城镇&quot;),
  231. NONLOCAL_VILLAGE(4, &quot;外地农村&quot;);
  232. </code></pre>
  233. <hr>
  234. <h1 id="wxyj_inc_normal_dec">8 参缴类型</h1>
  235. <pre><code>enum(int num, String desc)
  236. INC(1, &quot;增员&quot;),
  237. NORMAL(5, &quot;在保&quot;),
  238. DEC(8, &quot;减员&quot;),
  239. REPAY(11, &quot;补缴&quot;) // 补缴数据不区分增员还是在保.
  240. </code></pre>
  241. <hr>
  242. <script src="md.js"></script>
  243. </body>
  244. </html>