use of com.kendy.entity.ClubQuota in project financial by greatkendy123.
the class LMController method get_LM_club_info.
public Map<String, ClubQuota> get_LM_club_info() {
// {俱乐部ID : 俱乐部配额信息}
Map<String, ClubQuota> single_LM_map = new HashMap<>();
// {联盟Index : {俱乐部ID : 俱乐部配额信息}}
// Map<String,Map<String,List<ClubQuota>>> totalMap = new HashMap<>();
int lmType = getCurrentLMType() - 1;
// 遍历这三个
Map<String, List<Record>> current_LM_Map = LMTotalList.get(lmType);
Map<String, List<LMSumInfo>> allClubSumMap = getAllClubSumMap(current_LM_Map);
allClubSumMap.forEach((clubId, sumList) -> {
Club club = allClubMap.get(clubId);
String sumZJ = getSumZJ(sumList);
String yiJieshan = get_LM_YiJiesuan(club, lmType);
String zhuoFei = get_LM_Zhuofei(club, lmType);
String jieyu = NumUtil.digit0(NumUtil.getNum(sumZJ) + NumUtil.getNum(yiJieshan) + NumUtil.getNum(zhuoFei));
List<ClubQuota> list = new ArrayList<>();
ClubQuota quota = new ClubQuota();
quota.setEuotaClubId(clubId);
quota.setQuotaClubName(club.getName());
quota.setQuotaJieyu(jieyu);
quota.setQuotaRest(jieyu);
single_LM_map.put(clubId, quota);
});
return single_LM_map;
}
use of com.kendy.entity.ClubQuota in project financial by greatkendy123.
the class QuotaController method autoQuota.
/**
* 联盟自动配额
* 这是本控制类最核心的代码
* 算法:找剩余值中的两个最大最小值进行一方清零,不断循环
*
* @time 2017年12月18日
*/
public void autoQuota() {
if (TableUtil.isNullOrEmpty(tableQuota))
return;
boolean isDone = false;
int count = 0;
while (!isDone) {
count++;
ClubQuota row1 = getRecord(1);
ClubQuota row2 = getRecord(0);
// log.info(String.format("最大值:%s::%s", row1.getQuotaClubName(),row1.getQuotaRest()));
// log.info(String.format("最小值:%s::%s", row2.getQuotaClubName(),row2.getQuotaRest()));
Double first = NumUtil.getNum(row1.getQuotaRest());
Double second = NumUtil.getNum(row2.getQuotaRest());
if (first * second >= 0) {
isDone = true;
log.info("=====================联盟配额结束!count:" + (count - 1));
break;
}
// 转换(row1永远是绝对值的大数,row2是绝对值的小数 )
if (Double.compare(first, second) > 0) {
if (Double.compare(Math.abs(first), Math.abs(second)) < 0) {
ClubQuota tempRow;
tempRow = row1;
row1 = row2;
row2 = tempRow;
Double tempVal;
tempVal = first;
first = second;
second = tempVal;
// log.info(String.format("转换最大值:%s::%s", row1.getQuotaClubName(),row1.getQuotaRest()));
// log.info(String.format("转换最小值:%s::%s", row2.getQuotaClubName(),row2.getQuotaRest()));
}
}
// 绝对值大数行设值
if (StringUtil.isBlank(row1.getQuotaHedgeFirst())) {
row1.setQuotaHedgeFirst(row2.getQuotaRest());
} else if (StringUtil.isBlank(row1.getQuotaHedgeSecond())) {
row1.setQuotaHedgeSecond(row2.getQuotaRest());
} else if (StringUtil.isBlank(row1.getQuotaHedgeThree())) {
row1.setQuotaHedgeThree(row2.getQuotaRest());
} else if (StringUtil.isBlank(row1.getQuotaHedgeFour())) {
row1.setQuotaHedgeFour(row2.getQuotaRest());
} else if (StringUtil.isBlank(row1.getQuotaHedgeFive())) {
row1.setQuotaHedgeFive(row2.getQuotaRest());
}
row1.setQuotaRest(NumUtil.digit0(first + second));
// 绝对值小数行设值
String small = NumUtil.digit0(second * (-1));
if (StringUtil.isBlank(row2.getQuotaHedgeFirst())) {
row2.setQuotaHedgeFirst(small);
} else if (StringUtil.isBlank(row2.getQuotaHedgeSecond())) {
row2.setQuotaHedgeSecond(small);
} else if (StringUtil.isBlank(row2.getQuotaHedgeThree())) {
row2.setQuotaHedgeThree(small);
} else if (StringUtil.isBlank(row2.getQuotaHedgeFour())) {
row2.setQuotaHedgeFour(small);
} else if (StringUtil.isBlank(row2.getQuotaHedgeFive())) {
row2.setQuotaHedgeFive(small);
}
row2.setQuotaRest("0");
// 以下做其他逻辑
// 输出钱由输者转给赢者
String from, to, money = "";
ClubQuota winner;
if (small.contains("-")) {
from = row1.getQuotaClubName();
to = row2.getQuotaClubName();
money = Integer.valueOf(small.replace("-", "")).toString();
winner = row2;
} else {
from = row2.getQuotaClubName();
to = row1.getQuotaClubName();
money = small;
winner = row1;
}
log.info(String.format("%s转%s到%s", from, money, to));
addRecord2TableQuotaPay(new QuotaMoneyInfo(winner.getQuotaClubId(), from, money, to));
}
tableQuotaPay.refresh();
tableQuota.refresh();
// 配额最后还有剩余为负数的则全部结转到当前俱乐部
addNegativeRest2CurrentClub();
}
use of com.kendy.entity.ClubQuota in project financial by greatkendy123.
the class QuotaController method set_LM_club_info.
/**
* 设置单个联盟最新的结余
*
* @time 2017年12月18日
*/
public void set_LM_club_info() {
try {
if (LMTotalList.isEmpty()) {
return;
}
// {俱乐部ID : 俱乐部配额信息}
Map<String, ClubQuota> _single_LM_map = new HashMap<>();
// {联盟Index : {俱乐部ID : 俱乐部配额信息}} //后期如果性能慢的话,可以修改为这定个
// Map<String,Map<String,List<ClubQuota>>> totalMap = new HashMap<>();
int lmType = getCurrentLMType() - 1;
// 遍历这三个
Map<String, List<Record>> current_LM_Map = LMTotalList.get(lmType);
// LMController lmController= new LMController();
Map<String, List<LMSumInfo>> allClubSumMap = lmController.getAllClubSumMap(current_LM_Map);
allClubSumMap.forEach((clubId, sumList) -> {
Club club = allClubMap.get(clubId);
String sumZJ = getSumZJ(sumList);
String yiJieshan = lmController.get_LM_YiJiesuan(club, getCurrentLMType());
String zhuoFei = lmController.get_LM_Zhuofei(club, getCurrentLMType());
String jieyu = NumUtil.digit0(NumUtil.getNum(sumZJ) + NumUtil.getNum(yiJieshan) + NumUtil.getNum(zhuoFei));
// System.out.println(String.format("俱乐部:%s,总战绩:%s,桌费:%s,已结算:%s,===结余:%s",
// allClubMap.get(clubId).getName(),sumZJ,zhuoFei,yiJieshan,jieyu
// ));
List<ClubQuota> list = new ArrayList<>();
ClubQuota quota = new ClubQuota();
quota.setEuotaClubId(clubId);
quota.setQuotaClubName(club.getName());
quota.setQuotaJieyu(jieyu);
quota.setQuotaRest(jieyu);
_single_LM_map.put(clubId, quota);
});
single_LM_map.clear();
single_LM_map = _single_LM_map;
} catch (Exception e) {
ErrorUtil.err("设置单个联盟最新的结余出错,建议重启软件!", e);
}
}
Aggregations