Search in sources :

Example 6 with TypeValueInfo

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

the class TGController method refreshProfitTab.

/**
 * 刷新月利润表
 * @time 2018年3月17日
 */
public void refreshProfitTab() {
    String tgCompany = currentTGCompanyLabel.getText();
    if (StringUtil.isBlank(tgCompany)) {
        ShowUtil.show("请先选择托管公司!");
        return;
    }
    System.out.println("===========================刷新月利润表");
    List<TGLirunInfo> list = new ArrayList<>();
    TGLirunInfo lirun = new TGLirunInfo();
    // 获取数据库的历史日利润表 TODO
    List<TGLirunInfo> liruns = DBUtil.get_all_tg_lirun(tgCompany);
    if (CollectUtil.isHaveValue(liruns)) {
        // liruns = liruns.stream()
        // .filter(info->tgCompany.equals(info.getTgLirunCompanyName())) // 获取当前托管公司的数据,但剔除今天已经保存过的数据,因为下面会重新计算
        // .filter(info-> !(TimeUtil.getDateString().equals(info.getTgLirunDate()) && tgCompany.equals(info.getTgLirunCompanyName())))
        // .collect(Collectors.toList());
        list.addAll(liruns);
        String today = getDateString();
        boolean isTodayContains = list.stream().anyMatch(info -> today.equals(info.getTgLirunDate()));
        if (isTodayContains) {
            log.info("刷新月利润表时已经存在了今天" + today + "的数据了!所以不重复计算");
            tableTGLirun.setItems(FXCollections.observableArrayList(list));
            return;
        }
    }
    // 刷新服务费
    refreshFwfTab();
    // 获取日期(日期与当前托管公司为主键)
    String dateString = getDateString();
    lirun.setTgLirunDate(dateString);
    lirun.setTgLirunCompanyName(tgCompany);
    // 获取总利润(即服务费明细中的总利润)
    ObservableList<TypeValueInfo> fwfList = tableTGFwfSum.getItems();
    String tgLirunTotalProfit = fwfList.stream().filter(info -> "总利润".equals(info.getType())).map(TypeValueInfo::getValue).findFirst().orElse("0");
    lirun.setTgLirunTotalProfit(tgLirunTotalProfit);
    // 获取总开销
    List<TGKaixiaoInfo> allTGKaixiaos = DBUtil.get_all_tg_kaixiao();
    double sumOfKaixiao = allTGKaixiaos.stream().filter(info -> tgCompany.equals(info.getTgKaixiaoCompany())).map(TGKaixiaoInfo::getTgKaixiaoMoney).mapToDouble(NumUtil::getNum).sum();
    lirun.setTgLirunTotalKaixiao(NumUtil.digit0(sumOfKaixiao + ""));
    // 设置Rest合计
    lirun.setTgLirunRestHeji(NumUtil.digit2(NumUtil.getSum(tgLirunTotalProfit, sumOfKaixiao + "")));
    // 设置公司占股
    TGCompanyModel companyModel = DBUtil.get_tg_company_by_id(tgCompany);
    String companyRate = companyModel.getCompanyRate();
    companyRate = companyRate.endsWith("%") ? NumUtil.getNumByPercent(companyRate) + "" : NumUtil.getNum(companyRate) / 100.0 + "";
    Double atmCompanyProfit = NumUtil.getNumTimes(lirun.getTgLirunRestHeji(), companyRate);
    lirun.setTgLirunATMCompany(NumUtil.digit2(atmCompanyProfit + ""));
    // 设置托管公司占股
    String tgCompanyRate = StringUtil.nvl(companyModel.getTgCompanyRate(), "0%");
    tgCompanyRate = tgCompanyRate.endsWith("%") ? NumUtil.getNumByPercent(tgCompanyRate) + "" : NumUtil.getNum(tgCompanyRate) / 100.0 + "";
    Double tgCompanyProfit = NumUtil.getNumTimes(lirun.getTgLirunRestHeji(), tgCompanyRate);
    lirun.setTgLirunTGCompany(NumUtil.digit2(tgCompanyProfit + ""));
    // 设置团队服务费 TODO
    Double tgCompanyProxy = 0.0d;
    List<TGTeamModel> tgTeamInfos = DBUtil.get_all_tg_team();
    Set<String> proxyTeamSet = tgTeamInfos.stream().filter(info -> "1".equals(info.getTgTeamProxy())).map(TGTeamModel::getTgTeamId).collect(Collectors.toSet());
    tgCompanyProxy = tableTGFwf.getItems().stream().filter(info -> proxyTeamSet.contains(info.getTgFwfTeamId())).mapToDouble(info -> NumUtil.getNum(info.getTgFwfFanshui()) + NumUtil.getNum(info.getTgFwfFanbao())).sum();
    lirun.setTgLirunTeamProfit(NumUtil.digit2(tgCompanyProxy + ""));
    // 设置托管公司合计 = 托管公司占股 + 托管公司代理
    Double tgCompanyHeji = tgCompanyProfit + tgCompanyProxy;
    lirun.setTgLirunHeji(NumUtil.digit2(tgCompanyHeji + ""));
    list.add(lirun);
    tableTGLirun.setItems(FXCollections.observableArrayList(list));
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Initializable(javafx.fxml.Initializable) Constants(application.Constants) NumUtil(com.kendy.util.NumUtil) URL(java.net.URL) InputDialog(com.kendy.util.InputDialog) Random(java.util.Random) VBox(javafx.scene.layout.VBox) Huishui(com.kendy.entity.Huishui) Logger(org.apache.log4j.Logger) Parent(javafx.scene.Parent) TabPane(javafx.scene.control.TabPane) AlertType(javafx.scene.control.Alert.AlertType) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) TGTeamModel(com.kendy.entity.TGTeamModel) WindowEvent(javafx.stage.WindowEvent) MyController(application.MyController) TableView(javafx.scene.control.TableView) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) TgWaizhaiService(com.kendy.service.TgWaizhaiService) TGCompanyModel(com.kendy.entity.TGCompanyModel) FXML(javafx.fxml.FXML) List(java.util.List) TypeReference(com.alibaba.fastjson.TypeReference) CollectUtil(com.kendy.util.CollectUtil) ShowUtil(com.kendy.util.ShowUtil) TGKaixiaoInfo(com.kendy.entity.TGKaixiaoInfo) ProxyTeamInfo(com.kendy.entity.ProxyTeamInfo) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Scene(javafx.scene.Scene) TGCommentInfo(com.kendy.entity.TGCommentInfo) TGExportExcelService(com.kendy.service.TGExportExcelService) ListView(javafx.scene.control.ListView) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TGFwfService(com.kendy.service.TGFwfService) TypeValueInfo(com.kendy.entity.TypeValueInfo) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) TableUtil(com.kendy.util.TableUtil) TGLirunInfo(com.kendy.entity.TGLirunInfo) DataConstans(application.DataConstans) DBUtil(com.kendy.db.DBUtil) TGFwfinfo(com.kendy.entity.TGFwfinfo) Label(javafx.scene.control.Label) TGTeamInfo(com.kendy.entity.TGTeamInfo) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) TeamProxyService(com.kendy.service.TeamProxyService) Main(application.Main) ActionEvent(javafx.event.ActionEvent) JSON(com.alibaba.fastjson.JSON) Stage(javafx.stage.Stage) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) Entity(com.kendy.interfaces.Entity) TypeValueInfo(com.kendy.entity.TypeValueInfo) TGKaixiaoInfo(com.kendy.entity.TGKaixiaoInfo) ArrayList(java.util.ArrayList) TGTeamModel(com.kendy.entity.TGTeamModel) TGLirunInfo(com.kendy.entity.TGLirunInfo) TGCompanyModel(com.kendy.entity.TGCompanyModel)

