优化结算账户报表的统计
This commit is contained in:
@@ -41,7 +41,8 @@
|
|||||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
当前总余额:<span class="first-total">0</span>
|
本月发生总额:<span id="allMonthAmount">0</span>
|
||||||
|
当前总余额:<span id="allCurrentAmount">0</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
|
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
|
||||||
@@ -181,13 +182,25 @@
|
|||||||
if(res && res.code === 200){
|
if(res && res.code === 200){
|
||||||
if(res.data && res.data.page) {
|
if(res.data && res.data.page) {
|
||||||
$("#tableData").datagrid('loadData', res.data.page);
|
$("#tableData").datagrid('loadData', res.data.page);
|
||||||
var total = 0;
|
}
|
||||||
res.data.page.rows.forEach(function(value, index, array){
|
}
|
||||||
//执行某些操作
|
},
|
||||||
total += value.currentamount;
|
//此处添加错误处理
|
||||||
})
|
error: function () {
|
||||||
|
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(".first-total").text(total); //当前总余额
|
$.ajax({
|
||||||
|
type: "get",
|
||||||
|
url: "/account/getStatistics",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (res) {
|
||||||
|
if (res && res.code === 200) {
|
||||||
|
if(res.data) {
|
||||||
|
$("#allMonthAmount").text(res.data.allMonthAmount);
|
||||||
|
$("#allCurrentAmount").text(res.data.allCurrentAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -258,7 +271,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{title: '余额', field: 'balance', width: 80},
|
{title: '余额', field: 'balance', width: 80},
|
||||||
{title: '入库出库日期', field: 'operTime', width: 180}
|
{title: '日期', field: 'operTime', width: 180}
|
||||||
]],
|
]],
|
||||||
onLoadError: function () {
|
onLoadError: function () {
|
||||||
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
|
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.jsh.erp.constants.BusinessConstants;
|
|||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.Account;
|
import com.jsh.erp.datasource.entities.Account;
|
||||||
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||||
|
import com.jsh.erp.datasource.vo.AccountVo4List;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.account.AccountService;
|
import com.jsh.erp.service.account.AccountService;
|
||||||
import com.jsh.erp.utils.BaseResponseInfo;
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
@@ -182,4 +183,24 @@ public class AccountController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算账户的统计
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getStatistics")
|
||||||
|
public BaseResponseInfo getStatistics(HttpServletRequest request) throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = accountService.getStatistics();
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AccountService {
|
public class AccountService {
|
||||||
@@ -324,21 +322,17 @@ public class AccountService {
|
|||||||
if (!ids.equals("")) {
|
if (!ids.equals("")) {
|
||||||
ids = ids.substring(0, ids.length() - 1);
|
ids = ids.substring(0, ids.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountItemExample exampleAi = new AccountItemExample();
|
AccountItemExample exampleAi = new AccountItemExample();
|
||||||
if (!ids.equals("")) {
|
if (!ids.equals("")) {
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList)
|
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList)
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
} else {
|
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
|
||||||
exampleAi.createCriteria().andAccountidEqualTo(id)
|
if (dataListOne != null) {
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
for (AccountItem accountItem : dataListOne) {
|
||||||
}
|
if(accountItem.getEachamount()!=null) {
|
||||||
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
|
accountSum = accountSum.add(accountItem.getEachamount());
|
||||||
if (dataListOne != null) {
|
}
|
||||||
for (AccountItem accountItem : dataListOne) {
|
|
||||||
if(accountItem.getEachamount()!=null) {
|
|
||||||
accountSum = accountSum.add(accountItem.getEachamount());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -535,4 +529,43 @@ public class AccountService {
|
|||||||
return deleteTotal;
|
return deleteTotal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getStatistics() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
List<Account> list = getAccount();
|
||||||
|
String timeStr = Tools.getCurrentMonth();
|
||||||
|
BigDecimal allMonthAmount = BigDecimal.ZERO;
|
||||||
|
BigDecimal allCurrentAmount = BigDecimal.ZERO;
|
||||||
|
if (null != list && null !=timeStr) {
|
||||||
|
for (Account a : list) {
|
||||||
|
BigDecimal monthAmount = getAccountSum(a.getId(), timeStr, "month").add(getAccountSumByHead(a.getId(), timeStr, "month"))
|
||||||
|
.add(getAccountSumByDetail(a.getId(), timeStr, "month")).add(getManyAccountSum(a.getId(), timeStr, "month"));
|
||||||
|
BigDecimal currentAmount = getAccountSum(a.getId(), "", "month").add(getAccountSumByHead(a.getId(), "", "month"))
|
||||||
|
.add(getAccountSumByDetail(a.getId(), "", "month")).add(getManyAccountSum(a.getId(), "", "month")).add(a.getInitialamount());
|
||||||
|
allMonthAmount = allMonthAmount.add(monthAmount);
|
||||||
|
allCurrentAmount = allCurrentAmount.add(currentAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("allCurrentAmount", priceFormat(allCurrentAmount)); //当前总金额
|
||||||
|
map.put("allMonthAmount", priceFormat(allMonthAmount)); //本月发生额
|
||||||
|
} catch (Exception e) {
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格格式化
|
||||||
|
* @param price
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String priceFormat(BigDecimal price) {
|
||||||
|
String priceFmt = "0";
|
||||||
|
DecimalFormat df = new DecimalFormat(".##");
|
||||||
|
if ((price.compareTo(BigDecimal.ZERO))!=0) {
|
||||||
|
priceFmt = df.format(price);
|
||||||
|
}
|
||||||
|
return priceFmt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user