V2EX yuan434356430
yuan434356430

yuan434356430

V2EX 第 428621 号会员,加入于 2019-07-11 14:06:47 +08:00
yuan434356430 最近回复了
2021-11-10 15:50:23 +08:00
回复了 proletarius 创建的主题 程序员 感觉今年代码能力直线提升
最近在看 spring 源码的视频,讲的确实很好
2021-11-10 15:45:56 +08:00
回复了 yuan434356430 创建的主题 程序员 北京 Java3 年开发一般多少钱?
补充一下,toB 的业务,不做互联网
2020-11-05 09:57:14 +08:00
回复了 yuan434356430 创建的主题 程序员 问一下 selemium 的问题
刚刚解决了,可能是焦点的问题,我使用 Java AWT 的 Robot 类的回车就好使;
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
我肯定要使用外部方式排序了,业务需要,存到 Mysql 然后刷到 Redis 缓存,每次都读缓存初始化链
2020-08-27 15:08:19 +08:00
回复了 wuzhouhui 创建的主题 程序员 同事写的注释实在太多余了
我写过的最繁琐的业务逻辑
boolean flag = true;
boolean firstFlag = true;
int alreadyPlusTimes = 0;
//计算差值用
BigDecimal zero = new BigDecimal(0);
//违约金利率
BigDecimal rate = BigDecimal.valueOf(0.0005);
//已理赔的总和
BigDecimal tmpAmount = zero;
BigDecimal surplusClaimAmount = zero;
BigDecimal claimAmount = zero;
BigDecimal claimPenalty = zero;
//总违约金
BigDecimal totalClaimPenalty = zero;
//已偿还的理赔金总和
BigDecimal totalRepayClaimAmount = zero;
String loanNo = "";
int times = 0;
for (WanningClaimDto wanningClaimDto : wanningClaimDtos) {
List<DateAndAmount> dateAndAmounts = transfer(wanningClaimDto.getAmount_array());
//判断是否同一个人的数据,不是同一个人全部重置
if (!loanNo.equals(wanningClaimDto.getLoan_no())) {
surplusClaimAmount = zero;
alreadyPlusTimes = 0;
tmpAmount = zero;
totalClaimPenalty = zero;
totalRepayClaimAmount = zero;
claimPenalty = zero;
flag = true;
firstFlag = true;
claimAmount = dateAndAmounts.get(times).getAmount();
loanNo = wanningClaimDto.getLoan_no();
}
//当次理赔金额
BigDecimal currentClaimAmount = wanningClaimDto.getClaim_amt();
//依次累加的理赔金额
tmpAmount = tmpAmount.add(currentClaimAmount);
//flag = false 代表回款金额用完了
if (flag) {
while (times < dateAndAmounts.size()) {
//如果有多条,依次累加追偿金额和剩余追偿金额
if (times > 0 && alreadyPlusTimes < dateAndAmounts.size() - 1) {
alreadyPlusTimes++;
claimAmount = claimAmount.add(dateAndAmounts.get(alreadyPlusTimes).getAmount());
surplusClaimAmount = surplusClaimAmount.add(dateAndAmounts.get(alreadyPlusTimes).getAmount());
}
//理赔还款日期
Date claimDate = dateAndAmounts.get(alreadyPlusTimes).getDate();
//总追偿 >= 总理赔
if (claimAmount.compareTo(tmpAmount) > -1) {
//追偿还款日期
wanningClaimDto.setClaim_repay_amt(currentClaimAmount);
wanningClaimDto.setClaim_last_repay_date(claimDate);
//如果只有一期完全冲抵才算违约金
if (claimAmount.compareTo(dateAndAmounts.get(alreadyPlusTimes).getAmount()) == 0) {
wanningClaimDto.setClaim_penalty_amt(currentClaimAmount.multiply(new BigDecimal(DateUtils.getDayDiff(claimDate, wanningClaimDto.getRf_date())).multiply(rate)));
}
//剩余追偿金额
surplusClaimAmount = claimAmount.subtract(tmpAmount);
//当期追偿金额不足以抵扣,去加下一次的追偿金额
break;
//总追偿 < 总理赔
} else {
//最后一次进来
if (dateAndAmounts.size() - 1 == times) {
//剩余追偿大于 0
if (surplusClaimAmount.compareTo(zero) == 1) {
wanningClaimDto.setClaim_repay_amt(surplusClaimAmount);
//追偿金额不足时违约金
//理赔 * (还款日期 - 理赔日期) + (理赔 - 已理赔) * (当前日期 - 理赔日期)
//可能发生多次还款,要分别考虑
//总的违约金 = 0
if (totalClaimPenalty.compareTo(zero) == 0) {
claimPenalty = currentClaimAmount.multiply(new BigDecimal(DateUtils.getDayDiff(claimDate, wanningClaimDto.getRf_date()))).multiply(rate);
BigDecimal leftClaimPenalty = currentClaimAmount.subtract(surplusClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(new Date(), dateAndAmounts.get(alreadyPlusTimes).getDate())).multiply(rate));
wanningClaimDto.setClaim_penalty_amt(claimPenalty.add(leftClaimPenalty));
}
//有多次还款 且没有冲抵多期
if (dateAndAmounts.size() > 1 && dateAndAmounts.size() - 1 != times) {
BigDecimal leftClaimPenalty = currentClaimAmount.subtract(surplusClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(new Date(), dateAndAmounts.get(alreadyPlusTimes).getDate())).multiply(rate));
wanningClaimDto.setClaim_penalty_amt(totalClaimPenalty.add(leftClaimPenalty));
}
claimAmount = zero;
surplusClaimAmount = zero;
flag = false;
//理赔还款 < 第一个理赔金额(特殊情况)
} else {
wanningClaimDto.setClaim_repay_amt(dateAndAmounts.get(times).getAmount());
totalRepayClaimAmount = totalRepayClaimAmount.add(dateAndAmounts.get(alreadyPlusTimes).getAmount());
claimPenalty = currentClaimAmount.multiply(new BigDecimal(DateUtils.getDayDiff(claimDate, wanningClaimDto.getRf_date()))).multiply(rate);
BigDecimal leftClaimPenalty = currentClaimAmount.subtract(totalRepayClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(new Date(), dateAndAmounts.get(alreadyPlusTimes).getDate())).multiply(rate));
wanningClaimDto.setClaim_penalty_amt(claimPenalty.add(leftClaimPenalty));
flag = false;
}
//当期理赔金额 > 每次还款的和 (有多次还款对应一期理赔)
} else {
//如果加下期的回款 >= 当期理赔
if (dateAndAmounts.size() - 1 != alreadyPlusTimes && currentClaimAmount.compareTo(surplusClaimAmount.add(dateAndAmounts.get(alreadyPlusTimes + 1).getAmount())) < 1) {
//前一期剩下的钱 * 回款时间 - 理赔时间
claimPenalty = surplusClaimAmount.multiply(new BigDecimal(DateUtils.getDayDiff(dateAndAmounts.get(times + 1).getDate(), claimDate))).multiply(rate);
wanningClaimDto.setClaim_penalty_amt(claimPenalty.add(currentClaimAmount.subtract(surplusClaimAmount).
multiply(new BigDecimal(DateUtils.getDayDiff(claimDate, wanningClaimDto.getRf_date()))).multiply(rate)));
} else {
//总追偿(还款)金额
//未偿还前的违约金,只在开始时执行一次
if (firstFlag || surplusClaimAmount.compareTo(zero) == 1) {
claimPenalty = currentClaimAmount.multiply(new BigDecimal(DateUtils.getDayDiff(claimDate, wanningClaimDto.getRf_date()))).multiply(rate);
}
//当期偿还部分总和
if (firstFlag || surplusClaimAmount.compareTo(zero) == 1) {
totalRepayClaimAmount = totalRepayClaimAmount.add(surplusClaimAmount);
} else {
totalRepayClaimAmount = totalRepayClaimAmount.add(dateAndAmounts.get(times).getAmount());
}
//最后一次进来
BigDecimal leftClaimPenalty;
if (dateAndAmounts.size() - 1 == times) {
leftClaimPenalty = currentClaimAmount.subtract(totalRepayClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(new Date(), wanningClaimDto.getRf_date())).multiply(rate));
//使用最后一期回款金额时进入
} else if (dateAndAmounts.size() - 1 == alreadyPlusTimes) {
leftClaimPenalty = currentClaimAmount.subtract(totalRepayClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(new Date(), dateAndAmounts.get(alreadyPlusTimes).getDate())).multiply(rate));
} else {
leftClaimPenalty = currentClaimAmount.subtract(totalRepayClaimAmount).multiply(new BigDecimal(DateUtils.getDayDiff(dateAndAmounts.get(times + 1).getDate(), dateAndAmounts.get(times).getDate())).multiply(rate));
}
//总违约金 = 分期加和
if (firstFlag | surplusClaimAmount.compareTo(zero) == 1) {
totalClaimPenalty = claimPenalty.add(leftClaimPenalty);
firstFlag = false;
} else {
totalClaimPenalty = totalClaimPenalty.add(leftClaimPenalty);
}
wanningClaimDto.setClaim_penalty_amt(totalClaimPenalty);
}
}
}
times++;
}
times = 0;
}
}
2020-08-27 13:49:20 +08:00
回复了 xmge 创建的主题 程序员 4 千万的数据量, postgre order by 优化。
把 postgre 的并行打开试试会不会变快
2020-07-22 15:20:06 +08:00
回复了 yuan434356430 创建的主题 程序员 求问各位 V 友 PG 库的批量插入问题
领导教我一种方式直接用最朴素的方式,foreach 拼 sql,然后用 pipeline 提交到数据库
关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2584 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 29ms UTC 08:23 PVG 16:23 LAX 00:23 JFK 03:23
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86