Commit a0dcb77f authored by 黄奎's avatar 黄奎

新增定时器

parent 0e48510b
...@@ -5571,5 +5571,52 @@ namespace Edu.Module.Course ...@@ -5571,5 +5571,52 @@ namespace Edu.Module.Course
} }
} }
} }
/// <summary>
/// 处理学生上课进度
/// </summary>
public void DealStudentCourseChapterNoModule()
{
string toDay = Common.ConvertHelper.FormatDate(DateTime.Now.AddDays(-1));
var planList = class_PlanRepository.GetClassPlanListExtRepository(new RB_Class_Plan_ViewModel() {
StartTime = toDay,
EndTime = toDay,
PlanType = 1
});
List<RB_Order_Guest_ViewModel> guestList = new List<RB_Order_Guest_ViewModel>();
if (planList != null && planList.Count > 0)
{
string classIds = string.Join(",", planList.Select(qitem => qitem.ClassId));
if (!string.IsNullOrEmpty(classIds))
{
guestList = order_GuestRepository.GetOrderGuestListRepository(new RB_Order_Guest_ViewModel()
{
ClassIds = classIds
});
}
}
if (guestList != null && guestList.Count > 0)
{
foreach (var item in guestList)
{
var tempPlanList = planList.Where(qitem => qitem.ClassId == item.ClassId)?.ToList();
decimal times = 0;
if (tempPlanList != null && tempPlanList.Count > 0)
{
times = tempPlanList.Sum(qitem => qitem.TimeHour) / 2;
}
if (times > 0)
{
var tempCourseChapterNo = item.CourseChapterNo + times;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Order_Guest_ViewModel.CourseChapterNo), tempCourseChapterNo}
};
//order_GuestRepository.Update(fileds, new WhereHelper(nameof(RB_Order_Guest_ViewModel.Id), item.Id));
}
}
}
}
} }
} }
\ No newline at end of file
...@@ -830,10 +830,28 @@ namespace Edu.Module.Customer ...@@ -830,10 +830,28 @@ namespace Edu.Module.Customer
var CurMonthFollow = tempDataList?.Sum(qitem => qitem.CurMonthFollow) ?? 0; var CurMonthFollow = tempDataList?.Sum(qitem => qitem.CurMonthFollow) ?? 0;
var LastMonthFollow = tempDataList?.Sum(qitem => qitem.LastMonthFollow) ?? 0; var LastMonthFollow = tempDataList?.Sum(qitem => qitem.LastMonthFollow) ?? 0;
var AgFollow = Math.Round(yesDataList?.Average(qitem => qitem.AgFollow) ?? 0, 2); decimal AgFollow = 0;
var YestodayAgFollow = Math.Round(yesDataList?.Average(qitem => qitem.YestodayAgFollow) ?? 0, 2); if (yesDataList != null && yesDataList.Where(qitem=>qitem.AgFollow>0).Count() > 0)
var CurWeekAgFollow = Math.Round(curWeekList?.Average(qitem => qitem.CurWeekAgFollow) ?? 0, 2); {
var LastWeekAgFollow = Math.Round(lastWeekList?.Average(qitem => qitem.LastWeekAgFollow) ?? 0, 2); AgFollow = Math.Round(yesDataList?.Average(qitem => qitem.AgFollow) ?? 0, 2);
}
decimal YestodayAgFollow = 0;
if (yesDataList != null && yesDataList.Where(qitem => qitem.YestodayAgFollow > 0).Count() > 0)
{
YestodayAgFollow= Math.Round(yesDataList?.Average(qitem => qitem.YestodayAgFollow) ?? 0, 2);
}
decimal CurWeekAgFollow = 0;
if (yesDataList != null && yesDataList.Where(qitem => qitem.CurWeekAgFollow > 0).Count() > 0)
{
CurWeekAgFollow= Math.Round(curWeekList?.Average(qitem => qitem.CurWeekAgFollow) ?? 0, 2);
}
decimal LastWeekAgFollow = 0;
Math.Round(lastWeekList?.Average(qitem => qitem.LastWeekAgFollow) ?? 0, 2);
decimal CurMonthAgFollow = 0; decimal CurMonthAgFollow = 0;
decimal LastMonthAgFollow = 0; decimal LastMonthAgFollow = 0;
if (tempDataList != null && tempDataList.Count > 0) if (tempDataList != null && tempDataList.Count > 0)
......
...@@ -75,6 +75,10 @@ WHERE 1=1 ...@@ -75,6 +75,10 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND IFNULL(A.{0},'')<>'' ", nameof(RB_Class_Plan_ViewModel.RepeatPlanIds)); builder.AppendFormat(" AND IFNULL(A.{0},'')<>'' ", nameof(RB_Class_Plan_ViewModel.RepeatPlanIds));
} }
if (query.PlanType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.PlanType), query.PlanType);
}
} }
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList(); return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
} }
...@@ -123,10 +127,6 @@ WHERE 1=1 AND C.`Status`=0 AND C.ClassStatus<>3 ...@@ -123,10 +127,6 @@ WHERE 1=1 AND C.`Status`=0 AND C.ClassStatus<>3
{ {
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.TeacherId), query.TeacherId); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.TeacherId), query.TeacherId);
} }
//if (query.School_Id > 0)
//{
// builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.School_Id), query.School_Id);
//}
if (query.ClassTimeId > 0) if (query.ClassTimeId > 0)
{ {
builder.AppendFormat(" AND time.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassTimeId), query.ClassTimeId); builder.AppendFormat(" AND time.{0}={1} ", nameof(RB_Class_Plan_ViewModel.ClassTimeId), query.ClassTimeId);
...@@ -151,6 +151,10 @@ WHERE 1=1 AND C.`Status`=0 AND C.ClassStatus<>3 ...@@ -151,6 +151,10 @@ WHERE 1=1 AND C.`Status`=0 AND C.ClassStatus<>3
{ {
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y/%m/%d')= DATE_FORMAT('{1}','%y/%m/%d') ", nameof(RB_Class_Plan_ViewModel.ClassDate), query.QClassDateStr); builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y/%m/%d')= DATE_FORMAT('{1}','%y/%m/%d') ", nameof(RB_Class_Plan_ViewModel.ClassDate), query.QClassDateStr);
} }
if (query.PlanType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.PlanType), query.PlanType);
}
} }
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList(); return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
} }
......
...@@ -175,10 +175,7 @@ WHERE 1=1 AND A.Status=0 ...@@ -175,10 +175,7 @@ WHERE 1=1 AND A.Status=0
{ {
builder.AppendFormat($@" AND A.{nameof(RB_Order_Guest_ViewModel.Group_Id)} ={demodel.Group_Id}"); builder.AppendFormat($@" AND A.{nameof(RB_Order_Guest_ViewModel.Group_Id)} ={demodel.Group_Id}");
} }
//if (demodel.School_Id > 0)
//{
// builder.AppendFormat($@" AND A.{nameof(RB_Order_Guest_ViewModel.School_Id)} ={demodel.School_Id}");
//}
if (demodel.OrderId > 0) if (demodel.OrderId > 0)
{ {
builder.AppendFormat($@" AND A.{nameof(RB_Order_Guest_ViewModel.OrderId)} ={demodel.OrderId}"); builder.AppendFormat($@" AND A.{nameof(RB_Order_Guest_ViewModel.OrderId)} ={demodel.OrderId}");
......
...@@ -41,6 +41,11 @@ namespace Edu.WebApi.Timers ...@@ -41,6 +41,11 @@ namespace Edu.WebApi.Timers
/// </summary> /// </summary>
private static readonly PaperModule paperModule = new PaperModule(); private static readonly PaperModule paperModule = new PaperModule();
/// <summary>
/// 班级处理类对象
/// </summary>
private static readonly ClassModule classModule = new ClassModule();
/// <summary> /// <summary>
/// 使用redis第几号库 /// 使用redis第几号库
/// </summary> /// </summary>
...@@ -48,6 +53,7 @@ namespace Edu.WebApi.Timers ...@@ -48,6 +53,7 @@ namespace Edu.WebApi.Timers
static readonly RedisHelper redis = new RedisHelper(REDIS_DB3); static readonly RedisHelper redis = new RedisHelper(REDIS_DB3);
/// <summary> /// <summary>
/// 课程顾问部和市场部数据统计 /// 课程顾问部和市场部数据统计
/// </summary> /// </summary>
...@@ -69,11 +75,13 @@ namespace Edu.WebApi.Timers ...@@ -69,11 +75,13 @@ namespace Edu.WebApi.Timers
static System.Timers.Timer marketTimer;//处理市场部和课程顾问部数据统计 static System.Timers.Timer marketTimer;//处理市场部和课程顾问部数据统计
static System.Timers.Timer dealStudentProgressTimer;//处理学员上课进度
public static void RunTimer() public static void RunTimer()
{ {
timer1 = new System.Timers.Timer timer1 = new System.Timers.Timer
{ {
Interval = (1000 * 60) * (60 * 3) //3销售 Interval = (1000 * 60) * (60 * 3) //3小时执行一次
}; };
timer1.Elapsed += new System.Timers.ElapsedEventHandler(ClearFile); timer1.Elapsed += new System.Timers.ElapsedEventHandler(ClearFile);
timer1.Enabled = true; timer1.Enabled = true;
...@@ -123,10 +131,17 @@ namespace Edu.WebApi.Timers ...@@ -123,10 +131,17 @@ namespace Edu.WebApi.Timers
marketTimer = new System.Timers.Timer() marketTimer = new System.Timers.Timer()
{ {
Interval = (1000 * 60) * (1) //1小时检查一次 Interval = (1000 * 60) * (60 * 1) //1小时
}; };
marketTimer.Elapsed += new System.Timers.ElapsedEventHandler(DealMarketConsultantData); marketTimer.Elapsed += new System.Timers.ElapsedEventHandler(DealMarketConsultantData);
marketTimer.Enabled = true; marketTimer.Enabled = true;
dealStudentProgressTimer = new System.Timers.Timer()
{
Interval = (1000 * 60) * (60*1) //1小时检查一次
};
dealStudentProgressTimer.Elapsed += new System.Timers.ElapsedEventHandler(DealStudentProgressModule);
dealStudentProgressTimer.Enabled = true;
} }
public static void RunStop() public static void RunStop()
...@@ -139,6 +154,7 @@ namespace Edu.WebApi.Timers ...@@ -139,6 +154,7 @@ namespace Edu.WebApi.Timers
examTimer.Enabled = false; examTimer.Enabled = false;
finishGuest.Enabled = false; finishGuest.Enabled = false;
marketTimer.Enabled = false; marketTimer.Enabled = false;
dealStudentProgressTimer.Enabled = false;
} }
/// <summary> /// <summary>
...@@ -152,9 +168,26 @@ namespace Edu.WebApi.Timers ...@@ -152,9 +168,26 @@ namespace Edu.WebApi.Timers
private static int examPublish_Timer = 0; private static int examPublish_Timer = 0;
private static int guestfinish_Timer = 0; private static int guestfinish_Timer = 0;
private static int marketconsultant_Timer = 0; private static int marketconsultant_Timer = 0;
private static int dealstudentprogress_Timer = 0;
private static readonly string createMarkDataKey = "createMarkDataKey";
/// <summary>
/// 处理学员上课进度
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void DealStudentProgressModule(object sender, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.Exchange(ref dealstudentprogress_Timer, 1) == 0)
{
classModule.DealStudentCourseChapterNoModule();
//处理学员进度
Interlocked.Exchange(ref dealstudentprogress_Timer, 0);
}
}
private static string createMarkDataKey = "createMarkDataKey";
/// <summary> /// <summary>
/// 定时生成市场部和课程顾问部数据统计 /// 定时生成市场部和课程顾问部数据统计
/// </summary> /// </summary>
...@@ -162,7 +195,7 @@ namespace Edu.WebApi.Timers ...@@ -162,7 +195,7 @@ namespace Edu.WebApi.Timers
/// <param name="e"></param> /// <param name="e"></param>
public static void DealMarketConsultantData(object sender, System.Timers.ElapsedEventArgs e) public static void DealMarketConsultantData(object sender, System.Timers.ElapsedEventArgs e)
{ {
if (Interlocked.Exchange(ref marketconsultant_Timer,1) == 0) if (Interlocked.Exchange(ref marketconsultant_Timer, 1) == 0)
{ {
var currentDate = DateTime.Now; var currentDate = DateTime.Now;
string cacheData = redis.Get(createMarkDataKey); string cacheData = redis.Get(createMarkDataKey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment