use of com.kendy.entity.QuotaMoneyInfo in project financial by greatkendy123.
the class QuotaController method exportClubPayExcel.
/**
********************************************************************************
*
* 导出Excel
*
**********************************************************************************
*/
public void exportClubPayExcel(ActionEvent event) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
// 标题
String title = currentLMLabels.getText() + "俱乐部结账单-" + sdf.format(new Date());
// 列名
String[] rowName = new String[] { "付款方", "收款方", "转账", "支付类型", "联系人", "手机", "银行卡信息" };
;
// 输出
String out = "D:/" + title + System.currentTimeMillis();
// 数据
ObservableList<QuotaMoneyInfo> obList = tableQuotaPay.getItems();
if (CollectUtil.isNullOrEmpty(obList)) {
ShowUtil.show("没有需要导出的数据!");
return;
}
List<Object[]> dataList = new ArrayList<Object[]>();
Object[] objs = null;
String clubId = "";
for (QuotaMoneyInfo info : obList) {
ClubBankModel model = allClubBankModels.get(info.getQuotaMoneyClubId());
objs = new Object[rowName.length];
objs[0] = info.getQuotaMoneyPaytor();
objs[1] = info.getQuotaMoneyGather();
objs[2] = "转" + info.getQuotaMoney() + "到";
objs[3] = model.getMobilePayType();
objs[4] = model.getPersonName();
objs[5] = model.getPhoneNumber();
objs[6] = model.getBankAccountInfo();
dataList.add(objs);
}
ExportQuotaPayExcel excel = new ExportQuotaPayExcel(title, rowName, dataList, out);
try {
excel.export();
log.info("导出单个联盟俱乐部结账单完成!");
} catch (Exception e) {
ErrorUtil.err("导出单个联盟俱乐部结账单失败", e);
}
}
use of com.kendy.entity.QuotaMoneyInfo 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.QuotaMoneyInfo in project financial by greatkendy123.
the class QuotaController method addNegativeRest2CurrentClub.
/**
* 配额最后还有剩余为负数的则全部结转到当前俱乐部
* @time 2017年12月18日
*/
private void addNegativeRest2CurrentClub() {
String currentClubId = MyController.currentClubId.getText();
// Club winnerClub = allClubMap.get("555551");//555551为银河ATM的俱乐部ID
// 555551为银河ATM的俱乐部ID
Club winnerClub = allClubMap.get(currentClubId);
if (winnerClub == null) {
// ErrorUtil.err("当前俱乐部"+currentClubId+"不存在!!!请添加!!");
return;
}
tableQuota.getItems().parallelStream().filter(info -> NumUtil.getNum(info.getQuotaRest()) < 0).forEach(info -> {
String from, to, money = "";
to = winnerClub.getName();
money = NumUtil.digit0((-1) * NumUtil.getNum(info.getQuotaRest()));
from = info.getQuotaClubName();
// log.info(String.format("%s转%s到%s", from,money,to));
addRecord2TableQuotaPay(new QuotaMoneyInfo(winnerClub.getClubId(), from, money, to));
});
tableQuotaPay.refresh();
}
Aggregations