@@ -19,7 +19,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods | |||||
/// <summary> | /// <summary> | ||||
/// 商品Id | /// 商品Id | ||||
/// </summary> | /// </summary> | ||||
public string GoodId { get; set; } | |||||
public List<string> GoodsId { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 设备Id | /// 设备Id | ||||
/// </summary> | /// </summary> | ||||
@@ -1303,9 +1303,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
var names = ""; | var names = ""; | ||||
var dataModel = new GoodsTechnologyDataModel { Values = new List<GoodsTechnologyValueModel>() }; | var dataModel = new GoodsTechnologyDataModel { Values = new List<GoodsTechnologyValueModel>() }; | ||||
var dataList = new List<GoodsTechnologyDataModel>(); | var dataList = new List<GoodsTechnologyDataModel>(); | ||||
var name = sheetName.Split(' ')[0]; | |||||
foreach (var model in modelList) | foreach (var model in modelList) | ||||
{ | { | ||||
if (model.ActionName.Contains(sheetName)) | |||||
if(model.StepName.Contains(goodId)) | |||||
{ | { | ||||
if (model.ActionValue == null && dataModel.Values.Count > 0) | if (model.ActionValue == null && dataModel.Values.Count > 0) | ||||
{ | { | ||||
@@ -1355,6 +1356,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
stepName = model.StepName; | stepName = model.StepName; | ||||
} | } | ||||
} | } | ||||
if (dataModel.Values.Count > 0) | |||||
dataList.Add(dataModel); | |||||
var oldAtteibuteId = ""; | var oldAtteibuteId = ""; | ||||
var sort = 1; | var sort = 1; | ||||
var order = 0; | var order = 0; | ||||
@@ -1481,8 +1484,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
public async Task<string> GoodsTechnologyExport(GoodsTechnologyExportDto exportDto) | public async Task<string> GoodsTechnologyExport(GoodsTechnologyExportDto exportDto) | ||||
{ | { | ||||
var goodsInfo = new List<BPA_GoodsInfo>(); | var goodsInfo = new List<BPA_GoodsInfo>(); | ||||
goodsInfo = exportDto.GoodId != "" | |||||
? await _db.Queryable<BPA_GoodsInfo>().Where(t => t.Id == exportDto.GoodId).ToListAsync() | |||||
goodsInfo = exportDto.GoodsId.Count > 0 | |||||
? await _db.Queryable<BPA_GoodsInfo>().Where(t => exportDto.GoodsId.Contains(t.Id)).ToListAsync() | |||||
: await _db.Queryable<BPA_GoodsInfo, BPA_GoodsType>((a, b) => new JoinQueryInfos(JoinType.Left, a.GoodsTypeId == b.Id)).ToListAsync(); | : await _db.Queryable<BPA_GoodsInfo, BPA_GoodsType>((a, b) => new JoinQueryInfos(JoinType.Left, a.GoodsTypeId == b.Id)).ToListAsync(); | ||||
var deviceInfo = await _db.Queryable<BPA_DeviceInfo>().FirstAsync(t => t.Id == exportDto.DeviceId); | var deviceInfo = await _db.Queryable<BPA_DeviceInfo>().FirstAsync(t => t.Id == exportDto.DeviceId); | ||||
var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().ToListAsync(); | var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().ToListAsync(); | ||||
@@ -1490,7 +1493,13 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
IWorkbook workbook = new XSSFWorkbook(); | IWorkbook workbook = new XSSFWorkbook(); | ||||
foreach (var good in goodsInfo) | foreach (var good in goodsInfo) | ||||
{ | { | ||||
ISheet sheet = workbook.CreateSheet(good.Name); | |||||
var name = good.Name; | |||||
string[] charsToReplace = new string[] { "\\", "/", "?", "*", "[", "]" }; | |||||
foreach (string c in charsToReplace) | |||||
{ | |||||
name = name.Replace(c, " "); | |||||
} | |||||
ISheet sheet = workbook.CreateSheet(name); | |||||
ICellStyle style = workbook.CreateCellStyle(); | ICellStyle style = workbook.CreateCellStyle(); | ||||
IFont font = workbook.CreateFont(); | IFont font = workbook.CreateFont(); | ||||
font.Boldweight = (short)FontBoldWeight.Bold; | font.Boldweight = (short)FontBoldWeight.Bold; | ||||
@@ -42,5 +42,9 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion | |||||
/// 状态 0启用 1禁用 | /// 状态 0启用 1禁用 | ||||
/// </summary> | /// </summary> | ||||
public CommonStatus Status { get; set; } = CommonStatus.ENABLE; | public CommonStatus Status { get; set; } = CommonStatus.ENABLE; | ||||
/// <summary> | |||||
/// 是否使用 | |||||
/// </summary> | |||||
public bool IsUse { get;set; } | |||||
} | } | ||||
} | } |
@@ -29,6 +29,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
public async Task<PageUtil> GetDeviceVesionPageAsync(DeviceVesionQueryInputDto inputDto) | public async Task<PageUtil> GetDeviceVesionPageAsync(DeviceVesionQueryInputDto inputDto) | ||||
{ | { | ||||
var total = new RefAsync<int>(); | var total = new RefAsync<int>(); | ||||
var deviceInfoList = await _db.Queryable<BPA_DeviceInfo>().ToListAsync(); | |||||
var data = await _db.Queryable<BPA_ProductVesion,BPA_Product>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.ProductId)) | var data = await _db.Queryable<BPA_ProductVesion,BPA_Product>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.ProductId)) | ||||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.ProductName), (a, b) => b.Name.Contains(inputDto.ProductName)) | .WhereIF(!string.IsNullOrWhiteSpace(inputDto.ProductName), (a, b) => b.Name.Contains(inputDto.ProductName)) | ||||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (a, b) => a.Vesion.Contains(inputDto.Vesion)) | .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (a, b) => a.Vesion.Contains(inputDto.Vesion)) | ||||
@@ -41,6 +42,12 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
ProductNumber=a.ProductNumber, | ProductNumber=a.ProductNumber, | ||||
ProductUrl=a.ProductUrl, | ProductUrl=a.ProductUrl, | ||||
}) | }) | ||||
.Mapper(x => | |||||
{ | |||||
var productList = deviceInfoList.Where(t=>t.ProductVersionId == x.Id).ToList(); | |||||
if (productList.Any()) | |||||
x.IsUse = true; | |||||
}) | |||||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | ||||
return new PageUtil() | return new PageUtil() | ||||
@@ -61,6 +68,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
try | try | ||||
{ | { | ||||
_db.Ado.BeginTran(); | _db.Ado.BeginTran(); | ||||
var old = await _db.Queryable<BPA_ProductVesion>().FirstAsync(t => t.ProductId == inputDto.ProductId && t.Vesion == inputDto.Vesion); | |||||
if (old != null) | |||||
throw Oops.Oh("已存在该版本的设备!"); | |||||
var res = await _db.Insertable(new BPA_ProductVesion | var res = await _db.Insertable(new BPA_ProductVesion | ||||
{ | { | ||||
Vesion = inputDto.Vesion, | Vesion = inputDto.Vesion, | ||||
@@ -283,7 +293,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
_db.Ado.RollbackTran(); | _db.Ado.RollbackTran(); | ||||
throw Oops.Oh("添加失败,失败信息:"+e.Message); | |||||
throw Oops.Oh(e.Message); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -319,7 +329,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
_db.Ado.RollbackTran(); | _db.Ado.RollbackTran(); | ||||
throw Oops.Oh("删除失败,失败信息:"+e.Message); | |||||
throw Oops.Oh(e.Message); | |||||
} | } | ||||
} | } | ||||
@@ -330,7 +340,14 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
public async Task<bool> UpdateDeviceVesionAsync(DeviceVesionBaseDto inputDto) | public async Task<bool> UpdateDeviceVesionAsync(DeviceVesionBaseDto inputDto) | ||||
{ | { | ||||
var data = await _db.Queryable<BPA_ProductVesion>().Where(x => x.Id == inputDto.Id).FirstAsync(); | var data = await _db.Queryable<BPA_ProductVesion>().Where(x => x.Id == inputDto.Id).FirstAsync(); | ||||
var old = await _db.Queryable<BPA_ProductVesion>().FirstAsync(t => t.ProductId == inputDto.ProductId && t.Vesion == inputDto.Vesion); | |||||
if(old != null && old.Id!=data.Id) | |||||
throw Oops.Oh("已存在该版本的设备!"); | |||||
var deviceInfo = await _db.Queryable<BPA_DeviceInfo>().Where(x => x.ProductVersionId == inputDto.Id).ToListAsync(); | |||||
if (deviceInfo.Count > 0) | |||||
{ | |||||
throw Oops.Oh("当前版本已有设备使用,无法删除!"); | |||||
} | |||||
if (data != null) | if (data != null) | ||||
{ | { | ||||
var res = _db.Updateable<BPA_ProductVesion>().SetColumns(t => t.Vesion == inputDto.Vesion) | var res = _db.Updateable<BPA_ProductVesion>().SetColumns(t => t.Vesion == inputDto.Vesion) | ||||
@@ -85,6 +85,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> DeProduct(List<string> inputList) | public async Task<bool> DeProduct(List<string> inputList) | ||||
{ | { | ||||
var old = await _db.Queryable<BPA_ProductVesion>().Where(t => inputList.Contains(t.ProductId)).ToListAsync(); | |||||
if (old.Count > 0) | |||||
throw Oops.Oh("该产品已存在版本!"); | |||||
var datas = await _db.Queryable<BPA_Product>() | var datas = await _db.Queryable<BPA_Product>() | ||||
.Where(x => inputList.Contains(x.Id)) | .Where(x => inputList.Contains(x.Id)) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
@@ -1,6 +1,7 @@ | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | using BPA.SAAS.Manage.Application.Device.Dtos.Device; | ||||
using BPA.SAAS.Manage.Application.Device.Interface; | using BPA.SAAS.Manage.Application.Device.Interface; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.DataBase; | |||||
using BPA.SAAS.Manage.Core.Device; | using BPA.SAAS.Manage.Core.Device; | ||||
using BPA.SAAS.Manage.Core.Product; | using BPA.SAAS.Manage.Core.Product; | ||||
using LogicExtensions; | using LogicExtensions; | ||||
@@ -119,6 +120,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
var datas = await _db.Queryable<BPA_TechnologyExportRecode>().Where(x => x.Id == inputList).FirstAsync(); | 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 Technology = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == datas.DeviceVersionId).ToList(); | ||||
var TechnologyIds = Technology.Select(x => x.Id).ToArray(); | var TechnologyIds = Technology.Select(x => x.Id).ToArray(); | ||||
var goodsTechnologyAction = _db.Queryable<BPA_GoodsTechnologyAction>().Any(t => TechnologyIds.Contains(t.ChnologyId)); | |||||
if (goodsTechnologyAction) | |||||
throw Oops.Oh("删除的设备版本已存在工艺!"); | |||||
var TechnologyAction = _db.Queryable<BPA_TechnologyAction>().Where(p => TechnologyIds.Contains(p.TechnologyId)).ToList(); | var TechnologyAction = _db.Queryable<BPA_TechnologyAction>().Where(p => TechnologyIds.Contains(p.TechnologyId)).ToList(); | ||||
_db.Deleteable(TechnologyAction).ExecuteCommand(); | _db.Deleteable(TechnologyAction).ExecuteCommand(); | ||||
_db.Deleteable(Technology).ExecuteCommand(); | _db.Deleteable(Technology).ExecuteCommand(); | ||||
@@ -126,12 +130,11 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
_db.Ado.CommitTran(); | _db.Ado.CommitTran(); | ||||
return true; | return true; | ||||
} | } | ||||
catch (Exception) | |||||
catch (Exception e) | |||||
{ | { | ||||
_db.Ado.RollbackTran(); | _db.Ado.RollbackTran(); | ||||
throw Oops.Oh("删除失败"); | |||||
throw Oops.Oh(e.Message); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -3,6 +3,7 @@ using BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate; | |||||
using BPA.SAAS.Manage.Application.Device.Interface; | using BPA.SAAS.Manage.Application.Device.Interface; | ||||
using BPA.SAAS.Manage.Comm.Enum; | using BPA.SAAS.Manage.Comm.Enum; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.DataBase; | |||||
using BPA.SAAS.Manage.Core.Device; | using BPA.SAAS.Manage.Core.Device; | ||||
using BPA.SAAS.Manage.Core.Product; | using BPA.SAAS.Manage.Core.Product; | ||||
using NPOI.XSSF.UserModel; | using NPOI.XSSF.UserModel; | ||||
@@ -125,6 +126,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
try | try | ||||
{ | { | ||||
_db.Ado.BeginTran(); | _db.Ado.BeginTran(); | ||||
var old = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => inputList.Contains(t.WarehousrTemplateId)).ToListAsync(); | |||||
if (old.Count > 0) | |||||
throw Oops.Oh("仓位模版已存在工艺!"); | |||||
var datas = await _db.Queryable<BPA_WarehouseTemplate>() | var datas = await _db.Queryable<BPA_WarehouseTemplate>() | ||||
.Where(x => inputList.Contains(x.Id)) | .Where(x => inputList.Contains(x.Id)) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
@@ -136,10 +140,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
_db.Ado.CommitTran(); | _db.Ado.CommitTran(); | ||||
return true; | return true; | ||||
} | } | ||||
catch (Exception) | |||||
catch (Exception e) | |||||
{ | { | ||||
_db.Ado.RollbackTran(); | _db.Ado.RollbackTran(); | ||||
throw Oops.Oh("删除失败"); | |||||
throw Oops.Oh(e.Message); | |||||
} | } | ||||
} | } | ||||