|
@@ -4,20 +4,20 @@ import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
|
|
|
import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
|
|
import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
|
|
|
import com.ydtech.modules.admin.service.ProfitAnalysisService;
|
|
import com.ydtech.modules.admin.service.ProfitAnalysisService;
|
|
|
import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
|
|
|
+import com.ydtech.modules.console.dao.ProfitAnalysisMapper;
|
|
|
import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
|
|
import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
|
|
|
import com.ydtech.modules.inv.dao.InvAccountMapper;
|
|
import com.ydtech.modules.inv.dao.InvAccountMapper;
|
|
|
import com.ydtech.modules.inv.model.InvAccount;
|
|
import com.ydtech.modules.inv.model.InvAccount;
|
|
|
import com.ydtech.modules.inv.model.InvAccountCardVo;
|
|
import com.ydtech.modules.inv.model.InvAccountCardVo;
|
|
|
|
|
+import com.ydtech.modules.inv.model.InvAccountExpenses;
|
|
|
import com.ydtech.utils.BigDecimalUtils;
|
|
import com.ydtech.utils.BigDecimalUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.Calendar;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
@@ -32,6 +32,8 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private InsPlyIncomeMapper insPlyIncomeMapper;
|
|
private InsPlyIncomeMapper insPlyIncomeMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ProfitAnalysisMapper profitAnalysisMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
@@ -82,6 +84,68 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
|
|
|
return profitAnalysisQueryList;
|
|
return profitAnalysisQueryList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<ProfitAnalysisDto> getProfitAnalysisQueryDetailsList(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
|
|
|
|
|
+ List<ProfitAnalysisDto> resultList =new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(profitAnalysisQueryDto.getExpensesType()) && "3".equals(profitAnalysisQueryDto.getExpensesType())) {
|
|
|
|
|
+ List<ProfitAnalysisDto> profitAnalysisDtos = profitAnalysisMapper.selectAccountExpenses(profitAnalysisQueryDto);
|
|
|
|
|
+ resultList.addAll(profitAnalysisDtos) ;
|
|
|
|
|
+ List<ProfitAnalysisDto> addVariableCost = new ArrayList<>();
|
|
|
|
|
+ List<ProfitAnalysisDto> profitAnalysisDto1 = insPlyIncomeMapper.changeAmount(profitAnalysisQueryDto);
|
|
|
|
|
+ for (ProfitAnalysisDto analysisDto : profitAnalysisDto1) {
|
|
|
|
|
+ String outCardNum = analysisDto.getOutCardNum();
|
|
|
|
|
+ String enterCardNum = analysisDto.getEnterCardNum();
|
|
|
|
|
+ InvAccountCardVo outAccount = invAccountMapper.getByCarNumber(outCardNum);
|
|
|
|
|
+ InvAccountCardVo enterAccount = invAccountMapper.getByCarNumber(enterCardNum);
|
|
|
|
|
+ if (StringUtils.isNotEmpty(outAccount.getOuterFlag()) && StringUtils.isNotEmpty(enterAccount.getOuterFlag())) {
|
|
|
|
|
+ if (!enterAccount.getOuterFlag().equals(outAccount.getOuterFlag())) {
|
|
|
|
|
+ addVariableCost.add(analysisDto);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> profitAnalysisDtoMap = addVariableCost.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ ProfitAnalysisDto::getExpensesId, // keyMapper,用于提取键(expensesId)
|
|
|
|
|
+ ProfitAnalysisDto::getApplyAmount, // valueMapper,用于提取初始值(applyAmount)
|
|
|
|
|
+ BigDecimal::add // mergeFunction,用于处理键冲突(相加 applyAmount)
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ for (ProfitAnalysisDto profitAnalysisDto : resultList) {
|
|
|
|
|
+ String expensesId = profitAnalysisDto.getExpensesId();
|
|
|
|
|
+ if (profitAnalysisDtoMap.containsKey(expensesId)) {
|
|
|
|
|
+ BigDecimal bigDecimal = profitAnalysisDtoMap.get(expensesId);
|
|
|
|
|
+ profitAnalysisDto.setApplyAmount(bigDecimal);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ resultList.addAll(profitAnalysisMapper.getAllAccountExpenses(profitAnalysisQueryDto));
|
|
|
|
|
+ }
|
|
|
|
|
+ return getTree(resultList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 组装树形结构结果集方法
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public List<ProfitAnalysisDto> getTree(List<ProfitAnalysisDto> list){
|
|
|
|
|
+
|
|
|
|
|
+ return list.stream().filter(accountExpenses -> accountExpenses.getParentId().equals("0"))
|
|
|
|
|
+ .peek(accountExpenses -> accountExpenses.setChildren(getChildren(accountExpenses,list))).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<ProfitAnalysisDto> getChildren(ProfitAnalysisDto user,List<ProfitAnalysisDto> userList){
|
|
|
|
|
+ return userList.stream().filter(u -> Objects.equals(u.getParentId(),user.getExpensesId())).map(
|
|
|
|
|
+ u -> {
|
|
|
|
|
+ u.setChildren(getChildren(u,userList));
|
|
|
|
|
+ return u;
|
|
|
|
|
+ }
|
|
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
|
* @author: hxl
|
|
* @author: hxl
|