Commit 5ea00f2e authored by 黄奎's avatar 黄奎

也没修过

parent b7fef068
......@@ -342,6 +342,29 @@ namespace Edu.Module.Duty
if (model != null && model.Id > 0)
{
model.PlanDetails = GetDutyPlanDetailsListModule(new RB_Duty_PlanDetails_ViewModel() { PlanId = model.Id });
if (model.PlanDetails != null && model.PlanDetails.Count > 0)
{
foreach (var item in model.PlanDetails)
{
//值班状态
DutyStatusEnum dutyStatusEnum = DutyStatusEnum.NoStart;
var startTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + item?.StartTime);
var endTime = Convert.ToDateTime(Common.ConvertHelper.FormatDate(model?.Date) + " " + item?.EndTime);
if (DateTime.Now < startTime)
{
dutyStatusEnum = DutyStatusEnum.NoStart;
}
else if (startTime <= DateTime.Now && DateTime.Now <= endTime)
{
dutyStatusEnum = DutyStatusEnum.DutyIng;
}
else
{
dutyStatusEnum = DutyStatusEnum.DutyFinished;
}
item.DutyStatus = dutyStatusEnum;
}
}
}
return model;
}
......@@ -389,38 +412,22 @@ namespace Edu.Module.Duty
}
return flag;
}
/// <summary>
/// 用户值班
/// </summary>
/// <param name="Id"></param>
/// <param name="user"></param>
/// <param name="Id">值班编号</param>
/// <param name="Shift">值班班次</param>
/// <param name="user">用户信息</param>
/// <param name="isQueryWork">是否查询工作内容-TRUE(查询)</param>
/// <returns></returns>
public object OnDutyModule(int Id, int Shift, UserInfo user)
public Dictionary<string,object> OnDutyModule(int Id, int Shift, UserInfo user,bool isQueryWork=false)
{
object result = new object();
Dictionary<string, object> result = new Dictionary<string, object>();
var model = GetMyDutyPlanPageModule(1, 1, out _, new RB_Duty_Plan_ViewModel() { Id = Id, QDutyMan = user.Id.ToString(), QShift = Shift })?.FirstOrDefault();
if (model == null)
{
return result;
}
//获取所有的值班内容
var contentList = duty_ContentRepository.GetDutyContentListRepository(new RB_Duty_Content_ViewModel() { PlanId = model.Id });
foreach (var item in contentList)
{
if (!string.IsNullOrEmpty(item.FileURL))
{
try
{
item.FileList = Common.Plugin.JsonHelper.DeserializeObject<List<string>>(item.FileURL);
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "OnDutyModule_FileList");
}
}
}
//当前班次
var currentModel = new RB_Duty_PlanDetails_ViewModel();
//上一个班次
......@@ -465,46 +472,68 @@ namespace Edu.Module.Duty
{
dutyStatusEnum = DutyStatusEnum.DutyFinished;
}
var PlanList = currentModel?.DutyItemList ?? new List<RB_Duty_Item_ViewModel>();
List<object> pList = new List<object>();
var currentPlanContetList = contentList.Where(qitem => qitem.PlanShift == Shift && qitem.PlanType == 1)?.ToList();
foreach (var item in PlanList)
{
var c_workModel = currentPlanContetList?.Where(qitem => qitem.ItemId == item.Id)?.FirstOrDefault();
var pObj = new
{
Id = c_workModel?.Id ?? 0,
ItemId =item.Id,
item.ItemName,
item.ItemType,
IsChecked = c_workModel?.WorkIsFinish ?? 0,
WorkContent = c_workModel?.WorkContent ?? "",
};
pList.Add(pObj);
if (!isQueryWork)
{
result.Add("Id", model?.Id);
result.Add("PlanDate", Common.ConvertHelper.FormatDate(model?.Date));
result.Add("WeekDay", Common.ConvertHelper.GetWeekDay(model?.Date));
result.Add("CheckTime", Common.ConvertHelper.FormatTime(currentModel?.CheckTime));
result.Add("FinishTime", Common.ConvertHelper.FormatTime(currentModel?.FinishTime));
result.Add("SchoolName", model?.SchoolName);
result.Add("ShiftName", currentModel?.ShiftName);
result.Add("StartTime", currentModel?.StartTime);
result.Add("EndTime", currentModel?.EndTime);
result.Add("DutyManName", currentModel?.DutyManName);
result.Add("DutyManIcon", currentModel?.DutyManIcon);
result.Add("Status", currentModel?.Status);
result.Add("StatusStr", currentModel?.StatusStr);
}
result = new
else
{
model?.Id,
PlanDate = Common.ConvertHelper.FormatDate(model?.Date),
WeekDay = Common.ConvertHelper.GetWeekDay(model?.Date),
model?.SchoolName,
currentModel?.ShiftName,
currentModel?.StartTime,
currentModel?.EndTime,
currentModel?.DutyManName,
currentModel?.DutyManIcon,
currentModel?.Status,
currentModel?.StatusStr,
WorkList = pList,
var PlanList = currentModel?.DutyItemList ?? new List<RB_Duty_Item_ViewModel>();
//获取所有的值班内容
var contentList = duty_ContentRepository.GetDutyContentListRepository(new RB_Duty_Content_ViewModel() { PlanId = model.Id });
foreach (var item in contentList)
{
if (!string.IsNullOrEmpty(item.FileURL))
{
try
{
item.FileList = Common.Plugin.JsonHelper.DeserializeObject<List<string>>(item.FileURL);
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "OnDutyModule_FileList");
}
}
}
List<object> pList = new List<object>();
var currentPlanContetList = contentList.Where(qitem => qitem.PlanShift == Shift && qitem.PlanType == 1)?.ToList();
foreach (var item in PlanList)
{
var c_workModel = currentPlanContetList?.Where(qitem => qitem.ItemId == item.Id)?.FirstOrDefault();
var pObj = new
{
Id = c_workModel?.Id ?? 0,
ItemId = item.Id,
item.ItemName,
item.ItemType,
IsChecked = c_workModel?.WorkIsFinish ?? 0,
WorkContent = c_workModel?.WorkContent ?? "",
};
pList.Add(pObj);
}
result.Add("WorkList", pList);
//突发事项列表
EmergenciesList = contentList?.Where(qitem => qitem.PlanType == 3)?.ToList() ?? new List<RB_Duty_Content_ViewModel>(),
result.Add("EmergenciesList", contentList?.Where(qitem => qitem.PlanType == 3)?.ToList() ?? new List<RB_Duty_Content_ViewModel>());
//交接事项
HandoverList = contentList?.Where(qitem => qitem.PlanType == 2)?.ToList() ?? new List<RB_Duty_Content_ViewModel>(),
ReciveMan = nextModel?.DutyManName ?? "",
GiveMan = previousModel?.DutyManName ?? "",
DutyStatus = (int)dutyStatusEnum,
DutyStatusStr = Common.Plugin.EnumHelper.ToName(dutyStatusEnum),
};
result.Add("HandoverList", contentList?.Where(qitem => qitem.PlanType == 2)?.ToList() ?? new List<RB_Duty_Content_ViewModel>());
result.Add("ReciveMan", nextModel?.DutyManName ?? "");
result.Add("GiveMan", previousModel?.DutyManName ?? "");
result.Add("DutyStatus", (int)dutyStatusEnum);
result.Add("DutyStatusStr", Common.Plugin.EnumHelper.ToName(dutyStatusEnum));
}
return result;
}
......
......@@ -256,6 +256,19 @@ namespace Edu.WebApi.Controllers.Duty
return ApiResult.Success(data: obj);
}
/// <summary>
/// 用户值班
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetDutyWork()
{
var Id = base.ParmJObj.GetInt("Id");
var Shift = base.ParmJObj.GetInt("Shift");
var obj = dutyPlanModule.OnDutyModule(Id, Shift, base.UserInfo,isQueryWork:true);
return ApiResult.Success(data: obj);
}
/// <summary>
/// 获取值班详情
/// </summary>
......
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