package com.chart.display.gf1;
import com.DB.HbaseGetTaskResultDb;
import com.javabean.ComboBoxBean;
import com.model.TaskResultDetail;
import com.util.*;
import org.apache.logging.log4j.Logger;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.List;
public class GF_E_MP_DAY_READ implements Runnable {
private final Logger logger = LoggerUtil.getLogger(GF_E_MP_DAY_READ.class);
/**
* 表格
*/
private static JTable collectDateJTable = new JTable();
/**
* 表格数据
*/
private static Vector<Object> vData = new Vector<Object>();
/**
* 表格列名
*/
private static Vector<Object> vName = new Vector<Object>();
/**
* 表头
*/
String jtableHeader = "日期,采集对象ID,正向有功总,正向有功尖,正向有功峰,正向有功平,正向有功谷,反向有功总,反向有功尖,反向有功峰,反向有功平,反向有功谷";//配置文件获取表头数据
/**
* 显示日志类型集合
*/
private Vector<ComboBoxBean> refreshTypeBeans = new Vector<ComboBoxBean>();
/**
* 任务标志集合
*/
private Vector<ComboBoxBean> taskFlagBeans = new Vector<ComboBoxBean>();
/*k 优先级集合 */
private Vector<ComboBoxBean> collectPriBeans = new Vector<ComboBoxBean>();
/*** 显示条数集合 */
private Vector<ComboBoxBean> refreshCountBeans = new Vector<ComboBoxBean>()
/**
* 是否换行集合
*/
private Vector<ComboBoxBean> isChangeLineBeans = new Vector<ComboBoxBean>();
/**
* 任务配置ID集合
*/
private Vector<ComboBoxBean> taskConfigTypeBeans = new Vector<ComboBoxBean>();
/** 显示日志类型集合 */
private static String[][]REFRESH_TYPE= PropertiesUtil.getValues( "refreshType");
/** 任务标志 */
private static String[][]TASK_FLAG = PropertiesUtil.getValues("taskPlag");
/** 任务优先级 */
private static String[][]COLLECT_PRI= PropertiesUtil.getValues("collectPri");
/** 显示条数集合*/
private static String[][]REFRESH_COUNT = PropertiesUtil.getValues("refreshCount");
/** 是否换行 */
private static String[][]IS_CHANGE_LINE = PropertiesUtil.getValues("isChangeLine");
/**任务配置类型默认为null即全部*/
private static Integer taskConfigType=-1;
/**日志类型:默认显示数组第1个:显示全部*/
private static int refreshType = Integer.parseInt(REFRESH_TYPE[0] [0]);
/**任务标志:默认显示数组第1个:2、全部,0.手动;1,自动*/
private static int taskFlag = Integer.parseInt(TASK_FLAG[0][0]);
private static int collectPri = Integer.parseInt(COLLECT_PRI[0] [0]);
/** 显示条数:默认显示数组第一个:显示20条*/
private static int refreshCount = Integer.parseInt(REPRESH_COUNT[0] [0]);
/** 刷新时间:默认显示数组第一个:0 不刷新 */
private static int refreshTime=0;
/**是否换行:默认显示数组第一个:0不换行 1 换行 */
private static int isChangeLine = Integer.parseInt(IS_CHANGE_LINE[0] [0]);
/** 任务配置类型 */
private static String[][] TASK_CONFIG_TYPE= PropertiesUtil.getValues( "taskConfigType");
/** 表头字体 */
private static String TABLEHEAD_FONT="微软雅黑";
/** 行颜色 值是列表显示的最大值*/
public static List<Color> TABLEBODY_COLOR_STORM= new ArrayList<>();
/**最后刷新时间*/
static String lastRefreshTime = Calenders.dateToString(new Date(), Calenders.DATE_FORMAT_1);
//自动刷新文本框
private static JTextField consIDText = new JTextField(10);
//地市复选框
private static JPanel checkJapnel = new JPanel();
/**
* 开始日期按钮
*/
private JButton timeStartButton = new JButton();
/**
* 结束日期 按钮
*/
private JButton timeEndButton = new JButton();
/**
* 开始日期 按钮 显示值
*/
private String startDateTime = Calenders.getCurrentDayMin1StrO;
/**
* 结束日期 按钮 显示值
*/
private String endDateTime = Calenders.getCurrentTimeSO;
/**
* 告警JPanel
*/
private JPanel jpanelWarn = new JPanel();
public void initJComboBox() {
}
//顶部按钮
public JPanel initJpanelTop() {
//初始化顶部下拉框
initJComboBox();
// 日期选择控件
// 开始日期
JLabel startDate = new JLabel();
startDate.setText("开始日期 ");
timeStartButton = new DatePlug(startDateTime);
// 结束日期
JLabel endDate = new JLabel();
endDate.setText("结束日期 ");
timeEndButton = new DatePlug(endDateTime);
//查询按钮 ”查询“),
final JButton searchButton = new JButton("查询");
searchButton.setVisible(true);
searchButton.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent arg0) {
}
@Override
public void mousePressed(MouseEvent arg0) {
}
@Override
public void mouseReleased(MouseEvent arg0) {
}
@Override
public void mouseEntered(MouseEvent arg0) {
}
@Override
public void mouseExited(MouseEvent arg0) {
startDateTime = timeStartButton.getText().trim();
endDateTime = timeEndButton.getText().trim();
String consId = consIDText.getText().trim();
readUserInfo(consId, startDateTime, endDateTime);
}
});
// JLable告警相关
JLabel reminder = new JLabel();
reminder.setText("开始日期不能大于结束日期");
reminder.setFont(new Font("宋体",1, 15));
reminder.setForeground(Color.RED);
//reminder.setVisible(false);
//JPanel告警
jpanelWarn.setSize(800, 100);
jpanelWarn.setVisible(false);
jpanelWarn.add(reminder);
//自动刷新按钮相关
JLabel consId = new JLabel();
consId.setText("采集对象ID");
consIDText.setText("3");
JPanel japenlEast = new JPanel();
japenlEast.add(searchButton);
japenlEast.add(startDate);
japenlEast.add(timeStartButton);
japenlEast.add(endDate);
japenlEast.add(timeEndButton);
japenlEast.add(consId);
japenlEast.add(consIDText);
JPanel jPanelTop = new JPanel();
japenlEast.setLayout(new BorderLayout());
japenlEast.add(jpanelWarn, BorderLayout.CENTER);
japenlEast.add(japenlEast, BorderLayout.WEST);
japenlEast.add(checkJapnel, BorderLayout.SOUTH);
return jPanelTop;
}
/* * Storm采集运行日志界面 */
public JPanel getCollectDateJpanel(){
/* * 初始化顶部选择按钮布局 */
JPanel jpanelTop =initJpanelTop();
jpanelTop.setSize(700,100);
/**初始化表格和数据 */
initJtable();
/** 顶部按钮和表格整合 */
JScrollPane collectDateJscrollPane = new JScrollPane(collectDateJTable);/*按钮+表格 */
JPanel jpanel = new JPanel();
jpanel.setSize( 800, 600);
jpanel.setLayout(new BorderLayout());
jpanel.add(jpanelTop, BorderLayout. NORTH);
jpanel.add(collectDateJscrollPane, BorderLayout.CENTER);
return jpanel;
}
public void initJtable(){
//添加表头
String[] jtableHeaders=jtableHeader.split(",");
int length = jtableHeaders.length;
for(int i=0;i<length;i++){
vName.add(jtableHeaders[i]);//循环添加表数据
}
//设置表格数据
DefaultTableModel model = new DefaultTableModel();
model.setDataVector(vData, vName);
collectDateJTable.setModel(model);
}
public static void readUserInfo(String consId,String startDateStr,String endDateStr){
//表格数据sql 未写!
}
public void getJtableCenter(){}
@Override
public void run() {
while (true) {
if (refreshTime != 0) {
try {
//更新数据
getJtableCenter();
//刷新频率
Thread.sleep(refreshTime * 1000);
} catch (Exception e) {
e.printStackTrace();
logger.error("定时刷新出错");
}
} else {
try {
Thread.sleep(1);
} catch (Exception e) {
e.printStackTrace();
logger.error("休眠出错");
}
}
}
}
}