⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logpanel.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.idoc.app;

/**
 * <p>Title: IDOC Interface</p>
 * <p>Description: IDOC 转换器</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: SiChuan XinHua</p>
 * @author Richary
 * @version 1.0
 */
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.JOptionPane;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableColumn;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.io.ObjectInputStream;
import java.net.URL;
import java.net.URLConnection;
import java.lang.Object;
import java.util.Date;
import java.util.Hashtable;
import java.util.Vector;
import java.text.SimpleDateFormat;

import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Toolkit;
import java.util.Enumeration;
import java.io.File;
import java.util.Date;
import java.text.SimpleDateFormat;

import com.idoc.util.db.DBQueryBean;
import com.idoc.util.db.Row;
import com.idoc.util.db.RowSet;
import com.idoc.util.Operate;
import com.idoc.file.WriteData;
import com.idoc.util.GetProperty;
import com.idoc.file.DelFileFilter;

public class LogPanel
    extends JPanel
    implements ActionListener {

  private JPanel northPanel = null;
  private JPanel northEastPanel = null;
  private JPanel northWestPanel = null;
  private JPanel tablePanel = null;

  private JButton refreshButton = null;
  private JButton quitButton = null;

  private JScrollPane scrollpane = null;

  private JTable table = null;
  private JLabel nameLabel = null;
  private JTextField storeTextField = null;
  private JLabel merchLabel = null;
  private JTextField merchTextField = null;
  private JLabel dateFromLabel = null;
  private JLabel dateToLabel = null;
  private JTextField dateFrom = null;
  private JTextField dateTo = null;
  private JLabel flagLabel = null;
  private JLabel directionLabel = null;
  private JLabel typeLabel = null;
  //private JTextField flagTextField = null;

  private JLabel dateFromat = null;
  private DefaultTableModel dTableModel = null;

  private JComboBox storeComboBox = null;
  private JComboBox flagComboBox = null;
  private JComboBox directionComboBox = null;
  private JComboBox typeComboBox = null;

  private String[] columnNames = {
      "标志", "门店代码", "门店名称", "操作类型", "操作时间", "上传批处理标志", "文件名", "主键", "记录数",
      "传输方向", "备注"};
  private Object[] initObj = {
      "", "", "", "", "", "", "", "", "", "", "", ""};
  private DBQueryBean query = null;
  private Hashtable storeHash = new Hashtable();
  private Hashtable typeHash = new Hashtable();
  private Operate operate = null;

  public LogPanel() {
  }

  public void intializtion() {
    operate = new Operate();
    typeHash.put("material", "商品主数据");
    typeHash.put("price", "商品价格");
    typeHash.put("ean", "商品EAN码");
    typeHash.put("catalog", "商品类目");
    typeHash.put("storage", "商品库存");
    typeHash.put("set", "套装商品");
    typeHash.put("publish", "商品版别");
    typeHash.put("inventory", "盘点下传");
    typeHash.put("discount", "商品类目折扣下传");
    typeHash.put("sales", "销售上传");
    typeHash.put("upinventory", "盘点上传");

    Object[] obj = new Object[] {
        "全部", "成功", "失败"};

    flagComboBox = new JComboBox(obj);
    flagComboBox.setFont(new Font("宋体", 0, 12));
    flagComboBox.setSize(new Dimension(60, 16));

    obj = new Object[] {
        "全部", "SAP下传", "上传SAP","操作时间","汇总数据"};
    directionComboBox = new JComboBox(obj);
    directionComboBox.setFont(new Font("宋体", 0, 12));
    directionComboBox.setSize(new Dimension(60, 16));

    // type
    typeLabel = new JLabel("操作类型");
    typeLabel.setFont(new Font("宋体", 0, 12));
    obj = new Object[] {
        "全部", "商品主数据", "商品价格", "商品EAN码", "商品类目", "商品库存", "套装商品", "商品版别", "盘点下传",
        "商品类目折扣下传", "销售上传", "盘点上传"};
    typeComboBox = new JComboBox(obj);
    typeComboBox.setFont(new Font("宋体", 0, 12));
    typeComboBox.setSize(new Dimension(60, 16));

    // Query Button
    refreshButton = new JButton("查找");
    refreshButton.setFont(new Font("宋体", 0, 12));
    refreshButton.setMaximumSize(new Dimension(60, 22));
    refreshButton.setPreferredSize(new Dimension(60, 22));
    refreshButton.addActionListener(this);
    quitButton = new JButton("退出");
    quitButton.setFont(new Font("宋体", 0, 12));
    quitButton.setMaximumSize(new Dimension(60, 22));
    quitButton.setPreferredSize(new Dimension(60, 22));
    quitButton.setForeground(Color.RED);
    quitButton.addActionListener(this);

    // stroe
    nameLabel = new JLabel("门店");
    nameLabel.setFont(new Font("宋体", 0, 12));
    storeTextField = new JTextField();
    storeTextField.setPreferredSize(new Dimension(80, 20));
    storeTextField.setMaximumSize(new Dimension(80, 20));
    // flag
    flagLabel = new JLabel("标志");
    flagLabel.setFont(new Font("宋体", 0, 12));

    // directionLabel
    directionLabel = new JLabel("传输方向");
    directionLabel.setFont(new Font("宋体", 0, 12));

    // merch
    merchLabel = new JLabel("商品编码");
    merchLabel.setFont(new Font("宋体", 0, 12));
    merchTextField = new JTextField();
    merchTextField.setPreferredSize(new Dimension(120, 20));
    merchTextField.setMaximumSize(new Dimension(120, 20));
    storeComboBox = new JComboBox();

    // date
    dateFromLabel = new JLabel("日期 从");
    dateFromLabel.setFont(new Font("宋体", 0, 12));
    dateFrom = new JTextField();
    dateFrom.setPreferredSize(new Dimension(80, 20));
    dateFrom.setMaximumSize(new Dimension(80, 20));
    dateToLabel = new JLabel("到");
    dateToLabel.setFont(new Font("宋体", 0, 12));
    dateTo = new JTextField();
    dateTo.setPreferredSize(new Dimension(80, 20));
    dateTo.setMaximumSize(new Dimension(80, 20));

    dateFromat = new JLabel("(日期格式:2000-01-01)");
    dateFromat.setFont(new Font("宋体", 0, 12));
    dateFromat.setForeground(Color.red);
    table = new JTable();

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(table.getRowHeight() + 5);

    dTableModel = new DefaultTableModel(columnNames, 1);

    try {
      table.setModel(dTableModel);
      table.getColumn("标志").setMaxWidth(40);
      table.getColumn("门店代码").setMinWidth(80);
      table.getColumn("门店名称").setMinWidth(120);
      table.getColumn("操作类型").setMinWidth(40);
      table.getColumn("操作时间").setMinWidth(120);
      table.getColumn("上传批处理标志").setMinWidth(60);
      table.getColumn("文件名").setMinWidth(250);
      //table.getColumn("表名").setMinWidth(120);
      table.getColumn("主键").setMinWidth(180);
      table.getColumn("备注").setMinWidth(200);
      table.setRowSelectionInterval(0, 0);

      table.setShowHorizontalLines(true);
      table.setShowVerticalLines(true);
      //table.setEnabled(false);
      //table.setSelectionForeground(Color.RED);

      //table.setSelectionBackground(Color.PINK);

    }
    catch (Exception ex) {
      System.out.println("tableColumn : " + ex.toString());
    }

    table.setShowVerticalLines(false);
    table.getTableHeader().setReorderingAllowed(false);
    table.setIntercellSpacing(new Dimension(0, 0));

    scrollpane = new JScrollPane(table);
    scrollpane.setBorder(BorderFactory.createLineBorder(Color.gray));
    scrollpane.getViewport().setBackground(Color.white);

    // northEastPanel
    northEastPanel = new JPanel();
    northEastPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    northEastPanel.add(refreshButton);
    northEastPanel.add(quitButton);

    // northWestPanel
    northWestPanel = new JPanel();
    northWestPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    //northWestPanel.add(nameLabel);
    //northWestPanel.add(storeTextField);
    northWestPanel.add(flagLabel);
    northWestPanel.add(flagComboBox);
    northWestPanel.add(directionLabel);
    northWestPanel.add(directionComboBox);
    northWestPanel.add(typeLabel);
    northWestPanel.add(typeComboBox);

    //northWestPanel.add(merchLabel);
    //northWestPanel.add(merchTextField);
    northWestPanel.add(dateFromLabel);
    northWestPanel.add(dateFrom);
    northWestPanel.add(dateToLabel);
    northWestPanel.add(dateTo);
    northWestPanel.add(dateFromat);

    // northPanel
    northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    northPanel.add(northEastPanel, BorderLayout.EAST);
    northPanel.add(northWestPanel, BorderLayout.WEST);

    // tablePanel
    tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout( -6, -6));
    tablePanel.add(scrollpane);
    tablePanel.add(new JPanel(), BorderLayout.WEST);
    tablePanel.add(new JPanel(), BorderLayout.EAST);
    tablePanel.add(new JPanel(), BorderLayout.SOUTH);

    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createLoweredBevelBorder());
    this.add(northPanel, BorderLayout.NORTH);
    this.add(tablePanel, BorderLayout.CENTER);
    getStoreName();
  }

  private void getStoreName() {
    query = new DBQueryBean();
    String sql = null;
    RowSet rowSet = new RowSet();
    Row row = new Row(); ;
    sql = "select storeid,storename from interface_sy nolock where flag=3";
    try {
      rowSet = query.Query(sql);
      for (int i = 0; i < rowSet.length(); i++) {
        row = rowSet.get(i);
        storeHash.put(operate.convertNull(row.get("storeid")),
                      operate.convertNull(row.get("storename")));
      }
      //System.out.println("storeHash = " + storeHash);
/*
      for (Enumeration e = storeHash.keys(); e.hasMoreElements(); ) {
        //storeComboBox.setName(storeHash.get(e).toString());
        System.out.println("key = " + e + " -- > " +
                           storeHash.get(e.nextElement()).toString());
      }
*/
      //storeComboBox
    }
    catch (Exception ex) {
      System.out.println("getStoreName is Error!");
      ex.printStackTrace();
    } finally {
      query.close();
    }
  }

  /**
   * refresh Data
   */
  private void refreshData() {
    String store = storeTextField.getText();
    String merch = merchTextField.getText();
    String date1 = dateFrom.getText();
    String date2 = dateTo.getText();
    String sql = null;
    RowSet rowSet = null;
    Row row = null;
    Date f_date = null;
    Date t_date = null;
    String flag1 = "";
    String direction = "";
    int t = 3;
    String type = "";

    flag1 = flagComboBox.getSelectedItem().toString().trim();
    if (flag1.equalsIgnoreCase("全部")) {
      t = 3;
    }
    else if (flag1.equalsIgnoreCase("成功")) {
      t = 1;
    }
    else if (flag1.equalsIgnoreCase("失败")) {
      t = 0;
    }
    direction = directionComboBox.getSelectedItem().toString().trim();
    type = typeComboBox.getSelectedItem().toString().trim();

    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    try {
      query = new DBQueryBean();
      if (t == 3) {
        sql = "select * from operlog where oper=0 ";
      }
      else if (t==0 || t==1){
        sql = "select * from operlog where oper=0 and successflag = " + t;
      }

      if (direction.equalsIgnoreCase("汇总数据")) {
          sql = "select Operation,count(recordnum) as RecordNum,convert(varchar(10) ,OperTime,112) as Opertime,successflag,wayflag from operlog where  oper=0 and wayflag!='time'";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -