Browse Source

第三方接口 配方管理和商品属性

master
zhaoy 9 months ago
parent
commit
95e8b51906
23 changed files with 869 additions and 55 deletions
  1. +5
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
  2. +84
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs
  3. +38
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomDto.cs
  4. +26
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomEntryDto.cs
  5. +23
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomEntryInsertDto.cs
  6. +19
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomInsertDto.cs
  7. +19
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomUpdateDto.cs
  8. +211
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs
  9. +52
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs
  10. +2
    -1
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs
  11. +11
    -5
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs
  12. +1
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs
  13. +24
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsAttributeVewDto.cs
  14. +34
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsAttributeinsertDto.cs
  15. +12
    -2
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsDto.cs
  16. +2
    -2
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInsertDto.cs
  17. +49
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsTechnologyActionListViewDto.cs
  18. +44
    -3
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
  19. +180
    -37
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
  20. +27
    -3
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
  21. +4
    -0
      BPA.SAAS.Manage.Application/BPA.SAAS.Manage.Application.csproj
  22. +1
    -1
      BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json
  23. +1
    -1
      BPA.SAAS.Manage.Web.Entry/appsettings.json

+ 5
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs View File

@@ -97,5 +97,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum
/// </summary>
[ErrorCodeItemMetadata("授权过期")]
Code10014,
/// <summary>
/// 配方不存在
/// </summary>
[ErrorCodeItemMetadata("配方不存在")]
Code10015,
}
}

+ 84
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs View File

