using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using Model.ModelDto.LogDto;
|
using SqlSugar;
|
using WMS.DAL;
|
using WMS.Entity.Context;
|
using WMS.Entity.LogEntity;
|
using WMS.Entity.SysEntity;
|
using WMS.IBLL.ILogServer;
|
|
namespace WMS.BLL.LogServer
|
{
|
public class OperationCrServer: DbHelper<LogOperationCR>,IOperationCRServer
|
{
|
private static readonly SqlSugarScope Db = DataContext.Db;
|
public OperationCrServer() : base(Db)
|
{
|
}
|
public List<OperationDto> GetLogOperationCrList(string menuName, string type, string msg, string startTime, string endTime, int page, int limit, out int count)
|
{
|
try
|
{
|
var item = Expressionable.Create<LogOperationCR>()
|
.AndIF(!string.IsNullOrWhiteSpace(menuName), it => it.MenuName.Contains(menuName.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(type), it => it.Type == type)
|
.AndIF(!string.IsNullOrWhiteSpace(msg), it => it.Msg.Contains(msg.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(startTime), it => it.CreateTime >= Convert.ToDateTime(startTime))
|
.AndIF(!string.IsNullOrWhiteSpace(endTime), it => it.CreateTime <= Convert.ToDateTime(endTime).AddDays(1))
|
.ToExpression();//注意 这一句 不能少
|
var total = 0;
|
var list = GetAllWhereAsync(item)
|
.LeftJoin<SysDictionary>((it, dic) => it.Type == dic.Id.ToString())
|
.LeftJoin<SysUserInfor>((it, dic, users) => it.CreateUser == users.Id)
|
.Select((it, dic, users) => new OperationDto()
|
{
|
Id = it.Id,
|
ParentNo = it.ParentNo,
|
MenuNo = it.MenuNo,
|
MenuName = it.MenuName,
|
FkNo = it.FkNo,
|
Type = dic.DictName,
|
Msg = it.Msg,
|
CreateTime = it.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
CreateUserName = users.RealName,
|
})
|
.OrderByDescending(it => it.CreateTime)
|
.ToOffsetPage(page, limit, ref total);
|
|
count = total;
|
return list.OrderByDescending(m => m.CreateTime).ToList();
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
|
public bool AddLogOperationCr(string parentNo, string menuName, string fkNo, string type, string msg, int userId)
|
{
|
try
|
{
|
var contextDb = DataContext.Db;
|
var menu = contextDb.Queryable<SysFunctionMenu>().Where(m => m.IsDel == "0").ToList();
|
var dic = contextDb.Queryable<SysDictionary>().Where(m => m.ParentNo == "LogType" && m.IsDel == "0").ToList();
|
var typeId = dic.FirstOrDefault(m => m.DictName == type);
|
|
var n = Add(new LogOperationCR()
|
{
|
ParentNo = menu.FirstOrDefault(m => m.MenuName == parentNo) == null ? "" : menu.First(m => m.MenuName == parentNo).MenuNo,
|
MenuNo = menu.FirstOrDefault(m => m.MenuName == menuName) == null ? "" : menu.First(m => m.MenuName == menuName).MenuNo,
|
MenuName = $"{parentNo}-{menuName}",
|
FkNo = fkNo,
|
Type = typeId == null ? "" : typeId.Id.ToString(),
|
Msg = msg,
|
|
CreateUser = userId
|
});
|
return n > 0;
|
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
}
|
}
|