You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

838 lines
31 KiB
C#

using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;
using System.Runtime.InteropServices;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.UserModule;
using DS.WMS.Common.Enum;
using DS.WMS.Core.BaseInfo.Dtos;
using DS.WMS.Core.BaseInfo.Entity;
using DS.WMS.Core.ContractModule.Entity;
using DS.WMS.Core.FeeModule.Entity;
using DS.WMS.Core.OpenApiModule.Entity;
using DS.WMS.Core.SecurityModule.Entity;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using DS.WMS.Core.WmsModule.Entity;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using UAParser;
namespace DS.WMS.Core.System.Method;
/// <summary>
/// 公共服务
/// </summary>
public class CommonService : ICommonService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly IHttpContextAccessor IhttpContext;
private readonly IWebHostEnvironment _environment;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public CommonService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
IhttpContext = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
_environment = _serviceProvider.GetRequiredService<IWebHostEnvironment>();
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult<string> UserLogin(UserLoginModel model)
{
var userInfo = db.Queryable<SysUser>().Filter(null, true)
.First(x => x.UserCode == model.UserName);
if (userInfo == null)
{
return DataResult<string>.Failed("账号不存在,请检查!");
}
if (userInfo.MD5Password != model.Password)
{
return DataResult<string>.Failed("密码错误!");
}
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = userInfo.Id.ToString(),
CompanyId = userInfo.CompanyId,
GID = userInfo.GID,
TenantId = userInfo.TenantId,
};
var token = JwtHelper.Encrypt(tokenModel);
return DataResult<string>.Success(token);
}
/// <summary>
///
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public DataResult<CurrentUserViewModel> GetUserInfo()
{
var userId = user.UserId;
var tenantId = user.GetTenantId();
var data = db.Queryable<SysUser>().Filter(null, true).Where(x => x.Id == userId)
.Select(a => new CurrentUserViewModel
{
UserId = a.Id, UserCode = a.UserCode, UserName = a.NickName,
TenantId = tenantId, UserType = a.UserType,
CompanyId = a.CompanyId,GID = a.GID
// CompanyId = a.CompanyId.ToString(), CompanyName = a.CustomerName
})
.Mapper(it =>
{
//只能写在Select后面
it.HomePath = "/analysis" ;
})
.First();
return DataResult<CurrentUserViewModel>.Success(data);
}
/// <summary>
/// 查询用户拥有的菜单权限
/// </summary>
/// <returns></returns>
public DataResult<List<RouteItem>> GetUserPermissionByToken()
{
List<RouteItem> list = new List<RouteItem>();
var userId = user.UserId;
var userInfo = db.Queryable<SysUser>().Filter(null, true).Where(x => x.Id == userId).First();
//超级管理员
if (userInfo.UserType == 0)
{
list = db.Queryable<SysPermission>().Filter(null, true).Where(x => x.MenuType == 1 && x.IsHidden == false)
.OrderBy(x=>x.SortCode)
.Select(a => new RouteItem
{
Id = a.Id,
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Redirect = a.Redirect,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
})
.ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Filter(null, true)
.Where(x => x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false)
.OrderBy(x=>x.SortCode)
.Select(a => new RouteItem
{
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
}).ToList();
item.Children = childs;
}
}
else
{
var roleIds = db.Queryable<SysRoleUser>().Where(x => x.UserId == userId).Select(x => x.RoleId).ToList();
var permissions = db.Queryable<SysRolePermission>().Where(x => roleIds.Contains(x.RoleId))
.Select(x => x.PermissionId).Distinct().ToList();
var perlist = db.Queryable<SysPermission>()
.Where(x => x.MenuType == 1 && x.IsHidden == false && permissions.Contains(x.Id))
.OrderBy(x=>x.SortCode)
.Select(a => new RouteItem
{
Id = a.Id,
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Redirect = a.Redirect,
SortCode = a.SortCode,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
})
.ToList();
// if (perlist.Count == 0)
// {
// //公共菜单权限
// var publicFirstMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 1 && x.IsHidden == false && x.PermissionType == (int)PermissionType.Public)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// SortCode = a.SortCode,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// list.AddRange(publicFirstMenu);
//
// // 权限身份菜单
// var identityFirstMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 1 && x.IsHidden == false && x.PermissionType == userInfo.PermissionIdentity)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// SortCode = a.SortCode,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// list.AddRange(identityFirstMenu);
// }
list.AddRange(perlist);
//去重
list.Distinct();
//排序
list = list.OrderBy(x => x.SortCode).ToList();
foreach (var item in list)
{
var childs = db.Queryable<SysPermission>().Where(x =>
x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && permissions.Contains(x.Id))
.OrderBy(x=>x.SortCode)
.Select(a => new RouteItem
{
Path = a.Url,
Name = a.PermissionName,
Component = a.Component,
Meta = new RouteMeta()
{
Title = a.Title,
Icon = a.Icon,
}
}).ToList();
// if (childs.Count == 0)
// {
// var publicSecondMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && x.PermissionType == (int)PermissionType.Public)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// }).ToList();
// childs.AddRange(publicSecondMenu);
//
// // 权限身份菜单
// var identityecondMenu = db.Queryable<SysPermission>().Filter(null, true).Where(x =>
// x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && x.PermissionType == userInfo.PermissionIdentity)
// .OrderBy(x=>x.SortCode)
// .Select(a => new RouteItem
// {
// Id = a.Id,
// Path = a.Url,
// Name = a.PermissionName,
// Component = a.Component,
// Redirect = a.Redirect,
// Meta = new RouteMeta()
// {
// Title = a.Title,
// Icon = a.Icon,
// }
// })
// .ToList();
// childs.AddRange(identityecondMenu);
// }
//去重
childs.Distinct();
//排序
childs = childs.OrderBy(x => x.SortCode).ToList();
item.Children = childs;
}
}
#region 处理报警信息
var data = new CollectWarningCount();
data.ThermometryCount = db.Queryable<tb_HKThermometry>().Where(x => x.Status == 0).Count();
data.LineDetectionCount = db.Queryable<tb_HKLineDetection>().Where(x => x.Status == 0).Count();
data.GoodsAuditCount = db.Queryable<code_goods_audit>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.ClientAuditCount = db.Queryable<OP_YARD_COMPANY>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsInPlanCount = db.Queryable<OP_WMS_IN_PLAN>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsOutPlanCount = db.Queryable<OP_WMS_OUT_PLAN>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsClearanceCount = db.Queryable<OP_WMS_CLEARANCE>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.ContractCount = db.Queryable<tb_Contract>()
.Where(x => x.EndDate.AddDays(x.Days * (-1)) <= DateTime.Now && x.Status == 0).Count();
foreach (var item in list)
{
if (item.Name =="园区安全")
{
var temp = item.Children.Where(x => x.Name == "高温报警").First();
temp.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.ThermometryCount.ToString(),
};
var temp1 = item.Children.Where(x => x.Name == "越界侦测").First();
temp1.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.LineDetectionCount.ToString(),
};
}
if (item.Name =="仓储管理")
{
var temp = item.Children.Where(x => x.Name == "预约入库审批").First();
temp.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.WmsInPlanCount.ToString(),
};
var temp1 = item.Children.Where(x => x.Name == "预约出库审批").First();
temp1.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.WmsOutPlanCount.ToString(),
};
var temp2 = item.Children.Where(x => x.Name == "预约清关审批").First();
temp2.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.WmsClearanceCount.ToString(),
};
}
if (item.Name =="基础信息")
{
var temp = item.Children.Where(x => x.Name == "商品申报").First();
temp.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.GoodsAuditCount.ToString(),
};
var temp1 = item.Children.Where(x => x.Name == "企业用户审批").First();
temp1.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.ClientAuditCount.ToString(),
};
}
if (item.Name =="合同管理")
{
var temp = item.Children.Where(x => x.Name == "合同信息").First();
temp.Tag = new Tag()
{
Type = "error",
Dot = false,
Content = data.ContractCount.ToString(),
};
}
}
#endregion
// list = list.OrderBy(x => x.Id).ToList();
return DataResult<List<RouteItem>>.Success("获取数据成功!", list);
}
/// <summary>
/// APP更新
/// </summary>
/// <param name="appVersion"></param>
/// <returns></returns>
public DataResult AppUpdate(string appVersion)
{
var info = db.Queryable<sys_param_set>().Where(x => x.PARAMNAME == "AppVersion").First();
var versionArr = info.PARAMVALUE.Split(';'); //转换数组
if (versionArr[0].ToString() == appVersion)
{
return DataResult.Failed("已经是最新版本!");
}
else
{
return DataResult.Successed("获取最新版本成功!", versionArr[1]);
}
}
#region 获取下拉字典
/// <summary>
/// 获取下拉字典
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public DataResult GetDictTypeDropDown(string code)
{
var type = db.Queryable<Sys_Dictionary>().Where(x => x.DicNo == code).First();
if (type.IsNull())
{
return DataResult.Failed("字典类型不存在!");
}
var data = db.Queryable<Sys_DictionaryList>().Where(x => x.Dic_ID == type.Dic_ID)
.Select(a => new DropDownData
{
Value= a.DicValue,
Code = a.DicName,
Label = a.DicName
}).ToList();
return DataResult.Successed("获取字典成功!", data);
}
#endregion
/// <summary>
/// 批量获取字典值
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult<List<DictOptions>> GetDictOptions(DropDownDictTypeInput model)
{
var codes = model.Code.Split(',');
var types = db.Queryable<Sys_Dictionary>().Where(x =>codes.Contains(x.DicNo)).ToList();
var list =new List<DictOptions>();
foreach (var item in types)
{
var temp = new DictOptions
{
DictCode = item.DicNo,
Data = db.Queryable<Sys_DictionaryList>().Where(x => x.Dic_ID == item.Dic_ID)
.Select(it=>new DropDownData()
{
Value= it.DicValue,
Code = it.DicName,
Label = it.DicName
}).ToList()
};
list.Add(temp);
}
return DataResult<List<DictOptions>>.Success("获取字典成功!", list);
}
/// <summary>
/// 获取商品分类列表
/// </summary>
/// <returns></returns>
public DataResult<List<code_goodsType>> GetGoodsTypeList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<code_goodsType>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 获取商品计费大类列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<OP_WMS_GOODSFEETYPE>> GetGoodsFeeTypeList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<OP_WMS_GOODSFEETYPE>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 企业用户注册
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult CompanyRegister(CompanyRegisterInput model)
{
if (!model.policy)
{
return DataResult.Failed("请勾选合同规定!");
}
var exitCompany = db.Queryable<OP_YARD_COMPANY>().Where(x =>
x.TAXNO == model.TaxCode && x.AuditStatus == AuditStatus.Approve.ToEnumInt()).Select(x => x.TAXNO).First();
if (!exitCompany.IsNullOrEmpty())
{
return DataResult.Failed("该企业信息已经注册!");
}
var auditCompany = db.Queryable<OP_YARD_COMPANY>().Where(x =>
x.TAXNO == model.TaxCode && (x.AuditStatus == AuditStatus.NoAudit.ToEnumInt() && x.AuditStatus == AuditStatus.Auditing.ToEnumInt())).Select(x => x.TAXNO).First();
if (!auditCompany.IsNullOrEmpty())
{
return DataResult.Failed("该企业信息待提交或待审批,请勿重复提交!");
}
var checkShortName = db.Queryable<OP_YARD_COMPANY>().Where(x =>
x.SHORTNAME == model.ShortName.Trim()).Select(x => x.SHORTNAME).First();
if (!checkShortName.IsNullOrEmpty())
{
return DataResult.Failed(checkShortName + " 公司简称已经注册!");
}
var checkLOGINNAME = db.Queryable<OP_YARD_COMPANY>().Where(x =>
x.LOGINNAME == model.AdminAccount.Trim()).Select(x => x.LOGINNAME).First();
if (!checkLOGINNAME.IsNullOrEmpty())
{
return DataResult.Failed(checkLOGINNAME + " 登录账号已经注册!");
}
if (model.AdminPassword != model.AgainPassword)
return DataResult.Failed("密码不一致!");
try
{
//开启事务
db.Ado.BeginTran();
var GID = Guid.NewGuid();
var company = new OP_YARD_COMPANY
{
GID = GID,
TAXNO = model.TaxCode,
SHORTNAME = model.ShortName,
DESCRIPTION = model.CompanyName,
ADDR = "",
TEL = "",
EMAIL = "",
ISTRUCK = false,
ISSHIPPER = false,
ISCONSIGNEE = false,
ISAGENTCN = false,
ISOTHER = false,
LOGINNAME = model.AdminAccount,
LOGINPASSWORD = model.AdminPassword,
AuditStatus = AuditStatus.NoAudit.ToEnumInt() // 审核状态改为待提交
};
db.Insertable(company).ExecuteCommand();
//写入注册用户
var user = new tb_User
{
Gid = Guid.NewGuid(),
LoginName = model.AdminAccount,
Password = model.AdminPassword,
NickName = model.AdminAccount,
Email = "",
UserType = UserType.Admin.ToEnumInt(), //管理员
CustomerName = model.CompanyName,
UpTime = DateTime.Now.ToTimestamp(),
AddTime = DateTime.Now.ToTimestamp(),
Status = (short)NomalStatus.Approve, //已审核
CompanyId = GID,
};
db.Insertable(user).ExecuteCommand();
db.Ado.CommitTran();
return DataResult.Successed("企业注册成功!请登录后完善相关资料并提交审核!");
}
catch (Exception ex)
{
db.Ado.RollbackTran();
return DataResult.Failed("企业注册失败!" + ex);
}
}
#region 获取服务器信息
/// <summary>
/// 获取服务器信息
/// </summary>
/// <returns></returns>
public DataResult<dynamic> GetServerInfo()
{
//核心数
int cpuNum = Environment.ProcessorCount;
string computerName = Environment.MachineName;
string osName = RuntimeInformation.OSDescription;
string osArch = RuntimeInformation.OSArchitecture.ToString();
string version = RuntimeInformation.FrameworkDescription;
string appRAM = ((double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + " MB";
string startTime = Process.GetCurrentProcess().StartTime.ToString("yyyy-MM-dd HH:mm:ss");
string sysRunTime = ComputerHelper.GetRunTime();
string serverIP = IhttpContext.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString() + ":"
+ IhttpContext.HttpContext.Connection.LocalPort; //获取服务器IP
var programStartTime = Process.GetCurrentProcess().StartTime;
string programRunTime =
DateTimeHelper.FormatTime((DateTime.Now - programStartTime).TotalMilliseconds.ToString().Split('.')[0]
.ParseToLong());
var data = new
{
cpu = ComputerHelper.GetComputerInfo(),
disk = ComputerHelper.GetDiskInfos(),
sys = new { cpuNum, computerName, osName, osArch, serverIP, runTime = sysRunTime },
app = new
{
name = _environment.EnvironmentName,
rootPath = _environment.ContentRootPath,
webRootPath = _environment.WebRootPath,
version,
appRAM,
startTime,
runTime = programRunTime,
host = serverIP
},
};
return DataResult<dynamic>.Success(data);
}
#endregion
#region 获取角色下拉列表
/// <summary>
/// 获取角色下拉列表
/// </summary>
/// <returns></returns>
public DataResult<List<ApiSelectViewModel>> GetRoleList()
{
var list = db.Queryable<SysRole>()
.Select(a => new ApiSelectViewModel
{
Label = a.RoleName,
Value = a.Id,
})
.ToList();
return DataResult<List<ApiSelectViewModel>>.Success("获取数据成功!", list);
}
#endregion
#region 获取安全人员类别下拉列表
/// <summary>
/// 获取安全人员类别下拉列表
/// </summary>
/// <returns></returns>
public DataResult<List<ApiSelectViewModel>> GetSecurityUserTypeList()
{
var list = db.Queryable<tb_SecurityUserType>()
.Select(a => new ApiSelectViewModel
{
Label = a.UserTypeName,
Value = a.Id,
})
.ToList();
return DataResult<List<ApiSelectViewModel>>.Success("获取数据成功!", list);
}
#endregion
/// <summary>
/// 获取商品下拉列表
/// </summary>
/// <returns></returns>
public DataResult GetGoodsList(string code)
{
var list = db.Queryable<code_goods>()
.Where(x=>x.PinYinCode.Contains(code.Trim()) && x.ISSTOP ==false)
.Select<CodeGoodsViewModel>()
.ToList();
return DataResult.Successed("获取数据成功!", list);
}
/// <summary>
/// 获取仓库下拉列表
/// </summary>
/// <returns></returns>
public DataResult<List<StoreHouseViewModel>> GetStoreHouseList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<OP_WMS_STOREHOUSE>()
.Select<StoreHouseViewModel>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 获取仓库库位下拉列表
/// </summary>
/// <returns></returns>
public DataResult GetStoreHouseAreaList(string code)
{
//序列化查询条件
var data = db.Queryable<OP_WMS_STOREHOUSE_AREA>()
.LeftJoin<OP_WMS_STOREHOUSE>((a, b) => a.Pid == b.Id)
.Where((a,b)=>b.AREACODE == code )
.Select((a, b) => new StoreAreaSelectViewModel()
{
Id = a.Id,
ParentCode = b.AREACODE,
AREANAME = a.AREANAME,
AREACODE = a.AREACODE //手动指定一列在自动映射
}).ToList();
return DataResult.Successed("获取数据成功!", data);
}
/// <summary>
/// 获取客户列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<InfoClientViewModel>> GetInfoClientList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<info_client>()
.Select<InfoClientViewModel>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 获取费用列表
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public DataResult GetFeeList(string code)
{
var data = db.Queryable<CodeFee>()
.Where(x => x.FEECODE.Contains(code))
// .Select<WmsNeedInfo>()
.ToList();
return DataResult.Successed("获取数据成功!", data);
}
/// <summary>
/// 获取仓库选择
/// </summary>
/// <returns></returns>
public DataResult<List<ApiSelectViewModel>> GetStoreHouseSelect()
{
var list = db.Queryable<OP_WMS_STOREHOUSE>()
.Select(a => new ApiSelectViewModel
{
Label = a.AREANAME,
Value = a.AREACODE,
})
.ToList();
return DataResult<List<ApiSelectViewModel>>.Success("获取数据成功!", list);
}
/// <summary>
/// 获取集合提醒统计
/// </summary>
/// <returns></returns>
public DataResult<CollectWarningCount> GetCollectWarningCount()
{
var data = new CollectWarningCount();
data.ThermometryCount = db.Queryable<tb_HKThermometry>().Where(x => x.Status == 0).Count();
data.LineDetectionCount = db.Queryable<tb_HKLineDetection>().Where(x => x.Status == 0).Count();
data.GoodsAuditCount = db.Queryable<code_goods_audit>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.ClientAuditCount = db.Queryable<OP_YARD_COMPANY>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsInPlanCount = db.Queryable<OP_WMS_IN_PLAN>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsOutPlanCount = db.Queryable<OP_WMS_OUT_PLAN>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
data.WmsClearanceCount = db.Queryable<OP_WMS_CLEARANCE>().Where(x => x.AuditStatus == AuditStatus.Auditing.ToEnumInt()).Count();
return DataResult<CollectWarningCount>.Success("获取数据成功!", data);
}
/// <summary>
/// 获取已审批客户列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<OP_YARD_COMPANY>> GetCompanyList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<OP_YARD_COMPANY>().Where(x=>x.AuditStatus == AuditStatus.Approve.ToEnumInt())
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
#region 修改密码
/// <summary>
/// 修改密码
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult ChangePassword(ChangePasswordInput model)
{
var userId = user.UserId;
var userInfo = db.Queryable<SysUser>().First(x => x.Id == userId);
if (model.OldPassword == model.NewPassword)
{
return DataResult.Failed("旧密码与新密码一致!");
}
if (model.NewPassword != model.ConfirmPassword)
{
return DataResult.Failed("新密码与确认密码不一致!");
}
if (userInfo.Password == model.NewPassword)
{
return DataResult.Failed("新密码与用户密码一致!");
}
userInfo.Password = model.ConfirmPassword;
userInfo.MD5Password = MD5Helper.MD5Encrypt(model.ConfirmPassword);
db.Updateable(userInfo).ExecuteCommand();
return DataResult.Successed("密码修改成功!");
}
#endregion
}