src/main/java/com/ruoyi/account/controller/AccountExpenseController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/ruoyi/account/service/AccountExpenseService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/ruoyi/account/service/impl/AccountExpenseServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-demo.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/ruoyi/account/controller/AccountExpenseController.java
@@ -11,6 +11,8 @@ import com.ruoyi.dto.DateQueryDto; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.web.domain.AjaxResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; @@ -24,6 +26,7 @@ */ @RestController @RequestMapping("/account/accountExpense") @Api(tags = "财务管理--支出管理") public class AccountExpenseController { @Resource @@ -112,6 +115,16 @@ } /** * 财务报表-财务分析 * @return */ @GetMapping("/report/analysis") @ApiOperation("财务报表-财务分析") public AjaxResult analysis() { return AjaxResult.success(accountExpenseService.analysis()); } /** * 财务报表图表收入年度查询 * @param * @return src/main/java/com/ruoyi/account/service/AccountExpenseService.java
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; public interface AccountExpenseService extends IService<AccountExpense> { @@ -21,4 +22,6 @@ AccountDto report(DateQueryDto dateQueryDto); List<AccountDto3> reportExpense(); Map<String,List<String>> analysis(); } src/main/java/com/ruoyi/account/service/impl/AccountExpenseServiceImpl.java
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -115,5 +116,41 @@ return accountDto3s; } @Override public Map<String, List<String>> analysis() { // 获取本周的时间范围 LocalDate startOfWeek = LocalDate.now().with(DayOfWeek.MONDAY); LocalDate endOfWeek = LocalDate.now().with(DayOfWeek.SUNDAY); Map<String, List<String>> result = new HashMap<>(); List<String> days = new ArrayList<>(); List<String> totalIncomeList = new ArrayList<>(); List<String> totalExpenseList = new ArrayList<>(); List<String> netIncomeList = new ArrayList<>(); // 根据时间范围循环查询每一天的总收入,总支出,净收入(总收入-总支出) for (LocalDate date = startOfWeek; date.isBefore(endOfWeek) || date.isEqual(endOfWeek); date = date.plusDays(1)) { BigDecimal totalIncome = accountIncomeMapper.selectList(Wrappers.<AccountIncome>lambdaQuery() .eq(AccountIncome::getInputTime, date.toString())) .stream() .map(AccountIncome::getIncomeMoney) .reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal totalExpense = accountExpenseMapper.selectList(Wrappers.<AccountExpense>lambdaQuery() .eq(AccountExpense::getInputTime, date.toString())) .stream() .map(AccountExpense::getExpenseMoney) .reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal netIncome = totalIncome.subtract(totalExpense); days.add(date.toString()); totalIncomeList.add(totalIncome.toString()); totalExpenseList.add(totalExpense.toString()); netIncomeList.add(netIncome.toString()); } result.put("days", days); // 天 result.put("totalIncome", totalIncomeList); // 收入 result.put("totalExpense", totalExpenseList); // 支出 result.put("netIncome", netIncomeList); // 净收入 return result; } } src/main/resources/application-demo.yml
@@ -135,7 +135,7 @@ redis: # 地址 # host: 127.0.0.1 host: 172.17.0.1 host: 192.168.1.185 # 端口,默认为6379 port: 6379 # 数据库索引 src/main/resources/application.yml
@@ -1,4 +1,4 @@ # Spring配置 spring: profiles: active: dev active: demo