Search in sources :

Example 1 with WanjiaApplyInfo

use of com.kendy.spider.WanjiaApplyInfo in project financial by greatkendy123.

the class SMAutoController method startSpiderAction.

/**
 * 开始爬取后台数据
 *
 * @time 2018年3月26日
 * @param evet
 */
public void startSpiderAction(ActionEvent evet) {
    if (this.timer != null) {
        ShowUtil.show("后台程序正在运行!", 1);
        return;
    }
    tokenStatus.setText("正在爬取数据...");
    logInfo("开始爬取程序...");
    this.timer = new Timer();
    timer.schedule(new TimerTask() {

        public void run() {
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    logInfo("正在获取玩家信息..." + TimeUtil.getTimeString());
                    try {
                        // 调用接口
                        List<WanjiaApplyInfo> buyinList = HttpUtil.getBuyinList(getToken());
                        // 处理数据
                        if (buyinList == null) {
                            logInfo("获取到玩家为空!!!");
                        } else {
                            logInfo("获取到玩家个数:" + buyinList.size());
                            // 真正的处理逻辑
                            handleAutoShangma(buyinList);
                        }
                    } catch (Exception e) {
                        logInfo("获取玩家信息请求失败");
                        e.printStackTrace();
                    }
                    logInfo("");
                }
            });
        // logInfo("此处等待10秒...");
        }
    }, 1000, // 定时器的延迟时间及间隔时间
    8000);
}
Also used : WanjiaApplyInfo(com.kendy.spider.WanjiaApplyInfo) Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 2 with WanjiaApplyInfo

use of com.kendy.spider.WanjiaApplyInfo in project financial by greatkendy123.

the class SMAutoController method handleAutoShangma.

/**
 * 处理自动上码的逻辑(核心代码)
 * 备注:申请数量过两道关之后程序会去实时上码Tab中自动上码
 *
 * @time 2018年3月26日
 * @param buyinList
 */
public void handleAutoShangma(List<WanjiaApplyInfo> buyinList) {
    for (WanjiaApplyInfo wanjiaApplyInfo : buyinList) {
        /*
        	 * 玩家相关信息
        	 */
        String paijuStr = wanjiaApplyInfo.getGameRoomName();
        // 本系统桌号
        String paijuString = paijuStr.substring(wanjiaApplyInfo.getGameRoomName().lastIndexOf("-") + 1);
        // 购买数量
        String buyStack = wanjiaApplyInfo.getBuyStack().toString();
        String playerId = wanjiaApplyInfo.getShowId();
        String playerName = wanjiaApplyInfo.getStrNick();
        Player player = DataConstans.membersMap.get(playerId);
        if (player == null) {
            logInfo("玩家(" + playerName + ")未录入到系统中!!!");
            continue;
        }
        String teamId = player.getTeamName();
        Huishui huishui = DataConstans.huishuiMap.get(teamId);
        // 是否勾选了团队上码:1是  0否
        String selectTeamAvailabel = huishui.getTeamAvailabel();
        logInfo(playerName + "正在模拟更新实时上码...");
        // 模拟更新实时上码
        SMResultModel resultModel = ShangmaService.getDataAfterloadShangmaTable(teamId, playerId);
        ShangmaInfo selectedSMInfo = resultModel.getSelectedSMInfo();
        if (selectedSMInfo == null) {
            logInfo("玩家(" + playerName + ")在上码系统中不存在!!");
            continue;
        }
        // 获取团队可上码
        String teamAvailabel = resultModel.getTeamTotalAvailabel();
        // 获取可上码
        String calcAvailable = getAvailable(resultModel, selectTeamAvailabel, playerId, playerName);
        // 是否为次日上码:
        boolean isTodaySM = judgeIsTodaySM(paijuString);
        // 是否同意
        boolean passCheck = checkInRange(selectTeamAvailabel, buyStack, teamAvailabel, calcAvailable);
        /**
         *************************************
         */
        List<String> testList = new ArrayList<>();
        boolean addOK = false;
        if (hasFilterPlayerIds())
            testList = Arrays.stream(filterPlayIdFields.getText().trim().split("##")).collect(Collectors.toList());
        if (CollectUtil.isNullOrEmpty(testList) || testList.contains(playerId)) {
            // 添加上码到软件中,同时发送后台请求
            // 用户ID
            Long userUuid = wanjiaApplyInfo.getUuid();
            // 房间号
            Long roomId = wanjiaApplyInfo.getGameRoomId();
            addOK = addShangma(resultModel, isTodaySM, passCheck, playerId, playerName, paijuString, buyStack, userUuid, roomId);
        }
        /**
         *************************************
         */
        SMAutoInfo smAutoInfo = new SMAutoInfo(getTimeString(), playerId, playerName, paijuString, buyStack, // 团队可上码 (第一关)
        teamAvailabel, // 计算可上码(第二关)
        calcAvailable, // smAutoIsCurrentDay
        "1".equals(selectTeamAvailabel) ? "是" : "否", // smAutoIsCurrentDay
        isTodaySM ? "是" : "否", // smAutoIsNextDay
        isTodaySM ? "否" : "是", // smAutoIsAgree
        passCheck ? "是" : "否", // smAutoIsAgreeSuccess
        (passCheck) ? (addOK ? "成功" : "失败") : "-");
        addItem(smAutoInfo);
    }
}
Also used : Huishui(com.kendy.entity.Huishui) ShangmaInfo(com.kendy.entity.ShangmaInfo) WanjiaApplyInfo(com.kendy.spider.WanjiaApplyInfo) Player(com.kendy.entity.Player) SMResultModel(com.kendy.model.SMResultModel) ArrayList(java.util.ArrayList) SMAutoInfo(com.kendy.entity.SMAutoInfo)

Aggregations

WanjiaApplyInfo (com.kendy.spider.WanjiaApplyInfo)2 Huishui (com.kendy.entity.Huishui)1 Player (com.kendy.entity.Player)1 SMAutoInfo (com.kendy.entity.SMAutoInfo)1 ShangmaInfo (com.kendy.entity.ShangmaInfo)1 SMResultModel (com.kendy.model.SMResultModel)1 ArrayList (java.util.ArrayList)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1