use of com.kendy.entity.ShangmaInfo in project financial by greatkendy123.
the class ShangmaService method render_Shangma_info_talbe_0.
/**
* 添加合并ID
* @param srcList
* @throws Exception
*/
public static void render_Shangma_info_talbe_0() throws Exception {
LinkedList<ShangmaInfo> srcList = new LinkedList<>();
if (tableSM == null || tableSM.getItems() == null || tableSM.getItems().size() == 0) {
return;
} else {
for (ShangmaInfo info : tableSM.getItems()) srcList.add(info);
}
srcList = getCombineSMDataList(srcList);
// 更新
ObservableList<ShangmaInfo> obList = FXCollections.observableArrayList();
for (ShangmaInfo cmi : srcList) {
obList.add(cmi);
}
tableSM.setItems(obList);
tableSM.refresh();
}
use of com.kendy.entity.ShangmaInfo in project financial by greatkendy123.
the class ShangmaService method getNextSelectedPlayer.
/**
* 根据玩家名称获取对应的玩家ID
* @param searchText
* @return
*/
public static Player getNextSelectedPlayer(String searchText) {
TableView<ShangmaInfo> table = tableSM;
if (!StringUtil.isBlank(searchText)) {
if (table == null || table.getItems() == null) {
return null;
}
Player p;
String pId = "";
ShangmaInfo selectedInfo = table.getSelectionModel().getSelectedItem();
if (selectedInfo != null) {
pId = selectedInfo.getShangmaPlayerId();
}
List<String> idList = new LinkedList<>();
final Map<String, Player> tempMap = new LinkedHashMap<>();
DataConstans.membersMap.forEach((playerId, player) -> {
tempMap.put(playerId, player);
});
for (Map.Entry<String, Player> entry : tempMap.entrySet()) {
p = entry.getValue();
if (!StringUtil.isBlank(p.getPlayerName()) && (p.getPlayerName().contains(searchText) || p.getPlayerName().toLowerCase().contains(searchText.toLowerCase()) || p.getPlayerName().toUpperCase().contains(searchText.toUpperCase()) || p.getgameId().contains(searchText))) {
idList.add(entry.getKey());
}
}
int size = idList.size();
// 返回排序序号
if (size == 0) {
return null;
} else if (size == 1) {
return tempMap.get(idList.get(0));
} else {
if (idList.contains(pId)) {
int i = idList.indexOf(pId);
if (i == (size - 1)) {
// 返回第一个
return tempMap.get(idList.get(0));
} else {
// 返回下一个
return tempMap.get(idList.get(i + 1));
}
} else {
// 返回第一个
return tempMap.get(idList.get(0));
}
}
}
return null;
}
use of com.kendy.entity.ShangmaInfo in project financial by greatkendy123.
the class ShangmaService method getCombineSMDataList.
/**
* 添加合并ID
* @param srcList
* @throws Exception
*/
public static LinkedList<ShangmaInfo> getCombineSMDataList(List<ShangmaInfo> list) throws Exception {
LinkedList<ShangmaInfo> srcList = new LinkedList<>();
for (ShangmaInfo info : list) srcList.add(info);
// 组装数据为空
// 对组装的数据列表进行处理,空行直接删除,父ID删除,子ID删除后缓存
ListIterator<ShangmaInfo> it = srcList.listIterator();
// 存放父ID那条记录的信息
Map<String, ShangmaInfo> superIdInfoMap = new HashMap<>();
// 存放父ID下的所有子记录信息
Map<String, List<ShangmaInfo>> superIdSubListMap = new HashMap<>();
String playerId = "";
while (it.hasNext()) {
ShangmaInfo item = it.next();
// 删除空行
if (item == null || StringUtil.isBlank(item.getShangmaPlayerId())) {
// 没有玩家ID的就是空行
it.remove();
continue;
}
// 删除父ID
playerId = item.getShangmaPlayerId();
if (DataConstans.Combine_Super_Id_Map.get(playerId) != null) {
superIdInfoMap.put(playerId, item);
it.remove();
continue;
}
// 删除子ID
if (DataConstans.Combine_Sub_Id_Map.get(playerId) != null) {
// 是子ID节点
String parentID = DataConstans.Combine_Sub_Id_Map.get(playerId);
List<ShangmaInfo> childList = superIdSubListMap.get(parentID);
if (childList == null) {
childList = new ArrayList<>();
}
childList.add(item);
superIdSubListMap.put(parentID, childList);
it.remove();
continue;
}
}
// 添加子ID不在表中的父ID记录(单条父记录)
superIdInfoMap.forEach((superId, info) -> {
if (!superIdSubListMap.containsKey(superId)) {
// 添加父记录
srcList.add(info);
}
});
// 添加父ID不在表中的子ID记录
Iterator<Entry<String, List<ShangmaInfo>>> ite = superIdSubListMap.entrySet().iterator();
while (ite.hasNext()) {
Entry<String, List<ShangmaInfo>> entry = ite.next();
String superId = entry.getKey();
ShangmaInfo superInfo = superIdInfoMap.get(superId);
if (superInfo == null) {
for (ShangmaInfo info : entry.getValue()) {
// 添加子记录
srcList.add(info);
}
// 删除
ite.remove();
}
}
// 计算总和并填充父子节点和空行
String superId = "";
// 空开一行
srcList.add(new ShangmaInfo());
for (Map.Entry<String, List<ShangmaInfo>> entry : superIdSubListMap.entrySet()) {
superId = entry.getKey();
ShangmaInfo superInfo = superIdInfoMap.get(superId);
if (superInfo == null) {
// 原因,可能该玩家没有ID值
throw new Exception("该父ID与子ID不在同一个团队内:" + superId);
}
// 计算父节点总和
List<ShangmaInfo> subInfoList = entry.getValue();
// 合并ID的联合额度
Double lianheEdu = 0d;
// 合并ID的已存积分
Double sumOfYicunJifen = 0d;
// 合并ID的总已上码
Double sumOfYiSM = 0d;
// 合并ID的总战绩
Double sumOfZZJ = 0d;
// 合并ID的总战绩(忆剔除支付后的战绩)
Double sumOfZZJ_hasPayed = 0d;
for (ShangmaInfo info : subInfoList) {
sumOfYicunJifen += NumUtil.getNum(info.getShangmaYCJF());
sumOfYiSM += NumUtil.getNum(info.getShangmaYiSM());
sumOfZZJ += NumUtil.getNum(info.getShangmaSumOfZJ());
// add
Double[] subIdSingleSum = getSumDetail(info.getShangmaPlayerId(), info.getShangmaEdu(), info.getShangmaYCJF());
sumOfZZJ_hasPayed += NumUtil.getNum(NumUtil.digit0(subIdSingleSum[3]));
}
sumOfYicunJifen += NumUtil.getNum(superInfo.getShangmaYCJF());
sumOfYiSM += NumUtil.getNum(superInfo.getShangmaYiSM());
sumOfZZJ += NumUtil.getNum(superInfo.getShangmaSumOfZJ());
//
Double[] subIdSingleSum = getSumDetail(superInfo.getShangmaPlayerId(), superInfo.getShangmaEdu(), superInfo.getShangmaYCJF());
sumOfZZJ_hasPayed += NumUtil.getNum(NumUtil.digit0(subIdSingleSum[3]));
// 计算父节点的联合ID
// lianheEdu = NumUtil.getNum(superInfo.getShangmaEdu()) + sumOfYicunJifen + sumOfZZJ - sumOfYiSM;
lianheEdu = NumUtil.getNum(superInfo.getShangmaEdu()) + sumOfYicunJifen + sumOfZZJ_hasPayed - sumOfYiSM;
superInfo.setShangmaLianheEdu(NumUtil.digit0(lianheEdu));
// 添加空行和子节点
// srcList.add(new CurrentMoneyInfo());
// 先添加父节点
srcList.add(superInfo);
for (ShangmaInfo info : subInfoList) {
// 再添加子节点
srcList.add(info);
}
// 空开一行
srcList.add(new ShangmaInfo());
}
return srcList;
}
Aggregations