Search in sources :

Example 1 with QuotaMoneyInfo

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

the class QuotaController method exportClubPayExcel.

/**
 ********************************************************************************
 *
 *                                     导出Excel
 *
 **********************************************************************************
 */
public void exportClubPayExcel(ActionEvent event) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    // 标题
    String title = currentLMLabels.getText() + "俱乐部结账单-" + sdf.format(new Date());
    // 列名
    String[] rowName = new String[] { "付款方", "收款方", "转账", "支付类型", "联系人", "手机", "银行卡信息" };
    ;
    // 输出
    String out = "D:/" + title + System.currentTimeMillis();
    // 数据
    ObservableList<QuotaMoneyInfo> obList = tableQuotaPay.getItems();
    if (CollectUtil.isNullOrEmpty(obList)) {
        ShowUtil.show("没有需要导出的数据!");
        return;
    }
    List<Object[]> dataList = new ArrayList<Object[]>();
    Object[] objs = null;
    String clubId = "";
    for (QuotaMoneyInfo info : obList) {
        ClubBankModel model = allClubBankModels.get(info.getQuotaMoneyClubId());
        objs = new Object[rowName.length];
        objs[0] = info.getQuotaMoneyPaytor();
        objs[1] = info.getQuotaMoneyGather();
        objs[2] = "转" + info.getQuotaMoney() + "到";
        objs[3] = model.getMobilePayType();
        objs[4] = model.getPersonName();
        objs[5] = model.getPhoneNumber();
        objs[6] = model.getBankAccountInfo();
        dataList.add(objs);
    }
    ExportQuotaPayExcel excel = new ExportQuotaPayExcel(title, rowName, dataList, out);
    try {
        excel.export();
        log.info("导出单个联盟俱乐部结账单完成!");
    } catch (Exception e) {
        ErrorUtil.err("导出单个联盟俱乐部结账单失败", e);
    }
}
Also used : ExportQuotaPayExcel(com.kendy.excel.ExportQuotaPayExcel) QuotaMoneyInfo(com.kendy.entity.QuotaMoneyInfo) ArrayList(java.util.ArrayList) Date(java.util.Date) ClubBankModel(com.kendy.entity.ClubBankModel) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with QuotaMoneyInfo

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

the class QuotaController method autoQuota.

/**
 * 联盟自动配额
 * 这是本控制类最核心的代码
 * 算法:找剩余值中的两个最大最小值进行一方清零,不断循环
 *
 * @time 2017年12月18日
 */
public void autoQuota() {
    if (TableUtil.isNullOrEmpty(tableQuota))
        return;
    boolean isDone = false;
    int count = 0;
    while (!isDone) {
        count++;
        ClubQuota row1 = getRecord(1);
        ClubQuota row2 = getRecord(0);
        // log.info(String.format("最大值:%s::%s", row1.getQuotaClubName(),row1.getQuotaRest()));
        // log.info(String.format("最小值:%s::%s", row2.getQuotaClubName(),row2.getQuotaRest()));
        Double first = NumUtil.getNum(row1.getQuotaRest());
        Double second = NumUtil.getNum(row2.getQuotaRest());
        if (first * second >= 0) {
            isDone = true;
            log.info("=====================联盟配额结束!count:" + (count - 1));
            break;
        }
        // 转换(row1永远是绝对值的大数,row2是绝对值的小数	)
        if (Double.compare(first, second) > 0) {
            if (Double.compare(Math.abs(first), Math.abs(second)) < 0) {
                ClubQuota tempRow;
                tempRow = row1;
                row1 = row2;
                row2 = tempRow;
                Double tempVal;
                tempVal = first;
                first = second;
                second = tempVal;
            // log.info(String.format("转换最大值:%s::%s", row1.getQuotaClubName(),row1.getQuotaRest()));
            // log.info(String.format("转换最小值:%s::%s", row2.getQuotaClubName(),row2.getQuotaRest()));
            }
        }
        // 绝对值大数行设值
        if (StringUtil.isBlank(row1.getQuotaHedgeFirst())) {
            row1.setQuotaHedgeFirst(row2.getQuotaRest());
        } else if (StringUtil.isBlank(row1.getQuotaHedgeSecond())) {
            row1.setQuotaHedgeSecond(row2.getQuotaRest());
        } else if (StringUtil.isBlank(row1.getQuotaHedgeThree())) {
            row1.setQuotaHedgeThree(row2.getQuotaRest());
        } else if (StringUtil.isBlank(row1.getQuotaHedgeFour())) {
            row1.setQuotaHedgeFour(row2.getQuotaRest());
        } else if (StringUtil.isBlank(row1.getQuotaHedgeFive())) {
            row1.setQuotaHedgeFive(row2.getQuotaRest());
        }
        row1.setQuotaRest(NumUtil.digit0(first + second));
        // 绝对值小数行设值
        String small = NumUtil.digit0(second * (-1));
        if (StringUtil.isBlank(row2.getQuotaHedgeFirst())) {
            row2.setQuotaHedgeFirst(small);
        } else if (StringUtil.isBlank(row2.getQuotaHedgeSecond())) {
            row2.setQuotaHedgeSecond(small);
        } else if (StringUtil.isBlank(row2.getQuotaHedgeThree())) {
            row2.setQuotaHedgeThree(small);
        } else if (StringUtil.isBlank(row2.getQuotaHedgeFour())) {
            row2.setQuotaHedgeFour(small);
        } else if (StringUtil.isBlank(row2.getQuotaHedgeFive())) {
            row2.setQuotaHedgeFive(small);
        }
        row2.setQuotaRest("0");
        // 以下做其他逻辑
        // 输出钱由输者转给赢者
        String from, to, money = "";
        ClubQuota winner;
        if (small.contains("-")) {
            from = row1.getQuotaClubName();
            to = row2.getQuotaClubName();
            money = Integer.valueOf(small.replace("-", "")).toString();
            winner = row2;
        } else {
            from = row2.getQuotaClubName();
            to = row1.getQuotaClubName();
            money = small;
            winner = row1;
        }
        log.info(String.format("%s转%s到%s", from, money, to));
        addRecord2TableQuotaPay(new QuotaMoneyInfo(winner.getQuotaClubId(), from, money, to));
    }
    tableQuotaPay.refresh();
    tableQuota.refresh();
    // 配额最后还有剩余为负数的则全部结转到当前俱乐部
    addNegativeRest2CurrentClub();
}
Also used : QuotaMoneyInfo(com.kendy.entity.QuotaMoneyInfo) ClubQuota(com.kendy.entity.ClubQuota)

