瀏覽代碼

Merge branch 'master' into storemanagement

storemanagement
zhaoy 8 月之前
父節點
當前提交
d40b1416c9
共有 11 個檔案被更改,包括 201 行新增58 行删除
  1. +13
    -0
      BPA.SAAS.Manage.Application/DataBase/BomServices.cs
  2. +14
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Bom/BomDto.cs
  3. +18
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsBomPageView.cs
  4. +16
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsBomQueryDto.cs
  5. +3
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs
  6. +1
    -1
      BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
  7. +8
    -0
      BPA.SAAS.Manage.Application/DataBase/Interface/IBomService.cs
  8. +1
    -1
      BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs
  9. +21
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/BomService.cs
  10. +97
    -54
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  11. +9
    -2
      BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs

+ 13
- 0
BPA.SAAS.Manage.Application/DataBase/BomServices.cs 查看文件

@@ -1,5 +1,6 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -25,6 +26,7 @@ namespace BPA.SAAS.Manage.Application.DataBase
{
return await _bomService.GetBomList();
}

/// <summary>
/// 根据配方id查询配方信息
/// </summary>
@@ -94,5 +96,16 @@ namespace BPA.SAAS.Manage.Application.DataBase
{
return await _bomService.GetBomTypeList();
}

/// <summary>
///获取 配方列表
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/bom/BomPage")]
public async Task<PageUtil> BomPage(BomPageInputDto inputDto)
{
return await _bomService.BomPage(inputDto);
}
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Bom/BomDto.cs 查看文件

@@ -0,0 +1,14 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Bom
{
public class BomPageInputDto: PageInputBase
{

}
}

+ 18
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsBomPageView.cs 查看文件

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
{
public class GoodsBomPageView
{
public string Id { get; set; }
public string Name { get; set; }
public string BomId { get; set; }
public bool IsMain { get; set; }
public string GoodsAttributeValueId { get; set; }
public string GoodsAttributeValue { get; set; }
}
}

+ 16
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsBomQueryDto.cs 查看文件

@@ -0,0 +1,16 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
{
public class GoodsBomQueryDto: PageInputBase
{
public string GoodsId { get; set; }
public string Name { get; set; }
public string GoodsAttributeValue { get; set; }
}
}

+ 3
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs 查看文件

@@ -9,6 +9,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute
public class GoodsBomAttributeDto
{
public string GoodsId { get; set; }
public string BomId { get; set; }
public string GoodsAttributeValue { get; set; }
public string Type { get; set; }
public string BomName { get; set; }
public string BomType { get; set; }
public string[] BomtypeList { get; set; }


+ 1
- 1
BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs 查看文件

@@ -85,7 +85,7 @@ namespace BPA.SAAS.Manage.Application.DataBase
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goods/getgoodsbompage")]
public async Task<PageUtil> GetGoodsBomPageAsync(OrtherGoodsQueryDto dto)
public async Task<PageUtil> GetGoodsBomPageAsync(GoodsBomQueryDto dto)
{
return await _goodsService.GetGoodsBomPageAsync(dto);
}


+ 8
- 0
BPA.SAAS.Manage.Application/DataBase/Interface/IBomService.cs 查看文件

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -54,5 +55,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface
/// </summary>
/// <returns></returns>
Task<List<dynamic>> GetBomTypeList();

/// <summary>
///获取 配方列表
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
Task<PageUtil> BomPage(BomPageInputDto inputDto);
}
}

+ 1
- 1
BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs 查看文件

@@ -52,7 +52,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<PageUtil> GetGoodsBomPageAsync(OrtherGoodsQueryDto dto);
Task<PageUtil> GetGoodsBomPageAsync(GoodsBomQueryDto dto);
/// <summary>
/// 删除商品配方
/// </summary>


+ 21
- 0
BPA.SAAS.Manage.Application/DataBase/Services/BomService.cs 查看文件

@@ -1,6 +1,8 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using NPOI.SS.Formula.Functions;
using System;
@@ -219,5 +221,24 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
var str = string.Format("{0}", ram.ToString().Substring(0, Length));
return str;
}

/// <summary>
///获取 配方列表
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil> BomPage(BomPageInputDto inputDto)
{
int total = new RefAsync<int>();
var res = await _db.Queryable<BPA_Bom>()
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);

return new PageUtil()
{
Data = res,
Total= total,

};
}
}
}

+ 97
- 54
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs 查看文件

