From d96d86b6e2effda9010c02b414e14e49e962aade Mon Sep 17 00:00:00 2001 From: Wen JY Date: Fri, 19 Jan 2024 14:44:27 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E6=8A=95=E6=96=99=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E5=A4=A7=E6=96=99=E3=80=81=E5=B0=8F=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Model/dto/ApiResponse.cs | 62 +++++++++++++++ SlnMesnac.Model/dto/IngredientInfoDto.cs | 52 +++++++++++++ SlnMesnac/Controllers/IngCheckController.cs | 86 +++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 SlnMesnac.Model/dto/ApiResponse.cs create mode 100644 SlnMesnac.Model/dto/IngredientInfoDto.cs create mode 100644 SlnMesnac/Controllers/IngCheckController.cs diff --git a/SlnMesnac.Model/dto/ApiResponse.cs b/SlnMesnac.Model/dto/ApiResponse.cs new file mode 100644 index 0000000..b7e99ab --- /dev/null +++ b/SlnMesnac.Model/dto/ApiResponse.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.Serialization; + +namespace SlnMesnac.Model.dto +{ + /// + /// 接口返回信息 + /// + [DataContract(Name = "ApiResponse 返回信息")] + public class ApiResponse + { + + /// + /// 状态码,成功-200,异常-500 + /// + public int StatusCode { get; set; } + + /// + /// 是否成功 + /// + public bool IsSuccess { get; set; } + + /// + /// 信息 + /// + public string Message { get; set; } + + /// + /// 成功 + /// + /// + public void SetSuccess(string message = "") + { + StatusCode = 200; + IsSuccess = true; + Message = message; + } + + /// + /// 失败 + /// + /// + public void SetFailure(string message = "") + { + StatusCode = 500; + IsSuccess = false; + Message = message; + } + + /// + /// 异常 + /// + /// + /// + public void SetException(Exception ex, string message = "") + { + StatusCode = 500; + IsSuccess = false; + Message = message + ex.Message; + } + } +} \ No newline at end of file diff --git a/SlnMesnac.Model/dto/IngredientInfoDto.cs b/SlnMesnac.Model/dto/IngredientInfoDto.cs new file mode 100644 index 0000000..6d865aa --- /dev/null +++ b/SlnMesnac.Model/dto/IngredientInfoDto.cs @@ -0,0 +1,52 @@ +using System; +using System.Runtime.Serialization; + +namespace SlnMesnac.Model.dto +{ + /// + /// 投料信息 + /// + [DataContract(Name = "IngredientInfo 投料信息")] + public class IngredientInfo + { + /// + /// 料罐编号 + /// + public int CanNumber { get; set; } + + /// + /// 物料条码 + /// + public string MaterialBarcode { get; set; } + + /// + /// 投入数量 + /// + public int InputQuantity { get; set; } + + /// + /// 投入重量 + /// + public double InputWeight { get; set; } + + /// + /// 是否余料 + /// + public bool IsRemainder { get; set; } + + /// + /// 余料数量 + /// + public int RemainderQuantity { get; set; } + + /// + /// 余料重量 + /// + public double RemainderWeight { get; set; } + + /// + /// 记录时间 + /// + public DateTime RecordTime { get; set; } + } +} \ No newline at end of file diff --git a/SlnMesnac/Controllers/IngCheckController.cs b/SlnMesnac/Controllers/IngCheckController.cs new file mode 100644 index 0000000..db7dbf0 --- /dev/null +++ b/SlnMesnac/Controllers/IngCheckController.cs @@ -0,0 +1,86 @@ +using Microsoft.AspNetCore.Mvc; +using SlnMesnac.Model.dto; + +namespace SlnMesnac.Controllers; + +/// +/// ingredientsChenck 投料校验 +/// +[Route("api/[controller]")] +[ApiController] +public class IngCheckController +{ + private ILogger _logger; + + /// + /// + /// + /// + public IngCheckController(ILogger logger) + { + _logger = logger; + } + + /// + /// 大料投料校验 + /// + /// + /// + [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; + } + + /// + /// 小料投料校验 + /// + /// + /// + [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; + } +} \ No newline at end of file