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