Sfoglia il codice sorgente

首页新增总收入(现金+余额-财务支出)

zouxuan 4 anni fa
parent
commit
218088e067

+ 0 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -223,8 +223,6 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
 
     List<IndexBaseMonthData> getFinanceActualData(@Param("dayStr") String dayStr);
 
-    List<IndexBaseMonthData> getTotalAmountData(@Param("dayStr") String dayStr);
-
     List<IndexBaseMonthData> getFinancePayDataWithTimely(@Param("startDate") String startDate,
                                                          @Param("endDate") String endDate,
                                                          @Param("organIds") List<Integer> organIds);

+ 49 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -32,11 +32,12 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.ym.mec.biz.dal.enums.IndexDataType.FINANCE_AMOUNT;
 import static com.ym.mec.biz.dal.enums.IndexErrorType.WAIT_CREATE_PAYMENT_CALENDER;
 
 @Service
 public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBaseMonthData> implements IndexBaseMonthDataService {
-	
+
 	@Autowired
 	private IndexBaseMonthDataDao indexBaseMonthDataDao;
 	@Autowired
@@ -105,10 +106,43 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		}
 
 		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().filter(d->Objects.nonNull(d.getDataType())).collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
-		typeDateMap.put(IndexDataType.FINANCE_PAY,indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
+		List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+		typeDateMap.put(IndexDataType.FINANCE_PAY,financePayDataWithTimely);
 		typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
-		typeDateMap.put(IndexDataType.FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
-		typeDateMap.put(IndexDataType.TOTAL_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
+		typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
+		List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+
+		if(financePayDataWithTimely.size() > 0){
+			for (IndexBaseMonthData indexBaseMonthData : financePayDataWithTimely) {
+				BigDecimal percent = indexBaseMonthData.getPercent();
+				if(percent != null && percent.doubleValue() != 0d){
+					List<IndexBaseMonthData> collect = totalAmountDataWithTimely.stream().filter(e -> DateUtil.format(e.getMonth(), DateUtil.ISO_EXPANDED_DATE_FORMAT).
+							equals(DateUtil.format(indexBaseMonthData.getMonth(), DateUtil.ISO_EXPANDED_DATE_FORMAT))).collect(Collectors.toList());
+					IndexBaseMonthData totalAmountDate = null;
+					if(collect != null && collect.size() > 0){
+						totalAmountDate = collect.get(0);
+					}
+					if(totalAmountDate == null){
+						totalAmountDate = new IndexBaseMonthData();
+						totalAmountDate.setTotalNum(percent.negate());
+						totalAmountDate.setDataType(FINANCE_AMOUNT);
+						totalAmountDate.setActivateNum(percent.negate());
+						totalAmountDate.setOrganId(indexBaseMonthData.getOrganId());
+						totalAmountDate.setMonth(indexBaseMonthData.getMonth());
+						totalAmountDate.setPercent(percent.negate());
+						totalAmountDataWithTimely.add(totalAmountDate);
+					}else {
+						BigDecimal totalAmount = totalAmountDate.getPercent();
+						totalAmountDate.setActivateNum(totalAmount.subtract(percent));
+						totalAmountDate.setTotalNum(totalAmount.subtract(percent));
+						totalAmountDate.setPercent(totalAmount.subtract(percent));
+					}
+				}
+			}
+			totalAmountDataWithTimely = totalAmountDataWithTimely.stream().sorted(Comparator.comparing(IndexBaseMonthData::getMonth)).collect(Collectors.toList());
+		}
+
+		typeDateMap.put(IndexDataType.TOTAL_AMOUNT,totalAmountDataWithTimely);
 
 
 		for (IndexDataType dataType : IndexDataType.values()) {
@@ -130,7 +164,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			typeDateMap.put(dataType, new ArrayList<>(Arrays.asList(indexBaseMonthData)));
 		}
 
-		BigDecimal totalAmount = BigDecimal.ZERO;
+
 		for (Map.Entry<IndexDataType, List<IndexBaseMonthData>> typeDateMapEntry : typeDateMap.entrySet()) {
 			Set<String> hasMonths = typeDateMapEntry.getValue().stream().map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet());
 			LocalDate currentMonthDate = startDate;
@@ -167,7 +201,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			}
 			IndexBaseDto indexBaseData = new IndexBaseDto(typeDateMapEntry.getKey(),typeDateMapEntry.getKey().getMsg());
 			indexBaseData.setIndexMonthData(typeDateMapEntry.getValue(), currentMonth);
-			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || IndexDataType.FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 				IndexDataType.FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 					IndexDataType.TOTAL_AMOUNT.equals(typeDateMapEntry.getKey())){
 				indexBaseData.setPercent(typeDateMapEntry.getValue().stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -223,10 +257,15 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_PRACTICE_COURSE_NUM);
 
 		//经营数据
-		saveData(indexBaseMonthDataDao.getFinancePayData(dayStr),dayStr,IndexDataType.FINANCE_PAY);
-		saveData(indexBaseMonthDataDao.getFinanceBalanceData(dayStr),dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT);
-		saveData(indexBaseMonthDataDao.getFinanceActualData(dayStr),dayStr,IndexDataType.FINANCE_AMOUNT);
-		saveData(indexBaseMonthDataDao.getTotalAmountData(dayStr),dayStr,IndexDataType.TOTAL_AMOUNT);
+
+//		List<IndexBaseMonthData> financePayData = indexBaseMonthDataDao.getFinancePayData(dayStr);
+//		List<IndexBaseMonthData> financeBalanceData = indexBaseMonthDataDao.getFinanceBalanceData(dayStr);
+//		List<IndexBaseMonthData> financeActualData = indexBaseMonthDataDao.getFinanceActualData(dayStr);
+//
+//		saveData(financePayData,dayStr,IndexDataType.FINANCE_PAY);
+//		saveData(financeBalanceData,dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT);
+//		saveData(financeActualData,dayStr,IndexDataType.FINANCE_AMOUNT);
+//		saveData(totalAmountData,dayStr,IndexDataType.TOTAL_AMOUNT);
 
 		//业务数据
 		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), monday.toString(), IndexDataType.HOMEWORK_CREATE_RATE);

+ 0 - 8
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -927,14 +927,6 @@
 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
 		GROUP BY spo.organ_id_
 	</select>
-	<select id="getTotalAmountData" resultMap="IndexBaseMonthData">
-		SELECT spo.organ_id_,SUM(spo.actual_amount_ + spo.balance_payment_amount_) total_num_,
-			   SUM(spo.actual_amount_ + spo.balance_payment_amount_) activate_num_,
-			   SUM(spo.actual_amount_ + spo.balance_payment_amount_) percent_,#{dayStr} month_
-		FROM student_payment_order spo
-		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
-		GROUP BY spo.organ_id_
-	</select>
 
 	<select id="getFinancePayDataWithTimely"  resultMap="IndexBaseMonthData">
 		SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,DATE_FORMAT(fe.create_time_,'%Y-%m-%d') month_