Search in sources :

Example 1 with MyController

use of application.MyController in project financial by greatkendy123.

the class MoneyService method updatetTableProfitFirst.

private static void updatetTableProfitFirst(TableView<ProfitInfo> tableProfit) {
    /**
     ********************************************** 利润表  *************
     */
    // 1清空 表数据
    tableProfit.setItems(null);
    // 2获取InfoList
    ObservableList<ProfitInfo> observableList3 = FXCollections.observableArrayList();
    Map<String, String> profitMap = null;
    if (DataConstans.Index_Table_Id_Map.size() == 0) {
        log.info("=========================刷新(从昨天加载数据)");
        if (DBUtil.isPreData2017VeryFirst()) {
            profitMap = JSON.parseObject(DataConstans.preDataMap.get("昨日利润"), new TypeReference<Map<String, String>>() {
            });
            if (profitMap != null) {
                profitMap.forEach((type, account) -> {
                    observableList3.add(new ProfitInfo(type, digit0(account)));
                });
            }
        } else {
            List<ProfitInfo> list = JSON.parseObject(DataConstans.preDataMap.get("利润"), new TypeReference<List<ProfitInfo>>() {
            });
            if (list != null) {
                list.forEach(info -> {
                    observableList3.add(new ProfitInfo(info.getProfitType(), digit0(info.getProfitAccount())));
                });
            }
        }
    } else {
        log.info("=========================刷新(从上一场加载数据)");
        Map<String, String> map = DataConstans.All_Locked_Data_Map.get(DataConstans.Index_Table_Id_Map.size() + "");
        List<ProfitInfo> ProfitInfoList = JSON.parseObject(MoneyService.getJsonString(map, "利润"), new TypeReference<List<ProfitInfo>>() {
        });
        for (ProfitInfo infos : ProfitInfoList) {
            observableList3.add(infos);
        }
        // sumMap相关设值
        MyController mc = Main.myController;
        int size = DataConstans.Index_Table_Id_Map.size();
        if (size >= 1) {
            // 此情况下要从上一场加载==团队回水总和
            // DataConstans.SumMap = new HashMap<String,Double>();
            String shangchangKaixiao = MoneyService.getLockedInfo(size + "", "实时开销总和");
            // add 9-1
            DataConstans.SumMap.put("上场开销", Double.valueOf(shangchangKaixiao));
        }
    }
    tableProfit.setItems(observableList3);
    tableProfit.refresh();
}
Also used : List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) TypeReference(com.alibaba.fastjson.TypeReference) ProfitInfo(com.kendy.entity.ProfitInfo) MyController(application.MyController)

Example 2 with MyController

use of application.MyController in project financial by greatkendy123.

the class GDController method quotar_money_oneKey_Action.

/**
 * 一键配额
 *
 * @time 2018年2月25日
 * @param event
 */
public void quotar_money_oneKey_Action(ActionEvent event) {
    if (has_quotar_oneKey) {
        ShowUtil.show("您已经一键分配过了!");
        return;
    }
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("警告");
    alert.setHeaderText(null);
    alert.setContentText("\r\n 将清空场次信息中的利润栏以及把股东值赋到金额栏, 确定??");
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        MyController mc = Main.myController;
        // 金额表
        TableView<CurrentMoneyInfo> tableMoney = mc.tableCurrentMoneyInfo;
        // 利润表
        TableView<ProfitInfo> tableProfit = mc.tableProfit;
        // 清空利润表
        tableProfit.getItems().forEach(info -> info.setProfitAccount("0"));
        // 将股东值赋到金额栏
        String date = StringUtil.nvl(DataConstans.Date_Str, "2017-01-01");
        date = date.substring(5);
        for (GDDetailInfo info : tableGDDetail.getItems()) {
            String money = StringUtil.nvl(info.getTotal(), "0");
            String name = date + "#" + info.getName() + "#" + money;
            // mingzi, shishiJine,String wanjiaId,String cmiEdu
            CurrentMoneyInfo cmi = new CurrentMoneyInfo(name, money, "", "");
            tableMoney.getItems().add(cmi);
        }
        // 添加总利润差额
        String dif = difTotalProfit.getText();
        String name = date + "#贡献值差额#" + dif;
        // mingzi, shishiJine,String wanjiaId,String cmiEdu
        CurrentMoneyInfo difCMI = new CurrentMoneyInfo(name, dif, "", "");
        tableMoney.getItems().add(difCMI);
        tableMoney.refresh();
        tableProfit.refresh();
        has_quotar_oneKey = true;
    }
}
Also used : GDDetailInfo(com.kendy.entity.GDDetailInfo) Alert(javafx.scene.control.Alert) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) ButtonType(javafx.scene.control.ButtonType) MyController(application.MyController) ProfitInfo(com.kendy.entity.ProfitInfo)

Example 3 with MyController

use of application.MyController in project financial by greatkendy123.

the class AddController method addKaixiaoOKAction.

/**
 * 增加开销
 */
