|
|
|
|
@@ -50,6 +50,9 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|
|
|
|
@Resource
|
|
|
|
|
private AccountsTransferRecordMapper accountsTransferRecordMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AccountsDealRecordMapper accountsDealRecordMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getIncomeInfo() {
|
|
|
|
|
@@ -1482,4 +1485,212 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getAccountsDealAnalysis(AnalysisDto analysisDto) {
|
|
|
|
|
//返回数据
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.###");
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
//月查询
|
|
|
|
|
if(analysisDto.getType().equals("2")){
|
|
|
|
|
if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){
|
|
|
|
|
String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0));
|
|
|
|
|
String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24));
|
|
|
|
|
analysisDto.setStartTime(startTime);
|
|
|
|
|
analysisDto.setEndTime(endTime);
|
|
|
|
|
}else {
|
|
|
|
|
analysisDto.setStartTime(analysisDto.getStartTime()+"-01");
|
|
|
|
|
if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd");
|
|
|
|
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date()));
|
|
|
|
|
}else {
|
|
|
|
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-31");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//年查询
|
|
|
|
|
}else if(analysisDto.getType().equals("3")){
|
|
|
|
|
if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){
|
|
|
|
|
String endTime=dateFormat.format(DateUtils.getNowDate());
|
|
|
|
|
String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5));
|
|
|
|
|
analysisDto.setStartTime(startTime);
|
|
|
|
|
analysisDto.setEndTime(endTime);
|
|
|
|
|
}else {
|
|
|
|
|
analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01");
|
|
|
|
|
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
|
|
|
|
if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
|
|
|
|
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date()));
|
|
|
|
|
}else {
|
|
|
|
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AccountsDealRecordDto dto=new AccountsDealRecordDto();
|
|
|
|
|
//获取数据
|
|
|
|
|
dto.setEndTime(analysisDto.getEndTime());
|
|
|
|
|
dto.setStartTime(analysisDto.getStartTime());
|
|
|
|
|
dto.setType(analysisDto.getDataType());
|
|
|
|
|
dto.setAccountId(analysisDto.getId());
|
|
|
|
|
dto.setDealType(analysisDto.getDealType());
|
|
|
|
|
dto.setDealCategory(analysisDto.getDealCategory());
|
|
|
|
|
List<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(dto);
|
|
|
|
|
double income =0;
|
|
|
|
|
double expenses =0;
|
|
|
|
|
int incomeCount =0;
|
|
|
|
|
int expensesCount =0;
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
if(vo.getDealType().equals("1")){
|
|
|
|
|
income+=vo.getAmount();
|
|
|
|
|
incomeCount++;
|
|
|
|
|
}
|
|
|
|
|
//支出
|
|
|
|
|
if(vo.getDealType().equals("2")){
|
|
|
|
|
expenses+=vo.getAmount();
|
|
|
|
|
expensesCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map.put("amount",decimalFormat.format(income-expenses));
|
|
|
|
|
map.put("income",decimalFormat.format(income));
|
|
|
|
|
map.put("expenses",decimalFormat.format(expenses));
|
|
|
|
|
map.put("incomeCount",incomeCount);
|
|
|
|
|
map.put("expensesCount",expensesCount);
|
|
|
|
|
List<AccountsDealRecordVo> queryList =new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if("1".equals(analysisDto.getType())){
|
|
|
|
|
//日列表
|
|
|
|
|
List <String> staticsTimeList=new ArrayList<>();
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String dayString=dateFormat.format(vo.getCreateTime());
|
|
|
|
|
|
|
|
|
|
if(!staticsTimeList.contains(dayString)){
|
|
|
|
|
staticsTimeList.add(dayString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (String staticsTime :staticsTimeList
|
|
|
|
|
) {
|
|
|
|
|
double actualCreditBillDay=0;
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String dayString=dateFormat.format(vo.getCreateTime());
|
|
|
|
|
|
|
|
|
|
if(staticsTime.equals(dayString)){
|
|
|
|
|
if(vo.getDealType().equals("1")){
|
|
|
|
|
actualCreditBillDay+=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
if(vo.getDealType().equals("2")){
|
|
|
|
|
actualCreditBillDay-=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
|
|
|
|
analysisVo.setAmount(actualCreditBillDay);
|
|
|
|
|
analysisVo.setRemark(staticsTime);
|
|
|
|
|
queryList.add(analysisVo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//年查询
|
|
|
|
|
}
|
|
|
|
|
else if("2".equals(analysisDto.getType())){
|
|
|
|
|
//月列表
|
|
|
|
|
List <String> staticsTimeList=new ArrayList<>();
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7);
|
|
|
|
|
|
|
|
|
|
if(!staticsTimeList.contains(monthString)){
|
|
|
|
|
staticsTimeList.add(monthString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (String staticsTime :staticsTimeList
|
|
|
|
|
) {
|
|
|
|
|
double actualCreditBillMonth=0;
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7);
|
|
|
|
|
|
|
|
|
|
if(staticsTime.equals(monthString)){
|
|
|
|
|
if(vo.getDealType().equals("1")){
|
|
|
|
|
actualCreditBillMonth+=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
if(vo.getDealType().equals("2")){
|
|
|
|
|
actualCreditBillMonth-=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
|
|
|
|
analysisVo.setAmount(actualCreditBillMonth);
|
|
|
|
|
analysisVo.setRemark(staticsTime);
|
|
|
|
|
queryList.add(analysisVo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//年查询
|
|
|
|
|
}else if("3".equals(analysisDto.getType())){
|
|
|
|
|
List <String> staticsTimeList=new ArrayList<>();
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4);
|
|
|
|
|
|
|
|
|
|
if(!staticsTimeList.contains(yearString)){
|
|
|
|
|
staticsTimeList.add(yearString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (String staticsTime :staticsTimeList
|
|
|
|
|
) {
|
|
|
|
|
double actualCreditBillYear=0;
|
|
|
|
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
|
|
|
|
) {
|
|
|
|
|
String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4);
|
|
|
|
|
if(staticsTime.equals(yearString)){
|
|
|
|
|
if(vo.getDealType().equals("1")){
|
|
|
|
|
actualCreditBillYear+=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
if(vo.getDealType().equals("2")){
|
|
|
|
|
actualCreditBillYear-=vo.getAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
|
|
|
|
analysisVo.setAmount(actualCreditBillYear);
|
|
|
|
|
analysisVo.setRemark(staticsTime);
|
|
|
|
|
queryList.add(analysisVo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArrayList<Map<String, Object>> acccountsList = new ArrayList<>();
|
|
|
|
|
ArrayList<Map<String, Object>> tableAccountsList = new ArrayList<>();
|
|
|
|
|
for (AccountsDealRecordVo vo:queryList
|
|
|
|
|
) {
|
|
|
|
|
Map<String, Object> datamap = new HashMap<>();
|
|
|
|
|
datamap.put("time", vo.getRemark());
|
|
|
|
|
datamap.put("value", decimalFormat.format(vo.getAmount()));
|
|
|
|
|
tableAccountsList.add(datamap);
|
|
|
|
|
}
|
|
|
|
|
Collections.reverse(queryList);
|
|
|
|
|
for (AccountsDealRecordVo vo:queryList
|
|
|
|
|
) {
|
|
|
|
|
Map<String, Object> datamap = new HashMap<>();
|
|
|
|
|
datamap.put("time", vo.getRemark());
|
|
|
|
|
datamap.put("value", decimalFormat.format(vo.getAmount()));
|
|
|
|
|
acccountsList.add(datamap);
|
|
|
|
|
}
|
|
|
|
|
//列表
|
|
|
|
|
map.put("acccountsList",acccountsList);
|
|
|
|
|
map.put("tableAccountsList",tableAccountsList);
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|