@@ -1,5 +1,6 @@
using BPA.Franchisee.Application.FranchiseeCenter.GoodsServices;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Batching;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute;
using BPA.SAAS.Manage.Application.DataBase.Interface;
@@ -252,19 +253,26 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<PageUtil> GetGoodsBomPageAsync(OrtherGoodsQueryDto dto)
public async Task<PageUtil> GetGoodsBomPageAsync(GoodsBomQueryDto dto)
{
RefAsync<int> total = 0;
var res =await _db.Queryable<BPA_Bom, BPA_GoodsBom>((a, b) => new JoinQueryInfos(
JoinType.Left, a.Id == b.BomId
var res =await _db.Queryable<BPA_Bom, BPA_BomAttributeValueRe>((a, b) => new JoinQueryInfos(
JoinType.Left, a.Id == b.BoomId
))
.WhereIF(!string.IsNullOrWhiteSpace(dto.GoodsId), (a, b) => b.Goods_Id == dto.GoodsId)
.Select((a, b) => new
.WhereIF(!string.IsNullOrWhiteSpace(dto.GoodsId), (a, b) => b.GoodsId==dto.GoodsId)
.WhereIF(!string.IsNullOrWhiteSpace(dto.Name), (a, b) => a.Name.Contains(dto.Name))
.WhereIF(!string.IsNullOrWhiteSpace(dto.GoodsAttributeValue), (a, b) => b.GoodsAttributeValue.Contains(dto.GoodsAttributeValue))
.Select((a, b) => new GoodsBomPageView
{
Id = b.Id,
Name = a.Name,
BomId= b.BomId,
IsMain = a.IsMain
BomId= b.BoomId,
IsMain = a.IsMain,
GoodsAttributeValueId=b.GoodsAttributeValueId,
}).Mapper(x =>
{
var AttributeValue = _db.Queryable<BPA_GoodsAttributeValue>().Where(p => x.GoodsAttributeValueId.Contains(p.Id)).Select(p=>p.AttributeValue).ToArray();
x.GoodsAttributeValue =string.Join("-", AttributeValue);
})
.ToPageListAsync(dto.Current, dto.PageSize, total);
PageUtil util = new PageUtil()
@@ -281,10 +289,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
/// <returns></returns>
public async Task<bool> BatchDelGoodsBomAsync(string Ids)
{
// var GoodsBom=_db.Queryable<BPA_GoodsBom>().Where(x => x.Id == Ids).First();
// var GoodsBom=_db.Queryable<BPA_GoodsBom>().Where(x => x.Id == Ids).First();
var model=_db.Queryable<BPA_BomAttributeValueRe>().Where(x => x.Id == Ids).First();
if(model==null) throw Oops.Oh("配方不存在");
_db.Deleteable<BPA_GoodsBom>().Where(x => x.Goods_Id == model.GoodsId && x.BomId== model.BoomId).ExecuteCommand();
// 查询数据库中是否存在未删除的商品
var res = _db.Deleteable<BPA_GoodsBom>().In(Ids).ExecuteCommand();
var res = _db.Deleteable<BPA_BomAttributeValueRe>().In(Ids).ExecuteCommand();
return res > 0;
}
/// <summary>
@@ -297,55 +307,88 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
_db.Ado.BeginTran();
try
{
var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort);
BPA_Bom newbPA_BOM = new BPA_Bom
if(dto.Type== "add")
{
Name = dto.BomName,
Code = GetNumber2(),
IsMain = dto.BomType == "1" ? true : false,
Sort = sortMax + 1,
Id = Guid.NewGuid().ToString(),
CreateAt = DateTime.Now,
Status = CommonStatus.ENABLE,
};
//添加配方
var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand();
//添加配方分类
var list = dto.BomtypeList.Select(item => new BPA_BomTypeInfo() { BomId = newbPA_BOM.Id, BomTypeId = item }).ToList();
_db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommand();

BPA_GoodsBom bom = new BPA_GoodsBom();
bom.Goods_Id = dto.GoodsId;
bom.BomId = newbPA_BOM.Id;
bom.Status = CommonStatus.ENABLE;
//添加商品配方关系
_db.Insertable(bom).CallEntityMethod(m => m.Create()).ExecuteCommand();
List<BPA_BomEntry> BOMEntryList = new();
if (dto.Mate.Count > 0)
{
for (int i = 0; i < dto.Mate.Count; i++)
var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort);
BPA_Bom newbPA_BOM = new BPA_Bom
{
BPA_BomEntry newbPA_BOMEnty = new BPA_BomEntry
Name = dto.BomName,
Code = GetNumber2(),
IsMain = dto.BomType == "1" ? true : false,
Sort = sortMax + 1,
Id = Guid.NewGuid().ToString(),
CreateAt = DateTime.Now,
Status = CommonStatus.ENABLE,
};
//添加配方
var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand();
//添加配方分类
var list = dto.BomtypeList.Select(item => new BPA_BomTypeInfo() { BomId = newbPA_BOM.Id, BomTypeId = item }).ToList();
_db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommand();

BPA_GoodsBom bom = new BPA_GoodsBom();
bom.Goods_Id = dto.GoodsId;
bom.BomId = newbPA_BOM.Id;
bom.Status = CommonStatus.ENABLE;
//添加商品配方关系
_db.Insertable(bom).CallEntityMethod(m => m.Create()).ExecuteCommand();
List<BPA_BomEntry> BOMEntryList = new();
if (dto.Mate.Count > 0)
{
for (int i = 0; i < dto.Mate.Count; i++)
{
BatchingId = dto.Mate[i].batchingId,
//BatchingKey = dto.Mate[i].AutoKey,
BomQty = dto.Mate[i].dosage,
BomId = newbPA_BOM.Id,
Status = CommonStatus.ENABLE,
IsReplace = false,
};
BOMEntryList.Add(newbPA_BOMEnty);
BPA_BomEntry newbPA_BOMEnty = new BPA_BomEntry
{
BatchingId = dto.Mate[i].batchingId,
//BatchingKey = dto.Mate[i].AutoKey,
BomQty = dto.Mate[i].dosage,
BomId = newbPA_BOM.Id,
Status = CommonStatus.ENABLE,
IsReplace = false,
};
BOMEntryList.Add(newbPA_BOMEnty);
}
}
//添加配方物料关系
_db.Insertable(BOMEntryList).CallEntityMethod(m => m.Create()).ExecuteCommand();
BPA_BomAttributeValueRe bPA_BomAttributeValueRe = new();
bPA_BomAttributeValueRe.Id = Guid.NewGuid().ToString();
bPA_BomAttributeValueRe.GoodsId = dto.GoodsId;
bPA_BomAttributeValueRe.BoomId = newbPA_BOM.Id;
bPA_BomAttributeValueRe.GoodsAttributeValueId = string.Join(",", dto.Shuxing);
bPA_BomAttributeValueRe.GoodsAttributeValue = dto.GoodsAttributeValue;
//添加商品配方属性关系
_db.Insertable(bPA_BomAttributeValueRe).ExecuteCommand();
}
else
{
if (string.IsNullOrWhiteSpace(dto.BomId)) throw Oops.Oh("请选择配方");
if (!string.IsNullOrWhiteSpace(dto.BomId))
{
var check=_db.Queryable<BPA_GoodsBom>().Where(x => x.Goods_Id == dto.GoodsId && x.BomId == dto.BomId).Any();
if (!check)
{
BPA_GoodsBom bom = new BPA_GoodsBom();
bom.Goods_Id = dto.GoodsId;
bom.BomId = dto.BomId;
bom.Status = CommonStatus.ENABLE;
//添加商品配方关系
_db.Insertable(bom).CallEntityMethod(m => m.Create()).ExecuteCommand();
}
string vid = string.Join(",", dto.Shuxing);
var checkvid = _db.Queryable<BPA_BomAttributeValueRe>().Where(x => x.GoodsId == dto.GoodsId && x.BoomId == dto.BomId && x.GoodsAttributeValueId== vid).Any();
if(checkvid) throw Oops.Oh("该配方已经存在");
//添加商品配方属性关系
BPA_BomAttributeValueRe bPA_BomAttributeValueRe = new();
bPA_BomAttributeValueRe.Id = Guid.NewGuid().ToString();
bPA_BomAttributeValueRe.GoodsId = dto.GoodsId;
bPA_BomAttributeValueRe.BoomId = dto.BomId;
bPA_BomAttributeValueRe.GoodsAttributeValueId = vid;
bPA_BomAttributeValueRe.GoodsAttributeValue = dto.GoodsAttributeValue;
_db.Insertable(bPA_BomAttributeValueRe).ExecuteCommand();
}
}
//添加配方物料关系
_db.Insertable(BOMEntryList).CallEntityMethod(m => m.Create()).ExecuteCommand();
BPA_BomAttributeValueRe bPA_BomAttributeValueRe = new();
bPA_BomAttributeValueRe.Id = Guid.NewGuid().ToString();
bPA_BomAttributeValueRe.GoodsId = dto.GoodsId;
bPA_BomAttributeValueRe.BoomId = newbPA_BOM.Id;
bPA_BomAttributeValueRe.GoodsAttributeValueId = string.Join(",", dto.Shuxing);
//添加商品配方属性关系
_db.Insertable(bPA_BomAttributeValueRe).ExecuteCommand();
_db.Ado.CommitTran();
return true;
}


+ 9
- 2
BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs 查看文件

@@ -1,4 +1,5 @@
using SqlSugar;
using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,8 +12,9 @@ namespace BPA.SAAS.Manage.Core.DataBase
/// 配方商品属性关系
/// </summary>
[SugarTable("bpa_bomattributevaluere")]
public class BPA_BomAttributeValueRe
public class BPA_BomAttributeValueRe:IGroupId
{
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string Id { get; set; }
public string GoodsId { get; set; }
/// <summary>
@@ -23,5 +25,10 @@ namespace BPA.SAAS.Manage.Core.DataBase
/// 商品属性值id
/// </summary>
public string GoodsAttributeValueId { get; set; }
/// <summary>
/// 商品属性值
/// </summary>
public string GoodsAttributeValue { get; set; }
public string GroupId { get; set; }
}
}

Loading…
取消
儲存