Browse Source

学员小课管理,定时任务分批处理
经营报表

zouxuan 2 years ago
parent
commit
4a312fd8de

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java

@@ -154,9 +154,10 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 			operatingReportNew.setServiceAmount(operatingReportNew.getCloudAmount().add(operatingReportNew.getCourseAmount()).add(operatingReportNew.getMaintenanceAmount()));
 			operatingReportNew.setTotalIncome(operatingReportNew.getSaleAmount().add(operatingReportNew.getServiceAmount()).subtract(operatingReportNew.getBusinessRefund()));
 
+			operatingReportNew.setInternalSettlement(getAmount(collect18.get(organId)));
 			operatingReportNew.setFixedCosts(getAmount(collect7.get(organId)));
 			operatingReportNew.setVariableCosts(getAmount(collect8.get(organId)));
-			operatingReportNew.setTotalCost(operatingReportNew.getBusinessRefund().
+			operatingReportNew.setTotalCost(operatingReportNew.getInternalSettlement().
 					add(operatingReportNew.getFixedCosts()).add(operatingReportNew.getVariableCosts()));
 
 			operatingReportNew.setCloudPrepaidFee(getAmount(collect9.get(organId)).
@@ -175,7 +176,6 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 			operatingReportNew.setReceivables(getAmount(collect15.get(organId)).add(getAmount(collect16.get(organId))));
 			operatingReportNew.setPayable(getAmount(collect17.get(organId)));
 
-			operatingReportNew.setInternalSettlement(getAmount(collect18.get(organId)));
 			operatingReportNew.setPrepayments(getAmount(collect19.get(organId)));
 
 			operatingReportNew.setQuasiDiscretionaryProfit(operatingReportNew.getTotalIncome().subtract(operatingReportNew.getTotalCost()));

+ 31 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentStatisticsServiceImpl.java

@@ -17,6 +17,7 @@ import com.ym.mec.util.collection.MapUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -31,6 +32,8 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
 	private TeacherDao teacherDao;
 	@Autowired
 	private StudentBasicInfoDao studentBasicInfoDao;
+	@Autowired
+	private RedisTemplate<String,Integer> redisTemplate;
 
 	@Override
 	public BaseDAO<Integer, StudentStatistics> getDAO() {
@@ -39,24 +42,34 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
 
 	@Override
 	public void updateStudentStatistics() {
-		//更新声部班老师
-		studentBasicInfoDao.updateSubjectTeacher();
-		//更新乐团主管、指导老师
-		studentStatisticsDao.updateTeacherAndEdu();
-		//更新未排课总数
-		studentStatisticsDao.updateNoCourseNum();
-		//更新未开始价值总和
-		studentStatisticsDao.updateNotStartCourseFee();
-		//更新未排课价值
-		studentStatisticsDao.updateNoCourseFee();
-		//更新第一次课的时间\最近一次课时间
-		studentStatisticsDao.updateFirstAndLastCourseTime();
-		//更新进行中课程组数量
-		studentStatisticsDao.updateNormalGroupNum();
-		//更新总课时数、已完成、剩余课时数、最近30天课耗、最近1年课耗
-		studentStatisticsDao.updateCourseNum();
-		//更新第一次付费时间
-		studentStatisticsDao.updateFirstOrderTime();
+		Integer num = redisTemplate.opsForValue().get("updateStudentStatisticsNum:");
+		if(num == null || num == 1){
+			if(num == null){
+				num = 1;
+			}
+			//更新未排课总数
+			studentStatisticsDao.updateNoCourseNum();
+			//更新未开始价值总和
+			studentStatisticsDao.updateNotStartCourseFee();
+			//更新未排课价值
+			studentStatisticsDao.updateNoCourseFee();
+		}else if (num == 2){
+			//更新第一次课的时间\最近一次课时间
+			studentStatisticsDao.updateFirstAndLastCourseTime();
+			//更新进行中课程组数量
+			studentStatisticsDao.updateNormalGroupNum();
+			//更新总课时数、已完成、剩余课时数、最近30天课耗、最近1年课耗
+			studentStatisticsDao.updateCourseNum();
+		} else if (num == 3) {
+			//更新声部班老师
+			studentBasicInfoDao.updateSubjectTeacher();
+			//更新乐团主管、指导老师
+			studentStatisticsDao.updateTeacherAndEdu();
+			//更新第一次付费时间
+			studentStatisticsDao.updateFirstOrderTime();
+			num = 0;
+		}
+		redisTemplate.opsForValue().set("updateStudentStatisticsNum:",num++);
 	}
 
 	@Override

+ 8 - 4
mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml

@@ -189,12 +189,14 @@
 	<select id="sumCloudCourseAmount" resultType="java.util.Map">
 		SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
 		LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
-		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0 AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
+		AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
 	</select>
 	<select id="sumCourseAmount" resultType="java.util.Map">
 		SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
 		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
-		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cssp.actual_price_ > 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0 AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
+		AND cssp.actual_price_ > 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
 	</select>
 	<select id="sumPersonalCloudAmount" resultType="java.util.Map">
 		select cto.organ_id_ 'key',TRUNCATE(SUM(operating_amount_ / TIMESTAMPDIFF(DAY,start_time_,end_time_) *
@@ -240,13 +242,15 @@
 	<select id="sumCloudCoursePreAmount" resultType="java.util.Map">
 		SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
 		LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
-		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0 AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_) AND cs.class_date_ > #{lastDay}
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0
+		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_) AND cs.class_date_ > #{lastDay}
 		group by cs.organ_id_;
 	</select>
 	<select id="sumCoursePreAmount" resultType="java.util.Map">
 		SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
 		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
-		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0 AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_) AND cs.class_date_ > #{lastDay}
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.pre_course_flag_ = 0
+		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_) AND cs.class_date_ > #{lastDay}
 		AND cs.group_type_ != 'MUSIC'
 		group by cs.organ_id_;
 	</select>