123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
- <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
- <script src="${contextRoot}/develop/lib/plugin/switchery/switchery.js"></script>
- <script src="${contextRoot}/develop/lib/plugin/echarts/echarts-all.js"></script>
- <script>
- /* *************************** 自定义模块 ***************************** */
- var trackJob = {
- $form:$("#div_form"),
- grid:null,
- chart:null,
- dialog:null,
- repeat:null,
- switchery:null,
- init:function(){
- var me = this;
- //控件初始化
- $("#selJob").ligerComboBox({
- dict:true,
- dictName:"RS_JOB_CONFIG",
- onSelected:function(value,text)
- {
- me.search(value);
- },
- onSuccess:function(data)
- {
- if(data!=null&&data.length>0)
- {
- this.selectValue(data[0].code);
- }
- }
- });
- me.initSwitcher();
- me.chart=echarts.init(document.getElementById("echarts-bar-chart"));
- //列表控件
- me.grid = $("#div_grid").ligerGrid({
- url: '${contextRoot}/datacollect/getJobLog',
- selectRowButtonOnly:true,
- delayLoad:true,//初始化不加载
- columns: [
- {display:'采集开始时间',name:'jobStartTime', width: '12%'},
- {display:'采集结束时间',name:'jobEndTime', width: '12%'},
- {display:'采集数据集数',name:'jobDatasetCount', width: '12%'},
- {display:'成功数据集数',name:'jobDatasetSuccess', width: '12%'},
- {display:'数据总数',name:'count', width: '12%'},
- {display:'成功数据',name:'success', width: '12%'},
- {display:'补采数据',name:'repeatNum', width: '12%'},
- {
- display:'操作',name:'id',width: '16%',render:function(row){
- return '<a href="javascript:void(0)" onclick="javascript:trackJob.repeat()">补采</a>';
- }
- }
- ],
- onSuccess:function(data)
- {
- try {
- var list = data.detailModelList;
- if(list!=null&&list.length>0)
- {
- me.reload(list);
- }
- return true;
- }
- catch(e)
- {
- return false;
- }
- },
- onDblClickRow:function(data)
- {
- me.reloadRow(data.id);
- }
- });
- //任务补采
- $('#btnRepeatJob').click(function () {
- parent.indexPage.openMenuByText("任务补采", {
- jobId: $("#selJob").ligerComboBox("getValue")
- }, false);
- });
- //任务编辑
- $('#btnEditJob').click(function(){
- var title = "编辑任务";
- var params = {jobId:$("#selJob").ligerComboBox("getValue")};
- me.dialog=$.ligerDialog.open({
- height: 556,
- width: 700,
- title: title,
- url: '${contextRoot}/datacollect/editorJob',
- //load: true,
- urlParms: params
- });
- });
- },
- initSwitcher:function(){
- var me = this;
- //开关控件
- var changeCheckbox = document.querySelector('#jobStatusSwitch');
- me.switchery = new Switchery(changeCheckbox, { disabled: true,size: 'large' });
- changeCheckbox.onchange = function() {
- debugger
- var a = me.switchery;
- var jobId = $("#selJob").ligerComboBox("getValue");
- if(!changeCheckbox.checked)
- {
- me.valid(jobId,"0");
- }
- else{
- me.valid(jobId,"1");
- }
- };
- },
- repeat:function() {
- parent.indexPage.openMenuByText("任务补采", {jobId: $("#selJob").ligerComboBox("getValue")}, false);
- },
- callbackDialog:function(message){
- $.ligerDialog.success(message);
- this.dialog.close();
- },
- //获取任务相关数据
- search:function(jobId){
- debugger
- var me = this;
- me.clearTop();
- me.initSwitcher();
- if(jobId!="" && jobId.length>0)
- {
- //获取运行状态
- $.ajax({
- type: "POST",
- url : "${contextRoot}/datacollect/getJobInfo",
- dataType : "json",
- data:{jobId:jobId},
- cache:false,
- success :function(data){
- if(data.successFlg) {
- me.switchery.enable();
- me.setJobStatus(data.data);
- }
- else{
- $.ligerDialog.error(data.message);
- }
- },
- error :function(data){
- $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
- }
- });
- me.grid.set({
- parms: {jobId:jobId}
- });
- me.grid.reload();
- }
- },
- //任务状态
- setJobStatus:function(status)
- {
- var me = this;
- if(status=="1")
- {
- $('#jobStatusSwitch').attr("checked",true);
- me.switchery.element.checked=true;
- me.switchery.setPosition();
- $("#jobStatus").html('<span class="green job_run">正在运行中...</span>');
- }
- else{
- $('#jobStatusSwitch').removeAttr("checked");
- me.switchery.element.checked=false;
- me.switchery.setPosition();
- $("#jobStatus").html('<span class="red job_stop">运行暂停</span>');
- }
- },
- //生效失效
- valid:function(id,valid){
- if(id==null||id.length==0) return false;
- setTimeout(function () { return; }, 1000);
- $.ajax({
- type: "POST",
- url : "${contextRoot}/datacollect/validJob",
- dataType : "json",
- data:{jobId:id,valid:valid},
- cache:false,
- success :function(data){
- if(data.successFlg) {
- if(valid=="1")
- {
- $("#jobStatus").html('<span class="green job_run">正在运行中...</span>');
- }
- else{
- $("#jobStatus").html('<span class="red job_stop">运行暂停</span>');
- }
- }
- else{
- $.ligerDialog.error(data.message);
- }
- },
- error :function(data){
- $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
- }
- });
- },
- //上部数据情况
- clearTop:function(){
- var me = this;
- var parent = $("#jobStatusSwitch").parent();
- $("#jobStatusSwitch").next().remove();
- $("#jobStatusSwitch").remove();
- $('<input type="checkbox" class="js-switch" id="jobStatusSwitch" checked />').appendTo(parent);
- $("#divCount").html("-");
- $("#divSuccess").html("-");
- $("#divPercent").html("-");
- $("#echarts-bar-chart").hide();
- $("#echarts-blank").show();
- },
- setTop:function(count,success,percent){
- $("#divCount").html(count);
- $("#divSuccess").html(success);
- $("#divPercent").html(percent +"%");
- $("#echarts-bar-chart").show();
- $("#echarts-blank").hide();
- },
- //刷新页面数据
- reload:function(data)
- {
- var me =this;
- if(data!=null && data.length>0)
- {
- var count = 0
- var success =0;
- var x = [];
- var y1=[];
- var y2=[];
- for(var i=0;i<data.length;i++)
- {
- count += data[i].count;
- success += data[i].success;
- x.push(data[i].jobStartTime);
- y1.push(data[i].count);
- y2.push(data[i].success);
- }
- me.setTop(count,success,count?(success/count *100).toFixed(2):0);
- me.chart.setOption({
- title: {text:"采集情况"},
- tooltip:{trigger:"axis"},
- legend:{data:["数据总数","成功数据"]},
- grid:{x:30,x2:40,y2:24},
- calculable:!0,
- xAxis:[{type:"category",data:x}],
- yAxis:[{type:"value"}],
- series:[{name:"数据总数",type:"bar",data:y1,markLine:{data:[{type:"average",name:"平均值"}]}},
- {name:"成功数据",type:"bar",data:y2,markLine:{data:[{type:"average",name:"平均值"}]}}]},true);
- window.onresize=me.chart.resize;
- }
- else{
- me.clearTop();
- }
- },
- //根据某行获取刷新
- reloadRow:function(id)
- {
- var me = this;
- if(id!="" && id.length>0)
- {
- //获取某次采集情况数据
- $.ajax({
- type: "POST",
- url : "${contextRoot}/datacollect/getJobLogDataset",
- dataType : "json",
- data:{logId:id},
- cache:false,
- success :function(re){
- if(re.successFlg) {
- var data = re.detailModelList;
- if(data!=null && data.length>0)
- {
- var count = 0
- var success =0;
- var x = [];
- var y1=[];
- var y2=[];
- for(var i=0;i<data.length;i++)
- {
- count += data[i].y1;
- success += data[i].y2;
- x.push(data[i].x);
- y1.push(data[i].y1);
- y2.push(data[i].y2);
- }
- me.setTop(count,success,count?(success/count *100).toFixed(2):0);
- me.chart.setOption({title:{text:"采集情况"},
- tooltip:{trigger:"axis"},
- legend:{data:["数据总数","成功数据"]},
- grid:{x:30,x2:40,y2:24},
- calculable:!0,
- xAxis:[{type:"category",data:x}],
- yAxis:[{type:"value"}],
- series:[{name:"数据总数",type:"bar",data:y1,markLine:{data:[{type:"average",name:"平均值"}]}},
- {name:"成功数据",type:"bar",data:y2,markLine:{data:[{type:"average",name:"平均值"}]}}]},true);
- window.onresize=me.chart.resize;
- }
- else{
- me.clearTop();
- }
- }
- else{
- $.ligerDialog.error(re.message);
- }
- },
- error :function(data){
- $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
- }
- });
- }
- }
- }
- $(function () {
- trackJob.init();
- });
- </script>
|