Search in sources :

Example 6 with TGCompanyModel

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

the class TGController method loadDataLastest.

/**
 * 加载最新的数据
 *
 * @time 2018年3月5日
 */
public void loadDataLastest() {
    // 清空数据
    // 获取数据
    List<TGCompanyModel> tgCompanys = DBUtil.get_all_tg_company();
    if (CollectUtil.isHaveValue(tgCompanys)) {
        // 获取特定结构 {托管公司 :{ 团队名称 : 团队数据列表 }} TODO
        ObservableList<Node> companyButtons = TG_Company_VBox.getChildren();
        TG_Company_VBox.setPrefWidth(120);
        if (CollectUtil.isHaveValue(companyButtons)) {
            companyButtons.clear();
        }
        tgCompanys = tgCompanys.stream().filter(info -> MyController.currentClubId.getText().equals(info.getClubId())).collect(Collectors.toList());
        tgCompanys.forEach(company -> {
            Button companyBtn = getCompanyButton(company);
            companyButtons.add(companyBtn);
        });
    }
}
Also used : Button(javafx.scene.control.Button) Node(javafx.scene.Node) TGCompanyModel(com.kendy.entity.TGCompanyModel)

Example 7 with TGCompanyModel

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

the class TGController method saveCompanyInfoAction.

/**
 * 保存或修改公司信息(押金和额度)
 *
 * @time 2018年3月11日
 * @param event
 */
public void saveCompanyInfoAction(ActionEvent event) {
    String tgCompany = currentTGCompanyLabel.getText();
    if (StringUtil.isBlank(tgCompany)) {
        ShowUtil.show("请先选择托管公司!");
        return;
    }
    TGCompanyModel db_company = DBUtil.get_tg_company_by_id(tgCompany);
    if (db_company == null) {
        ShowUtil.show("数据库中没有存储此托管公司!");
        return;
    }
    // 托管公司押金
    String companyYajin = StringUtil.nvl(tgCompanyYajin.getText(), "0");
    // 托管公司额度
    String companyEdu = StringUtil.nvl(tgCompanyEdu.getText(), "0");
    // 托管公司已分红
    String yifenhong = StringUtil.nvl(tgYifenhong.getText(), "0");
    db_company.setYajin(companyYajin);
    db_company.setEdu(companyEdu);
    db_company.setYifenhong(yifenhong);
    DBUtil.saveOrUpdate_tg_company(db_company);
    ShowUtil.show("保存成功", 2);
}
Also used : TGCompanyModel(com.kendy.entity.TGCompanyModel)

Example 8 with TGCompanyModel

use of com.kendy.entity.TGCompanyModel 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 9 with TGCompanyModel

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

the class DBUtil method get_all_tg_company_By_clubId.

/**
 * 根据俱乐部ID获取托管公司
 * @time 2018年3月24日
 * @param clubId
 * @return
 */
public static List<TGCompanyModel> get_all_tg_company_By_clubId(String clubId) {
    List<TGCompanyModel> list = new ArrayList<>();
    if (StringUtil.isBlank(clubId)) {
        ShowUtil.show("当前俱乐部ID为空,请检查!", 2);
        return list;
    }
    try {
        con = DBConnection.getConnection();
        String sql = "select * from tg_company where club_id = '" + clubId + "'";
        ps = con.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            // tgCompanyName, companyRate, tgCompanyRate, yajin, edu, tgTeamsStr
            TGCompanyModel company = new TGCompanyModel(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(8), rs.getString(9));
            company.setBeizhu(rs.getString(7));
            if (StringUtil.isNotBlank(company.getTgTeamsStr())) {
                String[] teamArr = company.getTgTeamsStr().split("#");
                company.setTgTeamList(new ArrayList<String>(Arrays.asList(teamArr)));
            }
            list.add(company);
        }
    } 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) TGCompanyModel(com.kendy.entity.TGCompanyModel)

Example 10 with TGCompanyModel

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

the class DBUtil method get_all_tg_company.

/**
 * 获取所有托管公司
 *
 * @time 2018年3月4日
 * @return
 */
public static List<TGCompanyModel> get_all_tg_company() {
    List<TGCompanyModel> list = new ArrayList<>();
    try {
        con = DBConnection.getConnection();
        String sql = "select * from tg_company";
        ps = con.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            // tgCompanyName, companyRate, tgCompanyRate, yajin, edu, tgTeamsStr
            TGCompanyModel company = new TGCompanyModel(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(8), rs.getString(9));
            company.setBeizhu(rs.getString(7));
            if (StringUtil.isNotBlank(company.getTgTeamsStr())) {
                String[] teamArr = company.getTgTeamsStr().split("#");
                company.setTgTeamList(new ArrayList<String>(Arrays.asList(teamArr)));
            }
            list.add(company);
        }
    } 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) TGCompanyModel(com.kendy.entity.TGCompanyModel)

Aggregations

TGCompanyModel (com.kendy.entity.TGCompanyModel)11 ArrayList (java.util.ArrayList)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 MyController (application.MyController)2 TGController (com.kendy.controller.TGController)2 DBUtil (com.kendy.db.DBUtil)2 ProxyTeamInfo (com.kendy.entity.ProxyTeamInfo)2 TGFwfinfo (com.kendy.entity.TGFwfinfo)2 TGTeamInfo (com.kendy.entity.TGTeamInfo)2 TGTeamModel (com.kendy.entity.TGTeamModel)2 TypeValueInfo (com.kendy.entity.TypeValueInfo)2 CollectUtil (com.kendy.util.CollectUtil)2 NumUtil (com.kendy.util.NumUtil)2 ShowUtil (com.kendy.util.ShowUtil)2 StringUtil (com.kendy.util.StringUtil)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Node (javafx.scene.Node)2