Commit 4c782843 authored by 黄奎's avatar 黄奎

页面修改

parent 971f567e
using System;
using System.Collections.Generic;
using System.Text;
using Edu.Common.Enum.Duty;
using VT.FW.DB;
......@@ -18,7 +16,6 @@ namespace Edu.Model.Entity.Duty
/// </summary>
public int Id { get; set; }
/// <summary>
/// 事项名称
/// </summary>
......@@ -29,7 +26,6 @@ namespace Edu.Model.Entity.Duty
/// </summary>
public ItemTypeEnum? ItemType { get; set; }
/// <summary>
/// 班次
/// </summary>
......@@ -50,7 +46,6 @@ namespace Edu.Model.Entity.Duty
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
......@@ -66,6 +61,9 @@ namespace Edu.Model.Entity.Duty
/// </summary>
public string ItemSchools { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int Status { get; set; }
}
}
......@@ -34,5 +34,10 @@ namespace Edu.Model.ViewModel.Duty
/// 值班人员姓名
/// </summary>
public string DutyManName { get; set; }
/// <summary>
/// 工作清单列表
/// </summary>
public List<RB_Duty_Item_ViewModel> DutyItemList { get; set; }
}
}
......@@ -32,6 +32,11 @@ namespace Edu.Module.Duty
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 值班事项仓储层对象
/// </summary>
private readonly RB_Duty_ItemRepository duty_ItemRepository = new RB_Duty_ItemRepository();
/// <summary>
/// 获取值班计划分页列表【管理端】
/// </summary>
......@@ -73,14 +78,36 @@ namespace Edu.Module.Duty
if (list != null && list.Count > 0)
{
var ids = string.Join(",", list.Select(qitem => qitem.Id));
string schoolIds=string.Join(",", list.Select(qitem => qitem.School_Id));
string shiftIds = "";
List<RB_Duty_PlanDetails_ViewModel> planDetails = new List<RB_Duty_PlanDetails_ViewModel>();
List<RB_Duty_Item_ViewModel> dutyItemList = new List<RB_Duty_Item_ViewModel>();
if (!string.IsNullOrEmpty(ids))
{
planDetails = GetDutyPlanDetailsListModule(new RB_Duty_PlanDetails_ViewModel() { QPlanIds = ids }, IsQueryDutyMan: true);
}
if (planDetails != null && planDetails.Count > 0)
{
shiftIds = string.Join(",", planDetails.Select(qitem => qitem.Shift));
}
if (!string.IsNullOrEmpty(schoolIds) && !string.IsNullOrEmpty(shiftIds))
{
dutyItemList = duty_ItemRepository.GetDutyItemListRepository(new RB_Duty_Item_ViewModel()
{
ItemSchools = schoolIds,
Shifts = shiftIds
});
}
foreach (var item in list)
{
item.PlanDetails = planDetails?.Where(qitem => qitem.PlanId == item.Id)?.ToList() ?? new List<RB_Duty_PlanDetails_ViewModel>();
if (item.PlanDetails != null && item.PlanDetails.Count > 0)
{
foreach (var subItem in item.PlanDetails)
{
subItem.DutyItemList = dutyItemList.Where(qitem => qitem.ItemSchools.Contains(item.School_Id.ToString()) && qitem.Shifts.Contains(subItem.Shift.ToString()))?.ToList() ?? new List<RB_Duty_Item_ViewModel>();
}
}
}
}
return list;
......
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edu.Model.Entity.Duty;
......@@ -7,6 +6,9 @@ using Edu.Model.ViewModel.Duty;
namespace Edu.Repository.Duty
{
/// <summary>
/// 值班事项仓储层
/// </summary>
public class RB_Duty_ItemRepository : BaseRepository<RB_Duty_Item>
{
/// <summary>
......@@ -18,9 +20,11 @@ namespace Edu.Repository.Duty
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT A.*,(SELECT GROUP_CONCAT(SName) from rb_school where `Status`=0 and FIND_IN_SET(SId,a.ItemSchools) GROUP BY `Status`=0) as SchoolName,
(SELECT GROUP_CONCAT(`Name`) from rb_duty_frequency where `Status`=0 and FIND_IN_SET(Id,a.Shifts) GROUP BY `Status`=0) as ShiftsName
FROM RB_Duty_Item AS A WHERE 1=1 ");
builder.AppendFormat(@"
SELECT A.*,(SELECT GROUP_CONCAT(SName) FROM rb_school WHERE `Status`=0 AND FIND_IN_SET(SId,a.ItemSchools) GROUP BY `Status`=0) AS SchoolName
,(SELECT GROUP_CONCAT(Name) FROM rb_duty_frequency WHERE `Status`=0 AND FIND_IN_SET(Id,a.Shifts) GROUP BY `Status`=0) AS ShiftsName
FROM RB_Duty_Item AS A
WHERE 1=1 ");
if (query != null)
{
if (query.Group_Id > 0)
......@@ -31,7 +35,6 @@ namespace Edu.Repository.Duty
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Item_ViewModel.Id), query.Id);
}
if (query.Status >= 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Item_ViewModel.Status), (int)query.Status);
......@@ -39,5 +42,76 @@ namespace Edu.Repository.Duty
}
return Get<RB_Duty_Item_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 获取班次工作清单
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Duty_Item_ViewModel> GetDutyItemListRepository(RB_Duty_Item_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Duty_Item AS A
WHERE 1=1 ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Item_ViewModel.Status), 0);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Duty_Item_ViewModel.Group_Id), query.Group_Id);
}
//班次
if (!string.IsNullOrEmpty(query.Shifts))
{
List<int> shiftList = Common.ConvertHelper.StringToList(query.Shifts);
string str = "";
if (shiftList != null && shiftList.Count > 0)
{
for (var i = 0; i < shiftList.Count; i++)
{
if (i == 0)
{
str += string.Format(" FIND_IN_SET('{0}', A.Shifts)>0 ", shiftList[i]);
}
else
{
str += string.Format(" OR FIND_IN_SET('{0}', A.Shifts)>0 ", shiftList[i]);
}
}
}
if (!string.IsNullOrEmpty(str))
{
builder.AppendFormat(" AND ({0}) ", str);
}
}
//校区
if (!string.IsNullOrEmpty(query.ItemSchools))
{
List<int> schoolList = Common.ConvertHelper.StringToList(query.ItemSchools);
string str = "";
if (schoolList != null && schoolList.Count > 0)
{
for (var i = 0; i < schoolList.Count; i++)
{
if (i == 0)
{
str += string.Format(" FIND_IN_SET('{0}', A.ItemSchools)>0 ", schoolList[i]);
}
else
{
str += string.Format(" OR FIND_IN_SET('{0}', A.ItemSchools)>0 ", schoolList[i]);
}
}
}
if (!string.IsNullOrEmpty(str))
{
builder.AppendFormat(" AND ({0}) ", str);
}
}
}
return Get<RB_Duty_Item_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -63,8 +63,9 @@ WHERE 1=1
rowsCount = 0;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.ID,A.Date
SELECT A.ID,A.Date,IFNULL(C.SName,'') AS SchoolName,A.CreateBy,A.School_Id
FROM RB_Duty_Plan AS A INNER JOIN rb_duty_plandetails AS B ON A.Id=B.PlanId
INNER JOIN rb_school AS C ON A.School_Id=C.SId
WHERE 1=1 AND A.`Status`=0 AND B.`Status`=0
");
if (query == null)
......@@ -82,7 +83,7 @@ WHERE 1=1 AND A.`Status`=0 AND B.`Status`=0
builder.AppendFormat(@" AND B.{0}={1} ", nameof(RB_Duty_PlanDetails_ViewModel.DutyMan), query.QDutyMan);
}
}
builder.AppendFormat(" GROUP BY A.Id,A.Date ");
builder.AppendFormat(" GROUP BY A.Id,A.Date,C.SName,A.CreateBy,A.School_Id ");
builder.AppendFormat(" ORDER BY A.Date ASC ");
return GetPage<RB_Duty_Plan_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
......
......@@ -86,6 +86,7 @@ namespace Edu.WebApi.Controllers.Duty
{
School_Id = base.ParmJObj.GetInt("School_Id")
};
query.QDutyMan = base.UserInfo.Id;
query.Group_Id = base.UserInfo.Group_Id;
List<object> result = new List<object>();
var list = dutyPlanModule.GetMyDutyPlanPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
......@@ -95,22 +96,46 @@ namespace Edu.WebApi.Controllers.Duty
{
item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
}
if (item.UpdateBy > 0)
{
item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
}
//当前班次
var currentModel = new RB_Duty_PlanDetails_ViewModel();
//上一个班次
var previousModel = new RB_Duty_PlanDetails_ViewModel();
//下一个班次
var nextModel=new RB_Duty_PlanDetails_ViewModel();
if (item.PlanDetails != null && item.PlanDetails.Count > 0)
{
//当前值班人员索引
int currentIndex = item.PlanDetails.FindIndex(qitem => qitem.DutyMan == base.UserInfo.Id);
//上一个班次索引
int previousIndex = currentIndex - 1;
//下一个班次索引
int nextIndex = currentIndex + 1;
//当前班次
currentModel = item.PlanDetails[currentIndex];
//上一个班次
if(previousIndex >= 0)
{
previousModel = item.PlanDetails[previousIndex];
}
//下一个班次
if (nextIndex < item.PlanDetails.Count)
{
nextModel= item.PlanDetails[nextIndex];
}
}
result.Add(new
{
item.Id,
PlanDate = Common.ConvertHelper.FormatDate(item.Date),
item.SchoolName,
item.School_Id,
currentModel.ShiftName,
currentModel.StartTime,
currentModel.EndTime,
PlanList= currentModel?.DutyItemList??new List<RB_Duty_Item_ViewModel>(),
ReciveMan=nextModel?.DutyManName??"",
GiveMan=previousModel?.DutyManName??"",
item.CreateByName,
});
}
pageModel.Count = rowsCount;
......
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