@@ -0,0 +1,84 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Core.Base;
using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom
{
[ApiDescriptionSettings("开放平台", Tag = "配方管理"), AllowAnonymous]
public class BomServices:IDynamicApiController
{
IBomService _bomService;
public BomServices(IBomService bomService)
{
_bomService= bomService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Bom/GetBomPageList")]
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto)
{
return await _bomService.GetBomPageList(inputDto);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Bom/AddBom")]
public async Task<bool> AddBom(BaseRequestDto<BomInsertDto> dto)
{
return await _bomService.AddBom(dto);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Bom/UpdateBom")]
public async Task<bool> UpdateBom(BaseRequestDto<BomUpdateDto> dto)
{
return await _bomService.UpdateBom(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Bom/DeleteBom")]
public async Task<bool> DeleteBom(string[] ids)
{
return await _bomService.DeleteBom(ids);
}
/// <summary>
/// 根据配方id查询配方详情
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Bom/GetBomEntry")]
public async Task<BomEntryDto> GetBomEntry(string bomId)
{
return await _bomService.GetBomEntry(bomId);
}
/// <summary>
/// 添加配方详情
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Bom/AddBomEntry")]
public async Task<bool> AddBomEntry(BomEntryInsertDto dto)
{
return await _bomService.AddBomEntry(dto);
}
}
}

+ 38
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos
{
public class BomDto
{
public string Id { get; set; }
public string Name { get; set; }
/// <summary>
/// 1主料配方0 辅料配方
/// </summary>
public bool IsMain { get; set; }
public int Sort { get; set; }
public string GroupId { get; set; }
public List<BomEntr> BomEntr { get; set; }
}
public class BomEntr
{
public string Id { get; set; }
public string BatchingId { get; set; }
public string BatchingName { get; set; }
/// <summary>
/// 配方用量
/// </summary>
public decimal BomQty { get; set; }

/// <summary>
/// 配方id
/// </summary>
public string BomId { get; set; }
public int Sort { get; set; }
public string GroupId { get; set; }
}
}

+ 26
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomEntryDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos
{
public class BomEntryDto
{
public string Id { get; set; }
public string BatchingId { get; set; }
public string BatchingName { get; set; }
/// <summary>
/// 配方用量
/// </summary>
public decimal BomQty { get; set; }

/// <summary>
/// 配方id
/// </summary>
public string BomId { get; set; }
public string BomName { get; set; }
public int Sort { get; set; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomEntryInsertDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos
{
public class BomEntryInsertDto
{
public string BatchingId { get; set; }
/// <summary>
/// 配方用量
/// </summary>
public decimal BomQty { get; set; }

/// <summary>
/// 配方id
/// </summary>
public string BomId { get; set; }
public int Sort { get; set; }
}
}

+ 19
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomInsertDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos
{
public class BomInsertDto
{
public string Name { get; set; }
public string BomTypeName { get; set; }
/// <summary>
/// 1主料配方0 辅料配方
/// </summary>
public bool IsMain { get; set; }
public int Sort { get; set; }
}
}

+ 19
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomUpdateDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos
{
public class BomUpdateDto
{
public string Id { get; set; }
public string Name { get; set; }
/// <summary>
/// 1主料配方0 辅料配方
/// </summary>
public bool IsMain { get; set; }
public int Sort { get; set; }
}
}

+ 211
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs View File

@@ -0,0 +1,211 @@
using BPA.KitChen.GroupMeal.SqlSugar;
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using BPA.SAAS.Manage.Core.Device;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services
{
public class BomService: IBomService, ITransient
{
public BomService()
{

}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto)
{
int total = new RefAsync<int>();
var data = SqlSugarDb.Db.Queryable<BPA_Bom>()
.Select(a => new BomDto()
{
Id = a.Id.SelectAll(),
})
.Mapper(x =>
{
var list=SqlSugarDb.Db.Queryable<BPA_BomEntry, BPA_Batching>((a,b)=> new JoinQueryInfos(JoinType.Left, a.BatchingId == b.Id)).Select((a,b)=>new BomEntr
{
Id=a.Id,
BatchingId=a.BatchingId,
BomQty=a.BomQty,
BomId=a.BomId,
Sort=a.sort,
GroupId=a.GroupId,
BatchingName=b.Batching_Name
}).ToList();
x.BomEntr = list;
})
.ToPageList(inputDto.Current, inputDto.PageSize, ref total);

return new PageUtil<List<BomDto>>()
{
Total = total,
Data = data
};
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddBom(BaseRequestDto<BomInsertDto> dto)
{
try
{
SqlSugarDb.Db.BeginTran();
var resEntity = new BPA_Bom();
resEntity.Name = dto.DataInfo.Name;
resEntity.IsMain = dto.DataInfo.IsMain;
resEntity.Sort = dto.DataInfo.Sort;
resEntity.Code = GetNumber2(8);
var bom = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
BPA_BomTypeInfo _BomTypeInfo = new();
_BomTypeInfo.BomId = bom.Id;
var check = SqlSugarDb.Db.Queryable<BPA_BomType>().Where(x => x.Name == dto.DataInfo.BomTypeName).First();
if (check != null)
{
_BomTypeInfo.BomTypeId = check.Id;
}
else
{
var check1 = SqlSugarDb.Db.Queryable<BPA_BomType>().Where(x => x.Name == "默认分类").First();
if (check1 != null)
{
_BomTypeInfo.BomTypeId=check1.Id;
}
else
{
await SqlSugarDb.Db.Insertable(new BPA_BomType() { Name= "默认分类" }).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
}
}
// resEntity.Code = GetNumber2(8);
var res = await SqlSugarDb.Db.Insertable(_BomTypeInfo).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
SqlSugarDb.Db.CommitTran();
return res > 0;
}
catch (Exception)
{
SqlSugarDb.Db.RollbackTran();
throw Oops.Oh(ErrorCodeEnum.Code1007);
}

}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateBom(BaseRequestDto<BomUpdateDto> dto)
{
// 查询数据库中是否存在未删除的商品类型
var resEntity = SqlSugarDb.Db.Queryable<BPA_Bom>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.DataInfo.Id);
if (null == resEntity)
{
throw Oops.Oh(ErrorCodeEnum.Code10015);
}
resEntity.Name = dto.DataInfo.Name;
resEntity.IsMain = dto.DataInfo.IsMain;
resEntity.Sort = dto.DataInfo.Sort;

var res = await SqlSugarDb.Db.Updateable(resEntity).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<bool> DeleteBom(string[] ids)
{
try
{
SqlSugarDb.Db.BeginTran();
var goods = SqlSugarDb.Db.Queryable<BPA_Bom>().Where(x => ids.Contains(x.Id)).ToList();
if (goods == null) throw Oops.Oh(ErrorCodeEnum.Code10015);
var goodsbom = SqlSugarDb.Db.Queryable<BPA_BomEntry>().Where(x => ids.Contains(x.BomId)).ToList();
await SqlSugarDb.Db.Deleteable(goodsbom).ExecuteCommandAsync();
var res = await SqlSugarDb.Db.Deleteable(goods).ExecuteCommandAsync();
SqlSugarDb.Db.CommitTran();
return res > 0;
}
catch (Exception)
{
SqlSugarDb.Db.RollbackTran();
throw Oops.Oh("删除失败");
}

}
/// <summary>
/// 根据配方id查询配方详情
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
public async Task<BomEntryDto> GetBomEntry(string bomId)
{
try
{
var resEntity=await SqlSugarDb.Db.Queryable<BPA_BomEntry, BPA_Bom,BPA_Batching>((a,b,c)=> new JoinQueryInfos(JoinType.Left, a.BomId == b.Id, JoinType.Left, a.BatchingId == c.Id))
.Select((a, b, c)=> new BomEntryDto()
{
Id=a.Id,
BatchingId=a.BatchingId,
BomQty=a.BomQty,
Sort=a.sort,
BatchingName=c.Batching_Name,
BomId = a.BomId,
BomName=b.Name
}).FirstAsync();
return resEntity;
}
catch (Exception)
{
throw Oops.Oh(ErrorCodeEnum.Code1007);
}
}
/// <summary>
/// 添加配方详情
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddBomEntry(BomEntryInsertDto dto)
{
try
{
var resEntity = new BPA_BomEntry();
resEntity.BatchingId = dto.BatchingId;
resEntity.BomId = dto.BomId;
resEntity.BomQty = dto.BomQty;
resEntity.sort = dto.Sort;
var res = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
catch (Exception)
{
throw Oops.Oh(ErrorCodeEnum.Code1007);
}
}
private string GetNumber2(int Length = 10)
{
byte[] buffer = Guid.NewGuid().ToByteArray();
var ram = BitConverter.ToInt64(buffer, 0);
var str = string.Format("{0}", ram.ToString().Substring(0, Length));
return str;
}
}
}

+ 52
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs View File

@@ -0,0 +1,52 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
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.AExternalPlatform.Service.Bom.Services
{
public interface IBomService
{
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto);
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddBom(BaseRequestDto<BomInsertDto> dto);
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateBom(BaseRequestDto<BomUpdateDto> dto);
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<bool> DeleteBom(string[] ids);
/// <summary>
/// 根据配方id查询配方详情
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
public async Task<BomEntryDto> GetBomEntry(string bomId);
/// <summary>
/// 添加配方详情
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddBomEntry(BomEntryInsertDto dto);
}
}

+ 2
- 1
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs View File

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services;
using BPA.SAAS.Manage.Core.Base;
using Microsoft.AspNetCore.Components.Forms;


+ 11
- 5
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs View File

@@ -12,6 +12,7 @@ using BPA.SAAS.Manage.Core.Product;
using Furion.DependencyInjection;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -66,12 +67,17 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
resEntity.StopId = dto.StopId;
resEntity.ProductId = dto.ProductId;
resEntity.ProductVersionId = dto.ProductVersionId;
if (string.IsNullOrWhiteSpace(dto.ProductCode))
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == dto.ProductCode).First();
if (check != null)
{
resEntity.DeviceTypeId = check.Id;
}
else
{
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == "默认标签").First();
if (check != null)
var check1 = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == "默认标签").First();
if (check1 != null)
{
resEntity.DeviceTypeId = check.Id;
resEntity.DeviceTypeId = check1.Id;
}
else
{
@@ -105,7 +111,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
resEntity.ProductVersionId = dto.ProductVersionId;
if (!string.IsNullOrWhiteSpace(dto.ProductCode))
{
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Id == dto.ProductCode).First();
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == dto.ProductCode).First();
if (check != null)
{
resEntity.DeviceTypeId = check.Id;


+ 1
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs View File

@@ -1,4 +1,5 @@
using BPA.KitChen.GroupMeal.SqlSugar;
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos;
using BPA.SAAS.Manage.Core.Base;


+ 24
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsAttributeVewDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsAttributeVewDto
{
public string Id { get; set; }
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品小类id
/// </summary>
public string GoodsTypeId { get; set; }
public List<GoodsAttributeValue> AttributeValueList { get; set; }
public int Sort { get; set; }
}
}

+ 34
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsAttributeinsertDto.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsAttributeinsertDto
{
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品分类
/// </summary>
public string GoodsTypeName { get; set; }
public List<GoodsAttributeValue> GoodsAttributeValue { get; set; }
}
public class GoodsAttributeValue
{
public string Id { get; set; }
/// <summary>
///商品属性id
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 属性值
/// </summary>
public string AttributeValue { get; set; }
public int Sort { get; set; }
}
}

+ 12
- 2
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsDto.cs View File

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Core.DataBase;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,8 +8,17 @@ using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsDto:BPA_GoodsInfo
public class GoodsDto
{
public string Id { get; set; }
public string Name { get; set; }
public string Descritption { get; set; }
public string ImgUrl { get; set; }
public string Code { get; set; }
public decimal Price { get; set; }
public string GoodsUintId { get; set; }
public string GoodsTypeId { get; set; }
public string GroupId { get; set; }
public string GoodsTypeName { get; set; }
public string GoodsUnitName { get; set; }
}


+ 2
- 2
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInsertDto.cs View File

@@ -31,10 +31,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
/// <summary>
/// 商品分类id
/// </summary>
public string GoodsTypeId { get; set; }
public string GoodsTypeName { get; set; }
/// <summary>
/// 商品单位id
/// </summary>
public string GoodsUintId { get; set; }
public string GoodsUintName { get; set; }
}
}

+ 49
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsTechnologyActionListViewDto.cs View File

@@ -0,0 +1,49 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsTechnologyActionListViewDto
{
public string DeviceId { get; set; }
public string WarehousrTemplateId { get; set; }
public string GoodsAttributeId { get; set; }
public string DeviceName { get; set; }
public List<GoodsTechnologyActionViewDto> Data { get; set; }
}
public class GoodsTechnologyActionViewDto
{
public string Id { get; set; }
/// <summary>
/// 步骤名称
/// </summary>
public string StepName { get; set; }
/// <summary>
/// 动作json
/// </summary>
public string ActionJson { get; set; }
/// <summary>
/// 商品属性id集合
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 是否物料
/// </summary>
public bool IsBatch { get; set; }
/// <summary>
/// 动作value
/// </summary>
public string ChnologyId { get; set; }
public DateTime CreateAt { get; set; }
public string GroupId { get; set; }
public int IsDeleted { get; set; }
public int Sort { get; set; }
public string GoodsId { get; set; }
public string DeviceId { get; set; }
public string WarehousrTemplateId { get; set; }
}
}

+ 44
- 3
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs View File

@@ -1,8 +1,10 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services;
using BPA.SAAS.Manage.Core.Base;
using Microsoft.AspNetCore.Components.Forms;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -36,7 +38,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Goods/AddGoods")]
public async Task<bool> AddGoods(GoodsInsertDto dto)
public async Task<bool> AddGoods(BaseRequestDto<GoodsInsertDto> dto)
{
return await _goodsService.AddGoods(dto);
}
@@ -46,7 +48,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Goods/UpdateGoods")]
public async Task<bool> UpdateGoods(GoodsUpdateDto dto)
public async Task<bool> UpdateGoods(BaseRequestDto<GoodsUpdateDto> dto)
{
return await _goodsService.UpdateGoods(dto);
}
@@ -60,5 +62,44 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
{
return await _goodsService.DeleteGoods(ids);
}
/// <summary>
///添加商品属性
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Goods/AddGoodsAttribute")]
public async Task<bool> AddGoodsAttribute(GoodsAttributeinsertDto dto)
{
return await _goodsService.AddGoodsAttribute(dto);
}
/// <summary>
/// 查询商品属性
/// </summary>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Goods/GetGoodsAttributeList")]
public async Task<List<GoodsAttributeVewDto>> GetGoodsAttributeList()
{
return await _goodsService.GetGoodsAttributeList();
}
/// <summary>
/// 查询商品工艺
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Goods/GetGoodsTechnologyAction")]
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(string goodsId)
{
return await _goodsService.GetGoodsTechnologyAction(goodsId);
}
/// <summary>
/// 删除商品工艺
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Goods/DeleteGoodsTechnologyAction")]
public async Task<bool> DeleteGoodsTechnologyAction(string id)
{
return await _goodsService.DeleteGoodsTechnologyAction(id);
}
}
}

