fix: 功能优化完善,日常支出统计。
This commit is contained in:
@@ -26,4 +26,6 @@ public class AccountsDealRecordVo extends AccountsDealRecord
|
||||
|
||||
private String childCategoryName;
|
||||
|
||||
private String dateStr;
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,13 @@ public interface StatisticAnalysisMapper {
|
||||
*/
|
||||
@DataScope(businessAlias = "a")
|
||||
public List<AccountCalendarVo> selectSalaryByDate(AccountsDealRecordDto accountsDealRecordDto);
|
||||
|
||||
/**
|
||||
* 查询日常支出,按日统计
|
||||
*
|
||||
* @param accountsDealRecordDto
|
||||
* @return 收支集合
|
||||
*/
|
||||
@DataScope(businessAlias = "a")
|
||||
public List<AccountsDealRecordVo> selectDailyExpensesDateList(AccountsDealRecordDto accountsDealRecordDto);
|
||||
}
|
||||
|
||||
@@ -2542,6 +2542,98 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
||||
dto.setAccountId(analysisDto.getId());
|
||||
dto.setChildCategory(analysisDto.getChildCategory());
|
||||
List<AccountsDealRecordVo> accountsDealRecordVoList=statisticAnalysisMapper.selectDailyExpensesList(dto);
|
||||
List<AccountsDealRecordVo> accountsDateList=statisticAnalysisMapper.selectDailyExpensesDateList(dto);
|
||||
|
||||
List<AccountsDealRecordVo> queryList =new ArrayList<>();
|
||||
if("1".equals(analysisDto.getType())){
|
||||
for (AccountsDealRecordVo vo:accountsDateList
|
||||
) {
|
||||
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
||||
analysisVo.setAmount(vo.getAmount());
|
||||
analysisVo.setRemark(vo.getDateStr());
|
||||
queryList.add(analysisVo);
|
||||
}
|
||||
|
||||
//年查询
|
||||
}
|
||||
else if("2".equals(analysisDto.getType())){
|
||||
//月列表
|
||||
List <String> staticsTimeList=new ArrayList<>();
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
) {
|
||||
String monthString=vo.getDateStr().substring(0,7);
|
||||
if(!staticsTimeList.contains(monthString)){
|
||||
staticsTimeList.add(monthString);
|
||||
}
|
||||
}
|
||||
for (String staticsTime :staticsTimeList
|
||||
) {
|
||||
double actualCreditBillMonth=0;
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
) {
|
||||
String monthString=vo.getDateStr().substring(0,7);
|
||||
if(staticsTime.equals(monthString)){
|
||||
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=vo.getDateStr().substring(0,4);
|
||||
|
||||
if(!staticsTimeList.contains(yearString)){
|
||||
staticsTimeList.add(yearString);
|
||||
}
|
||||
}
|
||||
|
||||
for (String staticsTime :staticsTimeList
|
||||
) {
|
||||
double actualCreditBillYear=0;
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
) {
|
||||
String yearString=vo.getDateStr().substring(0,4);
|
||||
if(staticsTime.equals(yearString)){
|
||||
actualCreditBillYear+=vo.getAmount();
|
||||
}
|
||||
}
|
||||
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
||||
analysisVo.setAmount(actualCreditBillYear);
|
||||
analysisVo.setRemark(staticsTime);
|
||||
queryList.add(analysisVo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ArrayList<Map<String, Object>> acccountsDateList = 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()));
|
||||
acccountsDateList.add(datamap);
|
||||
}
|
||||
//列表
|
||||
map.put("acccountsDateList",acccountsDateList);
|
||||
map.put("tableAccountsDateList",tableAccountsList);
|
||||
|
||||
//日常支出 1
|
||||
double dailyExpenses=0;
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
@@ -2579,6 +2671,26 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
||||
map.put("top6Name",accountsDealRecordVoList.get(5).getName());
|
||||
map.put("top6",accountsDealRecordVoList.get(5).getAmount());
|
||||
}
|
||||
if(accountsDealRecordVoList.size()>6){
|
||||
map.put("top7Name",accountsDealRecordVoList.get(6).getName());
|
||||
map.put("top7",accountsDealRecordVoList.get(6).getAmount());
|
||||
}
|
||||
if(accountsDealRecordVoList.size()>7){
|
||||
map.put("top8Name",accountsDealRecordVoList.get(7).getName());
|
||||
map.put("top8",accountsDealRecordVoList.get(7).getAmount());
|
||||
}
|
||||
if(accountsDealRecordVoList.size()>8){
|
||||
map.put("top9Name",accountsDealRecordVoList.get(8).getName());
|
||||
map.put("top9",accountsDealRecordVoList.get(8).getAmount());
|
||||
}
|
||||
if(accountsDealRecordVoList.size()>9){
|
||||
map.put("top10Name",accountsDealRecordVoList.get(9).getName());
|
||||
map.put("top10",accountsDealRecordVoList.get(9).getAmount());
|
||||
}
|
||||
if(accountsDealRecordVoList.size()>10){
|
||||
map.put("top11Name",accountsDealRecordVoList.get(10).getName());
|
||||
map.put("top11",accountsDealRecordVoList.get(10).getAmount());
|
||||
}
|
||||
ArrayList<Map<String, Object>> acccountsList = new ArrayList<>();
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
) {
|
||||
|
||||
@@ -238,4 +238,32 @@
|
||||
to_char(a.create_time,
|
||||
'yyyy-MM-dd')
|
||||
</select>
|
||||
|
||||
<select id="selectDailyExpensesDateList" parameterType="AccountsDealRecordDto" resultMap="AccountsDealRecordResult">
|
||||
select
|
||||
sum(a.amount) as amount ,
|
||||
to_char(a.create_time,
|
||||
'yyyy-MM-dd') as dateStr
|
||||
from
|
||||
accounts_deal_record a
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
and a.deal_type = '2'
|
||||
and a.deal_category = '1'
|
||||
<if test="endTime!=null and endTime !=''">
|
||||
and #{endTime}>=to_char(a.create_time, 'yyyy-MM-dd')
|
||||
</if>
|
||||
<if test="startTime!=null and startTime !=''">
|
||||
and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime}
|
||||
</if>
|
||||
</where>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
group by
|
||||
to_char(a.create_time,
|
||||
'yyyy-MM-dd')
|
||||
order by
|
||||
to_char(a.create_time,
|
||||
'yyyy-MM-dd') desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user