add - 投料校验,大料、小料

master
Wen JY 10 months ago
parent 9ab11e32d6
commit d96d86b6e2

@ -0,0 +1,62 @@
using System;
using System.Runtime.Serialization;
namespace SlnMesnac.Model.dto
{
/// <summary>
/// 接口返回信息
/// </summary>
[DataContract(Name = "ApiResponse 返回信息")]
public class ApiResponse
{
/// <summary>
/// 状态码,成功-200异常-500
/// </summary>
public int StatusCode { get; set; }
/// <summary>
/// 是否成功
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 信息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 成功
/// </summary>
/// <param name="message"></param>
public void SetSuccess(string message = "")
{
StatusCode = 200;
IsSuccess = true;
Message = message;
}
/// <summary>
/// 失败
/// </summary>
/// <param name="message"></param>
public void SetFailure(string message = "")
{
StatusCode = 500;
IsSuccess = false;
Message = message;
}
/// <summary>
/// 异常
/// </summary>
/// <param name="ex"></param>
/// <param name="message"></param>
public void SetException(Exception ex, string message = "")
{
StatusCode = 500;
IsSuccess = false;
Message = message + ex.Message;
}
}
}

@ -0,0 +1,52 @@
using System;
using System.Runtime.Serialization;
namespace SlnMesnac.Model.dto
{
/// <summary>
/// 投料信息
/// </summary>
[DataContract(Name = "IngredientInfo 投料信息")]
public class IngredientInfo
{
/// <summary>
/// 料罐编号
/// </summary>
public int CanNumber { get; set; }
/// <summary>
/// 物料条码
/// </summary>
public string MaterialBarcode { get; set; }
/// <summary>
/// 投入数量
/// </summary>
public int InputQuantity { get; set; }
/// <summary>
/// 投入重量
/// </summary>
public double InputWeight { get; set; }
/// <summary>
/// 是否余料
/// </summary>
public bool IsRemainder { get; set; }
/// <summary>
/// 余料数量
/// </summary>
public int RemainderQuantity { get; set; }
/// <summary>
/// 余料重量
/// </summary>
public double RemainderWeight { get; set; }
/// <summary>
/// 记录时间
/// </summary>
public DateTime RecordTime { get; set; }
}
}

@ -0,0 +1,86 @@
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.dto;
namespace SlnMesnac.Controllers;
/// <summary>
/// ingredientsChenck 投料校验
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class IngCheckController
{
private ILogger<IngCheckController> _logger;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
public IngCheckController(ILogger<IngCheckController> logger)
{
_logger = logger;
}
/// <summary>
/// 大料投料校验
/// </summary>
/// <param name="ingredientInfo"></param>
/// <returns></returns>
[HttpPut("BigMaterial")]
public ApiResponse BigMaterialCheck(IngredientInfo ingredientInfo)
{
var result = new ApiResponse();
try
{
if (ingredientInfo != null)
{
result.SetSuccess($"校验成功,时间:{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,"小料投料校验异常");
}
return result;
}
/// <summary>
/// 小料投料校验
/// </summary>
/// <param name="ingredientInfo"></param>
/// <returns></returns>
[HttpPut("SmallMaterial")]
public ApiResponse SmallMaterialCheck(IngredientInfo ingredientInfo)
{
var result = new ApiResponse();
try
{
if (ingredientInfo != null)
{
result.SetSuccess($"校验成功,时间:{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,"小料投料校验异常");
}
return result;
}
}
Loading…
Cancel
Save