Search in sources :

Example 1 with LMDetailInfo

use of com.kendy.entity.LMDetailInfo in project financial by greatkendy123.

the class LMController method exportSingleClubAction.

/**
 ********************************************************************************
 *
 *                                     导出Excel
 *
 **********************************************************************************
 */
/**
 * 导出单个俱乐部帐单
 *
 * @time 2017年11月22日
 * @param event
 */
public void exportSingleClubAction(ActionEvent event) {
    Club club = getSelectedClub();
    if (StringUtil.isBlank(club.getClubId())) {
        ShowUtil.show("请先选择俱乐部!");
        return;
    }
    String clubName = club.getName();
    String clubId = club.getClubId();
    String time = DataConstans.Date_Str;
    if (StringUtil.isBlank(time)) {
    // ShowUtil.show("导出失败! 您今天还没导入01场次的战绩,无法确认时间!!");
    // return;
    }
    List<LMDetailInfo> list = new ArrayList<>();
    ObservableList<LMDetailInfo> obList = tableLMDetail.getItems();
    if (obList != null && obList.size() > 0) {
        for (LMDetailInfo info : obList) {
            list.add(info);
        }
    } else {
        ShowUtil.show(clubName + "没有需要导出的数据!!");
        return;
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    String title = clubName + "帐单-" + sdf.format(new Date());
    log.info(title);
    String[] rowsName = new String[] { "场次", "战绩", "保险", "人数" };
    List<Object[]> dataList = new ArrayList<Object[]>();
    Object[] objs = null;
    for (LMDetailInfo info : list) {
        objs = new Object[rowsName.length];
        objs[0] = info.getLmDetailTableId();
        objs[1] = info.getLmDetailZJ();
        objs[2] = info.getLmDetailInsure();
        objs[3] = info.getLmDetailPersonCount();
        dataList.add(objs);
    }
    String[] rowsName2 = new String[] { "名称", "总战绩", "总保险", "总人数" };
    List<Object[]> sumList = new ArrayList<>();
    Object[] sumObjs = null;
    ObservableList<LMSumInfo> ob_List = tableLMSum.getItems();
    if (ob_List != null && ob_List.size() > 0) {
        for (LMSumInfo info : ob_List) {
            sumObjs = new Object[rowsName2.length];
            sumObjs[0] = StringUtil.nvl(info.getLmSumName(), "");
            sumObjs[1] = StringUtil.nvl(info.getLmSumZJ(), "");
            sumObjs[2] = StringUtil.nvl(info.getLmSumInsure(), "");
            sumObjs[3] = StringUtil.nvl(info.getLmSumPersonCount(), "");
            sumList.add(sumObjs);
        }
    }
    String out = "D:/" + title + System.currentTimeMillis();
    ExportLMExcel ex = new ExportLMExcel(title, rowsName, dataList, out, rowsName2, sumList);
    try {
        ex.export();
        log.info("导出单个联盟帐单完成!");
    } catch (Exception e) {
        ErrorUtil.err("导出单个联盟帐单失败", e);
    }
}
Also used : LMSumInfo(com.kendy.entity.LMSumInfo) ExportLMExcel(com.kendy.excel.ExportLMExcel) ArrayList(java.util.ArrayList) Date(java.util.Date) LMDetailInfo(com.kendy.entity.LMDetailInfo) Club(com.kendy.entity.Club) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with LMDetailInfo

use of com.kendy.entity.LMDetailInfo in project financial by greatkendy123.

the class LMController method setDataTableLMDetail.

/**
 * 根据ID更新详情表
 *
 * @time 2017年11月25日
 * @param clubId
 * @param isNeedSum 是否需要进行求和
 */
public void setDataTableLMDetail(String clubId, boolean isNeedSum) {
    tableLMDetail.setItems(null);
    // List<Record> list = eachClubList.get(clubId);
    int LMTypeIndex = this.getCurrentLMType() - 1;
    Map<String, List<Record>> LMMap = LMTotalList.get(LMTypeIndex);
    List<Record> list = LMMap.get(clubId);
    ObservableList<LMDetailInfo> obList = FXCollections.observableArrayList();
    if (list == null) {
        tableLMDetail.setItems(obList);
        // 如果有回查功能就有可能出现这个问题
        log.warn("根据详情表找不到俱乐部信息:" + clubId);
        return;
    }
    if (isNeedSum)
        // 求和统计
        list = computSumList(list, true);
    list.forEach(record -> {
        // * @param lmDetailTableId
        // * @param lmDetailZJ
        // * @param lmDetailInsure
        // * @param lmDetailPersonCount
        String tableId = record.getTableId();
        String zj = record.getScore();
        String insure = record.getInsurance();
        String personNumbers = record.getPersonCount();
        obList.add(new LMDetailInfo(tableId, zj, insure, personNumbers));
    });
    tableLMDetail.setItems(obList);
}
Also used : List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) Record(com.kendy.entity.Record) LMDetailInfo(com.kendy.entity.LMDetailInfo)

