Commit faddee3b authored by 黄奎's avatar 黄奎

新增处理类

parent 08bf293b
...@@ -10,5 +10,9 @@ namespace Edu.Model.ViewModel.Duty ...@@ -10,5 +10,9 @@ namespace Edu.Model.ViewModel.Duty
/// </summary> /// </summary>
public class RB_Duty_Plan_ViewModel : RB_Duty_Plan public class RB_Duty_Plan_ViewModel : RB_Duty_Plan
{ {
/// <summary>
/// 值班详情
/// </summary>
public List<RB_Duty_PlanDetails_ViewModel> PlanDetails { get; set; }
} }
} }
using Edu.Model.ViewModel.Duty;
using Edu.Repository.Duty;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.AOP.CustomerAttribute;
using VT.FW.DB;
namespace Edu.Module.Duty
{
/// <summary>
/// 值班计划处理类
/// </summary>
public class DutyPlanModule
{
/// <summary>
/// 值班计划仓储层对象
/// </summary>
private readonly RB_Duty_PlanRepository duty_PlanRepository = new RB_Duty_PlanRepository();
/// <summary>
/// 值班班次仓储层对象
/// </summary>
private readonly RB_Duty_PlanDetailsRepository duty_PlanDetailsRepository = new RB_Duty_PlanDetailsRepository();
/// <summary>
/// 获取值班计划分页列表【管理端】
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Duty_Plan_ViewModel> GetDutyPlanPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Duty_Plan_ViewModel query)
{
var list = duty_PlanRepository.GetDutyPlanPageRepository(pageIndex, pageSize, out rowsCount, query);
return list;
}
/// <summary>
/// 获取我的值班计划分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Duty_Plan_ViewModel> GetMyDutyPlanPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Duty_Plan_ViewModel query)
{
var list = duty_PlanRepository.GetMyDutyPlanPageRepository(pageIndex, pageSize, out rowsCount, query);
return list;
}
/// <summary>
/// 新增修改值班计划
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[TransactionCallHandler]
public virtual bool SetDutyPlanModule(RB_Duty_Plan_ViewModel model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Duty_Plan_ViewModel.Date), model.Date}
};
flag = duty_PlanRepository.Update(fileds, new WhereHelper(nameof(RB_Duty_Plan_ViewModel.Id), model.Id));
}
else
{
var newId = duty_PlanRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
//原班次列表
var oldPlanDetailsList = duty_PlanDetailsRepository.GetDutyPlanDetailsListRepository(new RB_Duty_PlanDetails_ViewModel()
{
PlanId = model.Id
});
//原没有班次信息
if (oldPlanDetailsList == null || (oldPlanDetailsList != null && oldPlanDetailsList.Count == 0))
{
if (model.PlanDetails != null && model.PlanDetails.Count > 0)
{
foreach (var item in model.PlanDetails)
{
item.PlanId = model.Id;
duty_PlanDetailsRepository.Insert(item);
}
}
}
else
{
//现在没有阶梯报价了【直接删除以前的阶梯报价】
if (model.PlanDetails == null || (model.PlanDetails != null && model.PlanDetails.Count == 0))
{
duty_PlanDetailsRepository.DeletePlanDetailsRepository(model.Id);
}
//找出差异的数据
var deleteList = oldPlanDetailsList.Where(qitem => !model.PlanDetails.Any(oldItem => qitem.Id == oldItem.Id)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.Id > 0)
{
duty_PlanDetailsRepository.Delete(dItem.Id);
}
}
foreach (var item in model.PlanDetails)
{
item.PlanId = model.Id;
if (item.Id == 0)
{
duty_PlanDetailsRepository.Insert(item);
}
else
{
duty_PlanDetailsRepository.Update(item);
}
}
}
return flag;
}
/// <summary>
/// 根据编号获取计划详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Duty_Plan_ViewModel GetDutyPlanModule(int Id)
{
RB_Duty_Plan_ViewModel model = duty_PlanRepository.GetEntity<RB_Duty_Plan_ViewModel>(Id);
if (model != null && model.Id > 0)
{
model.PlanDetails = duty_PlanDetailsRepository.GetDutyPlanDetailsListRepository(new RB_Duty_PlanDetails_ViewModel() { PlanId = model.Id });
}
return model;
}
}
}
...@@ -42,5 +42,16 @@ WHERE 1=1 ...@@ -42,5 +42,16 @@ WHERE 1=1
} }
return Get<RB_Duty_PlanDetails_ViewModel>(builder.ToString()).ToList(); return Get<RB_Duty_PlanDetails_ViewModel>(builder.ToString()).ToList();
} }
/// <summary>
/// 根据计划编号删除班次
/// </summary>
/// <param name="PlanId"></param>
/// <returns></returns>
public bool DeletePlanDetailsRepository(int PlanId)
{
bool flag = base.DeleteOne(new VT.FW.DB.WhereHelper(nameof(RB_Duty_PlanDetails_ViewModel.PlanId), PlanId));
return flag;
}
} }
} }
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