Example 7 with TypeValueInfo

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

the class TGController method getMoniTGTeamRate.

private List<TypeValueInfo> getMoniTGTeamRate() {
    // DBUtil.delValueByKey(TG_TEAM_RATE_DB_KEY);
    List<TypeValueInfo> list = new ArrayList<>();
    Random random = new Random();
    for (int i = 1; i <= 40; i++) {
        double nextDouble = random.nextDouble();
        list.add(new TypeValueInfo("S" + i, NumUtil.digit1(1 + nextDouble + "") + "%"));
    }
    return list;
}
Also used : TypeValueInfo(com.kendy.entity.TypeValueInfo) Random(java.util.Random) ArrayList(java.util.ArrayList)

Example 8 with TypeValueInfo

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

the class TGExportExcelService method getTeamZJExcelModel.

/**
 * 导出战绩明细
 * @return
 */
private TGExcelModel getTeamZJExcelModel(String teamId, String hsRate) {
    TGExcelModel excelModel = new TGExcelModel();
    List<String> titleList = new LinkedList<>();
    List<Object[]> data = new LinkedList<>();
    List<String> titleSumList = new LinkedList<>();
    List<Object[]> dataSum = new LinkedList<>();
    titleList = new LinkedList<>(Arrays.asList("玩家ID", "玩家名称", "原始战绩", "保险", "战绩2.5%", "战绩" + hsRate, "回保", "利润", "场次"));
    ObservableList<TGTeamInfo> items = tgController.tableTGZhanji.getItems();
    if (CollectUtil.isHaveValue(items)) {
        data = items.stream().map(info -> {
            Object[] obj = new Object[9];
            obj[0] = info.getTgPlayerId();
            obj[1] = info.getTgPlayerName();
            obj[2] = info.getTgYSZJ();
            obj[3] = info.getTgBaoxian();
            obj[4] = info.getTgZJ25();
            obj[5] = info.getTgZJUnknow();
            obj[6] = info.getTgHuiBao();
            obj[7] = info.getTgProfit();
            obj[8] = info.getTgChangci();
            return obj;
        }).collect(Collectors.toList());
    }
    ObservableList<TypeValueInfo> sumItems = tgController.tableZJSum.getItems();
    if (CollectUtil.isHaveValue(sumItems)) {
        dataSum = sumItems.stream().map(info -> {
            Object[] obj = new Object[2];
            obj[0] = info.getType();
            obj[1] = info.getValue();
            return obj;
        }).collect(Collectors.toList());
    }
    excelModel.setColumnList(titleList);
    excelModel.setData(data);
    excelModel.setColumnSumList(titleSumList);
    excelModel.setDataSum(dataSum);
    excelModel.setSheetName(teamId);
    return excelModel;
}
Also used : TypeValueInfo(com.kendy.entity.TypeValueInfo) TGExcelModel(com.kendy.entity.TGExcelModel) TGTeamInfo(com.kendy.entity.TGTeamInfo) LinkedList(java.util.LinkedList)

