using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.DAL
|
{
|
/// <summary>
|
/// RepairTaskForm
|
/// </summary>
|
public partial class RepairTaskForm : CorpTraceDAL<Entity.RepairTaskForm>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get
|
{
|
return ConfigHelper.DefaultConnectionConfig;
|
}
|
}
|
|
/// <summary>
|
/// 通过 RequestID 获取
|
/// </summary>
|
public List<Entity.RepairTaskForm> GetByRequestID(long CorpID, long RequestID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RepairTaskForm>()
|
.Where(x => x.CorpID == CorpID && x.RequestID!=null && x.RequestID.Value == RequestID)
|
.OrderBy(x=>x.CreateTime,OrderByType.Desc)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过 RequestIds 获取
|
/// </summary>
|
public List<Entity.RepairTaskForm> GetByRequestIds(long CorpID, List<long> RequestIds)
|
{
|
if (RequestIds == null || RequestIds.Count < 1)
|
return default;
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RepairTaskForm>()
|
.Where(x => x.CorpID == CorpID && x.RequestID!=null && RequestIds.Contains(x.RequestID.Value))
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
public int GetCountByCorpID(long CorpID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RepairTaskForm>()
|
.Where(x => x.CorpID == CorpID)
|
.Count();
|
}
|
}
|
|
/// <summary>
|
/// 通过 CorpID 获取所有未验收的数据
|
/// </summary>
|
public List<Entity.RepairTaskForm> GetUnCheckedByCorpID(long CorpID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RepairTaskForm>()
|
.Where(x => x.CorpID == CorpID &&x.FormStatus<(int)Entity.Repair.eTaskStatus.Succeed)
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.ToList();
|
}
|
}
|
|
/// <summary>
|
/// 获取某日的数量
|
/// </summary>
|
public int GetCountOfDay(long CorpID, DateTime Day)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RepairTaskForm>()
|
.Where(x => x.CorpID == CorpID && x.CreateTime >= Day.Date && x.CreateTime < Day.Date.AddDays(1))
|
.Count();
|
}
|
}
|
|
/// <summary>
|
/// 更新 FormStatus
|
/// </summary>
|
public bool UpdateFormStatus(long CorpID, long ID, int FormStatus, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == FormStatus)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 派单
|
/// </summary>
|
public bool Assign(long CorpID, long ID,long RepairUserID, string Note, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Assigned)
|
.SetColumns(x=>x.RepairUserID == RepairUserID)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Assign;
|
entity4Log.OperateContent = "派单";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 接单
|
/// </summary>
|
public bool Receive(long CorpID, long ID, string Note, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Received)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Receive;
|
entity4Log.OperateContent = "接单";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 开工
|
/// </summary>
|
public bool Start(long CorpID,long ID,string Note, List<Entity.RepairTaskLogFile> entity4FileList,long UpdateUserID,DateTime UpdateTime)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var entity = db.Queryable<Entity.RepairTaskForm>().Where(x => x.CorpID == CorpID && x.ID == ID).First();
|
if (entity == null)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus != (int)Entity.Repair.eTaskStatus.Received)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Started)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Start;
|
entity4Log.OperateContent = "开工";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity4FileList != null && entity4FileList.Count > 0)
|
{
|
entity4FileList.ForEach(x => {
|
x.FormID = ID;
|
x.LogID = logId;
|
});
|
var fileIds = db.Insertable(entity4FileList).ExecuteReturnSnowflakeIdList();
|
if (fileIds == null || fileIds.Count != entity4FileList.Count)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 暂停
|
/// </summary>
|
public bool Pause(long CorpID,long ID,string Note,List<Entity.RepairTaskLogFile> entity4FileList, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var entity = db.Queryable<Entity.RepairTaskForm>().Where(x => x.CorpID == CorpID && x.ID == ID).First();
|
if (entity == null)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus == (int)Entity.Repair.eTaskStatus.Paused)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus < (int)Entity.Repair.eTaskStatus.Started)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus >= (int)Entity.Repair.eTaskStatus.Finished)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Paused)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Pause;
|
entity4Log.OperateContent = "暂停";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity4FileList != null && entity4FileList.Count > 0)
|
{
|
entity4FileList.ForEach(x => {
|
x.FormID = ID;
|
x.LogID = logId;
|
});
|
var fileIds = db.Insertable(entity4FileList).ExecuteReturnSnowflakeIdList();
|
if (fileIds == null || fileIds.Count != entity4FileList.Count)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 重新开工
|
/// </summary>
|
public bool Restart(long CorpID,long ID,string Note,List<Entity.RepairTaskLogFile> entity4FileList, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var entity = db.Queryable<Entity.RepairTaskForm>().Where(x => x.CorpID == CorpID && x.ID == ID).First();
|
if (entity == null)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus != (int)Entity.Repair.eTaskStatus.Paused)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Restarted)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Restart;
|
entity4Log.OperateContent = "重新开工";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity4FileList != null && entity4FileList.Count > 0)
|
{
|
entity4FileList.ForEach(x => {
|
x.FormID = ID;
|
x.LogID = logId;
|
});
|
var fileIds = db.Insertable(entity4FileList).ExecuteReturnSnowflakeIdList();
|
if (fileIds == null || fileIds.Count != entity4FileList.Count)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 完工
|
/// </summary>
|
public bool Finish(long CorpID,long ID, string Note, List<Entity.RepairTaskLogFile> entity4FileList, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var entity = db.Queryable<Entity.RepairTaskForm>().Where(x => x.CorpID == CorpID && x.ID == ID).First();
|
if (entity == null)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity.FormStatus != (int)Entity.Repair.eTaskStatus.Started&&entity.FormStatus!=(int)Entity.Repair.eTaskStatus.Restarted)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Finished)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Finish;
|
entity4Log.OperateContent = "完工";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
if (entity4FileList != null && entity4FileList.Count > 0)
|
{
|
entity4FileList.ForEach(x => {
|
x.FormID = ID;
|
x.LogID = logId;
|
});
|
var fileIds = db.Insertable(entity4FileList).ExecuteReturnSnowflakeIdList();
|
if (fileIds == null || fileIds.Count != entity4FileList.Count)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 验收通过
|
/// </summary>
|
public bool Success(long CorpID, long ID, string Note, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var bol = db.Updateable<Entity.RepairTaskForm>()
|
.SetColumns(x => x.FormStatus == (int)Entity.Repair.eTaskStatus.Succeed)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.CorpID == CorpID && x.ID == ID)
|
.ExecuteCommand() > 0;
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
var entity4Log = new Entity.RepairTaskLog();
|
entity4Log.CorpID = CorpID;
|
entity4Log.FormID = ID;
|
entity4Log.OperateType = (int)Entity.Repair.eTaskOperateType.Success;
|
entity4Log.OperateContent = "验收通过";
|
entity4Log.OperateTime = UpdateTime;
|
entity4Log.OperateUserID = UpdateUserID;
|
entity4Log.OperateNote = Note;
|
var logId = db.Insertable(entity4Log).ExecuteReturnSnowflakeId();
|
if (logId < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 获取模糊列表
|
/// </summary>
|
public List<Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>> GetFluzzyList
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? ProductID,
|
long? RepairUserID,
|
int? FormStatus,
|
int? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime
|
)
|
{
|
var exp = Expressionable.Create<Entity.RepairTaskForm, Entity.RepairRequestForm>();
|
exp.And((x, y) => x.CorpID == CorpID);
|
exp.AndIF(!string.IsNullOrEmpty(BelongType), (x, y) => x.BelongType == BelongType);
|
exp.AndIF(BelongID.HasValue, (x, y) => x.BelongID == BelongID);
|
exp.AndIF(ProductID.HasValue, (x, y) => x.ProductID == ProductID);
|
exp.AndIF(RepairUserID.HasValue, (x, y) => x.RepairUserID.Value == RepairUserID.Value);
|
exp.AndIF(FormStatus.HasValue, (x, y) => x.FormStatus == FormStatus.Value);
|
exp.AndIF(Urgency.HasValue, (x, y) => x.Urgency == Urgency.Value);
|
exp.AndIF(!string.IsNullOrEmpty(FormNo), (x, y) => x.FormNo.Contains(FormNo));
|
exp.AndIF(StartTime.HasValue, (x, y) => x.CreateTime >= StartTime.Value);
|
exp.AndIF(EndTime.HasValue, (x, y) => x.CreateTime <= EndTime.Value);
|
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
var list = db.Queryable<Entity.RepairTaskForm>()
|
.LeftJoin<Entity.RepairRequestForm>((x, y) => x.RequestID == y.ID)
|
.Where(exp.ToExpression())
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.Select((x, y) => new { x, y })
|
.ToList();
|
return list?.Select(x => new Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>(x.x, x.y)).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 获取分页列表
|
/// </summary>
|
public List<Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>> GetPageList
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? ProductID,
|
long? RepairUserID,
|
int? FormStatus,
|
int? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
if (PageIndex < 1)
|
PageIndex = 1;
|
if (PageSize < 1)
|
PageSize = 1;
|
var exp = Expressionable.Create<Entity.RepairTaskForm, Entity.RepairRequestForm>();
|
exp.And((x, y) => x.CorpID == CorpID);
|
exp.AndIF(!string.IsNullOrEmpty(BelongType), (x, y) => x.BelongType == BelongType);
|
exp.AndIF(BelongID.HasValue, (x, y) => x.BelongID == BelongID);
|
exp.AndIF(ProductID.HasValue, (x, y) => x.ProductID == ProductID);
|
exp.AndIF(RepairUserID.HasValue, (x, y) => x.RepairUserID.Value == RepairUserID.Value);
|
exp.AndIF(FormStatus.HasValue, (x, y) => x.FormStatus == FormStatus.Value);
|
exp.AndIF(Urgency.HasValue, (x, y) => x.Urgency == Urgency.Value);
|
exp.AndIF(!string.IsNullOrEmpty(FormNo), (x, y) => x.FormNo.Contains(FormNo));
|
exp.AndIF(StartTime.HasValue, (x, y) => x.CreateTime >= StartTime.Value);
|
exp.AndIF(EndTime.HasValue, (x, y) => x.CreateTime <= EndTime.Value);
|
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
var list= db.Queryable<Entity.RepairTaskForm>()
|
.LeftJoin<Entity.RepairRequestForm>((x, y) => x.RequestID == y.ID)
|
.Where(exp.ToExpression())
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.Select((x, y) => new { x,y})
|
.ToPageList(PageIndex, PageSize, ref Total);
|
return list?.Select(x => new Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>(x.x, x.y)).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 获取进行中的分页列表
|
/// </summary>
|
public List<Tuple<Entity.RepairTaskForm,Entity.RepairRequestForm>> GetProgressPageList
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? ProductID,
|
long? RepairUserID,
|
int? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
if (PageIndex < 1)
|
PageIndex = 1;
|
if (PageSize < 1)
|
PageSize = 1;
|
var exp = Expressionable.Create<Entity.RepairTaskForm, Entity.RepairRequestForm>();
|
exp.And((x, y) => x.CorpID == CorpID);
|
exp.AndIF(!string.IsNullOrEmpty(BelongType), (x, y) => x.BelongType == BelongType);
|
exp.AndIF(BelongID.HasValue, (x, y) => x.BelongID == BelongID);
|
exp.AndIF(ProductID.HasValue, (x, y) => x.ProductID == ProductID);
|
exp.AndIF(RepairUserID.HasValue, (x, y) => x.RepairUserID.Value == RepairUserID.Value);
|
exp.And((x,y)=>x.FormStatus>=(int)Entity.Repair.eTaskStatus.Received&&x.FormStatus<(int)Entity.Repair.eTaskStatus.Finished);
|
exp.AndIF(Urgency.HasValue, (x, y) => x.Urgency == Urgency.Value);
|
exp.AndIF(!string.IsNullOrEmpty(FormNo), (x, y) => x.FormNo.Contains(FormNo));
|
exp.AndIF(StartTime.HasValue, (x, y) => x.CreateTime >= StartTime.Value);
|
exp.AndIF(EndTime.HasValue, (x, y) => x.CreateTime <= EndTime.Value);
|
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
var list = db.Queryable<Entity.RepairTaskForm>()
|
.LeftJoin<Entity.RepairRequestForm>((x, y) => x.RequestID == y.ID)
|
.Where(exp.ToExpression())
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.Select((x, y) => new { x, y })
|
.ToPageList(PageIndex, PageSize, ref Total);
|
return list?.Select(x => new Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>(x.x, x.y)).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 获取已完成的分页列表
|
/// </summary>
|
public List<Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>> GetHasFinishedPageList
|
(
|
long CorpID,
|
string BelongType,
|
long? BelongID,
|
long? ProductID,
|
long? RepairUserID,
|
int? Urgency,
|
string FormNo,
|
DateTime? StartTime,
|
DateTime? EndTime,
|
int PageIndex,
|
int PageSize,
|
ref int Total
|
)
|
{
|
if (PageIndex < 1)
|
PageIndex = 1;
|
if (PageSize < 1)
|
PageSize = 1;
|
var exp = Expressionable.Create<Entity.RepairTaskForm, Entity.RepairRequestForm>();
|
exp.And((x, y) => x.CorpID == CorpID);
|
exp.AndIF(!string.IsNullOrEmpty(BelongType), (x, y) => x.BelongType == BelongType);
|
exp.AndIF(BelongID.HasValue, (x, y) => x.BelongID == BelongID);
|
exp.AndIF(ProductID.HasValue, (x, y) => x.ProductID == ProductID);
|
exp.AndIF(RepairUserID.HasValue, (x, y) => x.RepairUserID.Value == RepairUserID.Value);
|
exp.And((x, y) => x.FormStatus >= (int)Entity.Repair.eTaskStatus.Finished );
|
exp.AndIF(Urgency.HasValue, (x, y) => x.Urgency == Urgency.Value);
|
exp.AndIF(!string.IsNullOrEmpty(FormNo), (x, y) => x.FormNo.Contains(FormNo));
|
exp.AndIF(StartTime.HasValue, (x, y) => x.CreateTime >= StartTime.Value);
|
exp.AndIF(EndTime.HasValue, (x, y) => x.CreateTime <= EndTime.Value);
|
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
var list = db.Queryable<Entity.RepairTaskForm>()
|
.LeftJoin<Entity.RepairRequestForm>((x, y) => x.RequestID == y.ID)
|
.Where(exp.ToExpression())
|
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
.Select((x, y) => new { x, y })
|
.ToPageList(PageIndex, PageSize, ref Total);
|
return list?.Select(x => new Tuple<Entity.RepairTaskForm, Entity.RepairRequestForm>(x.x, x.y)).ToList();
|
}
|
}
|
|
|
|
|
}
|
}
|