@Override
 public DetailListVO getDetailList(UserVO operator) {
   DetailListVO vo = new DetailListVO();
   vo.setClient("David");
   vo.setCommodity(commodity.name);
   vo.setStart(saleslist.get(2).date.toString());
   vo.setEnd(saleslist.get(1).date.toString());
   vo.setOperator(operator.getName());
   vo.setStorehouse("南京仓库");
   vo.setList(new ArrayList<DetailListVO.DetailListItemVO>());
   for (int i = 0; i <= saleslist.size() - 1; i++) {
     DetailListVO.DetailListItemVO item = new DetailListVO().new DetailListItemVO();
     item.update(saleslist.get(i));
     vo.getList().add(item);
   }
   return vo;
 }
 @Override
 public DetailListVO getDetailList(GregorianCalendar start, GregorianCalendar end) {
   DetailListVO vo = new DetailListVO();
   vo.setClient("David");
   vo.setCommodity(commodity.name);
   vo.setStart(start.toString());
   vo.setEnd(end.toString());
   vo.setOperator("王一琦");
   vo.setStorehouse("南京仓库");
   vo.setList(new ArrayList<DetailListVO.DetailListItemVO>());
   for (int i = 0; i <= saleslist.size() - 1; i++) {
     if (saleslist.get(i).date.after(end) || saleslist.get(i).date.before(start)) {
       continue;
     } else {
       DetailListVO.DetailListItemVO item = new DetailListVO().new DetailListItemVO();
       item.update(saleslist.get(i));
       vo.getList().add(item);
     }
   }
   return vo;
 }
  public LookCommodityType(ArrayList<CommodityTypeVO> type) {

    for (int t = 0; t < type.size(); t++) {
      data[t][0] = type.get(t).getFather().getName();
      ArrayList<CommodityTypeVO> child = type.get(t).getChild();
      for (int k = 0; k < child.size(); k++) {
        data[t][k + 1] = child.get(k).getName();
      }
    }

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);

    JScrollPane scroller = new JScrollPane(table);
    table.setPreferredScrollableViewportSize(new Dimension(460, 60));

    panelCommodityType.setLayout(null);
    scroller.setBounds(0, 35, 820, 500);

    panelCommodityType.add(scroller);
  }
  public ArrayList<UnderflowBillVO> getUnderflow(
      ArrayList<UnderflowBillVO> listUnderflowTime,
      ArrayList<UnderflowBillVO> listUnderflowType,
      ArrayList<UnderflowBillVO> listUnderflowClient,
      ArrayList<UnderflowBillVO> listUnderflowOperator,
      ArrayList<UnderflowBillVO> listUnderflowStorehouse) {
    ArrayList<UnderflowBillVO> listUnderflow = new ArrayList<UnderflowBillVO>();
    int sizeTime = listUnderflowTime.size();
    int sizeType = listUnderflowType.size();
    int sizeClient = listUnderflowClient.size();
    int sizeOperator = listUnderflowOperator.size();
    int sizeStorehouse = listUnderflowStorehouse.size();

    if (sizeTime > 0) {
      listUnderflow = listUnderflowTime;
    } else {
      if (sizeType > 0) {
        listUnderflow = listUnderflowType;
      } else {
        if (sizeClient > 0) {
          listUnderflow = listUnderflowClient;
        } else {
          if (sizeOperator > 0) {
            listUnderflow = listUnderflowOperator;
          } else {
            listUnderflow = listUnderflowStorehouse;
          }
        }
      }
    }

    if (sizeTime > 0) {
      for (int t = 0; t < listUnderflow.size(); ) {
        for (int k = 0; k < sizeTime; k++) {
          if (listUnderflow.get(t).equals(listUnderflowTime.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeTime - 1) {
              listUnderflow.remove(t);
            }
          }
        }
      }
    }

    if (sizeType > 0) {
      for (int t = 0; t < listUnderflow.size(); ) {
        for (int k = 0; k < sizeType; k++) {
          if (listUnderflow.get(t).equals(listUnderflowType.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeType - 1) {
              listUnderflow.remove(t);
            }
          }
        }
      }
    }

    if (sizeClient > 0) {
      for (int t = 0; t < listUnderflow.size(); ) {
        for (int k = 0; k < sizeClient; k++) {
          if (listUnderflow.get(t).equals(listUnderflowClient.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeClient - 1) {
              listUnderflow.remove(t);
            }
          }
        }
      }
    }

    if (sizeOperator > 0) {
      for (int t = 0; t < listUnderflow.size(); ) {
        for (int k = 0; k < sizeOperator; k++) {
          if (listUnderflow.get(t).equals(listUnderflowOperator.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeOperator - 1) {
              listUnderflow.remove(t);
            }
          }
        }
      }
    }

    if (sizeStorehouse > 0) {
      for (int t = 0; t < listUnderflow.size(); ) {
        for (int k = 0; k < sizeStorehouse; k++) {
          if (listUnderflow.get(t).equals(listUnderflowStorehouse.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeStorehouse - 1) {
              listUnderflow.remove(t);
            }
          }
        }
      }
    }
    return listUnderflow;
  }
  public ArrayList<ExpenseVO> getExpense(
      ArrayList<ExpenseVO> listExpenseTime,
      ArrayList<ExpenseVO> listExpenseType,
      ArrayList<ExpenseVO> listExpenseClient,
      ArrayList<ExpenseVO> listExpenseOperator,
      ArrayList<ExpenseVO> listExpenseStorehouse) {
    ArrayList<ExpenseVO> listExpense = new ArrayList<ExpenseVO>();
    int sizeTime = listExpenseTime.size();
    int sizeType = listExpenseType.size();
    int sizeClient = listExpenseClient.size();
    int sizeOperator = listExpenseOperator.size();
    int sizeStorehouse = listExpenseStorehouse.size();

    if (sizeTime > 0) {
      listExpense = listExpenseTime;
    } else {
      if (sizeType > 0) {
        listExpense = listExpenseType;
      } else {
        if (sizeClient > 0) {
          listExpense = listExpenseClient;
        } else {
          if (sizeOperator > 0) {
            listExpense = listExpenseOperator;
          } else {
            listExpense = listExpenseStorehouse;
          }
        }
      }
    }

    if (sizeTime > 0) {
      for (int t = 0; t < listExpense.size(); ) {
        for (int k = 0; k < sizeTime; k++) {
          if (listExpense.get(t).equals(listExpenseTime.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeTime - 1) {
              listExpense.remove(t);
            }
          }
        }
      }
    }

    if (sizeType > 0) {
      for (int t = 0; t < listExpense.size(); ) {
        for (int k = 0; k < sizeType; k++) {
          if (listExpense.get(t).equals(listExpenseType.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeType - 1) {
              listExpense.remove(t);
            }
          }
        }
      }
    }

    if (sizeClient > 0) {
      for (int t = 0; t < listExpense.size(); ) {
        for (int k = 0; k < sizeClient; k++) {
          if (listExpense.get(t).equals(listExpenseClient.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeClient - 1) {
              listExpense.remove(t);
            }
          }
        }
      }
    }

    if (sizeOperator > 0) {
      for (int t = 0; t < listExpense.size(); ) {
        for (int k = 0; k < sizeOperator; k++) {
          if (listExpense.get(t).equals(listExpenseOperator.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeOperator - 1) {
              listExpense.remove(t);
            }
          }
        }
      }
    }

    if (sizeStorehouse > 0) {
      for (int t = 0; t < listExpense.size(); ) {
        for (int k = 0; k < sizeStorehouse; k++) {
          if (listExpense.get(t).equals(listExpenseStorehouse.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeStorehouse - 1) {
              listExpense.remove(t);
            }
          }
        }
      }
    }
    return listExpense;
  }
  public ArrayList<PurchaseReturnBillVO> getPurchaseReturn(
      ArrayList<PurchaseReturnBillVO> listPurchaseReturnTime,
      ArrayList<PurchaseReturnBillVO> listPurchaseReturnType,
      ArrayList<PurchaseReturnBillVO> listPurchaseReturnClient,
      ArrayList<PurchaseReturnBillVO> listPurchaseReturnOperator,
      ArrayList<PurchaseReturnBillVO> listPurchaseReturnStorehouse) {
    ArrayList<PurchaseReturnBillVO> listPurchaseReturn = new ArrayList<PurchaseReturnBillVO>();
    int sizeTime = listPurchaseReturnTime.size();
    int sizeType = listPurchaseReturnType.size();
    int sizeClient = listPurchaseReturnClient.size();
    int sizeOperator = listPurchaseReturnOperator.size();
    int sizeStorehouse = listPurchaseReturnStorehouse.size();

    if (sizeTime > 0) {
      listPurchaseReturn = listPurchaseReturnTime;
    } else {
      if (sizeType > 0) {
        listPurchaseReturn = listPurchaseReturnType;
      } else {
        if (sizeClient > 0) {
          listPurchaseReturn = listPurchaseReturnClient;
        } else {
          if (sizeOperator > 0) {
            listPurchaseReturn = listPurchaseReturnOperator;
          } else {
            listPurchaseReturn = listPurchaseReturnStorehouse;
          }
        }
      }
    }

    if (sizeTime > 0) {
      for (int t = 0; t < listPurchaseReturn.size(); ) {
        for (int k = 0; k < sizeTime; k++) {
          if (listPurchaseReturn.get(t).equals(listPurchaseReturnTime.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeTime - 1) {
              listPurchaseReturn.remove(t);
            }
          }
        }
      }
    }

    if (sizeType > 0) {
      for (int t = 0; t < listPurchaseReturn.size(); ) {
        for (int k = 0; k < sizeType; k++) {
          if (listPurchaseReturn.get(t).equals(listPurchaseReturnType.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeType - 1) {
              listPurchaseReturn.remove(t);
            }
          }
        }
      }
    }

    if (sizeClient > 0) {
      for (int t = 0; t < listPurchaseReturn.size(); ) {
        for (int k = 0; k < sizeClient; k++) {
          if (listPurchaseReturn.get(t).equals(listPurchaseReturnClient.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeClient - 1) {
              listPurchaseReturn.remove(t);
            }
          }
        }
      }
    }

    if (sizeOperator > 0) {
      for (int t = 0; t < listPurchaseReturn.size(); ) {
        for (int k = 0; k < sizeOperator; k++) {
          if (listPurchaseReturn.get(t).equals(listPurchaseReturnOperator.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeOperator - 1) {
              listPurchaseReturn.remove(t);
            }
          }
        }
      }
    }

    if (sizeStorehouse > 0) {
      for (int t = 0; t < listPurchaseReturn.size(); ) {
        for (int k = 0; k < sizeStorehouse; k++) {
          if (listPurchaseReturn.get(t).equals(listPurchaseReturnStorehouse.get(k))) {
            t++;
            break;
          } else {
            if (k == sizeStorehouse - 1) {
              listPurchaseReturn.remove(t);
            }
          }
        }
      }
    }
    return listPurchaseReturn;
  }
  public MessageStrategy() {

    JButton button = new JButton("刷新");
    button.addActionListener(new newListener());

    // 获取表格数据信息
    StrategyController controller = new StrategyController();
    int count = 0;
    ArrayList<DiscountStrategyVO> discounts = controller.getAllDiscounts();
    for (int t = 0; t < discounts.size(); t++) {
      int client = discounts.get(t).getRank();
      data[t][0] = discounts.get(t).getId();
      data[t][1] =
          "折扣:"
              + Double.toString(discounts.get(t).getDiscount())
              + "      "
              + "客户级别:"
              + Integer.toString(client);
      count++;
    }
    ArrayList<VoucherStrategyVO> vouchers = controller.getAllVouchers();
    for (int t = 0; t < vouchers.size(); t++) {
      int client = vouchers.get(t).getRank();
      data[count][0] = vouchers.get(t).getId();
      data[count][1] =
          "代金券:"
              + Double.toString(vouchers.get(t).getVoucher())
              + "      "
              + "客户级别:"
              + Integer.toString(client);
      count++;
    }
    ArrayList<CombinationStrategyVO> combinations = controller.getAllCombinations();
    for (int t = 0; t < combinations.size(); t++) {
      ArrayList<CombinationItemVO> comdities = combinations.get(t).getList();
      String comdity = "";
      for (int k = 0; k < comdities.size(); k++) {
        comdity =
            comdity
                + comdities.get(k).getCommodity()
                + ","
                + comdities.get(k).getModel()
                + ","
                + Integer.toString(comdities.get(k).getNumber())
                + ";";
      }
      data[count][0] = combinations.get(t).getId();
      data[count][1] =
          "组合商品:"
              + comdity
              + "     "
              + "原价:"
              + Double.toString(combinations.get(t).getInitialMoney())
              + "     "
              + "现价:"
              + Double.toString(combinations.get(t).getLaterMoney());
      count++;
    }
    ArrayList<GiftStrategyVO> giftClient = controller.getAllGifts();
    for (int t = 0; t < giftClient.size(); t++) {
      int client = giftClient.get(t).getRank();
      ArrayList<GiftItemVO> items = giftClient.get(t).getList();
      String giftItem = "";
      for (int k = 0; k < items.size(); k++) {
        giftItem =
            giftItem
                + items.get(k).getCommodity()
                + ","
                + items.get(k).getModel()
                + ","
                + Integer.toString(items.get(k).getNumber())
                + ";";
      }
      data[count][0] = giftClient.get(t).getId();
      data[count][1] = "客户级别:" + Integer.toString(client) + "     " + "赠品:" + giftItem;
      count++;
    }
    ArrayList<GiftBasedOnTotalMoneyVO> giftMoney = controller.getAllGBOTMs();
    for (int t = 0; t < giftMoney.size(); t++) {
      ArrayList<GBOTMItemVO> items = giftMoney.get(t).getList();
      String giftItem = "";
      for (int k = 0; k < items.size(); k++) {
        giftItem =
            giftItem
                + items.get(k).getCommodity()
                + ","
                + items.get(k).getModel()
                + ","
                + Integer.toString(items.get(k).getNumber())
                + ";";
      }
      data[count][0] = giftMoney.get(t).getId();
      data[count][1] =
          "价格下限:"
              + Double.toString(giftMoney.get(t).getLower())
              + "     "
              + "价格上限:"
              + Double.toString(giftMoney.get(t).getUpper())
              + "     "
              + "赠品:"
              + giftItem;
      count++;
    }
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);

    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().add(table);
    scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    table.getColumnModel().getColumn(1).setPreferredWidth(800);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    panel.setLayout(null);
    button.setBounds(330, 3, 65, 25);
    scroller.setBounds(0, 40, 410, 420);

    panel.add(button);
    panel.add(scroller);
  }
 public void actionPerformed(ActionEvent e) {
   // 获取表格数据信息
   StrategyController controller = new StrategyController();
   int count = 0;
   ArrayList<DiscountStrategyVO> discounts = controller.getAllDiscounts();
   for (int t = 0; t < discounts.size(); t++) {
     int client = discounts.get(t).getRank();
     data[t][0] = discounts.get(t).getId();
     data[t][1] =
         "折扣:"
             + Double.toString(discounts.get(t).getDiscount())
             + "      "
             + "客户级别:"
             + Integer.toString(client);
     count++;
   }
   ArrayList<VoucherStrategyVO> vouchers = controller.getAllVouchers();
   for (int t = 0; t < vouchers.size(); t++) {
     int client = vouchers.get(t).getRank();
     data[count][0] = vouchers.get(t).getId();
     data[count][1] =
         "代金券:"
             + Double.toString(vouchers.get(t).getVoucher())
             + "      "
             + "客户级别:"
             + Integer.toString(client);
     count++;
   }
   ArrayList<CombinationStrategyVO> combinations = controller.getAllCombinations();
   for (int t = 0; t < combinations.size(); t++) {
     ArrayList<CombinationItemVO> comdities = combinations.get(t).getList();
     String comdity = "";
     for (int k = 0; k < comdities.size(); k++) {
       comdity =
           comdity
               + comdities.get(k).getCommodity()
               + ","
               + comdities.get(k).getModel()
               + ","
               + Integer.toString(comdities.get(k).getNumber())
               + ";";
     }
     data[count][0] = combinations.get(t).getId();
     data[count][1] =
         "组合商品:"
             + comdity
             + "     "
             + "原价:"
             + Double.toString(combinations.get(t).getInitialMoney())
             + "     "
             + "现价:"
             + Double.toString(combinations.get(t).getLaterMoney());
     count++;
   }
   ArrayList<GiftStrategyVO> giftClient = controller.getAllGifts();
   for (int t = 0; t < giftClient.size(); t++) {
     int client = giftClient.get(t).getRank();
     ArrayList<GiftItemVO> items = giftClient.get(t).getList();
     String giftItem = "";
     for (int k = 0; k < items.size(); k++) {
       giftItem =
           giftItem
               + items.get(k).getCommodity()
               + ","
               + items.get(k).getModel()
               + ","
               + Integer.toString(items.get(k).getNumber())
               + ";";
     }
     data[count][0] = giftClient.get(t).getId();
     data[count][1] = "客户级别:" + Integer.toString(client) + "     " + "赠品:" + giftItem;
     count++;
   }
   ArrayList<GiftBasedOnTotalMoneyVO> giftMoney = controller.getAllGBOTMs();
   for (int t = 0; t < giftMoney.size(); t++) {
     ArrayList<GBOTMItemVO> items = giftMoney.get(t).getList();
     String giftItem = "";
     for (int k = 0; k < items.size(); k++) {
       giftItem =
           giftItem
               + items.get(k).getCommodity()
               + ","
               + items.get(k).getModel()
               + ","
               + Integer.toString(items.get(k).getNumber())
               + ";";
     }
     data[count][0] = giftMoney.get(t).getId();
     data[count][1] =
         "价格下限:"
             + Double.toString(giftMoney.get(t).getLower())
             + "     "
             + "价格上限:"
             + Double.toString(giftMoney.get(t).getUpper())
             + "     "
             + "赠品:"
             + giftItem;
     count++;
   }
 }