Commit 0d34ba67 authored by 黄奎's avatar 黄奎

新增枚举

parent b0ba828d
using Edu.Common.Plugin;
namespace Edu.Common.Enum.Duty
{
/// <summary>
/// 值班状态枚举
/// </summary>
public enum DutyStatusEnum
{
/// <summary>
/// 选择
/// </summary>
[EnumField("未开始")]
NoStart = 0,
/// <summary>
/// 值班中
/// </summary>
[EnumField("值班中")]
DutyIng = 1,
/// <summary>
/// 值班完成
/// </summary>
[EnumField("值班完成")]
DutyFinished = 2,
}
}
using Edu.Model.Entity.Duty; using Edu.Common.Enum.Duty;
using Edu.Model.Entity.Duty;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
...@@ -50,7 +51,6 @@ namespace Edu.Model.ViewModel.Duty ...@@ -50,7 +51,6 @@ namespace Edu.Model.ViewModel.Duty
/// </summary> /// </summary>
public string StatusStr public string StatusStr
{ {
get get
{ {
string str = "未开始"; string str = "未开始";
...@@ -65,5 +65,22 @@ namespace Edu.Model.ViewModel.Duty ...@@ -65,5 +65,22 @@ namespace Edu.Model.ViewModel.Duty
return str; return str;
} }
} }
/// <summary>
/// 值班状态(见枚举)
/// </summary>
public DutyStatusEnum DutyStatus { get; set; }
/// <summary>
/// 值班状态字符串
/// </summary>
public string DutyStatusStr
{
get
{
string str = Common.Plugin.EnumHelper.ToName(this.DutyStatus);
return str;
}
}
} }
} }
using Edu.Model.Entity.Duty; using Edu.Common.Enum.Duty;
using Edu.Model.Entity.Duty;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
...@@ -42,9 +43,9 @@ namespace Edu.Model.ViewModel.Duty ...@@ -42,9 +43,9 @@ namespace Edu.Model.ViewModel.Duty
/// <summary> /// <summary>
/// 值班状态(0-未开始,1-值班中,2-值班完成) /// 值班状态(见枚举)
/// </summary> /// </summary>
public int DutyStatus { get; set; } public DutyStatusEnum DutyStatus { get; set; }
/// <summary> /// <summary>
/// 值班状态字符串 /// 值班状态字符串
...@@ -53,15 +54,24 @@ namespace Edu.Model.ViewModel.Duty ...@@ -53,15 +54,24 @@ namespace Edu.Model.ViewModel.Duty
{ {
get get
{ {
string str = ""; string str = Common.Plugin.EnumHelper.ToName(this.DutyStatus);
switch (this.DutyStatus)
{
case 0: str = "未开始"; break;
case 1: str = "值班中"; break;
case 2: str = "值班完成"; break;
}
return str; return str;
} }
} }
/// <summary>
/// 校区查询
/// </summary>
public List<int> SchoolIdList { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public string QStartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public string QEndDate { get; set; }
} }
} }
using Edu.Common.Enum; using Edu.Common.Enum;
using Edu.Common.Enum.Duty;
using Edu.Common.Message; using Edu.Common.Message;
using Edu.Model.CacheModel; using Edu.Model.CacheModel;
using Edu.Model.ViewModel.Duty; using Edu.Model.ViewModel.Duty;
...@@ -71,6 +72,40 @@ namespace Edu.Module.Duty ...@@ -71,6 +72,40 @@ namespace Edu.Module.Duty
foreach (var item in list) foreach (var item in list)
{ {
item.PlanDetails = planDetails?.Where(qitem => qitem.PlanId == item.Id)?.ToList() ?? new List<RB_Duty_PlanDetails_ViewModel>(); item.PlanDetails = planDetails?.Where(qitem => qitem.PlanId == item.Id)?.ToList() ?? new List<RB_Duty_PlanDetails_ViewModel>();
item.DutyStatus = 0;
if (item.PlanDetails != null && item.PlanDetails.Count > 0)
{
foreach (var subItem in item.PlanDetails)
{
var startTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(item?.Date) + " " + subItem?.StartTime);
var endTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(item?.Date) + " " + subItem?.EndTime);
if (DateTime.Now < startTime)
{
subItem.DutyStatus = DutyStatusEnum.NoStart;
}
else if (startTime <= DateTime.Now && DateTime.Now <= endTime)
{
subItem.DutyStatus = DutyStatusEnum.DutyIng;
}
else
{
subItem.DutyStatus = DutyStatusEnum.DutyFinished;
}
}
if (item.PlanDetails.Where(qitem => qitem.DutyStatus == DutyStatusEnum.NoStart).Count() == item.PlanDetails.Count)
{
item.DutyStatus = DutyStatusEnum.NoStart;
}
else if (item.PlanDetails.Where(qitem => qitem.DutyStatus == DutyStatusEnum.DutyFinished).Count() == item.PlanDetails.Count)
{
item.DutyStatus = DutyStatusEnum.DutyFinished;
}
else
{
item.DutyStatus = DutyStatusEnum.DutyIng;
}
}
} }
} }
return list; return list;
...@@ -403,24 +438,21 @@ namespace Edu.Module.Duty ...@@ -403,24 +438,21 @@ namespace Edu.Module.Duty
nextModel = model.PlanDetails[nextIndex]; nextModel = model.PlanDetails[nextIndex];
} }
} }
int DutyStatus = 0; //值班状态
string DutyStatusStr = "未开始"; DutyStatusEnum dutyStatusEnum = DutyStatusEnum.NoStart;
var startTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + currentModel?.StartTime); var startTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + currentModel?.StartTime);
var endTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + currentModel?.EndTime); var endTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + currentModel?.EndTime);
if (DateTime.Now < startTime) if (DateTime.Now < startTime)
{ {
DutyStatus = 0; dutyStatusEnum = DutyStatusEnum.NoStart;
DutyStatusStr = "未开始";
} }
else if (startTime <= DateTime.Now && DateTime.Now <= endTime) else if (startTime <= DateTime.Now && DateTime.Now <= endTime)
{ {
DutyStatus = 1; dutyStatusEnum = DutyStatusEnum.DutyIng;
DutyStatusStr = "值班中";
} }
else else
{ {
DutyStatus = 2; dutyStatusEnum = DutyStatusEnum.DutyFinished;
DutyStatusStr = "值班结束";
} }
var PlanList = currentModel?.DutyItemList ?? new List<RB_Duty_Item_ViewModel>(); var PlanList = currentModel?.DutyItemList ?? new List<RB_Duty_Item_ViewModel>();
List<object> pList = new List<object>(); List<object> pList = new List<object>();
...@@ -459,8 +491,8 @@ namespace Edu.Module.Duty ...@@ -459,8 +491,8 @@ namespace Edu.Module.Duty
HandoverList = contentList?.Where(qitem => qitem.PlanType == 2)?.ToList() ?? new List<RB_Duty_Content_ViewModel>(), HandoverList = contentList?.Where(qitem => qitem.PlanType == 2)?.ToList() ?? new List<RB_Duty_Content_ViewModel>(),
ReciveMan = nextModel?.DutyManName ?? "", ReciveMan = nextModel?.DutyManName ?? "",
GiveMan = previousModel?.DutyManName ?? "", GiveMan = previousModel?.DutyManName ?? "",
DutyStatus, DutyStatus = (int)dutyStatusEnum,
DutyStatusStr, DutyStatusStr = Common.Plugin.EnumHelper.ToName(dutyStatusEnum),
}; };
return result; return result;
} }
......
...@@ -127,7 +127,7 @@ namespace Edu.Repository.Duty ...@@ -127,7 +127,7 @@ namespace Edu.Repository.Duty
{ {
builder.AppendFormat(" AND A.{0}<>{1} ", nameof(RB_Duty_Config_ViewModel.Id), query.Id); builder.AppendFormat(" AND A.{0}<>{1} ", nameof(RB_Duty_Config_ViewModel.Id), query.Id);
} }
if (query.School_Id > 0) if (query.School_Id >= 0)
{ {
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Config_ViewModel.School_Id), query.School_Id); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Config_ViewModel.School_Id), query.School_Id);
} }
......
...@@ -45,6 +45,36 @@ WHERE 1=1 ...@@ -45,6 +45,36 @@ WHERE 1=1
{ {
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Duty_Plan_ViewModel.School_Id), query.School_Id); builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Duty_Plan_ViewModel.School_Id), query.School_Id);
} }
if (query.SchoolIdList != null && query.SchoolIdList.Count > 0)
{
string str = "";
if (query.SchoolIdList != null && query.SchoolIdList.Count > 0)
{
for (var i = 0; i < query.SchoolIdList.Count; i++)
{
if (i == 0)
{
str += string.Format(" FIND_IN_SET('{0}', A.School_Id)>0 ", query.SchoolIdList[i]);
}
else
{
str += string.Format(" OR FIND_IN_SET('{0}', A.School_Id)>0 ", query.SchoolIdList[i]);
}
}
}
if (!string.IsNullOrEmpty(str))
{
builder.AppendFormat(" AND ({0}) ", str);
}
}
if (!string.IsNullOrEmpty(query.QStartDate))
{
builder.AppendFormat(@" AND A.{0}>='{1}' ", nameof(RB_Duty_Plan_ViewModel.Date), query.QStartDate);
}
if (!string.IsNullOrEmpty(query.QEndDate))
{
builder.AppendFormat(@" AND A.{0}<='{1} 23:59:59' ", nameof(RB_Duty_Plan_ViewModel.Date), query.QEndDate);
}
} }
builder.AppendFormat(@" ORDER BY A.{0} ASC ", nameof(RB_Duty_Plan_ViewModel.Date)); builder.AppendFormat(@" ORDER BY A.{0} ASC ", nameof(RB_Duty_Plan_ViewModel.Date));
return GetPage<RB_Duty_Plan_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList(); return GetPage<RB_Duty_Plan_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
......
...@@ -423,10 +423,6 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -423,10 +423,6 @@ namespace Edu.WebApi.Controllers.Duty
{ {
return ApiResult.Failed("请选择班次"); return ApiResult.Failed("请选择班次");
} }
if (query.School_Id == 0)
{
return ApiResult.Failed("请选择学校");
}
if (string.IsNullOrWhiteSpace(query.MachineCode)) if (string.IsNullOrWhiteSpace(query.MachineCode))
{ {
return ApiResult.Failed("请输入值班机器码"); return ApiResult.Failed("请输入值班机器码");
...@@ -445,10 +441,10 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -445,10 +441,10 @@ namespace Edu.WebApi.Controllers.Duty
query.UpdateTime = System.DateTime.Now; query.UpdateTime = System.DateTime.Now;
if (dutyModule.CheckDutyConfigModule(query)) if (dutyModule.CheckDutyConfigModule(query))
{ {
ApiResult.Failed("已经存在该校区的配置数据!"); return ApiResult.Failed("已经存在该校区的配置数据!");
} }
bool retult = dutyModule.SetDutyConfigModule(query); bool retult = dutyModule.SetDutyConfigModule(query);
return retult ? ApiResult.Success("新增/修改值班设置成功") : ApiResult.Failed("新增/修改值班设置失败"); return retult ? ApiResult.Success("值班设置成功") : ApiResult.Failed("值班设置失败");
} }
/// <summary> /// <summary>
......
...@@ -34,8 +34,10 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -34,8 +34,10 @@ namespace Edu.WebApi.Controllers.Duty
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString()); var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Duty_Plan_ViewModel() var query = new RB_Duty_Plan_ViewModel()
{ {
School_Id = base.ParmJObj.GetInt("School_Id") QStartDate = base.ParmJObj.GetStringValue("StartDate"),
QEndDate = base.ParmJObj.GetStringValue("EndDate"),
}; };
query.SchoolIdList = Common.Plugin.JsonHelper.DeserializeObject<List<int>>(base.ParmJObj.GetStringValue("School_Ids"));
query.Group_Id = base.UserInfo.Group_Id; query.Group_Id = base.UserInfo.Group_Id;
List<object> result = new List<object>(); List<object> result = new List<object>();
var list = dutyPlanModule.GetDutyPlanPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query); var list = dutyPlanModule.GetDutyPlanPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
...@@ -55,6 +57,8 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -55,6 +57,8 @@ namespace Edu.WebApi.Controllers.Duty
PlanDate = Common.ConvertHelper.FormatDate(item.Date), PlanDate = Common.ConvertHelper.FormatDate(item.Date),
item.SchoolName, item.SchoolName,
item.School_Id, item.School_Id,
item.DutyStatus,
item.DutyStatusStr,
PlanDetails = item?.PlanDetails?.Select(qitem => new PlanDetails = item?.PlanDetails?.Select(qitem => new
{ {
qitem.Id, qitem.Id,
...@@ -64,7 +68,9 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -64,7 +68,9 @@ namespace Edu.WebApi.Controllers.Duty
qitem.StartTime, qitem.StartTime,
qitem.EndTime, qitem.EndTime,
qitem.Shift, qitem.Shift,
qitem.ShiftName qitem.ShiftName,
qitem.DutyStatus,
qitem.DutyStatusStr,
}) })
}); });
} }
...@@ -129,15 +135,15 @@ namespace Edu.WebApi.Controllers.Duty ...@@ -129,15 +135,15 @@ namespace Edu.WebApi.Controllers.Duty
var dutyEndTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(item.Date) + " " + currentModel.EndTime); var dutyEndTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(item.Date) + " " + currentModel.EndTime);
if (DateTime.Now > dutyEndTime) if (DateTime.Now > dutyEndTime)
{ {
item.DutyStatus = 2; item.DutyStatus = Common.Enum.Duty.DutyStatusEnum.DutyFinished;
} }
else if (DateTime.Now >= dutyStartTime && DateTime.Now <= dutyEndTime) else if (DateTime.Now >= dutyStartTime && DateTime.Now <= dutyEndTime)
{ {
item.DutyStatus = 1; item.DutyStatus = Common.Enum.Duty.DutyStatusEnum.DutyIng;
} }
else else
{ {
item.DutyStatus = 0; item.DutyStatus = Common.Enum.Duty.DutyStatusEnum.NoStart;
} }
result.Add(new result.Add(new
{ {
......
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