增加获取带余额的账户的接口

This commit is contained in:
季圣华
2023-10-17 23:49:31 +08:00
parent 6b3eb23bdc
commit b4d97b7fb0
2 changed files with 89 additions and 23 deletions

View File

@@ -165,6 +165,35 @@ public class AccountController {
} }
} }
/**
* 获取带余额的报表
* @param request
* @return
*/
@GetMapping(value = "/listWithBalance")
@ApiOperation(value = "获取带余额的报表")
public BaseResponseInfo listWithBalance(@RequestParam("name") String name,
@RequestParam("serialNo") String serialNo,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
HttpServletRequest request) throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> map = new HashMap<>();
List<AccountVo4List> list = accountService.listWithBalance(name, serialNo, (currentPage-1)*pageSize, pageSize);
Long count = accountService.listWithBalanceCount(name, serialNo);
map.put("rows", list);
map.put("total", count);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/** /**
* 结算账户的统计 * 结算账户的统计
* @param request * @param request

View File

@@ -100,16 +100,12 @@ public class AccountService {
} }
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{ public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{
List<AccountVo4List> resList = new ArrayList<AccountVo4List>(); List<AccountVo4List> resList = new ArrayList<>();
List<AccountVo4List> list=null;
try{ try{
list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows); List<AccountVo4List> list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
String timeStr = Tools.getCurrentMonth(); String timeStr = Tools.getCurrentMonth();
Boolean forceFlag = systemConfigService.getForceApprovalFlag(); Boolean forceFlag = systemConfigService.getForceApprovalFlag();
if (null != list && null !=timeStr) { if (null != list) {
for (AccountVo4List al : list) { for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##"); DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month", forceFlag).add(getAccountSumByHead(al.getId(), timeStr, "month", forceFlag)) BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month", forceFlag).add(getAccountSumByHead(al.getId(), timeStr, "month", forceFlag))
@@ -125,6 +121,9 @@ public class AccountService {
resList.add(al); resList.add(al);
} }
} }
} catch(Exception e){
JshException.readFail(logger, e);
}
return resList; return resList;
} }
@@ -563,6 +562,44 @@ public class AccountService {
return sb.toString(); return sb.toString();
} }
public List<AccountVo4List> listWithBalance(String name, String serialNo, Integer offset, Integer rows) throws Exception {
List<AccountVo4List> resList = new ArrayList<>();
try{
List<AccountVo4List> list = accountMapperEx.selectByConditionAccount(name, serialNo, null, offset, rows);
String timeStr = Tools.getCurrentMonth();
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
if (null != list) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month", forceFlag).add(getAccountSumByHead(al.getId(), timeStr, "month", forceFlag))
.add(getAccountSumByDetail(al.getId(), timeStr, "month", forceFlag)).add(getManyAccountSum(al.getId(), timeStr, "month", forceFlag));
String thisMonthAmountFmt = "0";
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThisMonthAmount(thisMonthAmountFmt); //本月发生额
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month", forceFlag).add(getAccountSumByHead(al.getId(), "", "month", forceFlag))
.add(getAccountSumByDetail(al.getId(), "", "month", forceFlag)).add(getManyAccountSum(al.getId(), "", "month", forceFlag)) .add(al.getInitialAmount()) ;
al.setCurrentAmount(currentAmount);
resList.add(al);
}
}
} catch(Exception e){
JshException.readFail(logger, e);
}
return resList;
}
public Long listWithBalanceCount(String name, String serialNo) {
Long result = null;
try{
result = accountMapperEx.countsByAccount(name, serialNo, null);
} catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public Map<String, Object> getStatistics(String name, String serialNo) { public Map<String, Object> getStatistics(String name, String serialNo) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
try { try {