trackJobJs.jsp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
  3. <script src="${contextRoot}/develop/lib/plugin/switchery/switchery.js"></script>
  4. <script src="${contextRoot}/develop/lib/plugin/echarts/echarts-all.js"></script>
  5. <script>
  6. /* *************************** 自定义模块 ***************************** */
  7. var trackJob = {
  8. $form:$("#div_form"),
  9. grid:null,
  10. chart:null,
  11. dialog:null,
  12. repeat:null,
  13. switchery:null,
  14. init:function(){
  15. var me = this;
  16. //控件初始化
  17. $("#selJob").ligerComboBox({
  18. dict:true,
  19. dictName:"RS_JOB_CONFIG",
  20. onSelected:function(value,text)
  21. {
  22. me.search(value);
  23. },
  24. onSuccess:function(data)
  25. {
  26. if(data!=null&&data.length>0)
  27. {
  28. this.selectValue(data[0].code);
  29. }
  30. }
  31. });
  32. me.initSwitcher();
  33. me.chart=echarts.init(document.getElementById("echarts-bar-chart"));
  34. //列表控件
  35. me.grid = $("#div_grid").ligerGrid({
  36. url: '${contextRoot}/datacollect/getJobLog',
  37. selectRowButtonOnly:true,
  38. delayLoad:true,//初始化不加载
  39. columns: [
  40. {display:'采集开始时间',name:'jobStartTime', width: '10%'},
  41. {display:'采集结束时间',name:'jobEndTime', width: '10%'},
  42. {display:'采集数据集数',name:'jobDatasetCount', width: '10%'},
  43. {display:'成功数据集数',name:'jobDatasetSuccess', width: '10%'},
  44. {display:'数据总数',name:'count', width: '10%'},
  45. {display:'成功数据',name:'success', width: '10%'},
  46. {display:'补采数据',name:'repeatNum', width: '10%'},
  47. {
  48. display:'操作',name:'id',width: '12%',render:function(row){
  49. return '<a href="javascript:void(0)" onclick="javascript:trackJob.repeat()">补采</a>';
  50. }
  51. },
  52. {display:'信息',name:'jobContent', width: '18%'}
  53. ],
  54. onSuccess:function(data)
  55. {
  56. try {
  57. var list = data.detailModelList;
  58. if(list!=null&&list.length>0)
  59. {
  60. me.reload(list);
  61. }
  62. return true;
  63. }
  64. catch(e)
  65. {
  66. return false;
  67. }
  68. },
  69. onDblClickRow:function(data)
  70. {
  71. me.reloadRow(data.id);
  72. }
  73. });
  74. //任务补采
  75. $('#btnRepeatJob').click(function () {
  76. parent.indexPage.openMenuByText("任务补采", {
  77. jobId: $("#selJob").ligerComboBox("getValue")
  78. }, false);
  79. });
  80. //任务编辑
  81. $('#btnEditJob').click(function(){
  82. var title = "编辑任务";
  83. var params = {jobId:$("#selJob").ligerComboBox("getValue")};
  84. me.dialog=$.ligerDialog.open({
  85. height: 556,
  86. width: 700,
  87. title: title,
  88. url: '${contextRoot}/datacollect/editorJob',
  89. //load: true,
  90. urlParms: params
  91. });
  92. });
  93. },
  94. initSwitcher:function(){
  95. var me = this;
  96. //开关控件
  97. var changeCheckbox = document.querySelector('#jobStatusSwitch');
  98. me.switchery = new Switchery(changeCheckbox, { disabled: true,size: 'large' });
  99. changeCheckbox.onchange = function() {
  100. debugger
  101. var a = me.switchery;
  102. var jobId = $("#selJob").ligerComboBox("getValue");
  103. if(!changeCheckbox.checked)
  104. {
  105. me.valid(jobId,"0");
  106. }
  107. else{
  108. me.valid(jobId,"1");
  109. }
  110. };
  111. },
  112. repeat:function() {
  113. parent.indexPage.openMenuByText("任务补采", {jobId: $("#selJob").ligerComboBox("getValue")}, false);
  114. },
  115. callbackDialog:function(message){
  116. $.ligerDialog.success(message);
  117. this.dialog.close();
  118. },
  119. //获取任务相关数据
  120. search:function(jobId){
  121. debugger
  122. var me = this;
  123. me.clearTop();
  124. me.initSwitcher();
  125. if(jobId!="" && jobId.length>0)
  126. {
  127. //获取运行状态
  128. $.ajax({
  129. type: "POST",
  130. url : "${contextRoot}/datacollect/getJobInfo",
  131. dataType : "json",
  132. data:{jobId:jobId},
  133. cache:false,
  134. success :function(data){
  135. if(data.successFlg) {
  136. me.switchery.enable();
  137. me.setJobStatus(data.data);
  138. }
  139. else{
  140. $.ligerDialog.error(data.message);
  141. }
  142. },
  143. error :function(data){
  144. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  145. }
  146. });
  147. me.grid.set({
  148. parms: {jobId:jobId}
  149. });
  150. me.grid.reload();
  151. }
  152. },
  153. //任务状态
  154. setJobStatus:function(status)
  155. {
  156. var me = this;
  157. if(status=="1")
  158. {
  159. $('#jobStatusSwitch').attr("checked",true);
  160. me.switchery.element.checked=true;
  161. me.switchery.setPosition();
  162. $("#jobStatus").html('<span class="green job_run">正在运行中...</span>');
  163. }
  164. else{
  165. $('#jobStatusSwitch').removeAttr("checked");
  166. me.switchery.element.checked=false;
  167. me.switchery.setPosition();
  168. $("#jobStatus").html('<span class="red job_stop">运行暂停</span>');
  169. }
  170. },
  171. //生效失效
  172. valid:function(id,valid){
  173. if(id==null||id.length==0) return false;
  174. setTimeout(function () { return; }, 1000);
  175. $.ajax({
  176. type: "POST",
  177. url : "${contextRoot}/datacollect/validJob",
  178. dataType : "json",
  179. data:{jobId:id,valid:valid},
  180. cache:false,
  181. success :function(data){
  182. if(data.successFlg) {
  183. if(valid=="1")
  184. {
  185. $("#jobStatus").html('<span class="green job_run">正在运行中...</span>');
  186. }
  187. else{
  188. $("#jobStatus").html('<span class="red job_stop">运行暂停</span>');
  189. }
  190. }
  191. else{
  192. $.ligerDialog.error(data.message);
  193. }
  194. },
  195. error :function(data){
  196. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  197. }
  198. });
  199. },
  200. //上部数据情况
  201. clearTop:function(){
  202. var me = this;
  203. var parent = $("#jobStatusSwitch").parent();
  204. $("#jobStatusSwitch").next().remove();
  205. $("#jobStatusSwitch").remove();
  206. $('<input type="checkbox" class="js-switch" id="jobStatusSwitch" checked />').appendTo(parent);
  207. $("#divCount").html("-");
  208. $("#divSuccess").html("-");
  209. $("#divPercent").html("-");
  210. $("#echarts-bar-chart").hide();
  211. $("#echarts-blank").show();
  212. },
  213. setTop:function(count,success,percent){
  214. $("#divCount").html(count);
  215. $("#divSuccess").html(success);
  216. $("#divPercent").html(percent +"%");
  217. $("#echarts-bar-chart").show();
  218. $("#echarts-blank").hide();
  219. },
  220. //刷新页面数据
  221. reload:function(data)
  222. {
  223. var me =this;
  224. if(data!=null && data.length>0)
  225. {
  226. var count = 0
  227. var success =0;
  228. var x = [];
  229. var y1=[];
  230. var y2=[];
  231. for(var i=0;i<data.length;i++)
  232. {
  233. count += data[i].count;
  234. success += data[i].success;
  235. x.push(data[i].jobStartTime);
  236. y1.push(data[i].count);
  237. y2.push(data[i].success);
  238. }
  239. me.setTop(count,success,count?(success/count *100).toFixed(2):0);
  240. me.chart.setOption({
  241. title: {text:"采集情况"},
  242. tooltip:{trigger:"axis"},
  243. legend:{data:["数据总数","成功数据"]},
  244. grid:{x:30,x2:40,y2:24},
  245. calculable:!0,
  246. xAxis:[{type:"category",data:x}],
  247. yAxis:[{type:"value"}],
  248. series:[{name:"数据总数",type:"bar",data:y1,markLine:{data:[{type:"average",name:"平均值"}]}},
  249. {name:"成功数据",type:"bar",data:y2,markLine:{data:[{type:"average",name:"平均值"}]}}]},true);
  250. window.onresize=me.chart.resize;
  251. }
  252. else{
  253. me.clearTop();
  254. }
  255. },
  256. //根据某行获取刷新
  257. reloadRow:function(id)
  258. {
  259. var me = this;
  260. if(id!="" && id.length>0)
  261. {
  262. //获取某次采集情况数据
  263. $.ajax({
  264. type: "POST",
  265. url : "${contextRoot}/datacollect/getJobLogDataset",
  266. dataType : "json",
  267. data:{logId:id},
  268. cache:false,
  269. success :function(re){
  270. if(re.successFlg) {
  271. var data = re.detailModelList;
  272. if(data!=null && data.length>0)
  273. {
  274. var count = 0
  275. var success =0;
  276. var x = [];
  277. var y1=[];
  278. var y2=[];
  279. for(var i=0;i<data.length;i++)
  280. {
  281. count += data[i].y1;
  282. success += data[i].y2;
  283. x.push(data[i].x);
  284. y1.push(data[i].y1);
  285. y2.push(data[i].y2);
  286. }
  287. me.setTop(count,success,count?(success/count *100).toFixed(2):0);
  288. me.chart.setOption({title:{text:"采集情况"},
  289. tooltip:{trigger:"axis"},
  290. legend:{data:["数据总数","成功数据"]},
  291. grid:{x:30,x2:40,y2:24},
  292. calculable:!0,
  293. xAxis:[{type:"category",data:x}],
  294. yAxis:[{type:"value"}],
  295. series:[{name:"数据总数",type:"bar",data:y1,markLine:{data:[{type:"average",name:"平均值"}]}},
  296. {name:"成功数据",type:"bar",data:y2,markLine:{data:[{type:"average",name:"平均值"}]}}]},true);
  297. window.onresize=me.chart.resize;
  298. }
  299. else{
  300. me.clearTop();
  301. }
  302. }
  303. else{
  304. $.ligerDialog.error(re.message);
  305. }
  306. },
  307. error :function(data){
  308. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  309. }
  310. });
  311. }
  312. }
  313. }
  314. $(function () {
  315. trackJob.init();
  316. });
  317. </script>