diff --git a/SlnMesnac.Model/domain/McsBinToMater.cs b/SlnMesnac.Model/domain/McsBinToMater.cs new file mode 100644 index 0000000..0ebce7c --- /dev/null +++ b/SlnMesnac.Model/domain/McsBinToMater.cs @@ -0,0 +1,76 @@ +using System.Runtime.Serialization; +using SqlSugar; + +namespace SlnMesnac.Model.domain +{ + [SugarTable("MCSToMES_BinToMater"), TenantAttribute("mcs")] + [DataContract(Name = "McsBinToMater 大料料仓对应信息")] + public class McsBinToMater + { + /// + /// + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public string Guid { get; set; } + + /// + /// 机台编号 + /// + [SugarColumn(ColumnName = "EquipID")] + public int EquipId { get; set; } + + /// + /// 机台名称 + /// + [SugarColumn(ColumnName = "EquipName")] + public string EquipName { get; set; } + + /// + /// 机台类型:CWS-小料;MCS-上辅机 + /// + [SugarColumn(ColumnName = "EquipType")] + public string EquipType { get; set; } + + /// + /// 秤编号 + /// + [SugarColumn(ColumnName = "ScaleNum")] + public int ScaleNum { get; set; } + + /// + /// 秤类型 + /// + [SugarColumn(ColumnName = "ScaleClass")] + public string ScaleClass { get; set; } + + /// + /// 秤名称 + /// + [SugarColumn(ColumnName = "ScaleName")] + public string ScaleName { get; set; } + + /// + /// 罐号 + /// + [SugarColumn(ColumnName = "BinNo")] + public int BinNo { get; set; } + + /// + /// 物料代码 + /// + [SugarColumn(ColumnName = "MatCode")] + public string MatCode { get; set; } + + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MatName")] + public string MatName { get; set; } + + /// + /// 使用状态:Y-使用中;N-未使用 + /// + [SugarColumn(ColumnName = "UseYN")] + public string UseYN { get; set; } + } +} \ No newline at end of file diff --git a/SlnMesnac.Model/dto/IngredientInfoDto.cs b/SlnMesnac.Model/dto/IngredientInfoDto.cs index 6d865aa..ec79861 100644 --- a/SlnMesnac.Model/dto/IngredientInfoDto.cs +++ b/SlnMesnac.Model/dto/IngredientInfoDto.cs @@ -9,6 +9,11 @@ namespace SlnMesnac.Model.dto [DataContract(Name = "IngredientInfo 投料信息")] public class IngredientInfo { + /// + /// 机台编号,预留可传0 + /// + public int EquipId { get; set; } + /// /// 料罐编号 /// @@ -44,6 +49,11 @@ namespace SlnMesnac.Model.dto /// public double RemainderWeight { get; set; } + /// + /// 是否开仓:1-开仓;2-只保存 + /// + public int IsOpen { get; set; } + /// /// 记录时间 /// diff --git a/SlnMesnac.Repository/SqlsugarSetup.cs b/SlnMesnac.Repository/SqlsugarSetup.cs index 3b2addb..8c0e7bf 100644 --- a/SlnMesnac.Repository/SqlsugarSetup.cs +++ b/SlnMesnac.Repository/SqlsugarSetup.cs @@ -33,7 +33,7 @@ namespace SlnMesnac.Repository new ConnectionConfig() { ConfigId = "mcs", - DbType = DbType.Oracle, + DbType = DbType.SqlServer, ConnectionString = appConfig.mcsConnStr, InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, @@ -58,6 +58,7 @@ namespace SlnMesnac.Repository services.AddSingleton(typeof(Repository<>)); services.AddSingleton(); services.AddSingleton(); + services.AddScoped(); } } } diff --git a/SlnMesnac.Repository/service/IMcsBinToMaterService.cs b/SlnMesnac.Repository/service/IMcsBinToMaterService.cs new file mode 100644 index 0000000..76d391d --- /dev/null +++ b/SlnMesnac.Repository/service/IMcsBinToMaterService.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using SlnMesnac.Model.domain; + +namespace SlnMesnac.Repository.service +{ + /// + /// 上辅机料罐物料对应信息 + /// + public interface IMcsBinToMaterService + { + /// + /// 获取大料料罐物料对应信息 + /// + /// + List GetMcsBinToMaterList(); + + /// + /// 通过机台编号、料罐编号获取料罐物料对应信息 + /// + /// + /// + /// + McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,int BinNo); + } +} \ No newline at end of file diff --git a/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs b/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs new file mode 100644 index 0000000..31c93a3 --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.Logging; +using SlnMesnac.Model.domain; + +namespace SlnMesnac.Repository.service.Impl +{ + public class McsBinToMaterServiceImpl:IMcsBinToMaterService + { + private readonly Repository _rep; + + public McsBinToMaterServiceImpl(Repository rep) + { + _rep = rep; + } + + /// + /// 获取大料料罐物料对应信息 + /// + /// + /// + public List GetMcsBinToMaterList() + { + try + { + return _rep.GetList();; + } + catch (Exception e) + { + throw new ArgumentException($"获取料仓物料对应信息异常:{e.Message}"); + } + } + + /// + /// 通过机台编号、料罐编号获取料罐物料对应信息 + /// + /// + /// + /// + /// + public McsBinToMater GetMcsBinToMaterByBinNo(int EquipId, int BinNo) + { + try + { + return _rep.GetFirst(x=>x.EquipId == EquipId && x.BinNo == BinNo);; + } + catch (Exception e) + { + throw new ArgumentException($"根据设备编号、料罐编号获取料仓物料对应信息异常:{e.Message}"); + } + } + } +} \ No newline at end of file diff --git a/SlnMesnac/Controllers/IngCheckController.cs b/SlnMesnac/Controllers/IngCheckController.cs index fa27f2b..38309b2 100644 --- a/SlnMesnac/Controllers/IngCheckController.cs +++ b/SlnMesnac/Controllers/IngCheckController.cs @@ -1,5 +1,7 @@ +using System.Text.Json; using Microsoft.AspNetCore.Mvc; using SlnMesnac.Model.dto; +using SlnMesnac.Repository.service; namespace SlnMesnac.Controllers; @@ -11,14 +13,16 @@ namespace SlnMesnac.Controllers; public class IngCheckController { private ILogger _logger; + private IMcsBinToMaterService _mcsBinToMaterService; /// /// /// /// - public IngCheckController(ILogger logger) + public IngCheckController(ILogger logger,IMcsBinToMaterService mcsBinToMaterService) { _logger = logger; + _mcsBinToMaterService = mcsBinToMaterService; } /// @@ -33,20 +37,36 @@ public class IngCheckController try { + if (ingredientInfo != null) { - result.SetSuccess($"校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + string json = JsonSerializer.Serialize(ingredientInfo); + _logger.LogInformation($"大料验证参数:{json}"); + var info = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(ingredientInfo.EquipId, ingredientInfo.CanNumber); + if (info != null) + { + + if (info.MatCode == ingredientInfo.MaterialBarcode) + { + result.SetSuccess($"大料校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + else + { + result.SetFailure($"大料校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + } + } else { - result.SetSuccess($"校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + result.SetSuccess($"大料校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); } } catch (Exception e) { - Console.WriteLine(e); - result.SetException(e,"小料投料校验异常"); + result.SetException(e,"大料投料校验异常"); + _logger.LogError("大料投料校验异常",e); } return result; @@ -67,6 +87,8 @@ public class IngCheckController { if (ingredientInfo != null) { + string json = JsonSerializer.Serialize(ingredientInfo); + _logger.LogInformation($"小料验证参数:{json}"); result.SetSuccess($"校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); } else diff --git a/SlnMesnac/appsettings.json b/SlnMesnac/appsettings.json index f8e683a..82e15a0 100644 --- a/SlnMesnac/appsettings.json +++ b/SlnMesnac/appsettings.json @@ -9,7 +9,7 @@ "AllowedHosts": "*", "AppConfig": { "logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0", - "mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS", - "mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma" + "mcsConnStr": "server=58.63.214.27,23313;uid=dkmes;pwd=Duken123;database=mesnac_MCS_ShareDB", + "mesConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma" } }