Search in sources :

Example 1 with TGLirunInfo

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

the class TGController method saveCurrentTGCompanyLirnAction.

/**
 * 保存当前托管公司的日利润数据
 * @time 2018年3月19日
 * @param event
 */
public void saveCurrentTGCompanyLirnAction(ActionEvent event) {
    String tgCompany = currentTGCompanyLabel.getText();
    if (StringUtil.isBlank(tgCompany)) {
        ShowUtil.show("请选择托管公司!", 2);
        return;
    }
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("提示");
    alert.setHeaderText(null);
    alert.setContentText("确定这是最后一场了吗,将保存本场最后一条记录进数据库,确定数据正确了吗?");
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        int size = tableTGLirun.getItems().size();
        if (size > 0) {
            TGLirunInfo tgLirunInfo = tableTGLirun.getItems().get(size - 1);
            DBUtil.saveOrUpdate_tg_lirun(tgLirunInfo);
            ShowUtil.show("保存成功", 2);
        } else {
            ShowUtil.show("无可保存的数据!", 2);
        }
    }
}
Also used : Alert(javafx.scene.control.Alert) TGLirunInfo(com.kendy.entity.TGLirunInfo) ButtonType(javafx.scene.control.ButtonType)

Example 2 with TGLirunInfo

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

the class TGController method initialize.

/**
 * DOM加载完后的事件
 */
@SuppressWarnings("unchecked")
@Override
public void initialize(URL location, ResourceBundle resources) {
    // 绑定列值属性
    MyController.bindCellValue(tgKaixiaoDate, tgKaixiaoPlayerName, tgKaixiaoPayItem, tgKaixiaoMoney, tgKaixiaoCompany);
    MyController.bindCellValue(tgCommentDate, tgCommentPlayerId, tgCommentPlayerName, tgCommentType, tgCommentId, tgCommentName, tgCommentBeizhu, tgCommentCompany);
    MyController.bindCellValue(tgFwfCompany, tgFwfTeamId, tgFwfHuishui, tgFwfHuiBao, tgFwfProfit, tgFwfFanshui, tgFwfFanbao, tgFwfQuanshui, tgFwfQuanbao, tgFwfHeji);
    MyController.bindCellValue(tgLirunDate, tgLirunTotalProfit, tgLirunTotalKaixiao, tgLirunATMCompany, tgLirunTGCompany, tgLirunTeamProfit, tgLirunRestHeji, tgLirunHeji, tgLirunCompanyName);
    binCellValueDiff(tgTeamId, "type");
    binCellValueDiff(tgTeamRate, "value");
    binCellValueDiff(tgZJSumType, "type");
    binCellValueDiff(tgZJSumValue, "value");
    binCellValueDiff(tgWZTeamId, "type");
    binCellValueDiff(tgWZTeamValue, "value");
    binCellValueDiff(tgFwfType, "type");
    binCellValueDiff(tgFwfValue, "value");
    MyController.bindCellValue(tgPlayerId, tgPlayerName, tgYSZJ, tgZJ25, tgZJUnknow, tgProfit, tgHuiBao, tgBaoxian, tgChangci);
    bindColorColumns(new TGTeamInfo(), tgYSZJ, tgZJ25, tgZJUnknow, tgProfit, tgHuiBao, tgBaoxian);
    bindColorColumns(new TGFwfinfo(), tgFwfHuishui, tgFwfHuiBao, tgFwfProfit, tgFwfFanshui, tgFwfFanbao, tgFwfQuanshui, tgFwfQuanbao, tgFwfHeji);
    bindColorColumns(new TGLirunInfo(), tgLirunTotalProfit, tgLirunTotalKaixiao, tgLirunATMCompany, tgLirunTGCompany, tgLirunTeamProfit, tgLirunRestHeji, tgLirunHeji);
    // tabs切换事件
    tabsAction();
    // 加载托管团队比例数据
    refreshTableTGTeam();
    // 加载托管公司数据
    loadDataLastest();
// 点击代理CheckBox时的事件
// initTeamProxyAction();
}
Also used : TGTeamInfo(com.kendy.entity.TGTeamInfo) TGLirunInfo(com.kendy.entity.TGLirunInfo) TGFwfinfo(com.kendy.entity.TGFwfinfo)

Example 3 with TGLirunInfo

use of com.kendy.entity.TGLirunInfo 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 4 with TGLirunInfo

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

the class DBUtil method get_all_tg_lirun.

/**
 * 获取所有托管日利润
 *
 * @time 2018年3月4日
 * @return
 */