public void addKaixiaoOKAction(ActionEvent event) {
    if (!StringUtil.isBlank(kaixiaoTypes.getText())) {
        DataConstans.kaixiaoMap.put(kaixiaoTypes.getText(), kaixiaoMoneys.getText());
        ShowUtil.show("添加开销成功", 2);
        // 更新到表
        MyController mc = Main.myController;
        if (mc != null) {
            String kxGudong = gudongChoice.getSelectionModel().getSelectedItem();
            boolean isGudongEmpty = StringUtil.isBlank(kxGudong);
            String kaixiaoID = isGudongEmpty ? "" : UUID.randomUUID().toString().replace("-", "");
            String kaixiaoTime = StringUtil.nvl(DataConstans.Date_Str, "2017-01-01");
            String kxType = kaixiaoTypes.getText();
            String kxMoney = StringUtil.nvl(kaixiaoMoneys.getText(), "");
            KaixiaoInfo kaixiaoInfo = new KaixiaoInfo(kaixiaoID, kxType, kxMoney, kxGudong, kaixiaoTime);
            // 添加到场次信息中的开销表(若股东为空,则ID为空)
            mc.updateKaixiaoTable(kaixiaoInfo);
            // 添加到数据库中(如果股东不为空)
            if (!StringUtil.isAnyBlank(kxMoney, kxGudong)) {
                if (ALL_COMPANY.equals(kxGudong)) {
                    // N个股东平摊(包括银河股东)
                    ObservableList<String> gudongList = MyController.getGudongList();
                    // 股东平摊的开销值
                    String averageKaixiaoMoney = getAverageKaixiaoMoney(kxMoney, gudongList.size());
                    // 有几个股东就保存几条开销记录进数据库
                    int i = 0;
                    for (String gudongName : gudongList) {
                        // 共用一个开销ID, 从0编写到N
                        kaixiaoID = kaixiaoID + "#" + (i++);
                        KaixiaoInfo averageInfo = new KaixiaoInfo(kaixiaoID, kxType, averageKaixiaoMoney, gudongName, kaixiaoTime);
                        DBUtil.saveOrUpdate_gudong_kaixiao(averageInfo);
                    }
                } else {
                    DBUtil.saveOrUpdate_gudong_kaixiao(kaixiaoInfo);
                }
            // 缓存? TODO
            }
        } else {
            log.info("===========================mc = null ");
        }
    }
    // 获取到新增人员窗口的实例
    Stage addNewPlayerStage = DataConstans.framesNameMap.get(Constants.ADD_KAIXIAO_FRAME);
    DataConstans.framesNameMap.remove(Constants.ADD_KAIXIAO_FRAME);
    addNewPlayerStage.close();
}
Also used : KaixiaoInfo(com.kendy.entity.KaixiaoInfo) Stage(javafx.stage.Stage) MyController(application.MyController)

Example 4 with MyController

use of application.MyController in project financial by greatkendy123.

the class TGController method refreshTabTGWaizhai.

/**
 * 刷新外债Tab
 * @time 2018年3月8日
 */
public void refreshTabTGWaizhai() {
    TableUtil.clear(tgWZTeam);
    MyController myController = Main.myController;
    TgWaizhaiService.generateWaizhaiTables(tgWZTeam, tgWZTeamHBox, myController.tableCurrentMoneyInfo, myController.tableTeam);
}
Also used : MyController(application.MyController)

Example 5 with MyController

use of application.MyController in project financial by greatkendy123.

the class ShangmaService method refresh_cmiMap_if_null.

/**
 * 重新加载cmiMap如果为空
 * @time 2017年12月4日
 */
public static void refresh_cmiMap_if_null() {
    MyController mc = Main.myController;
    if (mc == null) {
        ErrorUtil.err("获取MyCtroller为空");
        return;
    }
    // 获取最新的实时金额Map {玩家ID={}}
    Map<String, CurrentMoneyInfo> lastCMIMap = new HashMap<>();
    ;
    ObservableList<CurrentMoneyInfo> obList = mc.tableCurrentMoneyInfo.getItems();
    if (obList != null) {
        String pId = "";
        for (CurrentMoneyInfo cmiInfo : obList) {
            pId = cmiInfo.getWanjiaId();
            if (!StringUtil.isBlank(pId)) {
                lastCMIMap.put(pId, cmiInfo);
            }
        }
    }
    ShangmaService.cmiMap = lastCMIMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CurrentMoneyInfo(com.kendy.entity.CurrentMoneyInfo) MyController(application.MyController)

Aggregations

MyController (application.MyController)5 CurrentMoneyInfo (com.kendy.entity.CurrentMoneyInfo)2 ProfitInfo (com.kendy.entity.ProfitInfo)2 TypeReference (com.alibaba.fastjson.TypeReference)1 GDDetailInfo (com.kendy.entity.GDDetailInfo)1 KaixiaoInfo (com.kendy.entity.KaixiaoInfo)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ObservableList (javafx.collections.ObservableList)1 Alert (javafx.scene.control.Alert)1 ButtonType (javafx.scene.control.ButtonType)1 Stage (javafx.stage.Stage)1