|
@@ -23,7 +23,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,6 +51,47 @@ public class TransactionServiceImpl extends ServiceImpl<TransactionMapper, Trans
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<TransactionVo> getPage(TransactionSelectDto dto) {
|
|
public Page<TransactionVo> getPage(TransactionSelectDto dto) {
|
|
|
|
+ Page<TransactionVo> page = this.baseMapper.getPage(dto.getPage(), setWrapper(dto));
|
|
|
|
+ //赋值往来单位名称
|
|
|
|
+ List<TransactionVo> records = page.getRecords();
|
|
|
|
+ transactionDepartmentService.attributeAssign(records, TransactionVo::getDepartmentId, (item, transactionDepartment) -> {
|
|
|
|
+ item.setDepartmentName(transactionDepartment.getName());
|
|
|
|
+ });
|
|
|
|
+ //赋值往来账户名称
|
|
|
|
+ accountManagementService.attributeAssign(records, TransactionVo::getAccountId, (item, account) -> {
|
|
|
|
+ item.setAccountName(account.getName());
|
|
|
|
+ });
|
|
|
|
+ //赋值归属公司名称
|
|
|
|
+ corporationService.attributeAssign(records, TransactionVo::getCorporationId, (item, corporation) -> {
|
|
|
|
+ item.setCorporationName(corporation.getName());
|
|
|
|
+ });
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 头部统计
|
|
|
|
+ * @param dto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String,Object> getHeadStatistic(TransactionSelectDto dto) {
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ List<Transaction> list = this.baseMapper.getHeadStatistic(setWrapper(dto));
|
|
|
|
+ BigDecimal incMoney = list.stream().filter(s ->s.getType() == 1).map(Transaction::getSumAmount).reduce(BigDecimal.ZERO,BigDecimal::add);//应收款
|
|
|
|
+ BigDecimal expMoney = list.stream().filter(s ->s.getType() == 0).map(Transaction::getSumAmount).reduce(BigDecimal.ZERO,BigDecimal::add);//应付款
|
|
|
|
+ Map<Long,List<Transaction>> traMap = list.stream().collect(Collectors.groupingBy(Transaction::getCorporationId));
|
|
|
|
+ map.put("incMoney",incMoney);
|
|
|
|
+ map.put("expMoney",expMoney);
|
|
|
|
+ map.put("tranList",traMap);
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 赋值插叙参数
|
|
|
|
+ * @param dto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private IWrapper<Transaction> setWrapper(TransactionSelectDto dto){
|
|
IWrapper<Transaction> wrapper = getWrapper();
|
|
IWrapper<Transaction> wrapper = getWrapper();
|
|
//条件筛选
|
|
//条件筛选
|
|
wrapper.eq(Transaction::getIsFlowingWater, dto.getIsFlowingWater());
|
|
wrapper.eq(Transaction::getIsFlowingWater, dto.getIsFlowingWater());
|
|
@@ -66,23 +110,8 @@ public class TransactionServiceImpl extends ServiceImpl<TransactionMapper, Trans
|
|
}
|
|
}
|
|
//排序
|
|
//排序
|
|
wrapper.orderByDesc("t", Transaction::getId);
|
|
wrapper.orderByDesc("t", Transaction::getId);
|
|
- Page<TransactionVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
- //赋值往来单位名称
|
|
|
|
- List<TransactionVo> records = page.getRecords();
|
|
|
|
- transactionDepartmentService.attributeAssign(records, TransactionVo::getDepartmentId, (item, transactionDepartment) -> {
|
|
|
|
- item.setDepartmentName(transactionDepartment.getName());
|
|
|
|
- });
|
|
|
|
- //赋值往来账户名称
|
|
|
|
- accountManagementService.attributeAssign(records, TransactionVo::getAccountId, (item, account) -> {
|
|
|
|
- item.setAccountName(account.getName());
|
|
|
|
- });
|
|
|
|
- //赋值归属公司名称
|
|
|
|
- corporationService.attributeAssign(records, TransactionVo::getCorporationId, (item, corporation) -> {
|
|
|
|
- item.setCorporationName(corporation.getName());
|
|
|
|
- });
|
|
|
|
- return page;
|
|
|
|
|
|
+ return wrapper;
|
|
}
|
|
}
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
@DSTransactional
|
|
@DSTransactional
|
|
public void add(TransactionDto transactionDto) {
|
|
public void add(TransactionDto transactionDto) {
|