diff --git a/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs b/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
index 7e966c2..cff1fb8 100644
--- a/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
@@ -165,7 +165,7 @@ namespace BPA.SAAS.Manage.Application.DataBase
///
///
[HttpPost("/api/goods/goodstemplateexport"), NonUnify]
- public async Task DeviceVersionTemplateImport(DeviceVersionTemplateImportInputDto inputDto)
+ public async Task DeviceVersionTemplateImport([FromForm] DeviceVersionTemplateImportInputDto inputDto)
{
return await _goodsService.DeviceVersionTemplateImport(inputDto);
}
diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
index 2b92dbd..5c794f2 100644
--- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
@@ -1016,18 +1016,17 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
_db.Ado.BeginTran();
- if (inputDto.IsAddGoodsTemplate)
- {
+ //if (inputDto.IsAddGoodsTemplate)
+ //{
+
+ //}
+ //else
+ //{
var path = await _SystemConfigService.GetCosImgesURL(file);
-
await _db.Updateable()
.SetColumns(it => it.TemplatePath == path)
.Where(it => it.Id == inputDto.Id)
.ExecuteCommandAsync();
- }
- else
- {
-
var source = file.OpenReadStream();
var mapper = new Mapper(source);
var deviceVersion = await _db.Queryable().FirstAsync(x => x.ProductId == inputDto.DeviceClientType && x.Vesion == inputDto.Version);
@@ -1035,10 +1034,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
#region 添加 设备_烹饪工序模型
ReadExcel readGoodstechnologyExcel = new();
var GoodstechnologyModellist = readGoodstechnologyExcel.ExcelToList(source, mapper);
- List GoodsTechnologyList = new();
- List GoodsTechnologyActionList = new();
- var GoodsTechnologyListDB = await _db.Queryable()
- .Where(x => x.DeviceVersionKey == deviceVersion.Id).ToListAsync();
+ List GoodsTechnologyList = new();
+ List GoodsTechnologyActionList = new();
+ var GoodsTechnologyListDB = await _db.Queryable()
+ .Where(x => x.DeviceVersionId == deviceVersion.Id).ToListAsync();
string currennaid = "";
string currennaname = "";
for (int i = 0; i < GoodstechnologyModellist.Count; i++)
@@ -1048,13 +1047,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
if (!string.IsNullOrWhiteSpace(GoodstechnologyModellist[i].Name))
{
- BPA_ProductFunction item = new BPA_ProductFunction()
+ BPA_Technology item = new BPA_Technology()
{
Id = goodsTechnologyId == null ? Guid.NewGuid().ToString() : goodsTechnologyId.Id,
Name = GoodstechnologyModellist[i].Name,
- Status = 0,
- IsDeleted = 0,
- DeviceVersionKey = deviceVersion.Id
+
+ DeviceVersionId = deviceVersion.Id
};
GoodsTechnologyList.Add(item);
currennaid = item.Id;
@@ -1065,10 +1063,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
throw Oops.Oh($"类型错误");
}
- BPA_ProductFunctionAction technologyAction = new()
+ BPA_TechnologyAction technologyAction = new()
{
Id = Guid.NewGuid().ToString(),
- ProductFunctionId = currennaid,
+ TechnologyId = currennaid,
ActionName = GoodstechnologyModellist[i].ActionName,
ActionType = CharacterConversion(GoodstechnologyModellist[i].ActionType),
Sort = i,
@@ -1095,35 +1093,57 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
if (thisitem != null)
{
item.Id = thisitem.Id;
+ item.CreateAt = DateTime.Now;
_db.Updateable(item).ExecuteCommand();
}
else
{
- await _db.Insertable(item).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
+ //item.Id = Guid.NewGuid().ToString();
+ item.CreateAt = DateTime.Now;
+ await _db.Insertable(item).ExecuteCommandAsync();
}
}
//修改添从表
GoodsTechnologyActionList = GoodsTechnologyActionList.Where(x => !string.IsNullOrEmpty(x.ActionName)).ToList();
var goodstechnologyIds = GoodsTechnologyList.Select(x => x.Id).ToList();
- var GoodsTechnologyActionListDb = await _db.Queryable()
- .Where(x => goodstechnologyIds.Contains(x.ProductFunctionId)).ToListAsync();
+ var GoodsTechnologyActionListDb = await _db.Queryable()
+ .Where(x => goodstechnologyIds.Contains(x.TechnologyId)).ToListAsync();
foreach (var item in GoodsTechnologyActionList)
{
- var thisitem = GoodsTechnologyActionListDb.FirstOrDefault(x => item.ProductFunctionId == x.ProductFunctionId && item.ActionName == x.ActionName);
+ var thisitem = GoodsTechnologyActionListDb.FirstOrDefault(x => item.TechnologyId == x.TechnologyId && item.ActionName == x.ActionName);
if (thisitem != null)
{
item.Id = thisitem.Id;
+ item.CreateAt = DateTime.Now;
_db.Updateable(item).ExecuteCommand();
}
else
{
- await _db.Insertable(item).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
+ item.Id = Guid.NewGuid().ToString();
+ item.CreateAt= DateTime.Now;
+ await _db.Insertable(item).ExecuteCommandAsync();
}
}
#endregion
- }
+ var TechnologyExportRecode = _db.Queryable().Where(x=>x.DeviceVersionId == inputDto.Id).First();
+ if (TechnologyExportRecode != null)
+ {
+ TechnologyExportRecode.CreateAt= DateTime.Now;
+ await _db.Updateable(TechnologyExportRecode).ExecuteCommandAsync();
+ }
+ else
+ {
+ BPA_TechnologyExportRecode _TechnologyExportRecode = new();
+ _TechnologyExportRecode.Id = Guid.NewGuid().ToString();
+ _TechnologyExportRecode.CreateAt = DateTime.Now;
+ _TechnologyExportRecode.ProductId = inputDto.DeviceClientType;
+ _TechnologyExportRecode.DeviceVersionId = inputDto.Id;
+ await _db.Insertable(_TechnologyExportRecode).ExecuteCommandAsync();
+ }
+
+ //}
_db.Ado.CommitTran();
}
catch (Exception e)
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductVesionView.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductVesionView.cs
new file mode 100644
index 0000000..34bb506
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductVesionView.cs
@@ -0,0 +1,30 @@
+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.Device.Dtos.Device
+{
+ public class ProductVesionView
+ {
+ public string Id { get; set; }
+ public string Vesion { get; set; }
+ public string ProductName { get; set; }
+ public DateTime CreateAt { get; set; }
+ public string DeviceVersionId { get; set; }
+ public string TemplatePath { get; set; }
+ public List TechnologyInfo { get; set; }
+
+ }
+ public class TechnologyInfo
+ {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string DeviceVersionId { get; set; }
+ public string ForeignKeyRe { get; set; }
+ public DateTime CreateAt { get; set; }
+ public List TechnologyActionInfo { get; set; }
+}
+}
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs
index cb1961f..6aa6253 100644
--- a/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs
@@ -9,5 +9,7 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.Device
{
public class TechnologyQueryInputDto: PageInputBase
{
+ public string ProductName { get;set; }
+ public string Vesion { get; set; }
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyView.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyView.cs
new file mode 100644
index 0000000..35c5e5c
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyView.cs
@@ -0,0 +1,19 @@
+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.Device.Dtos.Device
+{
+ public class TechnologyView
+ {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string DeviceVersionId { get; set; }
+ public string ForeignKeyRe { get; set; }
+ public DateTime CreateAt { get; set; }
+ public List TechnologyActionInfo { get; set; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs b/BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs
index 7923cc7..b6bf247 100644
--- a/BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs
@@ -10,6 +10,13 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
{
public interface ITechnologyService
{
- Task GetTechnologyPage(TechnologyQueryInputDto inputDto);
+ Task GetTechnologyExportRecodePage(TechnologyQueryInputDto inputDto);
+ Task DeTechnologyExportRecode(string inputList);
+ ///
+ /// 根据设备id查询设备工艺信息
+ ///
+ ///
+ ///
+ Task> GetTechnologyList(string deviceId);
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs b/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
index c7a67aa..b21d399 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
@@ -3,6 +3,10 @@ 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 Microsoft.AspNetCore.Routing.Template;
+using NPOI.POIFS.Storage;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -23,21 +27,36 @@ namespace BPA.SAAS.Manage.Application.Device.Services
///
///
///
- public async Task GetTechnologyPage(TechnologyQueryInputDto inputDto)
+ public async Task GetTechnologyExportRecodePage(TechnologyQueryInputDto inputDto)
{
var total = new RefAsync();
- var data = await _db.Queryable((a, b,c) => new JoinQueryInfos(
- JoinType.Left, a.Id == b.DeviceVersionId,
+ var data = await _db.Queryable((a, b,c) => new JoinQueryInfos(
+ JoinType.Left, a.DeviceVersionId == b.Id,
JoinType.Left, a.ProductId == c.Id
- )).Select((a, b, c) => new
+ ))
+ .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (a, b, c) => b.Vesion == inputDto.Vesion)
+ .WhereIF(!string.IsNullOrWhiteSpace(inputDto.ProductName), (a, b, c) => inputDto.ProductName.Contains(c.Name))
+ .Select((a, b,c) => new ProductVesionView
{
- Id=b.Id,
- Vesion=a.Vesion,
- ProductName=c.Name,
- CreateAt=b.CreateAt,
+ Id =a.Id,
+ Vesion = b.Vesion,
+ ProductName = c.Name,
+ CreateAt = a.CreateAt,
+ DeviceVersionId = b.Id,
+ TemplatePath=b.TemplatePath
+ })
+
+ .OrderBy(a=>a.CreateAt, OrderByType.Desc)
+ .Mapper(x =>
+ {
+ //var TechnologyInfo1 = _db.Queryable().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
+ var TechnologyInfo = _db.Queryable().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId,CreateAt=f.CreateAt }).Mapper(g =>
+ {
+ g.TechnologyActionInfo= _db.Queryable().Where(d=>d.TechnologyId==g.Id).ToList();
+ }).ToList();
+ x.TechnologyInfo = TechnologyInfo;
})
- .OrderBy(x => x.CreateAt, OrderByType.Desc)
- .ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
+ .ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
return new PageUtil()
{
@@ -46,5 +65,52 @@ namespace BPA.SAAS.Manage.Application.Device.Services
};
}
+ ///
+ /// 根据设备id查询设备工艺信息
+ ///
+ ///
+ ///
+ public async Task> GetTechnologyList(string deviceId)
+ {
+ var device= _db.Queryable().Where(x=>x.Id== deviceId).First();
+ var data = await _db.Queryable().Where(x=>x.DeviceVersionId== device.ProductVersionId).Select(a => new TechnologyView
+ {
+ Id = a.Id,
+ Name = a.Name,
+ DeviceVersionId = a.DeviceVersionId,
+ CreateAt = a.CreateAt,
+ }).OrderBy(a => a.CreateAt, OrderByType.Desc)
+ .Mapper(x =>
+ {
+ //var TechnologyInfo1 = _db.Queryable().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
+ var TechnologyInfo = _db.Queryable().Where(d => d.TechnologyId == x.Id).ToList();
+ x.TechnologyActionInfo = TechnologyInfo;
+ })
+ .ToListAsync();
+
+ return data;
+ }
+ public async Task DeTechnologyExportRecode(string inputList)
+ {
+ try
+ {
+ _db.Ado.BeginTran();
+ var datas = await _db.Queryable().Where(x => x.Id == inputList).FirstAsync();
+ var Technology = _db.Queryable().Where(p => p.DeviceVersionId == datas.DeviceVersionId).ToList();
+ var TechnologyIds = Technology.Select(x => x.Id).ToArray();
+ var TechnologyAction = _db.Queryable().Where(p => TechnologyIds.Contains(p.TechnologyId)).ToList();
+ _db.Deleteable(TechnologyAction).ExecuteCommand();
+ _db.Deleteable(Technology).ExecuteCommand();
+ _db.Deleteable(datas).ExecuteCommand();
+ _db.Ado.CommitTran();
+ return true;
+ }
+ catch (Exception)
+ {
+ _db.Ado.RollbackTran();
+ throw Oops.Oh("删除失败");
+ }
+
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/TechnologyServices.cs b/BPA.SAAS.Manage.Application/Device/TechnologyServices.cs
index 0bbf71b..50c8f06 100644
--- a/BPA.SAAS.Manage.Application/Device/TechnologyServices.cs
+++ b/BPA.SAAS.Manage.Application/Device/TechnologyServices.cs
@@ -1,6 +1,7 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Core.Base;
+using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -17,10 +18,35 @@ namespace BPA.SAAS.Manage.Application.Device
{
_technologyService= technologyService;
}
+ ///
+ /// 分页查询
+ ///
+ ///
+ ///
[HttpPost("/api/technology/page")]
public async Task GetTechnologyPage(TechnologyQueryInputDto inputDto)
{
- return await _technologyService.GetTechnologyPage(inputDto);
+ return await _technologyService.GetTechnologyExportRecodePage(inputDto);
+ }
+ ///
+ /// 删除
+ ///
+ ///
+ ///
+ [HttpGet("/api/technology/delete")]
+ public async Task DeTechnologyExportRecode(string id)
+ {
+ return await _technologyService.DeTechnologyExportRecode(id);
+ }
+ ///
+ /// 根据设备id查询设备工艺信息
+ ///
+ ///
+ ///
+ [HttpGet("/api/technology/gettechnologylist")]
+ public async Task> GetTechnologyList(string deviceId)
+ {
+ return await _technologyService.GetTechnologyList(deviceId);
}
}
}
diff --git a/BPA.SAAS.Manage.Core/Device/BPA_TechnologyExportRecode.cs b/BPA.SAAS.Manage.Core/Device/BPA_TechnologyExportRecode.cs
new file mode 100644
index 0000000..e11131a
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/Device/BPA_TechnologyExportRecode.cs
@@ -0,0 +1,21 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Core.Device
+{
+ public class BPA_TechnologyExportRecode
+ {
+ ///
+ /// 主键 Guid
+ ///
+ [SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)]
+ public string Id { get; set; }
+ public string DeviceVersionId { get; set; }
+ public string ProductId { get; set; }
+ public DateTime CreateAt { get; set; }
+ }
+}