Example 9 with TypeValueInfo

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

the class TGExportExcelService method getTGWaizhaiExcelModel.

/**
 * 导出托管公司的团队外债与团队外债明细
 * @return
 */
private TGExcelModel getTGWaizhaiExcelModel() {
    TGExcelModel excelModel = new TGExcelModel();
    List<String> titleList = new LinkedList<>();
    List<Object[]> data = new LinkedList<>();
    List<String> titleSumList = new LinkedList<>();
    List<Object[]> dataSum = new LinkedList<>();
    // 取值
    // 传给Excel的外债数据
    Map<String, List<Object[]>> teamMap = new LinkedHashMap<>();
    ObservableList<Node> items = tgController.tgWZTeamHBox.getChildren();
    // 存放总和表
    ObservableList<TypeValueInfo> sumItems = tgController.tgWZTeam.getItems();
    if (CollectUtil.isHaveValue(sumItems)) {
        List<Object[]> teamList = tgController.tgWZTeam.getItems().stream().map(info -> {
            Object[] obj = new Object[2];
            obj[0] = info.getType();
            obj[1] = info.getValue();
            return obj;
        }).collect(Collectors.toList());
        String key = tgController.tgWZTeam.getColumns().get(0).getText() + "#" + tgController.tgWZTeam.getColumns().get(1).getText();
        teamMap.put(key, teamList);
    }
    // 存放明细表
    if (CollectUtil.isHaveValue(items)) {
        for (Node node : items) {
            TableView<CurrentMoneyInfo> table = (TableView<CurrentMoneyInfo>) node;
            List<Object[]> teamList = table.getItems().stream().map(info -> {
                Object[] obj = new Object[2];
                obj[0] = info.getMingzi();
                obj[1] = info.getShishiJine();
                return obj;
            }).collect(Collectors.toList());
            String key = table.getColumns().get(0).getText() + "#" + table.getColumns().get(1).getText();
            teamMap.put(key, teamList);
        }
    }
    excelModel.setColumnList(titleList);
    excelModel.setData(data);
    excelModel.setColumnSumList(titleSumList);
    excelModel.setDataSum(dataSum);
    excelModel.setSheetName("外债");
    // 设值
    excelModel.setWaiZai(true);
    excelModel.setWaizhaiMap(teamMap);
    return excelModel;
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) TGCommentInfo(com.kendy.entity.TGCommentInfo) HashMap(java.util.HashMap) ExportTGExcel(com.kendy.excel.ExportTGExcel) TypeValueInfo(com.kendy.entity.TypeValueInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) LinkedList(java.util.LinkedList) TGLirunInfo(com.kendy.entity.TGLirunInfo) TableView(javafx.scene.control.TableView) TGFwfinfo(com.kendy.entity.TGFwfinfo) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) TGTeamInfo(com.kendy.entity.TGTeamInfo) Node(javafx.scene.Node) TGController(com.kendy.controller.TGController) Collectors(java.util.stream.Collectors) TGExcelModel(com.kendy.entity.TGExcelModel) FXML(javafx.fxml.FXML) List(java.util.List) CollectUtil(com.kendy.util.CollectUtil) ShowUtil(com.kendy.util.ShowUtil) TGKaixiaoInfo(com.kendy.entity.TGKaixiaoInfo) ObservableList(javafx.collections.ObservableList) ErrorUtil(com.kendy.util.ErrorUtil) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) TypeValueInfo(com.kendy.entity.TypeValueInfo) Node(javafx.scene.Node) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) TGExcelModel(com.kendy.entity.TGExcelModel) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ObservableList(javafx.collections.ObservableList) TableView(javafx.scene.control.TableView)

