|
@@ -9,10 +9,14 @@ import com.fjhx.fundAccount.FundAccountDetail;
|
|
|
import com.fjhx.fundAccount.entity.FundAccountIntercourse;
|
|
|
import com.fjhx.fundAccount.entity.MyCompanyBasics;
|
|
|
import com.fjhx.fundAccount.entity.MyFundAccount;
|
|
|
+import com.fjhx.fundAccount.mapper.FundAccountIntercourseMapper;
|
|
|
import com.fjhx.fundAccount.service.IFundAccountDetailService;
|
|
|
import com.fjhx.fundAccount.service.IFundAccountIntercourseService;
|
|
|
import com.fjhx.fundAccount.service.IFundAccountService;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.utils.AesUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.annotation.AnnotationUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -28,6 +32,9 @@ public class FundAccountIntercourseServiceImpl implements IFundAccountIntercours
|
|
|
@Autowired
|
|
|
private ICompanyBasicsService companyBasicsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ FundAccountIntercourseMapper fundAccountIntercourseMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public BigDecimal getMoney(int type, List<FundAccountDetail> fundAccountDetailList, FundAccountDetail fundAccountDetail) {
|
|
@@ -40,43 +47,42 @@ public class FundAccountIntercourseServiceImpl implements IFundAccountIntercours
|
|
|
|
|
|
@Override
|
|
|
public List getFundAccountIntercourse() {
|
|
|
- QueryWrapper<FundAccountDetail> wrapper = Wrappers.query();
|
|
|
- wrapper.eq("capital_matter ", "45");
|
|
|
- //所有往来款记录
|
|
|
- List<FundAccountDetail> fundAccountDetailList = fundAccountDetailService.list(wrapper);
|
|
|
- //所有往来款记录账户信息
|
|
|
- List<FundAccount> fundAccounts = fundAccountService.listByIds(fundAccountDetailList.stream().map(FundAccountDetail::getFromFundAccountId).distinct().collect(Collectors.toList()));
|
|
|
- //所有往来款记录账户对应的公司信息
|
|
|
- List<CompanyBasics> companyBasicss = companyBasicsService.listByIds(fundAccounts.stream().map(FundAccount::getCompanyId).distinct().collect(Collectors.toList()));
|
|
|
+ QueryWrapper<Object> wrapper1 = Wrappers.query();
|
|
|
+ wrapper1.eq("t_erp_fund_account_detail.capital_matter ", "45");
|
|
|
+ wrapper1.eq("t_erp_fund_account_detail.tenant_id", AuthUtil.getTenantId());
|
|
|
+ List<FundAccountIntercourse> fundAccountIntercourses = fundAccountIntercourseMapper.getIntercourseFunds(wrapper1);
|
|
|
+
|
|
|
+ List<FundAccountIntercourse> data = new ArrayList<>();
|
|
|
+ //根据公司分组
|
|
|
+ Map<String, List<FundAccountIntercourse>> collect = fundAccountIntercourses.stream().collect(Collectors.groupingBy(FundAccountIntercourse::getCompanyName));
|
|
|
+ for (Map.Entry<String, List<FundAccountIntercourse>> entry : collect.entrySet()) {
|
|
|
+ FundAccountIntercourse gs = new FundAccountIntercourse();
|
|
|
+ gs.setCompanyName(entry.getKey());
|
|
|
|
|
|
- //将所有往来款根据账户id分组
|
|
|
- Map<String, List<FundAccountIntercourse>> fundAccountDetailFromAccountIdList = fundAccountDetailList.stream().map(fundAccountDetail -> {
|
|
|
- FundAccountIntercourse fundAccountIntercourse = new FundAccountIntercourse();
|
|
|
- fundAccountIntercourse.setAccountName(fundAccountDetail.getAccountName());
|
|
|
- fundAccountIntercourse.setIncome(getMoney(1,fundAccountDetailList,fundAccountDetail));
|
|
|
- fundAccountIntercourse.setExpend(getMoney(2,fundAccountDetailList,fundAccountDetail));
|
|
|
- fundAccountIntercourse.setSurplus(fundAccountIntercourse.getIncome().subtract(fundAccountIntercourse.getExpend()));
|
|
|
- fundAccountIntercourse.setFromFundAccountId(fundAccountDetail.getFromFundAccountId());
|
|
|
- return fundAccountIntercourse;
|
|
|
- }).collect(Collectors.groupingBy(FundAccountIntercourse::getFromFundAccountId));
|
|
|
+ //根据目标账户分组
|
|
|
+ List<FundAccountIntercourse> value = entry.getValue();
|
|
|
+ Map<String, List<FundAccountIntercourse>> collect1 = value.stream().collect(Collectors.groupingBy(FundAccountIntercourse::getAccountName));
|
|
|
+ for (Map.Entry<String, List<FundAccountIntercourse>> entry1 : collect1.entrySet()) {
|
|
|
+ FundAccountIntercourse mb = new FundAccountIntercourse();
|
|
|
+ mb.setAccountName(entry1.getKey());
|
|
|
|
|
|
- //将所有往来款账户根据公司id分组
|
|
|
- Map<String, List<MyFundAccount>> fundAccountDetailFromCompanyIdList = fundAccounts.stream().map(fundAccount -> {
|
|
|
- MyFundAccount myFundAccount = new MyFundAccount();
|
|
|
- myFundAccount.setName(fundAccount.getName());
|
|
|
- myFundAccount.setList(fundAccountDetailFromAccountIdList.get(fundAccount.getId()));
|
|
|
- myFundAccount.setCompanyId(fundAccount.getCompanyId());
|
|
|
- return myFundAccount;
|
|
|
- }).collect(Collectors.groupingBy(MyFundAccount::getCompanyId));
|
|
|
+ //根据类型分组1收入2支出
|
|
|
+ Map<String, List<FundAccountIntercourse>> collect2 = entry1.getValue().stream().collect(Collectors.groupingBy(FundAccountIntercourse::getType));
|
|
|
+ BigDecimal income = collect2.get("1")==null?BigDecimal.ZERO:collect2.get("1").stream().map(FundAccountIntercourse::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal expend = collect2.get("2")==null?BigDecimal.ZERO:collect2.get("2").stream().map(FundAccountIntercourse::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal surplus = income.subtract(expend);
|
|
|
|
|
|
- //将往来款所有信息组成树状
|
|
|
- List<MyCompanyBasics> data = companyBasicss.stream().map(companyBasics -> {
|
|
|
- MyCompanyBasics myCompanyBasics = new MyCompanyBasics();
|
|
|
- myCompanyBasics.setCompanyName(companyBasics.getNameChinese());
|
|
|
- myCompanyBasics.setList(fundAccountDetailFromCompanyIdList.get(companyBasics.getId()));
|
|
|
- return myCompanyBasics;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ mb.setIncome(income);
|
|
|
+ mb.setExpend(expend);
|
|
|
+ mb.setSurplus(surplus);
|
|
|
|
|
|
+ List<FundAccountIntercourse> list = gs.getList();
|
|
|
+ list = list == null ? new ArrayList<FundAccountIntercourse>() : list;
|
|
|
+ list.add(mb);
|
|
|
+ gs.setList(list);
|
|
|
+ }
|
|
|
+ data.add(gs);
|
|
|
+ }
|
|
|
return data;
|
|
|
}
|
|
|
|