Example 3 with LMDetailInfo

use of com.kendy.entity.LMDetailInfo in project financial by greatkendy123.

the class LMController method setDataTableLMSum.

/**
 * 更新单个俱乐部总和表
 * 备注:需要用到最新的详情表数据
 * @time 2017年11月25日
 */
public void setDataTableLMSum() {
    // 初始化数据
    LMSumInfo info4 = new LMSumInfo();
    info4.setLmSumName("结余");
    LMSumInfo info2 = new LMSumInfo();
    info2.setLmSumName("桌费");
    LMSumInfo info3 = new LMSumInfo();
    info3.setLmSumName("已结算");
    LMSumInfo info1 = new LMSumInfo();
    info1.setLmSumName("当天总帐");
    tableLMSum.setItems(null);
    ObservableList<LMSumInfo> obList = FXCollections.observableArrayList();
    obList.add(info1);
    obList.add(info2);
    obList.add(info3);
    obList.add(info4);
    tableLMSum.setItems(obList);
    if (tableLMDetail == null && tableLMDetail.getItems() == null)
        return;
    // 桌费
    // info2.setLmSumZJ(getSelectedClub().getZhuoFei());
    // info3.setLmSumZJ(getSelectedClub().getYiJieSuan());
    info2.setLmSumZJ(this.get_LM_Zhuofei());
    info3.setLmSumZJ(this.get_LM_YiJiesuan());
    // 统计数据
    double sumOfEachClubZJ = 0d;
    // 这个要全部全和
    double sumOfEachClubInsure = 0d;
    int sumOfEachClubPersonCount = 0;
    for (LMDetailInfo detailInfo : tableLMDetail.getItems()) {
        sumOfEachClubZJ += NumUtil.getNum(detailInfo.getLmDetailZJ());
        sumOfEachClubInsure += NumUtil.getNum(detailInfo.getLmDetailInsure());
        sumOfEachClubPersonCount += NumUtil.getNum(detailInfo.getLmDetailPersonCount());
    }
    info1.setLmSumZJ(NumUtil.digit0("" + sumOfEachClubZJ));
    info1.setLmSumInsure(NumUtil.digit0("" + sumOfEachClubInsure));
    info1.setLmSumPersonCount("" + sumOfEachClubPersonCount);
    // 刷新才会显示
    tableLMSum.refresh();
    // 计算结余
    // 里面会去刷新表
    updateTableLMSumOnly();
}
Also used : LMSumInfo(com.kendy.entity.LMSumInfo) LMDetailInfo(com.kendy.entity.LMDetailInfo)

Example 4 with LMDetailInfo

use of com.kendy.entity.LMDetailInfo in project financial by greatkendy123.

the class LMController method initialize.

/**
 * FXML DOM节点加载完毕后的初始化
 */
