Browse Source

仓位模板和商品及接口修改

master
zhaoy 6 months ago
parent
commit
f468d777cd
16 changed files with 431 additions and 75 deletions
  1. +3
    -9
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs
  2. +13
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomIdDto.cs
  3. +2
    -10
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs
  4. +1
    -1
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs
  5. +13
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsIdDto.cs
  6. +26
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInfoPushDto.cs
  7. +3
    -13
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
  8. +70
    -35
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
  9. +1
    -7
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
  10. +13
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseDevideId.cs
  11. +24
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplatInsertDto.cs
  12. +15
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateQueryDto.cs
  13. +21
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateView.cs
  14. +18
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/IWarehouseTemplateService.cs
  15. +151
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
  16. +57
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs

+ 3
- 9
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs View File

@@ -3,12 +3,6 @@ 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
{
@@ -65,10 +59,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Bom/GetBomEntry")]
public async Task<BomEntryDto> GetBomEntry(string bomId)
[HttpPost("/api/ExternalPlatform/Bom/GetBomEntry")]
public async Task<BomEntryDto> GetBomEntry(BomIdDto dto)
{
return await _bomService.GetBomEntry(bomId);
return await _bomService.GetBomEntry(dto);
}
/// <summary>
/// 添加配方详情


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

@@ -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.Bom.Dtos
{
public class BomIdDto
{
public string BomId { get; set; }
}
}

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

@@ -2,18 +2,9 @@
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
{
@@ -155,11 +146,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
public async Task<BomEntryDto> GetBomEntry(string bomId)
public async Task<BomEntryDto> GetBomEntry(BomIdDto dto)
{
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))
.WhereIF(dto!=null && !string.IsNullOrWhiteSpace(dto.BomId), (a, b, c)=>b.Id== dto.BomId)
.Select((a, b, c)=> new BomEntryDto()
{
Id=a.Id,


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

@@ -41,7 +41,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services
/// </summary>
/// <param name="bomId"></param>
/// <returns></returns>
Task<BomEntryDto> GetBomEntry(string bomId);
Task<BomEntryDto> GetBomEntry(BomIdDto dto);
/// <summary>
/// 添加配方详情
/// </summary>


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

@@ -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.Goods.Dtos
{
public class GoodsIdDto
{
public string GoodsId { get; set; }
}
}

+ 26
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInfoPushDto.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.Goods.Dtos
{
public class GoodsInfoPushDto
{
public string Id { get; set; }
public string Name { get; set; }
public string Descritption { get; set; }
public string ImgUrl { get; set; }
public int Sort { get; set; }
public decimal Price { get; set; }
public string GoodsUintId { get; set; }
public string GoodsUintName { get; set; }
public bool IsWeigh { get; set; }
public string Design { get; set; }
public string DefaultMate { get; set; }
public bool IsAttrubute { get; set; }
public string GoodsTypeId { get; set; }
public string GoodsTypeName { get; set; }
}
}

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

@@ -76,7 +76,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
/// 查询商品属性
/// </summary>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Goods/GetGoodsAttributeList")]
[HttpPost("/api/ExternalPlatform/Goods/GetGoodsAttributeList")]
public async Task<List<GoodsAttributeVewDto>> GetGoodsAttributeList()
{
return await _goodsService.GetGoodsAttributeList();
@@ -86,20 +86,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
[HttpGet("/api/ExternalPlatform/Goods/GetGoodsTechnologyAction")]
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(string goodsId)
[HttpPost("/api/ExternalPlatform/Goods/GetGoodsTechnologyAction")]
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(GoodsIdDto 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);
}
}
}

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

@@ -2,18 +2,26 @@
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.ThirdpartyPush.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using BPA.SAAS.Manage.Core.Device;
using Microsoft.AspNetCore.Components.Forms;
using Newtonsoft.Json;
using GoodsDto = BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos.GoodsDto;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
{
public class GoodsService: IGoodsService, ITransient
{
public GoodsService()
private readonly IThirdpartyPushService _thirdpartyPushService;
public GoodsService(IThirdpartyPushService thirdpartyPushService)
{
_thirdpartyPushService= thirdpartyPushService;
}
/// <summary>
/// 分页查询商品
@@ -100,9 +108,37 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
resEntity.IsAttrubute = true;
resEntity.Code = GetNumber2(8);
var res = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
var res = await SqlSugarDb.Db.Insertable(resEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();

SqlSugarDb.Db.CommitTran();
return res > 0;
#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 == res.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, res.Id,
JsonConvert.SerializeObject(data));
}
#endregion
return res !=null;
}
catch (Exception)
{
@@ -133,6 +169,33 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
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)
{
await _thirdpartyPushService.AddPushRecordAndPushDevice(dto, 1, resEntity.Id,
JsonConvert.SerializeObject(data));
}
#endregion
return res > 0;
}
/// <summary>
@@ -239,10 +302,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(string goodsId)
public async Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(GoodsIdDto dto)
{
List<GoodsTechnologyActionListViewDto> goodsTechnologyActionListViews = new List<GoodsTechnologyActionListViewDto>();
var list = SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => x.GoodsId == goodsId)
var list = SqlSugarDb.Db.Queryable<BPA_GoodsTechnologyAction>().Where(x => x.GoodsId == dto.GoodsId)
.Select(x => new GoodsTechnologyActionViewDto()
{
Id = x.Id.SelectAll(),
@@ -273,35 +336,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services

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();


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

@@ -51,12 +51,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
/// </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);
Task<List<GoodsTechnologyActionListViewDto>> GetGoodsTechnologyAction(GoodsIdDto goodsId);
}
}