Example 10 with TypeValueInfo

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

the class TgWaizhaiService method setWaizhaiSum.

/**
 * 设置外债信息总和
 *
 * @time 2017年10月28日
 * @param tableWaizhai
 */
public static void setWaizhaiSum(TableView<TypeValueInfo> tableWaizhai) {
    Double sum = 0d;
    ObservableList<TypeValueInfo> list = tableWaizhai.getItems();
    if (list != null && list.size() > 0) {
        for (TypeValueInfo info : list) {
            sum += NumUtil.getNum(info.getValue());
        }
    } else {
        sum = 0d;
    }
    tableWaizhai.getColumns().get(1).setText(NumUtil.digit0(sum));
}
Also used : TypeValueInfo(com.kendy.entity.TypeValueInfo)

Aggregations

TypeValueInfo (com.kendy.entity.TypeValueInfo)11 ArrayList (java.util.ArrayList)6 TGFwfinfo (com.kendy.entity.TGFwfinfo)5 TGTeamInfo (com.kendy.entity.TGTeamInfo)5 List (java.util.List)5 Map (java.util.Map)5 ObservableList (javafx.collections.ObservableList)5 CollectUtil (com.kendy.util.CollectUtil)4 ShowUtil (com.kendy.util.ShowUtil)4 StringUtil (com.kendy.util.StringUtil)4 Collectors (java.util.stream.Collectors)4 TableView (javafx.scene.control.TableView)4 MyController (application.MyController)3 DBUtil (com.kendy.db.DBUtil)3 ProxyTeamInfo (com.kendy.entity.ProxyTeamInfo)3 TGCommentInfo (com.kendy.entity.TGCommentInfo)3 TGCompanyModel (com.kendy.entity.TGCompanyModel)3 TGExcelModel (com.kendy.entity.TGExcelModel)3 TGKaixiaoInfo (com.kendy.entity.TGKaixiaoInfo)3 TGLirunInfo (com.kendy.entity.TGLirunInfo)3