@Override
public void initialize(URL location, ResourceBundle resources) {
    log.info("联盟对帐页面加载数据开始...");
    // 绑定代理查询中的合计表
    bindCellValue(lmDetailTableId, lmDetailZJ, lmDetailInsure, lmDetailPersonCount);
    // 红色注释
    lmDetailZJ.setCellFactory(MyController.getColorCellFactory(new LMDetailInfo()));
    lmDetailInsure.setCellFactory(MyController.getColorCellFactory(new LMDetailInfo()));
    // 绑定代理查询中的合计表
    tableLMSum.setEditable(true);
    bindCellValue(lmSumName, lmSumZJ, lmSumInsure, lmSumPersonCount);
    // 红色注释
    lmSumInsure.setCellFactory(MyController.getColorCellFactory(new LMSumInfo()));
    lmSumZJ.setCellFactory(TextFieldTableCell.forTableColumn());
    // shishiJine.setCellFactory(redAndEditCellFactory);
    lmSumZJ.setOnEditCommit(new EventHandler<CellEditEvent<LMSumInfo, String>>() {

        @Override
        public void handle(CellEditEvent<LMSumInfo, String> t) {
            String oldValue = t.getOldValue();
            String newValue = t.getNewValue();
            // 修改原值
            LMSumInfo sumInfo = (LMSumInfo) t.getTableView().getItems().get(t.getTablePosition().getRow());
            List<String> noAllowList = Arrays.asList("结余", "当天总帐");
            if (sumInfo == null || noAllowList.contains(sumInfo.getLmSumName())) {
                ShowUtil.show("此行不能编辑!");
                sumInfo.setLmSumZJ(oldValue);
                tableLMSum.refresh();
                return;
            }
            if (sumInfo != null && "桌费".equals(sumInfo.getLmSumName()) && !("0".equals(newValue)) && !(newValue.contains("-"))) {
                ShowUtil.show("桌费只能填写负数!");
                sumInfo.setLmSumZJ(oldValue);
                tableLMSum.refresh();
                return;
            }
            // 因为桌费和已结算在战绩那列
            String zf_or_yiJieSuan = sumInfo.getLmSumZJ();
            try {
                if (!StringUtil.isBlank(newValue))
                    Double.valueOf(newValue);
            } catch (Exception e) {
                ShowUtil.show(newValue + "是非法数据!!");
                sumInfo.setLmSumZJ(oldValue);
                tableLMSum.refresh();
                return;
            }
            // 新旧两值相等,应该不操作
            // 总和表赋新值
            sumInfo.setLmSumZJ(newValue);
            // 缓存赋新值(桌费或已结算)
            Club club = getSelectedClub();
            int lmType = getCurrentLMType();
            if ("桌费".equals(sumInfo.getLmSumName())) {
                // club.setZhuoFei(newValue);
                // 将新桌费设置到不同联盟当中
                set_LM_Zhuofei(club, lmType, newValue);
                // add 2018-2-11 添加到历史联盟桌费
                String date = StringUtil.isBlank(DataConstans.Date_Str) ? "2017-01-01" : DataConstans.Date_Str;
                ClubZhuofei clubZhuofei = new ClubZhuofei(date, club.getClubId(), newValue, "联盟" + lmType);
                DBUtil.saveOrUpdate_club_zhuofei(clubZhuofei);
            } else if ("已结算".equals(sumInfo.getLmSumName())) {
                // club.setYiJieSuan(newValue);
                // 将新桌费设置到不同联盟当中
                set_LM_YiJiesuan(club, lmType, newValue);
            }
            // 更新结余
            updateTableLMSumOnly();
            // 同步到数据库
            DBUtil.updateClub(club);
            // 设置合计桌费(这个没多大影响)
            setNewSumOfZF();
        }
    });
    // 设置俱乐部的ListView监听
    initSingClubListen();
    // 软件一打开就从从数据库中获取所有俱乐部信息
    allClubMap = DBUtil.getAllClub();
    _clubListView = clubListView;
    refreshClubList();
    // 同步所有俱乐部信息总列表
    refresh_eachClubList();
    // 设置合计桌费(这个没多大影响)
    setNewSumOfZF();
    log.info("联盟对帐页面加载数据完成!");
}
Also used : ClubZhuofei(com.kendy.entity.ClubZhuofei) LMSumInfo(com.kendy.entity.LMSumInfo) Club(com.kendy.entity.Club) List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) CellEditEvent(javafx.scene.control.TableColumn.CellEditEvent) LMDetailInfo(com.kendy.entity.LMDetailInfo)

Aggregations

LMDetailInfo (com.kendy.entity.LMDetailInfo)4 LMSumInfo (com.kendy.entity.LMSumInfo)3 ArrayList (java.util.ArrayList)3 Club (com.kendy.entity.Club)2 List (java.util.List)2 ObservableList (javafx.collections.ObservableList)2 ClubZhuofei (com.kendy.entity.ClubZhuofei)1 Record (com.kendy.entity.Record)1 ExportLMExcel (com.kendy.excel.ExportLMExcel)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 CellEditEvent (javafx.scene.control.TableColumn.CellEditEvent)1