public static List<TGLirunInfo> get_all_tg_lirun(String tgCompany) {
    List<TGLirunInfo> list = new ArrayList<>();
    try {
        con = DBConnection.getConnection();
        String sql = "select * from tg_lirun where tg_lirun_company_name='" + tgCompany + "'";
        ps = con.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            TGLirunInfo lirun = new TGLirunInfo(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9));
            list.add(lirun);
        }
    } catch (SQLException e) {
        ErrorUtil.err("获取所有托管日利润失败", e);
    } finally {
        close(con, ps);
    }
    return list;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) TGLirunInfo(com.kendy.entity.TGLirunInfo)

Example 5 with TGLirunInfo

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

the class TGExportExcelService method getMonthLirunExcelModel.

/**
 * 月利润ExcelModel
 * @time 2018年3月19日
 * @return
 */
private TGExcelModel getMonthLirunExcelModel() {
    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("日期", "托管公司", "总利润", "总开销", "合计", "公司占股", "托管公司占股", "团队利润", "托管合计"));
    ObservableList<TGLirunInfo> items = tgController.tableTGLirun.getItems();
    if (CollectUtil.isHaveValue(items)) {
        data = items.stream().map(info -> {
            Object[] obj = new Object[9];
            obj[0] = info.getTgLirunDate();
            obj[1] = info.getTgLirunCompanyName();
            obj[2] = info.getTgLirunTotalProfit();
            obj[3] = info.getTgLirunTotalKaixiao();
            obj[4] = info.getTgLirunRestHeji();
            obj[5] = info.getTgLirunATMCompany();
            obj[6] = info.getTgLirunTGCompany();
            obj[7] = info.getTgLirunTeamProfit();
            obj[8] = info.getTgLirunHeji();
            return obj;
        }).collect(Collectors.toList());
    }
    // add 新增合计
    // 托管公司押金
    String yajin = StringUtil.nvl(tgController.tgCompanyYajin.getText());
    // 托管公司额度
    String edu = StringUtil.nvl(tgController.tgCompanyEdu.getText());
    // 托管公司已分红
    String yifenhong = StringUtil.nvl(tgController.tgYifenhong.getText());
    // 总外债
    String waizhai = StringUtil.nvl(tgController.totalWaizhai.getText());
    // 总利润
    String profit = StringUtil.nvl(tgController.tgTotalProfit.getText());
    // 总可分配
    String availabel = StringUtil.nvl(tgController.tgAvailable.getText());
    Object[] obj = new Object[2];
    obj[0] = "押金";
    obj[1] = yajin;
    dataSum.add(obj);
    obj = new Object[2];
    obj[0] = "额度";
    obj[1] = edu;
    dataSum.add(obj);
    obj = new Object[2];
    obj[0] = "已分红";
    obj[1] = yifenhong;
    dataSum.add(obj);
    obj = new Object[2];
    obj[0] = "总外债";
    obj[1] = waizhai;
    dataSum.add(obj);
    obj = new Object[2];
    obj[0] = "总利润";
    obj[1] = profit;
    dataSum.add(obj);
    obj = new Object[2];
    obj[0] = "可分配";
    obj[1] = availabel;
    dataSum.add(obj);
    excelModel.setColumnList(titleList);
    excelModel.setData(data);
    excelModel.setColumnSumList(titleSumList);
    excelModel.setDataSum(dataSum);
    excelModel.setSheetName("月利润");
    return excelModel;
}
Also used : TGExcelModel(com.kendy.entity.TGExcelModel) TGLirunInfo(com.kendy.entity.TGLirunInfo) LinkedList(java.util.LinkedList)

Aggregations

TGLirunInfo (com.kendy.entity.TGLirunInfo)5 TGFwfinfo (com.kendy.entity.TGFwfinfo)2 TGTeamInfo (com.kendy.entity.TGTeamInfo)2 ArrayList (java.util.ArrayList)2 Alert (javafx.scene.control.Alert)2 ButtonType (javafx.scene.control.ButtonType)2 Constants (application.Constants)1 DataConstans (application.DataConstans)1 Main (application.Main)1 MyController (application.MyController)1 JSON (com.alibaba.fastjson.JSON)1 TypeReference (com.alibaba.fastjson.TypeReference)1 DBUtil (com.kendy.db.DBUtil)1 Huishui (com.kendy.entity.Huishui)1 ProxyTeamInfo (com.kendy.entity.ProxyTeamInfo)1 TGCommentInfo (com.kendy.entity.TGCommentInfo)1 TGCompanyModel (com.kendy.entity.TGCompanyModel)1 TGExcelModel (com.kendy.entity.TGExcelModel)1 TGKaixiaoInfo (com.kendy.entity.TGKaixiaoInfo)1 TGTeamModel (com.kendy.entity.TGTeamModel)1