namespace Yw.Service
|
{
|
/// <summary>
|
/// 报修单
|
/// </summary>
|
public partial class RepairRequestForm
|
{
|
private readonly DAL.IRepairRequestForm _dal = DALCreateHelper.CreateDAL<DAL.IRepairRequestForm>();
|
|
#region Query
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
public List<Model.RepairRequestForm> GetAll()
|
{
|
var entity_list = _dal.GetAll();
|
var model_list = Entity2Models(entity_list);
|
return model_list?.OrderByDescending(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public Model.RepairRequestForm GetByID(long ID)
|
{
|
var entity = _dal.GetByID(ID);
|
var model = Entity2Model(entity);
|
return model;
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public List<Model.RepairRequestForm> GetByIds(List<long> Ids)
|
{
|
if (Ids == null || Ids.Count() < 1)
|
return default;
|
var entity_list = _dal.GetByIds(Ids);
|
var model_list = Entity2Models(entity_list);
|
return model_list?.OrderByDescending(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 获取最近列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetLastList(int Number = 1)
|
{
|
var entityList = _dal.GetLastList(Number);
|
var modelList = Entity2Models(entityList);
|
return modelList?.OrderByDescending(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 获取待受理列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetPendingList()
|
{
|
var entityList = _dal.GetPendingList();
|
var modelList = Entity2Models(entityList);
|
return modelList?.OrderByDescending(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 获取待受理数量
|
/// </summary>
|
public int GetPendingCount()
|
{
|
return _dal.GetPendingCount();
|
}
|
|
/// <summary>
|
/// 获取我的模糊分页列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetMyFluzzyPageList
|
(
|
long CreateUserID,
|
eRequestStatus? FormStatus,
|
eUrgency? Urgency,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
Total = 0;
|
if (StartTime > EndTime)
|
{
|
return default;
|
}
|
var entity_list = _dal.GetMyFluzzyPageList(CreateUserID, (int?)FormStatus, (int?)Urgency, StartTime, EndTime, PageIndex, PageSize, ref Total);
|
var model_list = Entity2Models(entity_list);
|
return model_list;
|
}
|
|
/// <summary>
|
/// 获取模糊分页列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetFluzzyPageList
|
(
|
List<long> EquipmentIds,
|
long? CreateUserID,
|
eRequestStatus? FormStatus,
|
eUrgency? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
Total = 0;
|
if (StartTime > EndTime)
|
{
|
return default;
|
}
|
var entity_list = _dal.GetFluzzyPageList(EquipmentIds, CreateUserID, (int?)FormStatus, (int?)Urgency, FormNo, StartTime, EndTime, PageIndex, PageSize, ref Total);
|
var model_list = Entity2Models(entity_list);
|
return model_list;
|
}
|
|
/// <summary>
|
/// 获取设备模糊分页列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetFluzzyPageListOfEquipmentIds
|
(
|
List<long> EquipmentIds,
|
long? CreateUserID,
|
eRequestStatus? FormStatus,
|
eUrgency? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
Total = 0;
|
if (EquipmentIds == null || EquipmentIds.Count < 1)
|
{
|
return default;
|
}
|
if (StartTime > EndTime)
|
{
|
return default;
|
}
|
var entity_list = _dal.GetFluzzyPageListOfEquipmentIds(EquipmentIds, CreateUserID, (int?)FormStatus, (int?)Urgency, FormNo, StartTime, EndTime, PageIndex, PageSize, ref Total);
|
var model_list = Entity2Models(entity_list);
|
return model_list;
|
}
|
|
/// <summary>
|
/// 获取待派单分页列表
|
/// </summary>
|
public List<Tuple<Model.RepairRequestForm, Model.RepairTaskForm>> GetJustAcceptedPageList
|
(
|
List<long> EquipmentIds,
|
long? CreateUserID,
|
eUrgency? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
Total = 0;
|
if (StartTime > EndTime)
|
return default;
|
var entity_list = _dal.GetJustAcceptedPageList(EquipmentIds, CreateUserID, (int?)Urgency, FormNo, StartTime, EndTime, PageIndex, PageSize, ref Total);
|
var model_list = entity_list?.Select(x => new Tuple<Model.RepairRequestForm, Model.RepairTaskForm>(Entity2Model(x.Item1), Entity2Model(x.Item2))).ToList();
|
return model_list;
|
}
|
|
/// <summary>
|
/// 获取设备待派单分页列表
|
/// </summary>
|
public List<Tuple<Model.RepairRequestForm, Model.RepairTaskForm>> GetJustAcceptedPageListOfEquipmentIds
|
(
|
List<long> EquipmentIds,
|
long? CreateUserID,
|
eUrgency? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
Total = 0;
|
if (EquipmentIds == null || EquipmentIds.Count < 1)
|
{
|
return default;
|
}
|
if (StartTime > EndTime)
|
{
|
return default;
|
}
|
var entity_list = _dal.GetJustAcceptedPageListOfEquipmentIds(EquipmentIds, CreateUserID, (int?)Urgency, FormNo, StartTime, EndTime, PageIndex, PageSize, ref Total);
|
var model_list = entity_list?.Select(x => new Tuple<Model.RepairRequestForm, Model.RepairTaskForm>(Entity2Model(x.Item1), Entity2Model(x.Item2))).ToList();
|
return model_list;
|
}
|
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条数据
|
/// </summary>
|
public long Insert(Model.RepairRequestForm model)
|
{
|
if (model == null)
|
{
|
return default;
|
}
|
var entity = Model2Entity(model);
|
var id = _dal.Insert(entity);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入一条数据
|
/// </summary>
|
public long Insert(Model.RepairRequestForm model, List<Model.RepairRequestFile> fileList)
|
{
|
if (model == null)
|
{
|
return default;
|
}
|
|
var entity = Model2Entity(model);
|
|
var entity4FileList = Model2Entities(fileList);
|
var id = _dal.Insert(entity, entity4FileList);
|
return id;
|
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public bool Update(Model.RepairRequestForm model)
|
{
|
if (model == null)
|
{
|
return default;
|
}
|
if (model.ID < 1)
|
{
|
return default;
|
}
|
var entity = Model2Entity(model);
|
var bol = _dal.Update(entity);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
public bool Updates(List<Model.RepairRequestForm> list)
|
{
|
if (list == null || list.Count < 1)
|
{
|
return default;
|
}
|
if (list.ToList().Exists(x => x.ID < 1))
|
{
|
return default;
|
}
|
var entity_list = Model2Entities(list.ToList());
|
var bol = _dal.Updates(entity_list);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新 FormStatus
|
/// </summary>
|
public bool UpdateFormStatus(long ID, eRequestStatus FormStatus)
|
{
|
var bol = _dal.UpdateFormStatus(ID, (int)FormStatus);
|
return bol;
|
}
|
|
/// <summary>
|
/// 驳回
|
/// </summary>
|
public bool Reject(long ID, string Reason)
|
{
|
var bol = _dal.Reject(ID, Reason);
|
return bol;
|
}
|
|
/// <summary>
|
/// 受理
|
/// </summary>
|
public bool Accept(long ID, string Note)
|
{
|
var bol = _dal.Accept(ID, Note);
|
return bol;
|
}
|
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
public bool DeleteByID(long ID, out string Msg)
|
{
|
Msg = string.Empty;
|
var bol = _dal.DeleteByID(ID);
|
return bol;
|
}
|
|
#endregion
|
|
|
}
|
}
|