@@ -22,7 +22,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto | |||
public List<string> DeviceIdList { get; set; } | |||
public T DataInfo { get; set; } | |||
public List<T> DataInfo { get; set; } | |||
} | |||
} |
@@ -20,7 +20,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/ExternalPlatform/Bom/GetBomPageList")] | |||
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto) | |||
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageQueryDto inputDto) | |||
{ | |||
return await _bomService.GetBomPageList(inputDto); | |||
} | |||
@@ -33,6 +33,5 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos | |||
/// </summary> | |||
public string BomId { get; set; } | |||
public int Sort { get; set; } | |||
public string GroupId { get; set; } | |||
} | |||
} |
@@ -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.AExternalPlatform.Service.Bom.Dtos | |||
{ | |||
public class BomPageQueryDto: PageInputBase | |||
{ | |||
public string Name { get; set; } | |||
} | |||
} |
@@ -5,6 +5,9 @@ using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Dtos; | |||
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.DataBase; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using NPOI.XWPF.UserModel; | |||
using SixLabors.ImageSharp.PixelFormats; | |||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
{ | |||
@@ -19,10 +22,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto) | |||
public async Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageQueryDto inputDto) | |||
{ | |||
int total = new RefAsync<int>(); | |||
var data = SqlSugarDb.Db.Queryable<BPA_Bom>() | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Name),x=>x.Name.Contains(inputDto.Name)) | |||
.Select(a => new BomDto() | |||
{ | |||
Id = a.Id.SelectAll(), | |||
@@ -36,7 +40,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
BomQty=a.BomQty, | |||
BomId=a.BomId, | |||
Sort=a.sort, | |||
GroupId=a.GroupId, | |||
BatchingName=b.Batching_Name | |||
}).ToList(); | |||
x.BomEntr = list; | |||
@@ -59,35 +62,46 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
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) | |||
List<BPA_Bom> list = new(); | |||
List<BPA_BomType> BomTypelist = new(); | |||
List<BPA_BomTypeInfo> BomTypeInfolist = new(); | |||
for (int i = 0; i < dto.DataInfo.Count; i++) | |||
{ | |||
_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 | |||
var resEntity = new BPA_Bom(); | |||
resEntity.Id = Guid.NewGuid().ToString(); | |||
resEntity.Name = dto.DataInfo[i].Name; | |||
resEntity.IsMain = dto.DataInfo[i].IsMain; | |||
resEntity.Sort = dto.DataInfo[i].Sort; | |||
resEntity.Code = GetNumber2(8); | |||
list.Add(resEntity); | |||
if (!string.IsNullOrEmpty(dto.DataInfo[i].BomTypeName)) | |||
{ | |||
await SqlSugarDb.Db.Insertable(new BPA_BomType() { Name= "默认分类" }).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||
var check = SqlSugarDb.Db.Queryable<BPA_BomType>().Where(x => x.Name == dto.DataInfo[i].BomTypeName).First(); | |||
if (check == null) | |||
{ | |||
var BomType = new BPA_BomType() { Id = Guid.NewGuid().ToString(),Name = dto.DataInfo[i].BomTypeName}; | |||
BomTypelist.Add(BomType); | |||
BPA_BomTypeInfo _BomTypeInfo = new(); | |||
_BomTypeInfo.Id = Guid.NewGuid().ToString(); | |||
_BomTypeInfo.BomId = resEntity.Id; | |||
_BomTypeInfo.BomTypeId = BomType.Id; | |||
BomTypeInfolist.Add(_BomTypeInfo); | |||
} | |||
else | |||
{ | |||
BPA_BomTypeInfo _BomTypeInfo = new(); | |||
_BomTypeInfo.Id = Guid.NewGuid().ToString(); | |||
_BomTypeInfo.BomId = resEntity.Id; | |||
_BomTypeInfo.BomTypeId = check.Id; | |||
BomTypeInfolist.Add(_BomTypeInfo); | |||
} | |||
} | |||
} | |||
// resEntity.Code = GetNumber2(8); | |||
var res = await SqlSugarDb.Db.Insertable(_BomTypeInfo).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||
await SqlSugarDb.Db.Insertable(list).ExecuteCommandAsync(); | |||
await SqlSugarDb.Db.Insertable(BomTypelist).ExecuteCommandAsync(); | |||
await SqlSugarDb.Db.Insertable(BomTypeInfolist).ExecuteCommandAsync(); | |||
SqlSugarDb.Db.CommitTran(); | |||
return res > 0; | |||
return true; | |||
} | |||
catch (Exception) | |||
{ | |||
@@ -103,17 +117,20 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
/// <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) | |||
if (dto.DataInfo.Count > 1) throw Oops.Oh("不支持多条商品修改"); | |||
var list = new List<BPA_Bom>(); | |||
for (int i = 0; i < dto.DataInfo.Count; i++) | |||
{ | |||
throw Oops.Oh(ErrorCodeEnum.Code10015); | |||
var resEntity = SqlSugarDb.Db.Queryable<BPA_Bom>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.DataInfo[i].Id); | |||
if (resEntity != null) | |||
{ | |||
resEntity.Name = dto.DataInfo[i].Name; | |||
resEntity.IsMain = dto.DataInfo[i].IsMain; | |||
resEntity.Sort = dto.DataInfo[i].Sort; | |||
list.Add(resEntity); | |||
} | |||
} | |||
resEntity.Name = dto.DataInfo.Name; | |||
resEntity.IsMain = dto.DataInfo.IsMain; | |||
resEntity.Sort = dto.DataInfo.Sort; | |||
var res = await SqlSugarDb.Db.Updateable(resEntity).ExecuteCommandAsync(); | |||
var res = await SqlSugarDb.Db.Updateable(list).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
@@ -17,7 +17,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageInputDto inputDto); | |||
Task<PageUtil<List<BomDto>>> GetBomPageList(BomPageQueryDto inputDto); | |||
/// <summary> | |||
/// 添加 | |||
/// </summary> | |||
@@ -55,7 +55,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device | |||
/// <param name="ids"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/ExternalPlatform/Device/DeleteDevice")] | |||
public async Task<bool> DeleteDevice(string[] ids) | |||
public async Task<bool> DeleteDevice(DeviceInfoDelDto ids) | |||
{ | |||
return await _deviceService.DeleteDevice(ids); | |||
} | |||
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos | |||
{ | |||
public class DeviceInfoDelDto | |||
{ | |||
public string[] Ids { get; set; } | |||
} | |||
} |
@@ -18,21 +18,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos | |||
/// 设备标签 | |||
/// </summary> | |||
public string DeviceTypeId { get; set; } | |||
/// <summary> | |||
///归属场景(店铺) | |||
/// </summary> | |||
public string StopId { get; set; } | |||
/// <summary> | |||
/// 所属产品 | |||
/// </summary> | |||
public string ProductId { get; set; } | |||
/// <summary> | |||
/// 产品标签 | |||
/// </summary> | |||
public string DeviceTypeName { get; set; } | |||
/// <summary> | |||
/// 产品版本 | |||
/// </summary> | |||
public string ProductVersionId { get; set; } | |||
} | |||
} |
@@ -13,6 +13,7 @@ using BPA.SAAS.Manage.Core.Product; | |||
using Furion.DependencyInjection; | |||
using Furion.RemoteRequest.Extensions; | |||
using Newtonsoft.Json; | |||
using NPOI.Util; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
@@ -68,24 +69,21 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||
resEntity.StopId = dto.StopId; | |||
resEntity.ProductId = dto.ProductId; | |||
resEntity.ProductVersionId = dto.ProductVersionId; | |||
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == dto.DeviceTypeName).First(); | |||
if (check != null) | |||
resEntity.DeviceTypeId= dto.DeviceTypeId; | |||
if (!string.IsNullOrEmpty(dto.DeviceTypeName)) | |||
{ | |||
resEntity.DeviceTypeId = check.Id; | |||
} | |||
else | |||
{ | |||
var check1 = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == "默认标签").First(); | |||
if (check1 != null) | |||
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == dto.DeviceTypeName).First(); | |||
if (check != null) | |||
{ | |||
resEntity.DeviceTypeId = check1.Id; | |||
resEntity.DeviceTypeId = check.Id; | |||
} | |||
else | |||
{ | |||
var DeviceType = await SqlSugarDb.Db.Insertable(new BPA_DeviceType() { Name = "默认标签" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
var DeviceType = await SqlSugarDb.Db.Insertable(new BPA_DeviceType() { Name = dto.DeviceTypeName }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
resEntity.DeviceTypeId = DeviceType.Id; | |||
} | |||
} | |||
var res = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||
SqlSugarDb.Db.CommitTran(); | |||
return res > 0; | |||
@@ -105,35 +103,29 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||
public async Task<bool>UpdateDevice(DeviceUpateDto dto) | |||
{ | |||
var resEntity = SqlSugarDb.Db.Queryable<BPA_DeviceInfo>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id); | |||
await CheckUpdateParm(dto);//验证参数 | |||
resEntity.DeviceName = dto.DeviceName; | |||
resEntity.StopId = dto.StopId; | |||
resEntity.ProductId = dto.ProductId; | |||
resEntity.ProductVersionId = dto.ProductVersionId; | |||
if (!string.IsNullOrWhiteSpace(dto.DeviceTypeName)) | |||
//resEntity.StopId = dto.StopId; | |||
//resEntity.ProductId = dto.ProductId; | |||
//resEntity.ProductVersionId = dto.ProductVersionId; | |||
if (!string.IsNullOrWhiteSpace(dto.DeviceTypeId)) | |||
{ | |||
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == dto.DeviceTypeName).First(); | |||
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Id == dto.DeviceTypeId).First(); | |||
if (check != null) | |||
{ | |||
resEntity.DeviceTypeId = check.Id; | |||
} | |||
else | |||
{ | |||
throw Oops.Oh(ErrorCodeEnum.Code10013); | |||
} | |||
} | |||
else | |||
{ | |||
var check = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == "默认标签").First(); | |||
if (check != null) | |||
{ | |||
resEntity.DeviceTypeId = check.Id; | |||
} | |||
else | |||
{ | |||
var DeviceType = await SqlSugarDb.Db.Insertable(new BPA_DeviceType() { Name = "默认标签" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
resEntity.DeviceTypeId = DeviceType.Id; | |||
var check1 = SqlSugarDb.Db.Queryable<BPA_DeviceType>().Where(x => x.Name == "默认标签").First(); | |||
if (check1 != null) | |||
{ | |||
resEntity.DeviceTypeId = check1.Id; | |||
} | |||
else | |||
{ | |||
var DeviceType = await SqlSugarDb.Db.Insertable(new BPA_DeviceType() { Name = "默认标签" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
resEntity.DeviceTypeId = DeviceType.Id; | |||
} | |||
} | |||
} | |||
var res = await SqlSugarDb.Db.Updateable(resEntity).ExecuteCommandAsync(); | |||
@@ -144,11 +136,14 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||
/// </summary> | |||
/// <param name="ids"></param> | |||
/// <returns></returns> | |||
public async Task<bool> DeleteDevice(string[] ids) | |||
public async Task<bool> DeleteDevice(DeviceInfoDelDto dto) | |||
{ | |||
var model = SqlSugarDb.Db.Queryable<BPA_DeviceInfo>().Where(x => ids.Contains(x.Id)).ToList(); | |||
if (model == null) throw Oops.Oh(ErrorCodeEnum.Code10012); | |||
var res = await SqlSugarDb.Db.Deleteable(model).ExecuteCommandAsync(); | |||
var data = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo>().Where(x => dto.Ids.Contains(x.Id)).ToListAsync(); | |||
var GoodsTechnology = await SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => dto.Ids.Contains(x.DeviceId)).AnyAsync(); | |||
if (GoodsTechnology) throw Oops.Oh("商品工艺已经关联到该设备下面,无法删除,请先解除商品工艺对应的设备"); | |||
var WarehouseTemplate = await SqlSugarDb.Db.Queryable<BPA_WarehouseTemplate>().Where(x => dto.Ids.Contains(x.DeviceId)).AnyAsync(); | |||
if (WarehouseTemplate) throw Oops.Oh("该设备已绑定了仓位模板,无法删除,请先删除该设备的仓位模板"); | |||
var res = await SqlSugarDb.Db.Deleteable(data).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
@@ -171,30 +166,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||
if (resStop == null) throw Oops.Oh(ErrorCodeEnum.Code10022); | |||
// if(!dataStop.Where(x=>x.Id == dto.StopId).Any()) throw Oops.Oh(ErrorCodeEnum.Code10022); | |||
var checkProduct = SqlSugarDb.Db.Queryable<BPA_Product>().Where(x => x.Id == dto.ProductId).Any(); | |||
if (!checkProduct) throw Oops.Oh(ErrorCodeEnum.Code10010); | |||
var checkProductVesion = SqlSugarDb.Db.Queryable<BPA_ProductVesion>().Where(x => x.Id == dto.ProductVersionId).Any(); | |||
if (!checkProductVesion) throw Oops.Oh(ErrorCodeEnum.Code10011); | |||
} | |||
/// <summary> | |||
/// 校验参数 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
private async Task CheckUpdateParm(DeviceUpateDto dto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(dto.StopId)) throw Oops.Oh(ErrorCodeEnum.Code1009); | |||
var getStopurl = BaseServerUrl + "api/store/getbyIdstorelist_alm?id=" + dto.StopId; | |||
var responseStop = await getStopurl.SetHeaders(new | |||
{ | |||
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value | |||
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync(); | |||
var responData = JsonConvert.DeserializeObject<ResponDataBase>(responseStop); | |||
var resStop = JsonConvert.DeserializeObject<StopDto>(responData.data.ToString()); | |||
if (responData.statusCode != "200") throw Oops.Oh(ErrorCodeEnum.Code10021); | |||
//var dataStop = responData?.data; | |||
if (resStop == null) throw Oops.Oh(ErrorCodeEnum.Code10022); | |||
var checkProduct = SqlSugarDb.Db.Queryable<BPA_Product>().Where(x => x.Id == dto.ProductId).Any(); | |||
if (!checkProduct) throw Oops.Oh(ErrorCodeEnum.Code10010); | |||
var checkProductVesion = SqlSugarDb.Db.Queryable<BPA_ProductVesion>().Where(x => x.Id == dto.ProductVersionId).Any(); | |||
@@ -37,6 +37,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||
/// </summary> | |||
/// <param name="ids"></param> | |||
/// <returns></returns> | |||
Task<bool> DeleteDevice(string[] ids); | |||
Task<bool> DeleteDevice(DeviceInfoDelDto ids); | |||
} | |||
} |
@@ -12,6 +12,8 @@ using BPA.SAAS.Manage.Core.DataBase; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using Newtonsoft.Json; | |||
using SqlSugar; | |||
using System.Linq; | |||
using GoodsDto = BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos.GoodsDto; | |||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services | |||
@@ -60,55 +62,51 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services | |||
try | |||
{ | |||
SqlSugarDb.Db.BeginTran(); | |||
var resEntity = new BPA_GoodsInfo(); | |||
//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) | |||
List< BPA_GoodsInfo > list = new(); | |||
List<BPA_GoodsType> GoodsTypelist = new(); | |||
List<BPA_GoodsUint> GoodsUintlist = new(); | |||
for (int i = 0; i < dto.DataInfo.Count; i++) | |||
{ | |||
resEntity.GoodsTypeId = check.Id; | |||
} | |||
else | |||
{ | |||
var check1 = SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == "默认分类").First(); | |||
if (check1 != null) | |||
{ | |||
resEntity.GoodsTypeId = check1.Id; | |||
} | |||
else | |||
{ | |||
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; | |||
} | |||
else | |||
{ | |||
var checkUint1 = SqlSugarDb.Db.Queryable<BPA_GoodsUint>().Where(x => x.Name == dto.DataInfo.GoodsUintName).First(); | |||
if (checkUint1 != null) | |||
var resEntity = new BPA_GoodsInfo(); | |||
resEntity.Name = dto.DataInfo[i].Name; | |||
resEntity.Descritption = dto.DataInfo[i].Descritption; | |||
resEntity.ImgUrl = dto.DataInfo[i].ImgUrl; | |||
resEntity.Price = dto.DataInfo[i].Price; | |||
resEntity.IsWeigh = dto.DataInfo[i].IsWeigh; | |||
resEntity.IsAttrubute = true; | |||
resEntity.Code = GetNumber2(8); | |||
if (!string.IsNullOrEmpty(dto.DataInfo[i].GoodsTypeName)) | |||
{ | |||
resEntity.GoodsUintId = checkUint1.Id; | |||
var check = SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Name == dto.DataInfo[i].GoodsTypeName).First(); | |||
if (check == null) | |||
{ | |||
var GoodsType = new BPA_GoodsType() { Id = Guid.NewGuid().ToString(), Pid = "", Name = dto.DataInfo[i].GoodsTypeName }; | |||
GoodsTypelist.Add(GoodsType); | |||
resEntity.GoodsTypeId = GoodsType.Id; | |||
} | |||
else | |||
{ | |||
resEntity.GoodsTypeId = check.Id; | |||
} | |||
} | |||
else | |||
if (!string.IsNullOrEmpty(dto.DataInfo[i].GoodsUintName)) | |||
{ | |||
var GoodsUint = await SqlSugarDb.Db.Insertable(new BPA_GoodsUint() { Name = "默认单位" }).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
resEntity.GoodsUintId = GoodsUint.Id; | |||
var check1 = SqlSugarDb.Db.Queryable<BPA_GoodsUint>().Where(x => x.Name == dto.DataInfo[i].GoodsUintName).First(); | |||
if (check1 == null) | |||
{ | |||
var GoodsUint = new BPA_GoodsUint() { Id = Guid.NewGuid().ToString(),Name = dto.DataInfo[i].GoodsUintName }; | |||
GoodsUintlist.Add(GoodsUint); | |||
resEntity.GoodsUintId = GoodsUint.Id; | |||
} | |||
else | |||
{ | |||
resEntity.GoodsUintId = check1.Id; | |||
} | |||
} | |||
} | |||
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); | |||
var res = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
await SqlSugarDb.Db.Insertable(GoodsTypelist).ExecuteCommandAsync(); | |||
await SqlSugarDb.Db.Insertable(GoodsUintlist).ExecuteCommandAsync(); | |||
var res = await SqlSugarDb.Db.Insertable(list).ExecuteReturnEntityAsync(); | |||
SqlSugarDb.Db.CommitTran(); | |||
#region 下发数据到设备 | |||
@@ -154,49 +152,54 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services | |||
/// <returns></returns> | |||
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.DataInfo.Id); | |||
if (null == resEntity) | |||
{ | |||
throw Oops.Oh(ErrorCodeEnum.Code1008); | |||
} | |||
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(); | |||
#region 下发数据到设备 | |||
var data = SqlSugarDb.Db.Queryable<BPA_GoodsInfo, BPA_GoodsType, BPA_GoodsUint>((a, b, c) => | |||
new JoinQueryInfos(JoinType.Left, a.GoodsTypeId == b.Id, | |||
JoinType.Left, a.GoodsUintId == c.Id)) | |||
.Where((a, b, c) => a.Id == resEntity.Id).Select((a, b, c) => new GoodsInfoPushDto() | |||
{ | |||
Id = a.Id, | |||
Name = a.Name, | |||
Descritption = a.Descritption, | |||
ImgUrl = a.ImgUrl, | |||
Sort = a.Sort, | |||
Price = a.Price, | |||
GoodsUintId = a.GoodsUintId, | |||
GoodsUintName = c.Name, | |||
IsWeigh = a.IsWeigh, | |||
Design = a.Design, | |||
DefaultMate = a.DefaultMate, | |||
IsAttrubute = a.IsAttrubute, | |||
GoodsTypeId = a.GoodsTypeId, | |||
GoodsTypeName = b.Name, | |||
}).First(); | |||
if (dto.IsPush) | |||
List<BPA_GoodsInfo> list = new(); | |||
if (dto.DataInfo.Count > 1) throw Oops.Oh("不支持多条商品修改"); | |||
for (int i = 0; i < dto.DataInfo.Count; i++) | |||
{ | |||
await _thirdpartyPushService.AddPushRecordAndPushDevice(dto, 1, resEntity.Id, | |||
JsonConvert.SerializeObject(data)); | |||
var resEntity = SqlSugarDb.Db.Queryable<BPA_GoodsInfo>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.DataInfo[i].Id); | |||
if (resEntity != null) | |||
{ | |||
resEntity.GoodsTypeId = dto.DataInfo[i].GoodsTypeId; | |||
resEntity.Name = dto.DataInfo[i].Name; | |||
resEntity.Descritption = dto.DataInfo[i].Descritption; | |||
resEntity.ImgUrl = dto.DataInfo[i].ImgUrl; | |||
resEntity.Price = dto.DataInfo[i].Price; | |||
resEntity.IsWeigh = dto.DataInfo[i].IsWeigh; | |||
resEntity.GoodsUintId = dto.DataInfo[i].GoodsUintId; | |||
list.Add(resEntity); | |||
var res = await SqlSugarDb.Db.Updateable(list).ExecuteCommandAsync(); | |||
#region 下发数据到设备 | |||
var data = SqlSugarDb.Db.Queryable<BPA_GoodsInfo, BPA_GoodsType, BPA_GoodsUint>((a, b, c) => | |||
new JoinQueryInfos(JoinType.Left, a.GoodsTypeId == b.Id, | |||
JoinType.Left, a.GoodsUintId == c.Id)) | |||
.Where((a, b, c) => a.Id == resEntity.Id).Select((a, b, c) => new GoodsInfoPushDto() | |||
{ | |||
Id = a.Id, | |||
Name = a.Name, | |||
Descritption = a.Descritption, | |||
ImgUrl = a.ImgUrl, | |||
Sort = a.Sort, | |||
Price = a.Price, | |||
GoodsUintId = a.GoodsUintId, | |||
GoodsUintName = c.Name, | |||
IsWeigh = a.IsWeigh, | |||
Design = a.Design, | |||
DefaultMate = a.DefaultMate, | |||
IsAttrubute = a.IsAttrubute, | |||
GoodsTypeId = a.GoodsTypeId, | |||
GoodsTypeName = b.Name, | |||
}).First(); | |||
if (dto.IsPush) | |||
{ | |||
await _thirdpartyPushService.AddPushRecordAndPushDevice(dto, 1, resEntity.Id, | |||
JsonConvert.SerializeObject(data)); | |||
} | |||
#endregion | |||
} | |||
} | |||
#endregion | |||
return res > 0; | |||
// 查询数据库中是否存在未删除的商品类型 | |||
return true; | |||
} | |||
/// <summary> | |||
/// 删除商品 | |||
@@ -10,8 +10,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Bom | |||
public class BomPageInputDto: PageInputBase | |||
{ | |||
public string Name { get; set; } | |||
public string bomTypeList { get; set; } | |||
public List<string> Pertains { get; set; } | |||
//public string bomTypeList { get; set; } | |||
//public List<string> Pertains { get; set; } | |||
} | |||
public class BomCreateInputDto | |||
@@ -235,8 +235,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
var pertainList = _db.Queryable<BPA_BomTypeInfo, BPA_BomType>((a, b) => | |||
new JoinQueryInfos(JoinType.Left, a.BomTypeId == b.Id)) | |||
.Where((a, b) => a.IsDeleted == 0 && b.IsDeleted == 0) | |||
.WhereIF(inputDto.Pertains != null && inputDto.Pertains.Count > 0, (a, b) => inputDto.Pertains.Contains(b.Pertain)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), (a, b) => b.Id == inputDto.bomTypeList) | |||
//.WhereIF(inputDto.Pertains != null && inputDto.Pertains.Count > 0, (a, b) => inputDto.Pertains.Contains(b.Pertain)) | |||
//.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), (a, b) => b.Id == inputDto.bomTypeList) | |||
.Select((a, b) => a.BomId) | |||
.ToList(); | |||
@@ -244,7 +244,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
var res = _db.Queryable<BPA_Bom>() | |||
.Where(it => it.IsDeleted == 0) | |||
.WhereIF(!string.IsNullOrEmpty(inputDto.Name),x=>x.Name.Contains(inputDto.Name)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), x => pertainList.Contains(x.Id)) | |||
//.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), x => pertainList.Contains(x.Id)) | |||
.OrderBy(i => i.CreateAt, OrderByType.Desc) | |||
.ToPageList(inputDto.Current, inputDto.PageSize, ref total); | |||
@@ -7,6 +7,7 @@ using BPA.SAAS.Manage.Comm.Enum; | |||
using BPA.SAAS.Manage.Comm.Model; | |||
using BPA.SAAS.Manage.Comm.Util; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.DataBase; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using BPA.SAAS.Manage.Core.Org; | |||
using BPA.SAAS.Manage.Core.Product; | |||
@@ -178,6 +179,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||
public async Task<bool> DelDeviceInfo(List<string> inputList) | |||
{ | |||
var data = await _db.Queryable<BPA_DeviceInfo>().Where(x => inputList.Contains(x.Id)).ToListAsync(); | |||
var GoodsTechnology = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(x => inputList.Contains(x.DeviceId)).AnyAsync(); | |||
if (GoodsTechnology) throw Oops.Oh("商品工艺已经关联到该设备下面,无法删除,请先解除商品工艺对应的设备"); | |||
var WarehouseTemplate = await _db.Queryable<BPA_WarehouseTemplate>().Where(x => inputList.Contains(x.DeviceId)).AnyAsync(); | |||
if (WarehouseTemplate) throw Oops.Oh("该设备已绑定了仓位模板,无法删除,请先删除该设备的仓位模板"); | |||
var res = await _db.Deleteable(data) .ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||