Commit 69823821 authored by liudong1993's avatar liudong1993

1

parent 442582d8
......@@ -82,5 +82,14 @@ namespace Mall.Common.API
/// 小程序登录用户编号
/// </summary>
public int UserId { get; set; }
/// <summary>
/// erp用户id
/// </summary>
public int ERPEmpId { get; set; }
/// <summary>
/// erp集团id
/// </summary>
public int ERPGroupId { get; set; }
}
}
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 耗材库存实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_Inventory
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 仓库id
/// </summary>
public int? WarehouseId
{
get;
set;
}
/// <summary>
/// 耗材id
/// </summary>
public int? SuppliesId
{
get;
set;
}
/// <summary>
/// 库存数量
/// </summary>
public int? Number
{
get;
set;
}
/// <summary>
/// 库存总金额
/// </summary>
public decimal? Money { get; set; }
/// <summary>
/// 状态 0正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateBy
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
\ No newline at end of file
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 耗材库存日志实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_InventoryDetail
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 库存表id
/// </summary>
public int? InventoryId
{
get;
set;
}
/// <summary>
/// 类型 增加还是减少 1增加 2减少
/// </summary>
public int? Type
{
get;
set;
}
/// <summary>
/// 库存数量
/// </summary>
public int? Number
{
get;
set;
}
/// <summary>
/// 变动的金额
/// </summary>
public decimal? Money { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description
{
get;
set;
}
/// <summary>
/// 状态 0正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
\ No newline at end of file
......@@ -181,5 +181,25 @@ namespace Mall.Model.Entity.Property
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId { get; set; }
/// <summary>
/// 规格名称
/// </summary>
public string SpecificationName { get; set; }
/// <summary>
/// 规格Key
/// </summary>
public string SpecificationKey { get; set; }
/// <summary>
/// 商品分类ids
/// </summary>
public string GoodsCategoryIds { get; set; }
/// <summary>
/// 商品分类名称
/// </summary>
public string GoodsCategoryName { get; set; }
}
}
\ No newline at end of file
using System;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// IJĿϸչʵ
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_InventoryDetail_Extend : RB_Supplies_InventoryDetail
{
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// 瘧第踱湔孺桯妗极
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_Inventory_Extend : RB_Supplies_Inventory
{
/// <summary>
/// 累踱id
/// </summary>
public string WarehouseIdStr { get; set; }
/// <summary>
/// 瘧第id
/// </summary>
public string SuppliesIdStr { get; set; }
/// <summary>
/// 累踱
/// </summary>
public RB_Supplies_WareHouse_Extend WModel { get; set; }
/// <summary>
/// 瘧第
/// </summary>
public RB_Supplies_Material_Extend SModel { get; set; }
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Entity.Product;
using Mall.Model.Entity.User;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.Property;
using Mall.Model.Extend.User;
using Mall.Model.Query;
using Mall.Repository;
using Mall.Repository.BaseSetUp;
using Mall.Repository.Product;
using Mall.Repository.Property;
using Mall.Repository.User;
using Newtonsoft.Json;
namespace Mall.Module.Property
{
/// <summary>
/// 商品处理层
/// </summary>
public class PropertyModule
{
/// <summary>
/// 商品分类
/// </summary>
private readonly RB_Product_CategoryRepository product_CategoryRepository = new RB_Product_CategoryRepository();
/// <summary>
/// 商品
/// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary>
/// 商品分类
/// </summary>
private readonly RB_Goods_CategoryRepository goods_CategoryRepository = new RB_Goods_CategoryRepository();
/// <summary>
/// 商品规格
/// </summary>
private readonly RB_Goods_SpecificationRepository goods_SpecificationRepository = new RB_Goods_SpecificationRepository();
/// <summary>
/// 商品规格值
/// </summary>
private readonly RB_Goods_SpecificationValueRepository goods_SpecificationValueRepository = new RB_Goods_SpecificationValueRepository();
/// <summary>
/// 物料档案
/// </summary>
private readonly RB_Supplies_MaterialRepository supplies_MaterialRepository = new RB_Supplies_MaterialRepository();
/// <summary>
/// 物料库存
/// </summary>
private readonly RB_Supplies_InventoryRepository supplies_InventoryRepository = new RB_Supplies_InventoryRepository();
#region 获取资产物料列表
/// <summary>
/// 获取物料档案分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="demodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Material_Extend> GetMaterialPageList(int pageIndex, int pageSize, RB_Supplies_Material_Extend demodel, out long count)
{
var list = supplies_MaterialRepository.GetPageList(pageIndex, pageSize, demodel, out count);
List<RB_Supplies_Inventory_Extend> iList = new List<RB_Supplies_Inventory_Extend>();
if (demodel.WareHouseId > 0 && list.Any())
{
//查询出该仓库 耗材下 所有的库存
string Sstr = string.Join(",", list.Select(x => x.Id).Distinct());
iList = supplies_InventoryRepository.GetList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = demodel.RB_Group_Id, WarehouseIdStr = demodel.WareHouseId.Value.ToString(), SuppliesIdStr = Sstr });
}
foreach (var item in list)
{
if (item.Images == "" || item.Images == null)
{
item.Images = "[]";
}
var imglist = JsonConvert.DeserializeObject<List<string>>(item.Images);
item.ImageList = new List<string>();
foreach (var img in imglist)
{
item.ImageList.Add(Config.GetFileUrl(img));
}
item.InventoryNum = iList.Where(x => x.SuppliesId == item.Id).FirstOrDefault()?.Number ?? 0;
}
return list;
}
#endregion
}
}
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 耗材仓库库存明细仓储类
/// </summary>
public partial class RB_Supplies_InventoryDetailRepository : RepositoryBase<RB_Supplies_InventoryDetail>
{
/// <summary>
/// 获取耗材仓库库存分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_InventoryDetail_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_InventoryDetail_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_InventoryDetail_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.InventoryId > 0) {
where += " and " + nameof(RB_Supplies_InventoryDetail_Extend.InventoryId) + $" ={dmodel.InventoryId}";
}
string sql = $@" select * from RB_Supplies_InventoryDetail {where} order by Id desc";
return GetPage<RB_Supplies_InventoryDetail_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_InventoryDetail_Extend> GetList(RB_Supplies_InventoryDetail_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_InventoryDetail_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.InventoryId > 0)
{
where += " and " + nameof(RB_Supplies_InventoryDetail_Extend.InventoryId) + $" ={dmodel.InventoryId}";
}
string sql = $@" select * from RB_Supplies_InventoryDetail {where} order by Id desc";
return Get<RB_Supplies_InventoryDetail_Extend>(sql).ToList();
}
}
}
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 耗材仓库库存仓储类
/// </summary>
public partial class RB_Supplies_InventoryRepository : RepositoryBase<RB_Supplies_Inventory>
{
/// <summary>
/// 获取耗材仓库库存分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_Inventory_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0) {
where += " and " + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and " + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
string sql = $@" select * from RB_Supplies_Inventory {where} order by Id desc";
return GetPage<RB_Supplies_Inventory_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_Inventory_Extend> GetList(RB_Supplies_Inventory_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0)
{
where += " and " + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and " + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
if (!string.IsNullOrEmpty(dmodel.WarehouseIdStr)) {
where += " and " + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" in({dmodel.WarehouseIdStr})";
}
if (!string.IsNullOrEmpty(dmodel.SuppliesIdStr))
{
where += " and " + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" in({dmodel.SuppliesIdStr})";
}
string sql = $@" select * from RB_Supplies_Inventory {where} order by Id desc";
return Get<RB_Supplies_Inventory_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public int GetSafetyStockWarningCount(RB_Supplies_Inventory_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND si.{0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and si.RB_Group_Id={dmodel.RB_Group_Id}";
where += $@" and si.Number<IFNULL(sm.SafetyStock,0)";
string sql = $@" select count(0) as Number
from RB_Supplies_Inventory si
left join rb_supplies_material sm on si.SuppliesId=sm.Id
{where} order by si.Id desc";
return Get<RB_Supplies_Inventory_Extend>(sql).FirstOrDefault()?.Number ?? 0;
}
/// <summary>
/// 获取库存日志
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_InventoryDetail_Extend> GetInventoryDetailPageList(int pageIndex, int pageSize, RB_Supplies_Inventory_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND sid.{0}={1}", nameof(RB_Supplies_Inventory_Extend.Status), 0);
where += $@" and sid.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.WarehouseId > 0)
{
where += " and si." + nameof(RB_Supplies_Inventory_Extend.WarehouseId) + $" ={dmodel.WarehouseId}";
}
if (dmodel.SuppliesId > 0)
{
where += " and si." + nameof(RB_Supplies_Inventory_Extend.SuppliesId) + $" ={dmodel.SuppliesId}";
}
string sql = $@" select sid.* from RB_Supplies_Inventory si
left join rb_supplies_inventorydetail sid on si.Id=sid.InventoryId
{where} order by sid.Id desc";
return GetPage<RB_Supplies_InventoryDetail_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Mall.Common.API;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Mall.Common.Plugin;
using Newtonsoft.Json.Linq;
using Mall.Common;
using Mall.Module.Property;
using Mall.Model.Extend.Property;
namespace Mall.WebApi.Controllers.MallBase
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class PropertyController : BaseController
{
private readonly PropertyModule propertyModule = new PropertyModule();
#region 同步商品
/// <summary>
/// 获取物料档案分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMaterialPageList()
{
var requestParm = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(requestParm.msg.ToString());
RB_Supplies_Material_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_Material_Extend>(requestParm.msg.ToString());
if (requestParm.ERPEmpId <= 0) {
return ApiResult.ParamIsNull("请传递参数");
}
demodel.RB_Group_Id = requestParm.ERPGroupId;
var list = propertyModule.GetMaterialPageList(pagelist.pageIndex, pagelist.pageSize, demodel, out long count);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.CategoryId,
x.CategoryName,
x.BrandName,
x.Money,
x.Units,
x.ImageList,
x.Remark,
x.SupplierName,
x.Barcode,
x.ReservedStock,
x.SafetyStock,
x.SuppliesModel,
x.SuppliesNum,
x.InventoryNum,
UpdateBy = CacheManager.User.UserReidsCache.GetEmployee(x.UpdateBy)?.EmName ?? "",
UpdateDate = x.UpdateDate.Value.ToString("yyyy-MM-dd")
});
return ApiResult.Success("", pagelist);
}
#endregion
}
}
\ No newline at end of file
......@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.WindowsService", "Mall.WindowsService\Mall.WindowsService.csproj", "{FC1D11B4-E016-485A-A5E3-906697362658}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Module.Property", "Mall.Module.Property\Mall.Module.Property.csproj", "{C7DE85C9-8620-47A9-AE2F-DD1408DD886B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -107,6 +109,10 @@ Global
{FC1D11B4-E016-485A-A5E3-906697362658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Release|Any CPU.Build.0 = Release|Any CPU
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -124,6 +130,7 @@ Global
{9C400D7F-2BE2-40E7-B179-498097AA00AB} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{D0386A52-CAFD-40B3-A515-9A9241189FBA} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{339DE5B1-FA62-4B3D-80D4-0C50398D2848} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {450F460D-A6AE-4FE3-948A-34E5FB8DBD7C}
......
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