Bläddra i källkod

Merge branch 'master' into kitchenmanage

tmp
zhaoy 10 månader sedan
förälder
incheckning
90a503345b
9 ändrade filer med 227 tillägg och 36 borttagningar
  1. +1
    -1
      BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
  2. +43
    -23
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  3. +30
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductVesionView.cs
  4. +2
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs
  5. +19
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyView.cs
  6. +8
    -1
      BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs
  7. +76
    -10
      BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
  8. +27
    -1
      BPA.SAAS.Manage.Application/Device/TechnologyServices.cs
  9. +21
    -0
      BPA.SAAS.Manage.Core/Device/BPA_TechnologyExportRecode.cs

+ 1
- 1
BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs Visa fil

@@ -165,7 +165,7 @@ namespace BPA.SAAS.Manage.Application.DataBase
/// </summary>
/// <returns></returns>
[HttpPost("/api/goods/goodstemplateexport"), NonUnify]
public async Task<bool> DeviceVersionTemplateImport(DeviceVersionTemplateImportInputDto inputDto)
public async Task<bool> DeviceVersionTemplateImport([FromForm] DeviceVersionTemplateImportInputDto inputDto)
{
return await _goodsService.DeviceVersionTemplateImport(inputDto);
}


+ 43
- 23
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs Visa fil

@@ -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<BPA_ProductVesion>()
.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<BPA_ProductVesion>().FirstAsync(x => x.ProductId == inputDto.DeviceClientType && x.Vesion == inputDto.Version);
@@ -1035,10 +1034,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
#region 添加 设备_烹饪工序模型
ReadExcel<GoodstechnologyModel> readGoodstechnologyExcel = new();
var GoodstechnologyModellist = readGoodstechnologyExcel.ExcelToList(source, mapper);
List<BPA_ProductFunction> GoodsTechnologyList = new();
List<BPA_ProductFunctionAction> GoodsTechnologyActionList = new();
var GoodsTechnologyListDB = await _db.Queryable<BPA_ProductFunction>()
.Where(x => x.DeviceVersionKey == deviceVersion.Id).ToListAsync();
List<BPA_Technology> GoodsTechnologyList = new();
List<BPA_TechnologyAction> GoodsTechnologyActionList = new();
var GoodsTechnologyListDB = await _db.Queryable<BPA_Technology>()
.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<BPA_ProductFunctionAction>()
.Where(x => goodstechnologyIds.Contains(x.ProductFunctionId)).ToListAsync();
var GoodsTechnologyActionListDb = await _db.Queryable<BPA_TechnologyAction>()
.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<BPA_TechnologyExportRecode>().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)


+ 30
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductVesionView.cs Visa fil

@@ -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> 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<BPA_TechnologyAction> TechnologyActionInfo { get; set; }
}
}

+ 2
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyQueryInputDto.cs Visa fil

@@ -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; }
}
}

+ 19
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/TechnologyView.cs Visa fil

@@ -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<BPA_TechnologyAction> TechnologyActionInfo { get; set; }
}
}

+ 8
- 1
BPA.SAAS.Manage.Application/Device/Interface/ITechnologyService.cs Visa fil

@@ -10,6 +10,13 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
{
public interface ITechnologyService
{
Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto);
Task<PageUtil> GetTechnologyExportRecodePage(TechnologyQueryInputDto inputDto);
Task<bool> DeTechnologyExportRecode(string inputList);
/// <summary>
/// 根据设备id查询设备工艺信息
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
Task<List<TechnologyView>> GetTechnologyList(string deviceId);
}
}

+ 76
- 10
BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs Visa fil

@@ -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
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto)
public async Task<PageUtil> GetTechnologyExportRecodePage(TechnologyQueryInputDto inputDto)
{
var total = new RefAsync<int>();
var data = await _db.Queryable<BPA_ProductVesion,BPA_Technology, BPA_Product>((a, b,c) => new JoinQueryInfos(
JoinType.Left, a.Id == b.DeviceVersionId,
var data = await _db.Queryable<BPA_TechnologyExportRecode,BPA_ProductVesion, BPA_Product>((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<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
var TechnologyInfo = _db.Queryable<BPA_Technology>().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<BPA_TechnologyAction>().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

};
}
/// <summary>
/// 根据设备id查询设备工艺信息
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
public async Task<List<TechnologyView>> GetTechnologyList(string deviceId)
{
var device= _db.Queryable<BPA_DeviceInfo>().Where(x=>x.Id== deviceId).First();
var data = await _db.Queryable<BPA_Technology>().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<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
var TechnologyInfo = _db.Queryable<BPA_TechnologyAction>().Where(d => d.TechnologyId == x.Id).ToList();
x.TechnologyActionInfo = TechnologyInfo;
})
.ToListAsync();

return data;
}
public async Task<bool> DeTechnologyExportRecode(string inputList)
{
try
{
_db.Ado.BeginTran();
var datas = await _db.Queryable<BPA_TechnologyExportRecode>().Where(x => x.Id == inputList).FirstAsync();
var Technology = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == datas.DeviceVersionId).ToList();
var TechnologyIds = Technology.Select(x => x.Id).ToArray();
var TechnologyAction = _db.Queryable<BPA_TechnologyAction>().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("删除失败");
}
}
}
}

+ 27
- 1
BPA.SAAS.Manage.Application/Device/TechnologyServices.cs Visa fil

@@ -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;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/technology/page")]
public async Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto)
{
return await _technologyService.GetTechnologyPage(inputDto);
return await _technologyService.GetTechnologyExportRecodePage(inputDto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/technology/delete")]
public async Task<bool> DeTechnologyExportRecode(string id)
{
return await _technologyService.DeTechnologyExportRecode(id);
}
/// <summary>
/// 根据设备id查询设备工艺信息
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
[HttpGet("/api/technology/gettechnologylist")]
public async Task<List<TechnologyView>> GetTechnologyList(string deviceId)
{
return await _technologyService.GetTechnologyList(deviceId);
}
}
}

+ 21
- 0
BPA.SAAS.Manage.Core/Device/BPA_TechnologyExportRecode.cs Visa fil

@@ -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
{
/// <summary>
/// 主键 Guid
/// </summary>
[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; }
}
}

Laddar…
Avbryt
Spara