|
|
@@ -454,6 +454,8 @@ namespace Business.Quartz
|
|
|
return actStart;
|
|
|
}
|
|
|
|
|
|
+ //开始时间往后推到半小时/整点节点
|
|
|
+ actStart = CalcStartTimeAfter(actStart);
|
|
|
//当天的工作日历
|
|
|
var shopCal = curCalendars.Where(p => p.WeekDay == weekDay).First();
|
|
|
//当前日期的工作时间段
|
|
|
@@ -502,6 +504,40 @@ namespace Business.Quartz
|
|
|
return actStart;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 排产开始时间处理为半小时/整点开始--向后取整
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="startTime"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public DateTime CalcStartTimeAfter(DateTime startTime)
|
|
|
+ {
|
|
|
+ DateTime rtnTime = startTime;
|
|
|
+ DateTime curDate = startTime.Date;
|
|
|
+ //时间转换为分钟
|
|
|
+ TimeSpan span = rtnTime - curDate;
|
|
|
+ decimal sumMinutes = (decimal)span.TotalMinutes;
|
|
|
+ int times = (int)Math.Ceiling(sumMinutes / 30);
|
|
|
+ rtnTime = curDate.AddMinutes(times * 30);
|
|
|
+ return rtnTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 排产开始时间处理为半小时/整点开始--向前取整
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="startTime"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public DateTime CalcStartTimeBefore(DateTime startTime)
|
|
|
+ {
|
|
|
+ DateTime rtnTime = startTime;
|
|
|
+ DateTime curDate = startTime.Date;
|
|
|
+ //时间转换为分钟
|
|
|
+ TimeSpan span = rtnTime - curDate;
|
|
|
+ decimal sumMinutes = (decimal)span.TotalMinutes;
|
|
|
+ int times = (int)Math.Floor(sumMinutes / 30);
|
|
|
+ rtnTime = curDate.AddMinutes(times * 30);
|
|
|
+ return rtnTime;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 判断当天是否是工作日
|
|
|
/// </summary>
|
|
|
@@ -557,6 +593,8 @@ namespace Business.Quartz
|
|
|
if (curMins >= needMinute)//当前时间段的可用提前期满足
|
|
|
{
|
|
|
actStart = startTime.AddMinutes((double)-needMinute);
|
|
|
+ //开始时间往前推到半小时/整点节点
|
|
|
+ actStart = CalcStartTimeBefore(actStart);
|
|
|
return actStart;
|
|
|
}
|
|
|
//当前时间段的可用提前期不满足
|
|
|
@@ -577,6 +615,8 @@ namespace Business.Quartz
|
|
|
}
|
|
|
if (!flag)
|
|
|
{
|
|
|
+ //开始时间往前推到半小时/整点节点
|
|
|
+ actStart = CalcStartTimeBefore(actStart);
|
|
|
return actStart;
|
|
|
}
|
|
|
//今天可用提前期不够,往前工作日找
|
|
|
@@ -608,6 +648,8 @@ namespace Business.Quartz
|
|
|
needMinute -= sumWorkMins;
|
|
|
}
|
|
|
}
|
|
|
+ //开始时间往前推到半小时/整点节点
|
|
|
+ actStart = CalcStartTimeBefore(actStart);
|
|
|
return actStart;
|
|
|
}
|
|
|
|