发表于: 2017-10-28 23:35:48
0 838
今天完成的事情:
1.债权管理模块的动态查询以及债务详情和新增接口
这个动态查询是整个项目里查询条件最多的一个接口,和之前的比起来就是多了些参数,没什么难度。先动态拼接sql,在根据条件查询,第三步需要计算一下每个债务的带匹配金额来显示该债务的匹配完成度,最后一步输出页面信息,这些都还好,接下来的债权匹配接口就比较麻烦了,没写完就不贴上来了。
/**
* 债权列表
*
* @param request
* @param response
* @param model
* @param creditorName
* @param amount
* @param minBeginAt
* @param maxBeginAt
* @param monthLimit
* @param status
* @param code
* @return
*/
@RequestMapping(value = "/a/u/credit/condition/search", method = RequestMethod.GET)
public String getCreditList(HttpServletRequest request, HttpServletResponse response,
ModelMap model, Integer page, Integer size, String creditorName,
String creditorIdno, String creditorMobile, BigDecimal minAmount,
BigDecimal maxAmount, Long minBeginAt, Long maxBeginAt,
Integer minMonthLimit, Integer maxMonthLimit, Integer status,
Long minEndAt, Long maxEndAt, String code) {
log.info("method getCreditList begin...");
if (page == null) {
page = 1;
}
if (size == null) {
size = 10;
}
int start = (page - 1) * size;
if (start < 0) {
start = 0;
}
int total = 0, totalPage = 0;
log.info("credit list page paramer is: page = " + page + ", size = " + size);
log.info("arguments: creditorName = [" + creditorName + "], creditorIdno = [" + creditorIdno
+ "], creditorMobile = [" + creditorMobile + "], minAmount = [" + minAmount
+ "], maxAmount = [" + maxAmount + "], minBeginAt = [" + minBeginAt + "], maxBeginAt = ["
+ maxBeginAt + "], minMonthLimit = [" + minMonthLimit + "], maxMonthLimit = ["
+ maxMonthLimit + "], status = [" + status + "], minEndAt = [" + minEndAt
+ "], maxEndAt = [" + maxEndAt + "], code = [" + code + "]");
try {
/* 第一步、动态拼接条件查询sql */
Map<String, Object> params = CreditUtil.getCreditListParams(creditorName, creditorIdno,
creditorMobile, minAmount, maxAmount, minBeginAt, maxBeginAt, minMonthLimit,
maxMonthLimit, status, minEndAt, maxEndAt, code);
log.info("params is: " + params);
/* 第二步、 条件查询 */
List<Long> ids = creditService.getIdsByDynamicCondition(Credit.class, params, start, size);
log.info("ids size is: " + ids.size());
List<Credit> creditList = new ArrayList<>();
if (CollectionUtils.isEmpty(ids)) {
log.info("ids is empty, find no data");
}
else {
creditList = creditService.getObjectsByIds(ids);
log.info("creditList size is: " + creditList.size());
/* 第三步、计算每一个原始债务的待匹金额 */
for (Credit credit : creditList) {
if (credit.getStatus() == Credit.UNUSE) {
log.info("credit is unuse, credit id is: " + credit.getId());
credit.setNotMatchAmount(credit.getAmount());
}
else if (credit.getStatus() == Credit.USE_ING) {
log.info("credit is use_ing, credit id is: " + credit.getId());
List<CreditSplit> notMatchedCreditSplits = splitService
.getNotMatchedCreditSplitList(credit.getId());
BigDecimal notMatchedAmount = SplitUtil.calcNotMatchedAmount(notMatchedCreditSplits);
credit.setNotMatchAmount(notMatchedAmount);
}
else {
log.info("credit is use_finish, credit id is: " + credit.getId());
credit.setNotMatchAmount(BigDecimal.ZERO);
}
}
/* 第四步、 计算totalPage */
total = creditService
.getIdsByDynamicCondition(Credit.class, params, 0, Integer.MAX_VALUE).size();
log.info("credit list total is: " + total);
totalPage = (total - 1) / size + 1;
}
model.addAttribute("code", 0);
model.addAttribute("page", page);
model.addAttribute("size", size);
model.addAttribute("total", total);
model.addAttribute("totalPage", totalPage);
model.addAttribute("creditList", creditList);
}
catch (Throwable t) {
log.error(t.getMessage());
log.error("get credit list error");
model.addAttribute("code", -1);
}
log.info("method getCreditList end...");
return "/playboy-invest-service/credit/json/creditListJson";
}
明天计划的事情:完成债权管理
遇到的问题:无
收获:熟悉业务逻辑
评论