浏览代码

商品新增查重,工艺导出的商品同名修改20240705

ingredientmanage
gwbvipvip 4 个月前
父节点
当前提交
4470d20793
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. +10
    -5
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs

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

@@ -257,6 +257,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
/// <returns></returns>
public async Task<bool> AddGoods(GoodsDto dto)
{
var old = await _db.Queryable<BPA_GoodsInfo>().FirstAsync(t => t.Name == dto.Name && t.GoodsTypeId == dto.GoodsTypeId);
if (old != null)
throw Oops.Oh("已存在相同商品,添加失败!");
if (string.IsNullOrWhiteSpace(dto.Id))
{
var resEntity = new BPA_GoodsInfo();
@@ -1263,7 +1266,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
string pattern = @"(?<part1>[^,(]+),(?<part2>\([^)]+\)),(?<part3>[^,]+)";
var file = importDto.file;
var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
if (string.IsNullOrEmpty(userId))
{
userId = "";
@@ -1289,6 +1292,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
modelList.RemoveAll(t => t.StepName == "主料(例)" && t.ActionName == "主料位置(例)" && t.ActionValue == "1号位(例)" && t.Index == "2(例)");
modelList.RemoveAll(t => t.StepName == null && t.ActionName == null && t.ActionValue == null && t.Index == null);
modelList.RemoveAll(t => t.StepName == "工序" && t.ActionName == "工序参数" && t.ActionValue == "工序参数值" && t.Index == "值序号");
FillStepName(modelList);
var modelMatch = Regex.Match(modelList[0].StepName, pattern);
var deviceId = modelMatch.Groups["part3"].Value.Trim();
var deviceInfo = deviceList.FirstOrDefault(t => t.Id == deviceId);
@@ -1306,7 +1310,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
var name = sheetName.Split(' ')[0];
foreach (var model in modelList)
{
if(model.StepName.Contains(goodId))
if (model.StepName.Contains(goodId))
{
if (model.ActionValue == null && dataModel.Values.Count > 0)
{
@@ -1325,7 +1329,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
if (stepName == "" || stepName == model.StepName)
{
if(actionName == model.ActionName)
if (actionName == model.ActionName)
{
dataList.Add(dataModel);
dataModel = new GoodsTechnologyDataModel
@@ -1374,7 +1378,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
order++;
sort = 1;
}
FillStepName(data.Values);
var groupList = data.Values.GroupBy(t => t.StepName).ToList();
foreach (var groupItem in groupList)
{
@@ -1487,13 +1490,15 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
goodsInfo = exportDto.GoodsId.Count > 0
? await _db.Queryable<BPA_GoodsInfo>().Where(t => exportDto.GoodsId.Contains(t.Id)).ToListAsync()
: await _db.Queryable<BPA_GoodsInfo, BPA_GoodsType>((a, b) => new JoinQueryInfos(JoinType.Left, a.GoodsTypeId == b.Id)).ToListAsync();
var goodsTypeList = await _db.Queryable<BPA_GoodsType>().ToListAsync();
var deviceInfo = await _db.Queryable<BPA_DeviceInfo>().FirstAsync(t => t.Id == exportDto.DeviceId);
var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().ToListAsync();
var goodsAttributeValueList = await _db.Queryable<BPA_GoodsAttributeValue>().Where(t => goodsAttributeList.Select(a => a.Id).Contains(t.GoodsAttributeId)).OrderBy(a => a.Sort).ToListAsync();
IWorkbook workbook = new XSSFWorkbook();
foreach (var good in goodsInfo)
{
var name = good.Name;
var type = goodsTypeList.FirstOrDefault(a => a.Id == good.GoodsTypeId);
var name = good.Name + "_" + type.Name;
string[] charsToReplace = new string[] { "\\", "/", "?", "*", "[", "]" };
foreach (string c in charsToReplace)
{


正在加载...
取消
保存