Example 3 with QuotaMoneyInfo

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

the class QuotaController method addNegativeRest2CurrentClub.

/**
 * 配额最后还有剩余为负数的则全部结转到当前俱乐部
 * @time 2017年12月18日
 */
private void addNegativeRest2CurrentClub() {
    String currentClubId = MyController.currentClubId.getText();
    // Club winnerClub = allClubMap.get("555551");//555551为银河ATM的俱乐部ID
    // 555551为银河ATM的俱乐部ID
    Club winnerClub = allClubMap.get(currentClubId);
    if (winnerClub == null) {
        // ErrorUtil.err("当前俱乐部"+currentClubId+"不存在!!!请添加!!");
        return;
    }
    tableQuota.getItems().parallelStream().filter(info -> NumUtil.getNum(info.getQuotaRest()) < 0).forEach(info -> {
        String from, to, money = "";
        to = winnerClub.getName();
        money = NumUtil.digit0((-1) * NumUtil.getNum(info.getQuotaRest()));
        from = info.getQuotaClubName();
        // log.info(String.format("%s转%s到%s", from,money,to));
        addRecord2TableQuotaPay(new QuotaMoneyInfo(winnerClub.getClubId(), from, money, to));
    });
    tableQuotaPay.refresh();
}
Also used : ExportQuotaPayExcel(com.kendy.excel.ExportQuotaPayExcel) Button(javafx.scene.control.Button) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) NumUtil(com.kendy.util.NumUtil) URL(java.net.URL) Date(java.util.Date) Record(com.kendy.entity.Record) SimpleDateFormat(java.text.SimpleDateFormat) QuotaMoneyInfo(com.kendy.entity.QuotaMoneyInfo) InputDialog(com.kendy.util.InputDialog) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) LMSumInfo(com.kendy.entity.LMSumInfo) Club(com.kendy.entity.Club) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) LinkedHashMap(java.util.LinkedHashMap) Logger(org.apache.log4j.Logger) ResourceBundle(java.util.ResourceBundle) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) TableUtil(com.kendy.util.TableUtil) ClubBankModel(com.kendy.entity.ClubBankModel) MyController(application.MyController) TableView(javafx.scene.control.TableView) DataConstans(application.DataConstans) DBUtil(com.kendy.db.DBUtil) PropertiesUtil(application.PropertiesUtil) Label(javafx.scene.control.Label) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) ClubQuota(com.kendy.entity.ClubQuota) Collectors(java.util.stream.Collectors) ClubBankInfo(com.kendy.entity.ClubBankInfo) FXML(javafx.fxml.FXML) List(java.util.List) ActionEvent(javafx.event.ActionEvent) CollectUtil(com.kendy.util.CollectUtil) ShowUtil(com.kendy.util.ShowUtil) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Comparator(java.util.Comparator) ErrorUtil(com.kendy.util.ErrorUtil) Entity(com.kendy.interfaces.Entity) QuotaMoneyInfo(com.kendy.entity.QuotaMoneyInfo) Club(com.kendy.entity.Club)

Aggregations

QuotaMoneyInfo (com.kendy.entity.QuotaMoneyInfo)3 ClubBankModel (com.kendy.entity.ClubBankModel)2 ClubQuota (com.kendy.entity.ClubQuota)2 ExportQuotaPayExcel (com.kendy.excel.ExportQuotaPayExcel)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 DataConstans (application.DataConstans)1 MyController (application.MyController)1 PropertiesUtil (application.PropertiesUtil)1 DBUtil (com.kendy.db.DBUtil)1 Club (com.kendy.entity.Club)1 ClubBankInfo (com.kendy.entity.ClubBankInfo)1 LMSumInfo (com.kendy.entity.LMSumInfo)1 Record (com.kendy.entity.Record)1 Entity (com.kendy.interfaces.Entity)1 CollectUtil (com.kendy.util.CollectUtil)1 ErrorUtil (com.kendy.util.ErrorUtil)1 InputDialog (com.kendy.util.InputDialog)1 NumUtil (com.kendy.util.NumUtil)1