add - 大料校验数据接口

master
Wen JY 10 months ago
parent 6450bd5a0f
commit 6ee56047f0

@ -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
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)]
public string Guid { get; set; }
/// <summary>
/// 机台编号
///</summary>
[SugarColumn(ColumnName = "EquipID")]
public int EquipId { get; set; }
/// <summary>
/// 机台名称
///</summary>
[SugarColumn(ColumnName = "EquipName")]
public string EquipName { get; set; }
/// <summary>
/// 机台类型CWS-小料MCS-上辅机
///</summary>
[SugarColumn(ColumnName = "EquipType")]
public string EquipType { get; set; }
/// <summary>
/// 秤编号
///</summary>
[SugarColumn(ColumnName = "ScaleNum")]
public int ScaleNum { get; set; }
/// <summary>
/// 秤类型
///</summary>
[SugarColumn(ColumnName = "ScaleClass")]
public string ScaleClass { get; set; }
/// <summary>
/// 秤名称
///</summary>
[SugarColumn(ColumnName = "ScaleName")]
public string ScaleName { get; set; }
/// <summary>
/// 罐号
///</summary>
[SugarColumn(ColumnName = "BinNo")]
public int BinNo { get; set; }
/// <summary>
/// 物料代码
///</summary>
[SugarColumn(ColumnName = "MatCode")]
public string MatCode { get; set; }
/// <summary>
/// 物料名称
///</summary>
[SugarColumn(ColumnName = "MatName")]
public string MatName { get; set; }
/// <summary>
/// 使用状态Y-使用中N-未使用
///</summary>
[SugarColumn(ColumnName = "UseYN")]
public string UseYN { get; set; }
}
}

@ -9,6 +9,11 @@ namespace SlnMesnac.Model.dto
[DataContract(Name = "IngredientInfo 投料信息")]
public class IngredientInfo
{
/// <summary>
/// 机台编号预留可传0
/// </summary>
public int EquipId { get; set; }
/// <summary>
/// 料罐编号
/// </summary>
@ -44,6 +49,11 @@ namespace SlnMesnac.Model.dto
/// </summary>
public double RemainderWeight { get; set; }
/// <summary>
/// 是否开仓1-开仓2-只保存
/// </summary>
public int IsOpen { get; set; }
/// <summary>
/// 记录时间
/// </summary>

@ -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<IBaseUserService, BaseUserServiceImpl>();
services.AddSingleton<IBaseMaterialService, BaseMaterialServiceImpl>();
services.AddScoped<IMcsBinToMaterService, McsBinToMaterServiceImpl>();
}
}
}

@ -0,0 +1,25 @@
using System.Collections.Generic;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service
{
/// <summary>
/// 上辅机料罐物料对应信息
/// </summary>
public interface IMcsBinToMaterService
{
/// <summary>
/// 获取大料料罐物料对应信息
/// </summary>
/// <returns></returns>
List<McsBinToMater> GetMcsBinToMaterList();
/// <summary>
/// 通过机台编号、料罐编号获取料罐物料对应信息
/// </summary>
/// <param name="EquipId"></param>
/// <param name="BinNo"></param>
/// <returns></returns>
McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,int BinNo);
}
}

@ -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<McsBinToMater> _rep;
public McsBinToMaterServiceImpl(Repository<McsBinToMater> rep)
{
_rep = rep;
}
/// <summary>
/// 获取大料料罐物料对应信息
/// </summary>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public List<McsBinToMater> GetMcsBinToMaterList()
{
try
{
return _rep.GetList();;
}
catch (Exception e)
{
throw new ArgumentException($"获取料仓物料对应信息异常:{e.Message}");
}
}
/// <summary>
/// 通过机台编号、料罐编号获取料罐物料对应信息
/// </summary>
/// <param name="EquipId"></param>
/// <param name="BinNo"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
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}");
}
}
}
}

@ -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<IngCheckController> _logger;
private IMcsBinToMaterService _mcsBinToMaterService;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
public IngCheckController(ILogger<IngCheckController> logger)
public IngCheckController(ILogger<IngCheckController> logger,IMcsBinToMaterService mcsBinToMaterService)
{
_logger = logger;
_mcsBinToMaterService = mcsBinToMaterService;
}
/// <summary>
@ -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.SetSuccess($"校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
result.SetFailure($"大料校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
}
else
{
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

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

Loading…
Cancel
Save