using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
/// 报修单
|
/// </summary>
|
public partial class RepairRequestForm
|
{
|
private readonly DAL.RepairRequestForm _dal = new DAL.RepairRequestForm();
|
|
#region Query
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
public List<Model.RepairRequestForm> GetByCorpID(long CorpID)
|
{
|
var entity_list = _dal.GetByCorpID(CorpID);
|
var model_list = Entity2Models(entity_list);
|
return model_list;
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取待受理数量
|
/// </summary>
|
public int GetPendingCountByCorpID(long CorpID)
|
{
|
return _dal.GetPendingCountByCorpID(CorpID);
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取最近几条
|
/// </summary>
|
public List<Model.RepairRequestForm> GetLastByCorpID(long CorpID, int Number)
|
{
|
var entityList = _dal.GetLastByCorpID(CorpID,Number);
|
var modelList = Entity2Models(entityList);
|
return modelList?.OrderByDescending(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public Model.RepairRequestForm GetByID(long CorpID, long ID)
|
{
|
var entity = _dal.GetByID(CorpID, ID);
|
var model = Entity2Model(entity);
|
return model;
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public List<Model.RepairRequestForm> GetByIds(long CorpID, List<long> Ids)
|
{
|
if (Ids == null || Ids.Count() < 1)
|
return default;
|
var entity_list = _dal.GetByIds(CorpID, Ids);
|
var model_list = Entity2Models(entity_list);
|
return model_list?.OrderBy(x => x.CreateTime).ToList();
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取待受理
|
/// </summary>
|
public List<Model.RepairRequestForm> GetPendingByCorpID(long CorpID)
|
{
|
var entityList = _dal.GetPendingByCorpID(CorpID);
|
var modelList = Entity2Models(entityList);
|
return modelList;
|
}
|
|
/// <summary>
|
/// 获取我的模糊分页列表
|
/// </summary>
|
public List<Model.RepairRequestForm> GetMyFluzzyPageList
|
(
|
long CorpID,
|
long CreateUserID,
|
Model.Repair.eRequestStatus? FormStatus,
|
Model.Repair.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(CorpID, 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
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? CreateUserID,
|
Model.Repair.eRequestStatus? FormStatus,
|
Model.Repair.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(CorpID,BelongType,BelongID, 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
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? CreateUserID,
|
Model.Repair.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.GetJustAccepedPageList(CorpID, BelongType, BelongID, 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;
|
if (model.CorpID < 1)
|
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;
|
if (model.CorpID < 1)
|
return default;
|
|
var entity = Model2Entity(model);
|
|
var entity4Log = new Entity.RepairRequestLog();
|
entity4Log.CorpID = model.CorpID;
|
entity4Log.OperateType = (int)Model.Repair.eRequestOperateType.Create;
|
entity4Log.OperateContent = "创建";
|
entity4Log.OperateTime = model.CreateTime;
|
entity4Log.OperateUserID = model.CreateUserID;
|
|
var entity4FileList = Model2Entities(fileList);
|
var id = _dal.Insert(entity, entity4Log, entity4FileList);
|
return id;
|
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public bool Update(Model.RepairRequestForm model)
|
{
|
if (model == null)
|
return default;
|
if (model.CorpID < 1)
|
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;
|
var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
|
if (corpIds.Count != 1 || corpIds[0] < 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>
|
/// 更新文件状态
|
/// </summary>
|
public bool UpdateFileStatus(long CorpID, long ID, Model.Repair.eRequestStatus FormStatus, long UpdateUserID, DateTime UpdateTime)
|
{
|
var bol = _dal.UpdateFormStatus(CorpID, ID, (int)FormStatus, UpdateUserID, UpdateTime);
|
return bol;
|
}
|
|
/// <summary>
|
/// 驳回
|
/// </summary>
|
public bool Reject(long CorpID, long ID, string Reason, long UpdateUserID, DateTime UpdateTime)
|
{
|
var bol = _dal.Reject(CorpID,ID,Reason,UpdateUserID,UpdateTime);
|
return bol;
|
}
|
|
/// <summary>
|
/// 受理
|
/// </summary>
|
public bool Accept(long CorpID, long ID,string Note, long UpdateUserID, DateTime UpdateTime)
|
{
|
var bol = _dal.Accept(CorpID, ID,Note, UpdateUserID, UpdateTime);
|
return bol;
|
}
|
|
|
#endregion
|
|
#region Exist
|
|
/// <summary>
|
/// 根据 ID 判断是否存在
|
/// </summary>
|
public bool IsExistByID(long CorpID, long ID)
|
{
|
var all = GetByCorpID(CorpID);
|
return all.Exists(x => x.ID == ID);
|
}
|
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
public bool DeleteByID(long CorpID, long ID, out string Msg)
|
{
|
Msg = string.Empty;
|
var dal = new DAL.RepairRequestForm();
|
var bol = dal.DeleteByID(CorpID, ID);
|
return bol;
|
}
|
|
#endregion
|
|
|
}
|
}
|