+ 180
- 37
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs View File

@@ -2,18 +2,10 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.SAAS.Manage.Core.Device;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
{
@@ -55,45 +47,56 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoods(GoodsInsertDto dto)
public async Task<bool> AddGoods(BaseRequestDto<GoodsInsertDto> dto)
{
try
{
SqlSugarDb.Db.BeginTran();
var resEntity = new BPA_GoodsInfo();
resEntity.GoodsTypeId = dto.GoodsTypeId;
resEntity.GoodsUintId = dto.GoodsUintId;
if (string.IsNullOrWhiteSpace(dto.GoodsTypeId))
//resEntity.GoodsTypeId = dto.DataInfo.GoodsTypeName;
//resEntity.GoodsUintId = dto.DataInfo.GoodsUintName;
var check = SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == dto.DataInfo.GoodsTypeName).First();
if (check != null)
{
var check=SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == "默认分类").First();
if (check!=null)
resEntity.GoodsTypeId = check.Id;
}
else
{
var check1 = SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == "默认分类").First();
if (check1 != null)
{
resEntity.GoodsTypeId = check.Id;
resEntity.GoodsTypeId = check1.Id;
}
else
{
var GoodsType=await SqlSugarDb.Db.Insertable(new BPA_GoodsType() { Pid="",Name= "默认分类" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
var GoodsType = await SqlSugarDb.Db.Insertable(new BPA_GoodsType() { Pid = "", Name = "默认分类" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
resEntity.GoodsTypeId = GoodsType.Id;
}
}
var checkUint = SqlSugarDb.Db.Queryable<BPA_GoodsUint>().Where(x => x.Name == dto.DataInfo.GoodsUintName).First();
if (checkUint != null)
{
resEntity.GoodsUintId = checkUint.Id;
}
if (string.IsNullOrWhiteSpace(dto.GoodsUintId))
else
{
var check = SqlSugarDb.Db.Queryable<BPA_GoodsUint>().Where(x => x.Name == "默认单位").First();
if (check != null)
var checkUint1 = SqlSugarDb.Db.Queryable<BPA_GoodsUint>().Where(x => x.Name == dto.DataInfo.GoodsUintName).First();
if (checkUint1 != null)
{
resEntity.GoodsTypeId = check.Id;
resEntity.GoodsUintId = checkUint1.Id;
}
else
{
var GoodsUint = await SqlSugarDb.Db.Insertable(new BPA_GoodsUint() {Name = "默认单位" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
var GoodsUint = await SqlSugarDb.Db.Insertable(new BPA_GoodsUint() { Name = "默认单位" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
resEntity.GoodsUintId = GoodsUint.Id;
}
}
resEntity.Name = dto.Name;
resEntity.Descritption = dto.Descritption;
resEntity.ImgUrl = dto.ImgUrl;
resEntity.Price = dto.Price;
resEntity.IsWeigh = dto.IsWeigh;
resEntity.Name = dto.DataInfo.Name;
resEntity.Descritption = dto.DataInfo.Descritption;
resEntity.ImgUrl = dto.DataInfo.ImgUrl;
resEntity.Price = dto.DataInfo.Price;
resEntity.IsWeigh = dto.DataInfo.IsWeigh;
resEntity.IsAttrubute = true;
resEntity.Code = GetNumber2(8);
@@ -113,21 +116,21 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateGoods(GoodsUpdateDto dto)
public async Task<bool> UpdateGoods(BaseRequestDto<GoodsUpdateDto> dto)
{
// 查询数据库中是否存在未删除的商品类型
var resEntity = SqlSugarDb.Db.Queryable<BPA_GoodsInfo>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id);
var resEntity = SqlSugarDb.Db.Queryable<BPA_GoodsInfo>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.DataInfo.Id);
if (null == resEntity)
{
throw Oops.Oh(ErrorCodeEnum.Code1008);
}
resEntity.GoodsTypeId = dto.GoodsTypeId;
resEntity.Name = dto.Name;
resEntity.Descritption = dto.Descritption;
resEntity.ImgUrl = dto.ImgUrl;
resEntity.Price = dto.Price;
resEntity.IsWeigh = dto.IsWeigh;
resEntity.GoodsUintId = dto.GoodsUintId;
resEntity.GoodsTypeId = dto.DataInfo.GoodsTypeId;
resEntity.Name = dto.DataInfo.Name;
resEntity.Descritption = dto.DataInfo.Descritption;
resEntity.ImgUrl = dto.DataInfo.ImgUrl;
resEntity.Price = dto.DataInfo.Price;
resEntity.IsWeigh = dto.DataInfo.IsWeigh;
resEntity.GoodsUintId = dto.DataInfo.GoodsUintId;
var res = await SqlSugarDb.Db.Updateable(resEntity).ExecuteCommandAsync();
return res > 0;
@@ -159,6 +162,146 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
}

}
/// <summary>
///添加商品属性
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsAttribute(GoodsAttributeinsertDto dto)
{
try
{
SqlSugarDb.Db.BeginTran();
BPA_GoodsAttribute _GoodsAttribute = new();
_GoodsAttribute.Id = Guid.NewGuid().ToString();
_GoodsAttribute.AttributeName = dto.AttributeName;
var GoodsType = SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == dto.GoodsTypeName).First();
if (GoodsType == null)
{
var resGoodsType = await SqlSugarDb.Db.Insertable(new BPA_GoodsType() { Pid = "", Name = "默认分类" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
_GoodsAttribute.GoodsTypeId = resGoodsType.Id;
}
else
{
_GoodsAttribute.GoodsTypeId = GoodsType.Id;
}
var res = await SqlSugarDb.Db.Insertable(_GoodsAttribute).ExecuteCommandAsync();
List<BPA_GoodsAttributeValue> GoodsAttributeValueList = new();
if (dto.GoodsAttributeValue.Count > 0)
{
SqlSugarDb.Db.Deleteable<BPA_GoodsAttributeValue>().Where(x => x.GoodsAttributeId == _GoodsAttribute.Id).ExecuteCommand();
for (int i = 0; i < dto.GoodsAttributeValue.Count; i++)
{
BPA_GoodsAttributeValue _GoodsAttributeValue = new();
_GoodsAttributeValue.GoodsAttributeId = _GoodsAttribute.Id;
_GoodsAttributeValue.AttributeValue = dto.GoodsAttributeValue[i].AttributeValue;
_GoodsAttributeValue.Sort = dto.GoodsAttributeValue[i].Sort;
GoodsAttributeValueList.Add(_GoodsAttributeValue);
}
SqlSugarDb.Db.Insertable(GoodsAttributeValueList).ExecuteCommand();
}
SqlSugarDb.Db.CommitTran();
return res > 0;
}
catch (Exception)
{
SqlSugarDb.Db.RollbackTran();
throw Oops.Oh(ErrorCodeEnum.Code1007);
throw;
}
}
/// <summary>
/// 查询商品属性
/// </summary>
/// <returns></returns>
public async Task<List<GoodsAttributeVewDto>> GetGoodsAttributeList()
{
var res = await SqlSugarDb.Db.Queryable<BPA_GoodsAttribute>()
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.Select(a => new GoodsAttributeVewDto
{
Id = a.Id,
AttributeName = a.AttributeName,
GoodsTypeId = a.GoodsTypeId,
Sort = a.Sort,
})
.Mapper(x =>
{
var list = SqlSugarDb.Db.Queryable<BPA_GoodsAttributeValue>().Where(p => p.GoodsAttributeId == x.Id).Select(x=>new GoodsAttributeValue() { AttributeValue=x.AttributeValue,Id=x.Id, GoodsAttributeId =x.GoodsAttributeId}).ToList();
x.AttributeValueList = list;
})
.ToListAsync();
return res;
}
/// <summary>
/// 查询商品工艺
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(string goodsId)
{
List<GoodsTechnologyActionListViewDto> goodsTechnologyActionListViews = new List<GoodsTechnologyActionListViewDto>();
var list = SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => x.GoodsId == goodsId)
.Select(x => new GoodsTechnologyActionViewDto()
{
Id = x.Id.SelectAll(),
}).OrderBy(x => x.Sort, OrderByType.Asc).ToList();
var Devicelist = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo>().ToListAsync();
var GoodsAttributeValue = await SqlSugarDb.Db.Queryable<BPA_GoodsAttributeValue>().ToListAsync();
var sf = list.GroupBy(x => x.GoodsAttributeId).ToList();
var sf1 = list.GroupBy(x => x.WarehousrTemplateId).ToList();
for (int i = 0; i < sf.Count; i++)
{
var sd = GoodsAttributeValue?.Where(x => sf[i].Key.Contains(x.Id)).Select(x => x.AttributeValue).ToArray();
var sdw = GoodsAttributeValue?.Where(x => sf[i].Key.Contains(x.Id)).Select(x => x.Id).ToArray();
var nane = string.Join('-', sd);
var s = sf[i].AsQueryable().ToList().GroupBy(x => x.DeviceId).ToList();
for (int t = 0; t < s.Count; t++)
{
GoodsTechnologyActionListViewDto item = new()
{
DeviceId = s[t].Key,
WarehousrTemplateId = sf1[t].Key,
GoodsAttributeId = string.Join(',', sdw),
DeviceName = Devicelist?.FirstOrDefault(x => x.Id == s[t].Key).DeviceName + "【" + nane + "】",
Data = s[t].AsQueryable().ToList(),
};
goodsTechnologyActionListViews.Add(item);
}
}

return goodsTechnologyActionListViews;
}
/// <summary>
/// 删除商品工艺
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<bool> DeleteGoodsTechnologyAction(string id)
{
var item = await SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => x.Id == id).FirstAsync();
if (item != null)
{
var res = await SqlSugarDb.Db.Deleteable(item).ExecuteCommandAsync() > 0;
var list = SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => x.GoodsId == item.GoodsId && x.DeviceId == item.DeviceId).OrderBy(x => x.Sort, OrderByType.Asc).ToList();
var uplist = new List<BPA_GoodsTechnologyAction>();
for (int i = 0; i < list.Count; i++)
{
list[i].Sort = i + 1;
uplist.Add(list[i]);
}
if (uplist.Count > 0)
{
await SqlSugarDb.Db.Updateable(uplist).ExecuteCommandAsync();
}
return true;
}
else
{
throw Oops.Oh("找不到相关数据,删除失败");
}
}
private string GetNumber2(int Length = 10)
{
byte[] buffer = Guid.NewGuid().ToByteArray();


+ 27
- 3
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs View File

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
@@ -21,18 +22,41 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoods(GoodsInsertDto dto);
Task<bool> AddGoods(BaseRequestDto<GoodsInsertDto> dto);
/// <summary>
/// 更新商品
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> UpdateGoods(GoodsUpdateDto dto);
Task<bool> UpdateGoods(BaseRequestDto<GoodsUpdateDto> dto);
/// <summary>
/// 删除商品
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<bool> DeleteGoods(string[] ids);
/// <summary>
///添加商品属性
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoodsAttribute(GoodsAttributeinsertDto dto);
/// <summary>
/// 查询商品属性
/// </summary>
/// <returns></returns>
Task<List<GoodsAttributeVewDto>> GetGoodsAttributeList();
/// <summary>
/// 查询商品工艺
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(string goodsId);
/// <summary>
/// 删除商品工艺
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<bool> DeleteGoodsTechnologyAction(string id);
}
}

+ 4
- 0
BPA.SAAS.Manage.Application/BPA.SAAS.Manage.Application.csproj View File

@@ -30,4 +30,8 @@
<ProjectReference Include="..\BPA.SAAS.Manage.Core\BPA.SAAS.Manage.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="AExternalPlatform\Service\Bom\Dtos\" />
</ItemGroup>

</Project>

+ 1
- 1
BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json View File

@@ -14,7 +14,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5009"
"applicationUrl": "http://localhost:5006"
},
"Docker": {
"commandName": "Docker",


+ 1
- 1
BPA.SAAS.Manage.Web.Entry/appsettings.json View File

@@ -8,7 +8,7 @@
}
},
"AllowedHosts": "*",
"baseurl": "http://localhost:5007/",
"baseurl": "http://localhost:5008/",
"ConnectionConfigs": [
{
"ConnectionString": "server=10.2.1.21;Database=bpa_kitchen_kitchenbasemanage;Uid=root;Pwd=cygadmin;Allow Zero Datetime=True;Convert Zero Datetime=True;",


Loading…
Cancel
Save