Commit 86962f9a authored by 吴春's avatar 吴春

提交库存预警发送消息

parent f0c29b37
......@@ -75,5 +75,9 @@ namespace Property.Model.Entity.Mall
/// </summary>
public int ERPGroupId { get; set; }
/// <summary>
/// 是否发送IM消息 0-否,1-是
/// </summary>
public int IsSendIMMsg { get; set; }
}
}
......@@ -60,8 +60,24 @@ namespace Property.Model.Extend
public string StartTime { get; set; }
/// <summary>
/// 操作结束时间
/// 操作开始时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 安全库存
/// </summary>
public int ReservedStock { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 商品规格
/// </summary>
public string SpecificationName { get; set; }
}
}
\ No newline at end of file
......@@ -1124,6 +1124,10 @@ namespace Property.Module.FixedAssets
return true;
}
/// <summary>
/// 保存出库单
/// </summary>
......@@ -2697,12 +2701,12 @@ namespace Property.Module.FixedAssets
}
/// <summary>
/// 保存商品盘点记录
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetReportLossRecord(RB_Supplies_ReportLossRecord_Extend applyModel, RB_Supplies_StockOut_Extend demodel, RB_Supplies_StockIn_Extend inDemodel, int RB_Department_Id)
/// <summary>
/// 保存商品盘点记录
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetReportLossRecord(RB_Supplies_ReportLossRecord_Extend applyModel, RB_Supplies_StockOut_Extend demodel, RB_Supplies_StockIn_Extend inDemodel, int RB_Department_Id)
{
var trans = suppliesReportLossRecordRepository.DbTransaction;
try
......@@ -3215,7 +3219,8 @@ namespace Property.Module.FixedAssets
if (dmodel != null)
{
dmodel.DetailList = supplies_StockInDetailRepository.GetList(new RB_Supplies_StockInDetail_Extend() { StockInId = stockInId, RB_Group_Id = userInfo.RB_Group_id });
foreach (var qitem in dmodel.DetailList) {
foreach (var qitem in dmodel.DetailList)
{
qitem.GoodsSpecificationList = new List<string>();
qitem.GoodsCategoryList = new List<string>();
if (!string.IsNullOrEmpty(qitem.SpecificationName))
......@@ -3232,7 +3237,7 @@ namespace Property.Module.FixedAssets
List<Rb_Workflow_AuditRelevance_Extend> warlist = workflow_AuditRelevanceRepository.GetAuditRelevanceList(dmodel.Id, "", null, 1);
List<Rb_Workflow_Auditrecord_Extend> walist = new List<Rb_Workflow_Auditrecord_Extend>();
walist = workflow_AuditrecordRepository.GetFinaceAuditRecordList(new Rb_Workflow_Auditrecord_Extend() { WorkFlowId = dmodel.Id });
//流程
dmodel.AuditSteps = new List<Rb_Workflow_AuditRelevance_Extend>();
#region 制单人信息
......
......@@ -6,6 +6,7 @@
<ItemGroup>
<ProjectReference Include="..\Property.Common\Property.Common.csproj" />
<ProjectReference Include="..\Property.IM\Property.IM.csproj" />
<ProjectReference Include="..\Property.Model\Property.Model.csproj" />
<ProjectReference Include="..\Property.Repository\Property.Repository.csproj" />
</ItemGroup>
......
......@@ -9,6 +9,7 @@ using Property.Repository.Mall;
using REBORN.Common;
using REBORN.Common.Enum;
using REBORN.Common.Plugin;
using REBORN.IM.Service;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -38,6 +39,10 @@ namespace Property.Module.Mall
private readonly RB_Goods_OrderDetailRepository goodsOrderDetailRepository = new RB_Goods_OrderDetailRepository();
/// <summary>
/// 商户仓储
/// </summary>
private readonly RB_ERP_AuthorizeRepository ERPAuthorizeRepository = new RB_ERP_AuthorizeRepository();
/// <summary>
/// 商户仓储
......@@ -72,8 +77,6 @@ namespace Property.Module.Mall
/// </summary>
private readonly RB_Supplies_StockOutDetailRepository supplies_StockOutDetailRepository = new RB_Supplies_StockOutDetailRepository();
/// <summary>
/// 出库申请列表
/// </summary>
......@@ -285,6 +288,19 @@ namespace Property.Module.Mall
}
/// <summary>
/// 验证出库单是否超过安预警库存
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> ValidateSafetyStock(RB_Supplies_StockOut_Extend demodel)
{
//更新明细
var list = demodel.DetailList;
string SuppliesIds = string.Join(",", demodel.DetailList.Select(x => x.SuppliesId));
var ilist = supplies_InventoryRepository.GetSafetyStockList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = demodel.RB_Group_Id, WarehouseId = demodel.WarehouseId, SuppliesIdStr = SuppliesIds });
return ilist;
}
/// <summary>
/// 保存出库单
/// </summary>
......@@ -530,7 +546,47 @@ namespace Property.Module.Mall
}
}
supplies_StockOutRepository.DBSession.Commit();
return Id > 0;
bool result = Id > 0;
if (result)//推送消息,看当前商品的库存是否超过预警库存
{
try
{
var inventoryList = ValidateSafetyStock(demodel);
if (inventoryList.Any(x => x.Number < x.ReservedStock))//有超过预警的发送IM消息
{
//查询接收IM预警的人员信息
var list = ERPAuthorizeRepository.GetIMAuthorizeList(new RB_ERP_Authorize_Extend { Status = 2, Type = 1, ERPGroupId = demodel.RB_Group_Id ?? 0, IsSendIMMsg = 1 });
if (list != null && list.Any())
{
var empList = employeeRepository.GetEmpInfoByMobiles(list.Select(x => x.Account).ToList(), "", demodel.RB_Group_Id ?? 0);
if (empList != null)
{
List<EmAccoutIdModel> account = new List<EmAccoutIdModel>();
foreach (var item in empList)
{
account.Add(new EmAccoutIdModel()
{
EmployeeId = item.EmployeeId,
EmAccount = string.IsNullOrWhiteSpace(item.OpenAccount) ? item.EmLoginMobile : item.OpenAccount
});
}
foreach (var item in inventoryList.Where(x => x.Number < x.ReservedStock))
{
//发送通知
PushBuyingMessage(account, 0, $"商品:{item.GoodsName},规格:{item.SpecificationName}不足{item.ReservedStock}", "库存预警消息通知", demodel.CreateBy, SysTemPushTypeEnum.PropertyAudit);
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "库存预警消息推送失败");
}
}
return result;
}
catch (Exception ex)
......@@ -541,5 +597,29 @@ namespace Property.Module.Mall
}
}
/// <summary>
/// 推送资产库存预警消息
/// </summary>
/// <param name="account"></param>
/// <param name="workFlowId"></param>
/// <param name="content"></param>
/// <param name="title"></param>
/// <param name="empId"></param>
/// <param name="type"></param>
public void PushBuyingMessage(List<EmAccoutIdModel> account, int workFlowId, string content, string title, int? empId, SysTemPushTypeEnum type)
{
//Dictionary<string, object> appExtras = new Dictionary<string, object>();
Dictionary<string, object> webExtras = new Dictionary<string, object>
{
{ "jumpUrl", "" }
};
//appExtras.Add("jumpUrl", "vt://financeApprovalDetail/view?ID=" + workFlowId + "&Conditon=3&Source=message&Type=" + Type);
//IMService.PushFinanceMessage(account, empId, content, title, type, SystemPushLogTypeEnum.XMApp, appExtras);
IMService.PushMessage(account.RefMapperToList<Property.Common.Models.EmAccoutIdModel>(), empId, content, title, type, SystemPushLogTypeEnum.Web, webExtras);
}
}
}
......@@ -107,5 +107,53 @@ LEFT JOIN rb_tenant as e on e.TenantId = a.TenantId where 1=1");
}
return Get<RB_ERP_Authorize_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 授权列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_ERP_Authorize_Extend> GetIMAuthorizeList(RB_ERP_Authorize_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@$" SELECT a.* FROM {TableName} as a where 1=1");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.ID)}={query.ID}");
}
if (query.Status > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.Status)}={query.Status}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.Type > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.Type)}={query.Type}");
}
if (query.MallUserId > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.MallUserId)}={query.MallUserId}");
}
if (query.ERPGroupId > 0)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.ERPGroupId)}={query.ERPGroupId}");
}
if (query.IsSendIMMsg > -1)
{
builder.Append($" AND a.{nameof(RB_ERP_Authorize_Extend.IsSendIMMsg)}={query.IsSendIMMsg}");
}
}
return Get<RB_ERP_Authorize_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -68,6 +68,35 @@ namespace Property.Repository
return Get<RB_Supplies_Inventory_Extend>(sql).ToList();
}
public List<RB_Supplies_Inventory_Extend> GetSafetyStockList(RB_Supplies_Inventory_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND a.{0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and a.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0)
{
where += " and a." + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and a." + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
if (!string.IsNullOrEmpty(dmodel.WarehouseIdStr))
{
where += " and a." + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" in({dmodel.WarehouseIdStr})";
}
if (!string.IsNullOrEmpty(dmodel.SuppliesIdStr))
{
where += " and a." + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" in({dmodel.SuppliesIdStr})";
}
string sql = $@" select a.*,b.ReservedStock,b.`Name` as GoodsName,b.SpecificationName from RB_Supplies_Inventory as a LEFT JOIN rb_supplies_material as b on a.SuppliesId=b.Id {where} order by a.Id desc";
return Get<RB_Supplies_Inventory_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
......
......@@ -56,7 +56,8 @@ WHERE 1=1 ");
{
sb.AppendFormat(" AND e.{0}={1} ", nameof(Model.Entity.RB_Employee.RB_Post_Id), where.RB_Post_Id);
}
if (!string.IsNullOrEmpty(where.EmName)) {
if (!string.IsNullOrEmpty(where.EmName))
{
sb.AppendFormat(" AND e.{0} like '%{1}%' ", nameof(Model.Entity.RB_Employee.EmName), where.EmName);
}
sb.Append(" AND e.IsLeave=0 ");
......@@ -133,5 +134,49 @@ WHERE 1=1 ");
}
return new List<RB_Employee_Extend>();
}
/// <summary>
/// 根据员工
/// </summary>
/// <param name="ids">员工Id,多个员工用,</param>
/// <returns></returns>
public List<RB_Employee_Extend> GetEmpInfoByMobiles(List<string> emLoginMobileList, string domain, int RB_Group_id)
{
if (RB_Group_id > 0)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat(@$"SELECT a.*,b.OpenAccount from rb_employee as a
LEFT JOIN rb_account_mapping as b on a.EmployeeId=b.EmpId and b.MappingSource=3
LEFT JOIN rb_group as c on c.Id=a.RB_Group_id where 1=1");
//where a.EmLoginMobile in('13551132417') and a.RB_Group_id=2 ");
if (emLoginMobileList != null && emLoginMobileList.Any())
{
int i = 0;
sb.AppendFormat(@$" and (");
foreach (var item in emLoginMobileList)
{
if (i == 0)
{
sb.AppendFormat(@$" a.EmLoginMobile='{item}' ");
}
else {
sb.AppendFormat(@$" or a.EmLoginMobile='{item}' ");
}
i += 1;
}
sb.AppendFormat(@$" )");
}
sb.AppendFormat(@$"and a.RB_Group_id={RB_Group_id} ");
return Get<RB_Employee_Extend>(sb.ToString()).ToList();
}
return new List<RB_Employee_Extend>();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment