diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs
index 7cd9f15..53ed772 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/BomServices.cs
@@ -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
///
///
///
- [HttpGet("/api/ExternalPlatform/Bom/GetBomEntry")]
- public async Task GetBomEntry(string bomId)
+ [HttpPost("/api/ExternalPlatform/Bom/GetBomEntry")]
+ public async Task GetBomEntry(BomIdDto dto)
{
- return await _bomService.GetBomEntry(bomId);
+ return await _bomService.GetBomEntry(dto);
}
///
/// 添加配方详情
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomIdDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomIdDto.cs
new file mode 100644
index 0000000..d4b8753
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Dtos/BomIdDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs
index 8fb3a02..952cd5d 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/BomService.cs
@@ -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
///
///
///
- public async Task GetBomEntry(string bomId)
+ public async Task GetBomEntry(BomIdDto dto)
{
try
{
var resEntity=await SqlSugarDb.Db.Queryable((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,
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs
index 9865f2f..55143f7 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Bom/Services/IBomService.cs
@@ -41,7 +41,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Bom.Services
///
///
///
- Task GetBomEntry(string bomId);
+ Task GetBomEntry(BomIdDto dto);
///
/// 添加配方详情
///
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsIdDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsIdDto.cs
new file mode 100644
index 0000000..28cda91
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsIdDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInfoPushDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInfoPushDto.cs
new file mode 100644
index 0000000..40c4345
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsInfoPushDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
index cc8b612..72937eb 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
@@ -76,7 +76,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
/// 查询商品属性
///
///
- [HttpGet("/api/ExternalPlatform/Goods/GetGoodsAttributeList")]
+ [HttpPost("/api/ExternalPlatform/Goods/GetGoodsAttributeList")]
public async Task> GetGoodsAttributeList()
{
return await _goodsService.GetGoodsAttributeList();
@@ -86,20 +86,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
///
///
///
- [HttpGet("/api/ExternalPlatform/Goods/GetGoodsTechnologyAction")]
- public async Task> GetGoodsTechnologyAction(string goodsId)
+ [HttpPost("/api/ExternalPlatform/Goods/GetGoodsTechnologyAction")]
+ public async Task> GetGoodsTechnologyAction(GoodsIdDto goodsId)
{
return await _goodsService.GetGoodsTechnologyAction(goodsId);
}
- ///
- /// 删除商品工艺
- ///
- ///
- ///
- [HttpGet("/api/ExternalPlatform/Goods/DeleteGoodsTechnologyAction")]
- public async Task DeleteGoodsTechnologyAction(string id)
- {
- return await _goodsService.DeleteGoodsTechnologyAction(id);
- }
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
index dfbd7b0..e133b7d 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
@@ -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;
}
///
/// 分页查询商品
@@ -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((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((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;
}
///
@@ -239,10 +302,10 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
///
///
///
- public async Task> GetGoodsTechnologyAction(string goodsId)
+ public async Task> GetGoodsTechnologyAction(GoodsIdDto dto)
{
List goodsTechnologyActionListViews = new List();
- var list = SqlSugarDb.Db.Queryable().Where(x => x.GoodsId == goodsId)
+ var list = SqlSugarDb.Db.Queryable().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;
}
- ///
- /// 删除商品工艺
- ///
- ///
- ///
- public async Task DeleteGoodsTechnologyAction(string id)
- {
- var item = await SqlSugarDb.Db.Queryable().Where(x => x.Id == id).FirstAsync();
- if (item != null)
- {
- var res = await SqlSugarDb.Db.Deleteable(item).ExecuteCommandAsync() > 0;
- var list = SqlSugarDb.Db.Queryable().Where(x => x.GoodsId == item.GoodsId && x.DeviceId == item.DeviceId).OrderBy(x => x.Sort, OrderByType.Asc).ToList();
- var uplist = new List();
- 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();
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
index 2a7ade6..a22dc36 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
@@ -51,12 +51,6 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
///
///
///
- Task> GetGoodsTechnologyAction(string goodsId);
- ///
- /// 删除商品工艺
- ///
- ///
- ///
- Task DeleteGoodsTechnologyAction(string id);
+ Task> GetGoodsTechnologyAction(GoodsIdDto goodsId);
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseDevideId.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseDevideId.cs
new file mode 100644
index 0000000..04ec57f
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseDevideId.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplatInsertDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplatInsertDto.cs
new file mode 100644
index 0000000..261a24d
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplatInsertDto.cs
@@ -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 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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateQueryDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateQueryDto.cs
new file mode 100644
index 0000000..3929b4c
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateQueryDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateView.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateView.cs
new file mode 100644
index 0000000..256d7dd
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Dtos/WarehouseTemplateView.cs
@@ -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 WarehousePostion { get; set; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/IWarehouseTemplateService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/IWarehouseTemplateService.cs
new file mode 100644
index 0000000..97e49d3
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/IWarehouseTemplateService.cs
@@ -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 GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto);
+ Task> GetWarehouseTemplateList(WarehouseDevideId dto);
+ Task AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto);
+ Task UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto);
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
new file mode 100644
index 0000000..b3055f3
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
@@ -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 GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto)
+ {
+ var total = new RefAsync();
+ var data = await SqlSugarDb.Db.Queryable((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().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> GetWarehouseTemplateList(WarehouseDevideId dto)
+ {
+ var total = new RefAsync();
+ var data = await SqlSugarDb.Db.Queryable((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().Where(t => t.TemplateId == x.Id).ToList();
+ })
+ .OrderBy(a => a.CreateAt, OrderByType.Desc)
+ .ToListAsync();
+
+ return data;
+ }
+ ///
+ /// 新增
+ ///
+ ///
+
+ public async Task AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
+ {
+ try
+ {
+ SqlSugarDb.Db.Ado.BeginTran();
+ var check = SqlSugarDb.Db.Queryable().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 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);
+ }
+
+ }
+
+ ///
+ /// 修改
+ ///
+ ///
+ public async Task UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
+ {
+ try
+ {
+ SqlSugarDb.Db.Ado.BeginTran();
+ var model = SqlSugarDb.Db.Queryable().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().Where(x => x.TemplateId == inputDto.Id).ToList();
+ await SqlSugarDb.Db.Deleteable(warehousePostion).ExecuteCommandAsync();
+ List 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;
+ }
+ }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs
new file mode 100644
index 0000000..214bda1
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs
@@ -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;
+ }
+ ///
+ /// 分页查询
+ ///
+ ///
+ ///
+ [HttpPost("/api/WareHouseTemplate/GetWarehouseTemplatePage")]
+ public async Task GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto)
+ {
+ return await _warehouseTemplateService.GetWarehouseTemplatePage(inputDto);
+ }
+ ///
+ /// 根据设备id查询设备仓位模板
+ ///
+ ///
+ ///
+ [HttpPost("/api/WareHouseTemplate/GetWarehouseTemplateList")]
+ public async Task> GetWarehouseTemplateList(WarehouseDevideId dto)
+ {
+ return await _warehouseTemplateService.GetWarehouseTemplateList(dto);
+ }
+ ///
+ /// 添加
+ ///
+ ///
+ ///
+ [HttpPost("/api/WareHouseTemplate/AddWarehouseTemplate")]
+ public async Task AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
+ {
+ return await _warehouseTemplateService.AddWarehouseTemplate(inputDto);
+ }
+ ///
+ /// 更新
+ ///
+ ///
+ ///
+ [HttpPost("/api/WareHouseTemplate/UpdateWarehouseTemplate")]
+ public async Task UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
+ {
+ return await _warehouseTemplateService.UpdateWarehouseTemplate(inputDto);
+ }
+ }
+}
+