change - 配置文件修改

master
Wen JY 10 months ago
parent 6ee56047f0
commit 2b8b337ada

@ -1,5 +1,6 @@
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic;
namespace SlnMesnac.Config namespace SlnMesnac.Config
{ {
@ -23,6 +24,11 @@ namespace SlnMesnac.Config
/// </summary> /// </summary>
public string mcsConnStr { get; set; } public string mcsConnStr { get; set; }
/// <summary>
/// PLC连接配置
/// </summary>
public List<PlcConfig> plcConfig { get; set; }
public AppConfig Value => this; public AppConfig Value => this;
} }
} }

@ -0,0 +1,33 @@
namespace SlnMesnac.Config
{
/// <summary>
/// PLC配置通过AppConfig进行获取
/// </summary>
public class PlcConfig
{
/// <summary>
/// PLC配置ID
/// </summary>
public int configId { get; set; }
/// <summary>
/// PIC类型
/// </summary>
public string plcType { get; set; }
/// <summary>
/// PLC IP
/// </summary>
public string plcIp { get; set; }
/// <summary>
/// PLC Port
/// </summary>
public int plcPort { get; set; }
/// <summary>
/// PLC Key
/// </summary>
public string plcKey { get; set; }
}
}

@ -1,5 +1,6 @@
using System.Text.Json; using System.Text.Json;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Config;
using SlnMesnac.Model.dto; using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service; using SlnMesnac.Repository.service;
@ -13,16 +14,18 @@ namespace SlnMesnac.Controllers;
public class IngCheckController public class IngCheckController
{ {
private ILogger<IngCheckController> _logger; private ILogger<IngCheckController> _logger;
private AppConfig _appConfig;
private IMcsBinToMaterService _mcsBinToMaterService; private IMcsBinToMaterService _mcsBinToMaterService;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="logger"></param> /// <param name="logger"></param>
public IngCheckController(ILogger<IngCheckController> logger,IMcsBinToMaterService mcsBinToMaterService) public IngCheckController(ILogger<IngCheckController> logger,IMcsBinToMaterService mcsBinToMaterService,AppConfig appConfig)
{ {
_logger = logger; _logger = logger;
_mcsBinToMaterService = mcsBinToMaterService; _mcsBinToMaterService = mcsBinToMaterService;
_appConfig = appConfig;
} }
/// <summary> /// <summary>
@ -31,17 +34,14 @@ public class IngCheckController
/// <param name="ingredientInfo"></param> /// <param name="ingredientInfo"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("BigMaterial")] [HttpPost("BigMaterial")]
public ApiResponse BigMaterialCheck(IngredientInfo ingredientInfo) public ApiResponse BigMaterialCheck(IngredientInfo? ingredientInfo)
{ {
var result = new ApiResponse(); var result = new ApiResponse();
try try
{ {
if (ingredientInfo != null) if (ingredientInfo != null)
{ {
string json = JsonSerializer.Serialize(ingredientInfo); _logger.LogInformation($"大料验证参数:{JsonSerializer.Serialize(ingredientInfo)}");
_logger.LogInformation($"大料验证参数:{json}");
var info = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(ingredientInfo.EquipId, ingredientInfo.CanNumber); var info = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(ingredientInfo.EquipId, ingredientInfo.CanNumber);
if (info != null) if (info != null)
{ {
@ -55,6 +55,10 @@ public class IngCheckController
result.SetFailure($"大料校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); result.SetFailure($"大料校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
} }
else
{
result.SetFailure($"大料校验失败,根据料罐获取对应信息异常,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
} }
else else
@ -66,7 +70,7 @@ public class IngCheckController
catch (Exception e) catch (Exception e)
{ {
result.SetException(e,"大料投料校验异常"); result.SetException(e,"大料投料校验异常");
_logger.LogError("大料投料校验异常",e); _logger.LogError($"大料投料校验异常:{e.Message}");
} }
return result; return result;
@ -78,7 +82,7 @@ public class IngCheckController
/// <param name="ingredientInfo"></param> /// <param name="ingredientInfo"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("SmallMaterial")] [HttpPost("SmallMaterial")]
public ApiResponse SmallMaterialCheck(IngredientInfo ingredientInfo) public ApiResponse SmallMaterialCheck(IngredientInfo? ingredientInfo)
{ {
var result = new ApiResponse(); var result = new ApiResponse();
@ -87,20 +91,19 @@ public class IngCheckController
{ {
if (ingredientInfo != null) if (ingredientInfo != null)
{ {
string json = JsonSerializer.Serialize(ingredientInfo); _logger.LogInformation($"小料验证参数:{JsonSerializer.Serialize(ingredientInfo)}");
_logger.LogInformation($"小料验证参数:{json}"); result.SetSuccess($"小料校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
result.SetSuccess($"校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
else 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) catch (Exception e)
{ {
Console.WriteLine(e);
result.SetException(e,"小料投料校验异常"); result.SetException(e,"小料投料校验异常");
_logger.LogError($"小料投料校验异常:{e.Message}");
} }
return result; return result;

@ -10,6 +10,22 @@
"AppConfig": { "AppConfig": {
"logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0", "logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsConnStr": "server=58.63.214.27,23313;uid=dkmes;pwd=Duken123;database=mesnac_MCS_ShareDB", "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" "mesConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma",
"PlcConfig":[
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 102,
"plcKey": "mcs"
},
{
"configId": 2,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 102,
"plcKey": "cwss"
}
]
} }
} }

Loading…
Cancel
Save