use of com.kendy.entity.UserInfos in project financial by greatkendy123.
the class MoneyService method fillTablerAfterImportZJ.
/**
* 导入战绩成功后
* 自动填充玩家信息表、牌局表、团队表以及当局
* 备注:这些表数据在当局范围内是固定不变的
*
* @param table 玩家信息表
* @param tablePaiju 牌局表
* @param userInfoList 导入的玩家战绩列表
*/
public static void fillTablerAfterImportZJ(TableView<TotalInfo> table, TableView<WanjiaInfo> tablePaiju, TableView<DangjuInfo> tableDangju, TableView<JiaoshouInfo> tableJiaoshou, TableView<TeamInfo> tableTeam, List<UserInfos> userInfoList, String tableId) {
// 1清空 表数据
table.setItems(null);
// 2获取InfoList
ObservableList<TotalInfo> tableTotalInfoList = FXCollections.observableArrayList();
ObservableList<WanjiaInfo> tableWanjiaInfoList = FXCollections.observableArrayList();
TotalInfo info = null;
Player player;
WanjiaInfo wanjia;
// 用于缓存和计算团累计团队回水
List<TeamHuishuiInfo> teamHuishuiList = null;
// 用于只展示本次战绩的团队信息
Set<String> relatedTeamIdSet = new HashSet<>();
// 每次导入都去初始化当局团队战绩信息
DataConstans.Dangju_Team_Huishui_List = new LinkedList<>();
for (UserInfos zj : userInfoList) {
/**
************************************************* 填充信息表 ****************
*/
info = new TotalInfo();
// 团 ID 玩家 计分 实收 保险
String playerId = zj.getPlayerId();
player = DataConstans.membersMap.get(playerId);
String teamId = "";
if (player != null) {
teamId = player.getTeamName();
teamId = StringUtil.isBlank(teamId) ? "" : teamId.toUpperCase();
} else // add 2017-10-26
{
Player tempPlayer = DBUtil.getMemberById(playerId);
if (tempPlayer != null && !StringUtil.isBlank(tempPlayer.getTeamName())) {
DataConstans.membersMap.put(playerId, tempPlayer);
teamId = tempPlayer.getTeamName();
teamId = StringUtil.isBlank(teamId) ? "" : teamId.toUpperCase();
}
}
String name = zj.getPlayerName();
String baoxian = zj.getinsurance();
String shishou = getShiShou(zj.getZj());
String chuHuishui = digit1(getChuhuishui(zj.getZj(), teamId));
String shuihouxian = digit1((-1) * Double.valueOf(zj.getinsurance()) * 0.975 + "");
String shouHuishui = digit1(Math.abs(Double.valueOf(zj.getZj())) * 0.025 + "");
String baohui = digit1(getHuiBao(baoxian, teamId));
String heLirun = digit2(getHeLirun(shouHuishui, chuHuishui, shuihouxian, baohui));
// 团(团ID)
info.setTuan(teamId);
// ID
info.setWanjiaId(playerId);
// 玩家
info.setWanjia(name);
// 计分
// ?计分 = 战绩?
info.setJifen(zj.getZj());
// 实收
info.setShishou(shishou);
// 保险
info.setBaoxian(baoxian);
// 出回水
info.setChuHuishui(chuHuishui);
// 保回
info.setBaohui(baohui);
// 水后险
info.setShuihouxian(shuihouxian);
// 收回水
info.setShouHuishui(shouHuishui);
// 合利润
info.setHeLirun(heLirun);
tableTotalInfoList.add(info);
/**
************************************************* 填充牌局表 ****************
*/
wanjia = new WanjiaInfo();
String yicunJifen = getYicunJifen(zj.getPlayerId());
String heji = digit0(getNum(yicunJifen) + getNum(shishou) + "");
wanjia.setPaiju("第" + tableId + "局");
wanjia.setWanjiaName(zj.getPlayerName());
wanjia.setYicunJifen(yicunJifen);
wanjia.setZhangji(shishou);
wanjia.setHeji(heji);
wanjia.setWanjiaId(playerId);
/**
************************************************* 缓存各团队回水记录 ****************
*/
teamId = teamId.toUpperCase();
// if(!StringUtil.isBlank(teamId) && !"公司".equals(teamId)) {
if (!StringUtil.isBlank(teamId)) {
// 缓存到当局团队战绩信息中
TeamHuishuiInfo teamHuishuiInfo = new TeamHuishuiInfo(teamId, playerId, name, shishou, baoxian, chuHuishui, "第" + tableId + "局", zj.getZj(), baohui, shouHuishui, zj.getDay());
DataConstans.Dangju_Team_Huishui_List.add(teamHuishuiInfo);
if (!"公司".equals(teamId)) {
relatedTeamIdSet.add(teamId);
}
// 缓存到总团队回水中(结算按钮后从中减少)
teamHuishuiList = DataConstans.Team_Huishui_Map.get(teamId);
if (teamHuishuiList == null) {
teamHuishuiList = new ArrayList<>();
}
teamHuishuiList.add(teamHuishuiInfo);
DataConstans.Team_Huishui_Map.put(teamId, teamHuishuiList);
// //缓存到总团队回水中(不会从中减少)
// teamHuishuiList = DataConstans.Total_Team_Huishui_Map.get(teamId);
// if( teamHuishuiList == null ) {
// teamHuishuiList = new ArrayList<>();
// }
// teamHuishuiList.add(
// new TeamHuishuiInfo(teamId,playerId,name,shishou,baoxian,chuHuishui,"第"+tableId+"局")
// );
// DataConstans.Total_Team_Huishui_Map.put(teamId,teamHuishuiList);
} else {
log.warn("检测到团队ID是空或为公司,玩家是:" + name);
}
// 是否显示支付按钮
wanjia.setHasPayed(relatedTeamIdSet.contains(teamId) ? teamId : "");
tableWanjiaInfoList.add(wanjia);
}
// 3填充
table.setItems(tableTotalInfoList);
table.refresh();
// tablePaiju.setItems(tableWanjiaInfoList);
// 添加需要支付的按钮靠前排
fillTablePaiju(tablePaiju, tableWanjiaInfoList);
// 缓存当局固定总和
DataConstans.SumMap.putAll(getSums(tableTotalInfoList));
// 填充当局表和交收表
initTableDangjuAndTableJiaoshou(tableDangju, tableJiaoshou);
// 填充团队表
fillTableTeam(tableTeam, relatedTeamIdSet);
// 更新实时上码表的个人详情
ShangmaService.updateShangDetailMap(tablePaiju);
}
use of com.kendy.entity.UserInfos in project financial by greatkendy123.
the class MyController method importZJExcelAction.
/**
* 导入战绩文件
*/
public void importZJExcelAction(ActionEvent even) {
String zjFilePath = excelDir.getText();
if (!StringUtil.isBlank(zjFilePath)) {
String tableId = zjFilePath.substring(zjFilePath.lastIndexOf("-") + 1, zjFilePath.lastIndexOf("."));
if (!NumUtil.isNumeric(tableId)) {
ErrorUtil.err(zjFilePath + "不是一个合法的Excel文件名称,请检查!");
return;
}
if (hbox_autoTestMode.isVisible()) {
final_selected_LM_type = "联盟1";
selected_LM_type = "联盟1";
} else {
selectLM();
if (StringUtil.isBlank(selected_LM_type)) {
String msg = "导入战绩时没有选择对应的联盟,场次:" + tableId + " Excel不准导入!";
ShowUtil.show(msg);
log.warn(msg);
return;
}
}
// 将人员名单文件缓存起来
Wrap wrap = ExcelReaderUtil.readZJRecord(new File(zjFilePath), lable_currentClubId.getText(), selected_LM_type, getVersionType());
dateLabel.setText(DataConstans.Date_Str);
if (wrap.resultSuccess) {
indexLabel.setText("第" + tableId + "局");
// //1 填充总信息表
// MoneyService.fillTablerAfterImportZJ(tableTotalInfo, tablePaiju,tableDangju,tableJiaoshou,tableTeam,(List<UserInfos>)wrap.obj,tableId);
// //2填充当局表和交收表和团队表的总和
// MoneyService.setTotalNumOnTable(tableDangju, DataConstans.SumMap.get("当局"));
// MoneyService.setTotalNumOnTable(tableJiaoshou, DataConstans.SumMap.get("交收"));
// tableTeam.getColumns().get(4).setText(MoneyService.digit0(DataConstans.SumMap.get("团队回水及保险总和")));
importExcelData(tableId, (List<UserInfos>) wrap.obj);
// 导入不可用
importZJBtn.setDisable(true);
ShowUtil.show("导入战绩文件成功", 2);
} else {
ShowUtil.show("导入失败!!!原因:" + wrap.obj, 2);
}
}
}
use of com.kendy.entity.UserInfos in project financial by greatkendy123.
the class ExcelReaderUtil method readZJRecord_NewVersion.
/**
* 导入战绩Excel
*
* 两个功能:
* A:导入到场次信息
* B:导入到联盟Tab
*
* @param file 文件夹
* @return
*/
public static Wrap readZJRecord_NewVersion(File file, String userClubId, String LMType) {
// 新增了联盟类型
List<UserInfos> userInfoList = new LinkedList<>();
UserInfos info = null;
FileInputStream is = null;
// 是否已经判断过为空 波哥要求添加
boolean isHasJudged = false;
try {
// 桌号
String name = file.getName();
String tableId = name.substring(name.lastIndexOf("-") + 1, name.lastIndexOf("."));
tableId = "第" + tableId + "局";
if (StringUtil.isBlank(userClubId) || DataConstans.Index_Table_Id_Map.containsValue(tableId)) {
return new Wrap(false, "该战绩表(" + tableId + "场次)已经导过");
}
log.info("开始----------导入战绩Excel");
userInfoList = new LinkedList<>();
is = new FileInputStream(file);
// 获取excel sheet
Workbook workbook = (XSSFWorkbook) getWeebWork(file.getAbsolutePath());
XSSFSheet sheet = (XSSFSheet) workbook.getSheetAt(0);
// 若无数据,要提示
int rowNum = sheet.getLastRowNum();
if (rowNum == 0 && !isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
// 开始遍历Excel行数据
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
XSSFRow row = (XSSFRow) rowIterator.next();
// add 总手数为空的提示
// Cell ZSScell = row.getCell(6);
XSSFCell ZSScell = row.getCell(7);
if (ZSScell == null) {
continue;
}
// 总手数
String totalHandCount = ZSScell.toString();
Integer _tempCount = 0;
if (!"总手数".equals(totalHandCount)) {
try {
_tempCount = Integer.valueOf(totalHandCount);
if (_tempCount == 0) {
if (!isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
}
} catch (Exception e) {
_tempCount = 1;
}
}
info = new UserInfos();
// 排除第一行以及俱乐部ID不匹配的情况
// String clubID = row.getCell(9).toString();
String clubID = row.getCell(10).toString();
if (row.getRowNum() != 0 && userClubId.equals(row.getCell(10).toString())) {
// 对于符合条件的进行存储
// int[] clumns = new int[]{6,7,8,9, 10,15,17,18,19};
int[] clumns = new int[] { 7, 8, 9, 10, 11, 16, 18, 19, 20 };
for (int cn : clumns) {
XSSFCell cell = row.getCell(cn);
if (cell == null) {
log.error("出现空值,导入战绩文件夹失败" + "\t");
return new Wrap();
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String value = cell.getStringCellValue();
value = StringUtil.isBlank(value) ? "" : value.trim();
switch(cn) {
case // add 总手数(只判断不导入)
7:
if ((StringUtil.isBlank(value) || "0".equals(value)) && !isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
break;
case 8:
info.setPlayerId(value);
break;
case 9:
info.setPlayerName(value);
break;
case 10:
info.setClubId(value);
break;
case 11:
info.setClubName(value);
break;
case 16:
info.setInsurance(value);
break;
case 19:
info.setZj(value);
break;
case 20:
{
String dateStr = value.split(" ")[0];
info.setDay(value);
// add 导入的第一局作为当天的时间
if (StringUtil.isBlank(DataConstans.Date_Str)) {
DataConstans.Date_Str = dateStr;
} else {
try {
if (sdf.parse(dateStr).before(sdf.parse(DataConstans.Date_Str))) {
DataConstans.Date_Str = dateStr;
}
} catch (Exception e) {
}
}
break;
}
default:
break;
}
}
info.setTableId(tableId);
userInfoList.add(info);
}
}
// 遍历excel结束
// 存储数据 {场次=infoList...}
DataConstans.zjMap.put(tableId, userInfoList);
is.close();
// add 添加所有记录到联盟对帐表
LMController.currentRecordList = LM_ExcelReaderUtil.readRecord_NewVersion(file);
// LMController.refreshClubList();//放到锁定时去添加
// LMController.checkOverEdu();
log.info("结束----------导入战绩Excel" + " ===size:" + userInfoList.size());
} catch (Exception e) {
e.printStackTrace();
return new Wrap();
}
return new Wrap(true, userInfoList);
}
use of com.kendy.entity.UserInfos in project financial by greatkendy123.
the class ExcelReaderUtil method readZJRecord_OldVersion.
/**
* 导入战绩Excel
*
* 两个功能:
* A:导入到场次信息
* B:导入到联盟Tab
*
* @param file 文件夹
* @return
*/
public static Wrap readZJRecord_OldVersion(File file, String userClubId, String LMType) {
// 新增了联盟类型
List<UserInfos> userInfoList = new LinkedList<>();
UserInfos info = null;
FileInputStream is = null;
// 是否已经判断过为空 波哥要求添加
boolean isHasJudged = false;
try {
// 桌号
String name = file.getName();
String tableId = name.substring(name.lastIndexOf("-") + 1, name.lastIndexOf("."));
tableId = "第" + tableId + "局";
if (StringUtil.isBlank(userClubId) || DataConstans.Index_Table_Id_Map.containsValue(tableId)) {
return new Wrap(false, "该战绩表(" + tableId + "场次)已经导过");
}
log.info("开始----------导入战绩Excel");
userInfoList = new LinkedList<>();
is = new FileInputStream(file);
// 获取excel sheet
Workbook workbook = getWeebWork(file.getAbsolutePath());
Sheet sheet = workbook.getSheetAt(0);
// 若无数据,要提示
int rowNum = sheet.getLastRowNum();
if (rowNum == 0 && !isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
// 开始遍历Excel行数据
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
// add 总手数为空的提示
Cell ZSScell = row.getCell(6);
if (ZSScell == null) {
break;
}
// 总手数
String totalHandCount = ZSScell.toString();
Integer _tempCount = 0;
if (!"总手数".equals(totalHandCount)) {
try {
_tempCount = Integer.valueOf(totalHandCount);
if (_tempCount == 0) {
if (!isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
}
} catch (Exception e) {
_tempCount = 1;
}
}
info = new UserInfos();
// 排除第一行以及俱乐部ID不匹配的情况
String clubID = row.getCell(9).toString();
if (row.getRowNum() != 0 && userClubId.equals(row.getCell(9).toString())) {
// 对于符合条件的进行存储
int[] clumns = new int[] { 6, 7, 8, 9, 10, 15, 17, 18, 19 };
for (int cn : clumns) {
Cell cell = row.getCell(cn);
if (cell == null) {
log.error("出现空值,导入战绩文件夹失败" + "\t");
return new Wrap();
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String value = cell.getStringCellValue();
value = StringUtil.isBlank(value) ? "" : value.trim();
switch(cn) {
case // add 总手数(只判断不导入)
6:
if ((StringUtil.isBlank(value) || "0".equals(value)) && !isHasJudged) {
isHasJudged = true;
ShowUtil.show("提示:总手数为0!");
}
break;
case 7:
info.setPlayerId(value);
break;
case 8:
info.setPlayerName(value);
break;
case 9:
info.setClubId(value);
break;
case 10:
info.setClubName(value);
break;
case 15:
info.setInsurance(value);
break;
case 18:
info.setZj(value);
break;
case 19:
{
String dateStr = value.split(" ")[0];
info.setDay(value);
// add 导入的第一局作为当天的时间
if (StringUtil.isBlank(DataConstans.Date_Str)) {
DataConstans.Date_Str = dateStr;
} else {
try {
if (sdf.parse(dateStr).before(sdf.parse(DataConstans.Date_Str))) {
DataConstans.Date_Str = dateStr;
}
} catch (Exception e) {
}
}
break;
}
default:
break;
}
}
info.setTableId(tableId);
userInfoList.add(info);
}
}
// 遍历excel结束
// 存储数据 {场次=infoList...}
DataConstans.zjMap.put(tableId, userInfoList);
is.close();
// add 添加所有记录到联盟对帐表
LMController.currentRecordList = LM_ExcelReaderUtil.readRecord(file);
// LMController.refreshClubList();//放到锁定时去添加
// LMController.checkOverEdu();
log.info("结束----------导入战绩Excel" + " ===size:" + userInfoList.size());
} catch (Exception e) {
e.printStackTrace();
return new Wrap();
}
return new Wrap(true, userInfoList);
}
Aggregations