+ 13
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseDevideId.cs View File

@@ -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.WarehouseTemplate.Dtos
{
public class WarehouseDevideId
{
public string DeviceId { get; set; }
}
}

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

@@ -0,0 +1,24 @@
using BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos
{
public class WarehouseTemplatInsertDto
{
public string Id { get; set; }
public string DeviceId { get; set; }
public string TemplateName { get; set; }
public List<WarehousePostionInsert> WarehousePostionData { get; set; }
}
public class WarehousePostionInsert
{
public string Id { get; set; }
public string TemplateId { get; set; }
public string Code { get; set; }
public string BatchingId { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateQueryDto.cs View File

@@ -0,0 +1,15 @@
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.WarehouseTemplate.Dtos
{
public class WarehouseTemplateQueryDto: PageInputBase
{
public string DeviceName { get; set; }
public string TemplateName { get; set; }
}
}

+ 21
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateView.cs View File

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

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos
{
public class WarehouseTemplateView
{
public string Id { get; set; }
public string DeviceId { get; set; }
public string DeviceName { get; set; }
public string TemplateName { get; set; }
public DateTime CreateAt { get; set; }
public int ProductNumber { get; set; }
public string ProductUrl { get; set; }
public List<BPA_WarehousePostion> WarehousePostion { get; set; }
}
}

+ 18
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/IWarehouseTemplateService.cs View File

@@ -0,0 +1,18 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos;
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.WarehouseTemplate.Services
{
public interface IWarehouseTemplateService
{
Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto);
Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(WarehouseDevideId dto);
Task<bool> AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto);
Task<bool> UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto);
}
}

+ 151
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs View File

@@ -0,0 +1,151 @@
using BPA.KitChen.GroupMeal.SqlSugar;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using BPA.SAAS.Manage.Core.Product;
using LogicExtensions;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Services
{
public class WarehouseTemplateService : IWarehouseTemplateService, ITransient
{
public async Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto)
{
var total = new RefAsync<int>();
var data = await SqlSugarDb.Db.Queryable<BPA_WarehouseTemplate, BPA_DeviceInfo, BPA_ProductVesion>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.DeviceId == b.Id, JoinType.Left, b.ProductVersionId == c.Id))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.TemplateName), (a, b, c) => a.TemplateName.Contains(inputDto.TemplateName))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceName), (a, b, c) => a.DeviceId.Contains(inputDto.DeviceName))
.Select((a, b, c) => new WarehouseTemplateView
{
Id = a.Id,
DeviceId = a.DeviceId,
DeviceName = b.DeviceName,
TemplateName = a.TemplateName,
CreateAt = a.CreateAt,
ProductNumber = c.ProductNumber,
ProductUrl = c.ProductUrl
})
.Mapper(x =>
{
x.WarehousePostion = SqlSugarDb.Db.Queryable<BPA_WarehousePostion>().Where(t => t.TemplateId == x.Id).ToList();
})
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);

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

};
}
public async Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(WarehouseDevideId dto)
{
var total = new RefAsync<int>();
var data = await SqlSugarDb.Db.Queryable<BPA_WarehouseTemplate, BPA_DeviceInfo, BPA_ProductVesion>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.DeviceId == b.Id, JoinType.Left, b.ProductVersionId == c.Id))
.WhereIF(!string.IsNullOrWhiteSpace(dto.DeviceId), (a, b, c) => a.DeviceId.Contains(dto.DeviceId))
.Select((a, b, c) => new WarehouseTemplateView
{
Id = a.Id,
DeviceId = a.DeviceId,
DeviceName = b.DeviceName,
TemplateName = a.TemplateName,
CreateAt = a.CreateAt,
ProductNumber = c.ProductNumber,
ProductUrl = c.ProductUrl
})
.Mapper(x =>
{
x.WarehousePostion = SqlSugarDb.Db.Queryable<BPA_WarehousePostion>().Where(t => t.TemplateId == x.Id).ToList();
})
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.ToListAsync();

