zhaoy 10 months ago
parent
commit
e02b3bb993
5 changed files with 57 additions and 19 deletions
  1. +3
    -1
      BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs
  2. +25
    -18
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  3. +1
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs
  4. +27
    -0
      BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
  5. +1
    -0
      BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs

+ 3
- 1
BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs View File

@@ -19,6 +19,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
/// 状态 【正常 停用】默认 正常
/// </summary>
public string Status { get; set; }
public string Descritption { get; set; }


}
}

+ 25
- 18
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs View File

@@ -20,6 +20,7 @@ using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using Org.BouncyCastle.Asn1.Cms;
using System;
using System.Collections;
using System.ComponentModel.DataAnnotations.Schema;
@@ -67,7 +68,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
conModels.Add(new ConditionalModel() { FieldName = "a.Status", ConditionalType = ConditionalType.Like, FieldValue = dto.Status });
}

if (!string.IsNullOrEmpty(dto.Descritption))
{
conModels.Add(new ConditionalModel() { FieldName = "a.Descritption", ConditionalType = ConditionalType.Like, FieldValue = dto.Descritption });
}
#endregion

RefAsync<int> total = 0;
@@ -774,8 +778,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services

deviceGoodsPositionList.Add(new BPA_DeviceGoodsPosition()
{
DeviceId = thisDevice.Id,
GoodsId = thisGoods.Id,
DeviceId = thisDevice?.Id,
GoodsId = thisGoods?.Id,
Id = Guid.NewGuid().ToString(),
Position1 = item.Position1,
Position2 = item.Position2,
@@ -836,13 +840,14 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services

var thisName = goodTechnologyModel[i].Name == null ? cName : goodTechnologyModel[i].Name;

var data = await _db.Queryable<BPA_ProductFunction>()
.Where(x => x.Name == thisName && x.DeviceVersionKey == device.ProductVersionId).FirstAsync();

var data2 = await _db.Queryable<BPA_ProductFunctionAction>()
.Where(x => x.ActionName == goodTechnologyModel[i].Configuration && x.ProductFunctionId == data.Id).FirstAsync();


var data = await _db.Queryable<BPA_Technology>()
.Where(x => x.Name == thisName && x.DeviceVersionId == device.ProductVersionId).FirstAsync();
var data2 = new BPA_TechnologyAction();
if (data != null)
{
data2 = await _db.Queryable<BPA_TechnologyAction>()
.Where(x => x.ActionName == goodTechnologyModel[i].Configuration && x.TechnologyId == data.Id).FirstAsync();
}
var batching = new BPA_Batching();
var IsBatch = goodTechnologyModel[i].Name != "液体料";

@@ -905,8 +910,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
var v1 = json.FirstOrDefault(x => x.actionName == "主料名称");
var v2 = deviceGoodsPosition.FirstOrDefault(x => x.GoodsName == name2 && x.DeviceName == name1);
var jsondb = await _db.Queryable<BPA_ProductFunctionAction>()
.Where(x => x.ProductFunctionId == thisItem.ChnologyId)
var jsondb = await _db.Queryable<BPA_TechnologyAction>()
.Where(x => x.TechnologyId == thisItem.ChnologyId)
.ToListAsync();

foreach (var item in from item in jsondb let insertableJsondb = json.FirstOrDefault(x => x.technologyactionId == item.Id) where insertableJsondb == null select item)
@@ -915,7 +920,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{
actionName = item.ActionName,
actionValue = item.ActionName == "主料重量" ? "0" : item.ActionValue,
chnologyId = item.ProductFunctionId,
chnologyId = item.TechnologyId,
index = thisItem.Index,
technologyactionId = item.Id

@@ -978,11 +983,13 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
}
if (value.ToString().Trim() == goodsName.Trim())
{
if (item2.IsDefined(typeof(ColumnAttribute), false))
{
ColumnAttribute attribute = (ColumnAttribute)item2.GetCustomAttribute(typeof(ColumnAttribute), false);
return attribute.Name;
}
ColumnAttribute attribute = (ColumnAttribute)item2.GetCustomAttribute(typeof(ColumnAttribute), false);
return attribute?.Name;
//if (item2.IsDefined(typeof(ColumnAttribute), false))
//{
// ColumnAttribute attribute = (ColumnAttribute)item2.GetCustomAttribute(typeof(ColumnAttribute), false);
// return attribute.Name;
//}
}
}
return "";


+ 1
- 0
BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs View File

@@ -58,5 +58,6 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction
/// </summary>
public string Description { get; set; }
public string ProductId { get; set; }
public string DataJson { get; set; }
}
}

+ 27
- 0
BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs View File

@@ -4,6 +4,7 @@ using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Product;
using Newtonsoft.Json;
using NPOI.POIFS.Crypt.Dsig;
using NPOI.Util;
using System;
@@ -45,6 +46,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
x.Id,
x.ForeignKeyRe,
x.DeviceVersionKey,
x.DataJson,
DeviceTypeKey = b.ProductId,
Vesion = b.Vesion,
CreateAt=x.CreateAt,
@@ -58,6 +60,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
BoolLabel = x.BoolLabel,
ReadWrite = x.ReadWrite,
Description= x.Description,
})
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
return new PageUtil()
@@ -99,6 +102,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services
}
else
{
if (!string.IsNullOrWhiteSpace(inputDto.DataJson))
{
if (!IsValidJson(inputDto.DataJson.Replace("\n", ""))) throw Oops.Oh("json字符格式不正确");
}
var res =await _db.Insertable(new BPA_ProductFunction()
{
Id = Guid.NewGuid().ToString(),
@@ -119,6 +126,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
ReadWrite = inputDto.ReadWrite,
Description=inputDto.Description,
ProductId= inputDto.ProductId,
DataJson= inputDto.DataJson?.Replace("\n",""),
}).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
@@ -132,6 +140,10 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
var check = _db.Queryable<BPA_ProductFunction>().Any(a => a.Id != inputDto.Id && a.Name == inputDto.Name);
if (check) throw Oops.Oh("功能名称已存在");
if (!string.IsNullOrWhiteSpace(inputDto.DataJson))
{
if(!IsValidJson(inputDto.DataJson.Replace("\n", ""))) throw Oops.Oh("json字符格式不正确");
}
var data = _db.Queryable<BPA_ProductFunction>().Where(a => a.Id == inputDto.Id).First();
data.Name = inputDto.Name;
data.DeviceVersionKey = inputDto.DeviceVersionKey;
@@ -145,6 +157,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
data.BoolLabel = inputDto.BoolLabel;
data.ReadWrite = inputDto.ReadWrite;
data.Description= inputDto.Description;
data.DataJson= inputDto.DataJson?.Replace("\n", "");
data.Status = (CommonStatus)Enum.ToObject(typeof(CommonStatus), inputDto.Status);
var res =await _db.Updateable(data).ExecuteCommandAsync();
return res > 0;
@@ -252,5 +265,19 @@ namespace BPA.SAAS.Manage.Application.Device.Services
return res > 0;
}
#endregion

private bool IsValidJson(string jsonString)
{
try
{
JsonConvert.DeserializeObject<object>(jsonString);
return true;
}
catch (Exception ex)
{
Console.WriteLine("Invalid JSON string: " + ex.Message);
return false;
}
}
}
}

+ 1
- 0
BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs View File

@@ -76,5 +76,6 @@ namespace BPA.SAAS.Manage.Core.Product
/// </summary>
public string Description { get; set; }
public string ProductId { get; set; }
public string DataJson { get; set; }
}
}

Loading…
Cancel
Save