return data;
}
/// <summary>
/// 新增
/// </summary>
/// <returns></returns>

public async Task<bool> AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
try
{
SqlSugarDb.Db.Ado.BeginTran();
var check = SqlSugarDb.Db.Queryable<BPA_WarehouseTemplate>().Where(x => x.TemplateName == inputDto.TemplateName).Any();
if (check) throw Oops.Oh("模板名称不能重复");
var res = await SqlSugarDb.Db.Insertable(new BPA_WarehouseTemplate
{
DeviceId = inputDto.DeviceId,
TemplateName = inputDto.TemplateName,

}).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
List<BPA_WarehousePostion> list = new();
for (int i = 0; i < inputDto.WarehousePostionData.Count; i++)
{
var tem = new BPA_WarehousePostion
{
TemplateId = res.Id,
Code = inputDto.WarehousePostionData[i].Code,
BatchingId = inputDto.WarehousePostionData[i].BatchingId,
};
list.Add(tem);
}
var res1 = await SqlSugarDb.Db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
SqlSugarDb.Db.Ado.CommitTran();
return true;
}
catch (Exception e)
{
SqlSugarDb.Db.Ado.RollbackTran();
throw Oops.Oh("添加失败," + e.Message);
}

}

/// <summary>
/// 修改
/// </summary>
/// <returns></returns>
public async Task<bool> UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
try
{
SqlSugarDb.Db.Ado.BeginTran();
var model = SqlSugarDb.Db.Queryable<BPA_WarehouseTemplate>().Where(x => x.Id == inputDto.Id).First();
model.DeviceId = inputDto.DeviceId;
model.TemplateName = inputDto.TemplateName;
var res = await SqlSugarDb.Db.Updateable(model).ExecuteCommandAsync();
var warehousePostion = SqlSugarDb.Db.Queryable<BPA_WarehousePostion>().Where(x => x.TemplateId == inputDto.Id).ToList();
await SqlSugarDb.Db.Deleteable(warehousePostion).ExecuteCommandAsync();
List<BPA_WarehousePostion> list = new();
for (int i = 0; i < inputDto.WarehousePostionData.Count; i++)
{
var tem = new BPA_WarehousePostion
{
TemplateId = inputDto.Id,
Code = inputDto.WarehousePostionData[i].Code,
BatchingId = inputDto.WarehousePostionData[i].BatchingId,
};
list.Add(tem);
}
var res1 = await SqlSugarDb.Db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
SqlSugarDb.Db.Ado.CommitTran();
return true;
}
catch (Exception)
{
SqlSugarDb.Db.Ado.RollbackTran();
return false;
}
}
}
}

+ 57
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs View File

@@ -0,0 +1,57 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Services;
using BPA.SAAS.Manage.Core.Base;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate
{
[ApiDescriptionSettings("开放平台", Tag = "设备仓位模板")]
public class WarehouseTemplateServices : IDynamicApiController, ITransient
{
IWarehouseTemplateService _warehouseTemplateService;
public WarehouseTemplateServices(IWarehouseTemplateService warehouseTemplateService)
{
_warehouseTemplateService = warehouseTemplateService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/WareHouseTemplate/GetWarehouseTemplatePage")]
public async Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto)
{
return await _warehouseTemplateService.GetWarehouseTemplatePage(inputDto);
}
/// <summary>
/// 根据设备id查询设备仓位模板
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/WareHouseTemplate/GetWarehouseTemplateList")]
public async Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(WarehouseDevideId dto)
{
return await _warehouseTemplateService.GetWarehouseTemplateList(dto);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/WareHouseTemplate/AddWarehouseTemplate")]
public async Task<bool> AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
return await _warehouseTemplateService.AddWarehouseTemplate(inputDto);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/WareHouseTemplate/UpdateWarehouseTemplate")]
public async Task<bool> UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
return await _warehouseTemplateService.UpdateWarehouseTemplate(inputDto);
}
}
}


Loading…
Cancel
Save