add - 获取MCS物料信息接口

master
wenjy 10 months ago
parent 060fec29c6
commit 182447b1d0

@ -1,284 +0,0 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;
namespace SlnMesnac.Model.domain
{
[SugarTable("BasMaterial"), TenantAttribute("mes")]
[DataContract(Name = "BasMaterial 物料信息")]
public class BaseMaterialInfo
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ObjID", IsPrimaryKey = true)]
public int ObjID { get; set; }
/// <summary>
/// 大类+小类+规格+胶代码或最后4顺序号
///</summary>
[SugarColumn(ColumnName = "MaterialCode")]
public string MaterialCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MajorTypeID")]
public int? MajorTypeID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MinorTypeID")]
public string MinorTypeID { get; set; }
/// <summary>
///
/// 默认值: ('')
///</summary>
[SugarColumn(ColumnName = "RubCode")]
public string RubCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaterialName")]
public string MaterialName { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaterialOtherName")]
public string MaterialOtherName { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaterialSimpleName")]
public string MaterialSimpleName { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ProductMaterialCode")]
public string ProductMaterialCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaterialLevel")]
public string MaterialLevel { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaterialGroup")]
public string MaterialGroup { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UserCode")]
public string UserCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "PlanPrice")]
public decimal? PlanPrice { get; set; }
/// <summary>
/// 具体到县级市长度为6国外的只具体国家
///</summary>
[SugarColumn(ColumnName = "ProductArea")]
public string ProductArea { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MinStock")]
public decimal? MinStock { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "MaxStock")]
public decimal? MaxStock { get; set; }
/// <summary>
/// 千克,克,块,桶,升
///</summary>
[SugarColumn(ColumnName = "UnitID")]
public int? UnitID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "StaticUnitID")]
public int? StaticUnitID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "StaticUnitCoefficient")]
public decimal? StaticUnitCoefficient { get; set; }
/// <summary>
/// 显为百分比
///</summary>
[SugarColumn(ColumnName = "CheckPermitError")]
public decimal? CheckPermitError { get; set; }
/// <summary>
/// 按小时计算
///</summary>
[SugarColumn(ColumnName = "MaxParkTime")]
public decimal? MaxParkTime { get; set; }
/// <summary>
/// 小时计算
///</summary>
[SugarColumn(ColumnName = "MinParkTime")]
public decimal? MinParkTime { get; set; }
/// <summary>
///
/// 默认值: (getdate())
///</summary>
[SugarColumn(ColumnName = "DefineDate")]
public DateTime? DefineDate { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "StandardCode")]
public string StandardCode { get; set; }
/// <summary>
///
/// 默认值: ((1))
///</summary>
[SugarColumn(ColumnName = "StaticClass")]
public int? StaticClass { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName = "IsEqualMaterial")]
public string IsEqualMaterial { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName = "IsPutJar")]
public string IsPutJar { get; set; }
/// <summary>
///
/// 默认值: ((1))
///</summary>
[SugarColumn(ColumnName = "IsQualityRateCount")]
public string IsQualityRateCount { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ERPCode")]
public string ERPCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "Remark")]
public string Remark { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "DeleteFlag")]
public string DeleteFlag { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName = "ValidDate")]
public decimal ValidDate { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName = "ValidDateB")]
public decimal ValidDateB { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "SAPMaterialCode")]
public string SAPMaterialCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "SAPMaterialShortCode")]
public string SAPMaterialShortCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ERPCode_Bak")]
public string ErpcodeBak { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "OperSourceTemp")]
public string OperSourceTemp { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "IsQualityrateCountBak")]
public int? IsQualityrateCountBak { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "CMaterialLevel")]
public string CMaterialLevel { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "CMaterialGroup")]
public string CMaterialGroup { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "XBStock")]
public decimal? XBStock { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "HFCode")]
public string HFCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "HFCode2")]
public string HFCode2 { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UNITName")]
public string UNITName { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "KFACSTATUS")]
public string Kfacstatus { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "Ordertype")]
public string Ordertype { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "CreateDate")]
public string CreateDate { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UpdateDate")]
public string UpdateDate { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UnAudit")]
public string UnAudit { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ChkStand")]
public string ChkStand { get; set; }
/// <summary>
/// 1 KG 2 PC 3 标准KG
/// 默认值: ((1))
///</summary>
[SugarColumn(ColumnName = "SapUpUnit")]
public int? SapUpUnit { get; set; }
/// <summary>
/// 是否为轨道事业部物料0不是1
///</summary>
[SugarColumn(ColumnName = "IsGDMaterial")]
public int? IsGDMaterial { get; set; }
}
}

@ -1,108 +0,0 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Security.Principal;
using System.Text;
using System.Xml.Linq;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// 系统基础资料-人员基础资料 yuany
///</summary>
[SugarTable("BasUser"), TenantAttribute("mes")]
[DataContract(Name = "BaseUser 人员基础资料")]
public class BaseUser
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ObjID", IsPrimaryKey = true, IsIdentity = true)]
public int ObjID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UserName")]
public string UserName { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "UserPWD")]
public string UserPWD { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "RealName")]
public string RealName { get; set; }
/// <summary>
///
/// 默认值: ((1))
///</summary>
[SugarColumn(ColumnName = "Sex")]
public int? Sex { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "Telephone")]
public string Telephone { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "WorkBarcode")]
public string WorkBarcode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "DeptCode")]
public string DeptCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "WorkID")]
public int? WorkID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ShiftID")]
public int? ShiftID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "WorkShopID")]
public int? WorkShopID { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "HRCode")]
public string HRCode { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "ERPCode")]
public string ERPCode { get; set; }
/// <summary>
///
/// 默认值: ((0))
///</summary>
[SugarColumn(ColumnName = "DeleteFlag")]
public string DeleteFlag { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "Remark")]
public string Remark { get; set; }
/// <summary>
///
/// 默认值: ((1))
///</summary>
[SugarColumn(ColumnName = "IsEmployee")]
public string IsEmployee { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "RecordTime")]
public DateTime? RecordTime { get; set; }
}
}

@ -0,0 +1,93 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;
namespace SlnMesnac.Model.domain
{
[SugarTable("MESToMCS_Material"), TenantAttribute("mcs")]
[DataContract(Name = "MESToMCS_Material MCS 物料信息")]
public class McsMaterialInfo
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)]
public string Guid { get; set; }
/// <summary>
/// 机台编号
///</summary>
[SugarColumn(ColumnName = "EquipID")]
public int EquipId { get; set; }
/// <summary>
/// 机台类型CWS-小料MCS-上辅机
///</summary>
[SugarColumn(ColumnName = "EquipType")]
public string EquipType { get; set; }
/// <summary>
/// 物料代码
///</summary>
[SugarColumn(ColumnName = "MatCode")]
public string MatCode { get; set; }
/// <summary>
/// 物料名称
///</summary>
[SugarColumn(ColumnName = "MatName")]
public string MatName { get; set; }
/// <summary>
/// 物料条码
///</summary>
[SugarColumn(ColumnName = "MatBarcode")]
public string MatBarcode { get; set; }
/// <summary>
/// 物料类型编号
///</summary>
[SugarColumn(ColumnName = "MatTypeID")]
public string MatTypeId { get; set; }
/// <summary>
/// 物料类型
///</summary>
[SugarColumn(ColumnName = "MatType")]
public string MatType { get; set; }
/// <summary>
/// 物料秤类别
///</summary>
[SugarColumn(ColumnName = "ScaleID")]
public string ScaleId { get; set; }
/// <summary>
/// 秤名称
///</summary>
[SugarColumn(ColumnName = "ScaleName")]
public string ScaleName { get; set; }
/// <summary>
/// 胶料类别
///</summary>
[SugarColumn(ColumnName = "MatRubType")]
public string MatRubType { get; set; }
/// <summary>
/// 小料设备号
///</summary>
[SugarColumn(ColumnName = "CWSID")]
public string CWSID { get; set; }
/// <summary>
/// 写入时间
/// </summary>
[SugarColumn(ColumnName = "WriteTime")]
public DateTime WriteTime { get; set; }
}
}

@ -19,7 +19,7 @@ namespace SlnMesnac.Model.dto
/// 是否成功
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 信息
/// </summary>

@ -17,7 +17,7 @@ namespace SlnMesnac.Model.dto
/// <summary>
/// 料罐编号
/// </summary>
public int CanNumber { get; set; }
public string CanNumber { get; set; }
/// <summary>
/// 物料条码

@ -55,10 +55,9 @@ namespace SlnMesnac.Repository
{
//services.AddSingleton<Repository<BaseUser>>();
services.AddSingleton(typeof(Repository<>));
services.AddSingleton<IBaseUserService, BaseUserServiceImpl>();
services.AddSingleton<IBaseMaterialService, BaseMaterialServiceImpl>();
services.AddSingleton<IMcsBinToMaterService, McsBinToMaterServiceImpl>();
services.AddSingleton<IWmsTaskOutService, WmsTaskOutServiceImpl>();
services.AddSingleton<IMcsMaterialInfoService, McsMaterialInfoServiceImpl>();
}
}
}

@ -1,39 +0,0 @@
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Repository.service
{
public interface IBaseMaterialService
{
/// <summary>
/// 获取所有的物料信息
/// </summary>
/// <returns></returns>
List<BaseMaterialInfo> GetMaterialInfos();
/// <summary>
/// 通过物料编码获取物料信息
/// </summary>
/// <param name="materialCode"></param>
/// <returns></returns>
BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode);
/// <summary>
/// 通过SAP物料编码获取物料信息
/// </summary>
/// <param name="sapMaterialCode"></param>
/// <returns></returns>
BaseMaterialInfo GetMaterialInfoBySapMaterialCode(string sapMaterialCode);
/// <summary>
/// 通过物料类别获取物料信息
/// </summary>
/// <param name="majorTypeId">物料大类</param>
/// <param name="minorTypeId">物料细类</param>
/// <returns></returns>
List<BaseMaterialInfo> GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId);
}
}

@ -20,6 +20,6 @@ namespace SlnMesnac.Repository.service
/// <param name="EquipId"></param>
/// <param name="BinNo"></param>
/// <returns></returns>
McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,int BinNo);
McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,string BinNo);
}
}

@ -5,19 +5,19 @@ using System.Text;
namespace SlnMesnac.Repository.service
{
public interface IBaseUserService
public interface IMcsMaterialInfoService
{
/// <summary>
/// 获取用户信息
/// 获取MCS物料信息
/// </summary>
/// <returns></returns>
List<BaseUser> GetUsers();
List<McsMaterialInfo> GetMcsMaterialInfoList();
/// <summary>
/// 验证添加用户信息,有一个错误时进行回滚
/// 根据物料代码获取物料信息
/// </summary>
/// <param name="user"></param>
/// <param name="MatCode"></param>
/// <returns></returns>
bool InsertUsers(List<BaseUser> users);
McsMaterialInfo GetMcsMaterialInfoByMatCode(string MatCode);
}
}

@ -1,111 +0,0 @@
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
using SlnMesnac.Common;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
namespace SlnMesnac.Repository.service.Impl
{
public class BaseMaterialServiceImpl : IBaseMaterialService
{
private Repository<BaseMaterialInfo> _repository;
private ILogger<BaseMaterialServiceImpl> _logger;
public BaseMaterialServiceImpl(Repository<BaseMaterialInfo> repository, ILogger<BaseMaterialServiceImpl> logger)
{
_repository = repository;
_logger = logger;
}
/// <summary>
/// 通过物料编码获取物料信息
/// </summary>
/// <param name="materialCode"></param>
/// <returns></returns>
public BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode)
{
BaseMaterialInfo materialInfo = null;
try
{
materialInfo = _repository.GetFirst(x => x.MaterialCode == materialCode);
}
catch (Exception ex)
{
_logger.LogError($"根据物料编号获取物料信息异常:{ex.Message}");
}
return materialInfo;
}
/// <summary>
/// 通过SAP物料编码获取物料信息
/// </summary>
/// <param name="sapMaterialCode"></param>
/// <returns></returns>
public BaseMaterialInfo GetMaterialInfoBySapMaterialCode(string sapMaterialCode)
{
BaseMaterialInfo materialInfo = null;
try
{
materialInfo = _repository.GetFirst(x => x.SAPMaterialCode == sapMaterialCode);
}
catch (Exception ex)
{
_logger.LogError($"根据SAP物料编号获取物料信息异常:{ex.Message}");
}
return materialInfo;
}
/// <summary>
/// 获取所有的物料信息
/// </summary>
/// <returns></returns>
public List<BaseMaterialInfo> GetMaterialInfos()
{
List<BaseMaterialInfo> materialInfos = null;
try
{
materialInfos = _repository.GetList();
}
catch (Exception ex)
{
_logger.LogError($"获取物料信息异常:{ex.Message}");
}
return materialInfos;
}
/// <summary>
/// 通过物料类别获取物料信息
/// </summary>
/// <param name="majorTypeId">物料大类</param>
/// <param name="minorTypeId">物料细类</param>
/// <returns></returns>
public List<BaseMaterialInfo> GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId)
{
List<BaseMaterialInfo> materialInfos = null;
try
{
Expression<Func<BaseMaterialInfo, bool>> exp = x => true;
if (majorTypeId != 0)
{
exp = exp.And(x => x.MajorTypeID == majorTypeId);
}
else if (!string.IsNullOrEmpty(minorTypeId))
{
exp = exp.And(x => x.MinorTypeID == minorTypeId);
}
materialInfos = _repository.GetList(exp);
}
catch (Exception ex)
{
_logger.LogError($"通过物料类型获取物料信息异常:{ex.Message}");
}
return materialInfos;
}
}
}

@ -1,55 +0,0 @@
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Repository.service.Impl
{
public class BaseUserServiceImpl : IBaseUserService
{
private readonly ILogger<BaseUser> _logger;
private readonly Repository<BaseUser> _rep;
public BaseUserServiceImpl(ILogger<BaseUser> logger, Repository<BaseUser> rep)
{
_logger = logger;
_rep = rep;
}
public List<BaseUser> GetUsers()
{
List<BaseUser> users = null;
try
{
users = _rep.GetList();
}
catch (Exception ex)
{
_logger.LogError($"获取用户信息异常{ex.Message}");
}
return users;
}
public bool InsertUsers(List<BaseUser> users)
{
bool result = false;
try
{
_rep.AsTenant().BeginTran();
result = _rep.InsertRange(users);
_rep.AsTenant().CommitTran();
}
catch (Exception ex)
{
_rep.AsTenant().RollbackTran();
_logger.LogError($"用户信息添加异常:{ex.Message}");
}
return result;
}
}
}

@ -39,11 +39,12 @@ namespace SlnMesnac.Repository.service.Impl
/// <param name="BinNo"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public McsBinToMater GetMcsBinToMaterByBinNo(int EquipId, int BinNo)
public McsBinToMater GetMcsBinToMaterByBinNo(int EquipId, string BinNo)
{
try
{
return _rep.GetFirst(x=>x.ScaleNum == 101 && x.EquipId == EquipId && x.BinNo == BinNo);;
//return _rep.GetFirst(x=>x.ScaleNum == 101 && x.EquipId == EquipId && x.BinNo == BinNo);
return _rep.GetFirst(x => x.EquipId.ToString()+x.ScaleNum.ToString()+x.BinNo.ToString() == BinNo);
}
catch (Exception e)
{

@ -0,0 +1,55 @@
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SlnMesnac.Repository.service.Impl
{
public class McsMaterialInfoServiceImpl : IMcsMaterialInfoService
{
private readonly Repository<McsMaterialInfo> _rep;
public McsMaterialInfoServiceImpl(Repository<McsMaterialInfo> rep)
{
_rep = rep;
}
/// <summary>
/// 根据物料代码获取物料信息
/// </summary>
/// <param name="MatCode"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public McsMaterialInfo GetMcsMaterialInfoByMatCode(string MatCode)
{
try
{
//return _rep.GetList(x => x.MatCode == MatCode).OrderByDescending(x => x.WriteTime).First();
return _rep.GetFirst(x => x.MatCode == MatCode);
}
catch (Exception e)
{
throw new ArgumentException($"根据物料代码获取物料信息异常:{e.Message}");
}
}
/// <summary>
/// 获取MCS物料信息
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public List<McsMaterialInfo> GetMcsMaterialInfoList()
{
try
{
return _rep.GetList();
}
catch (Exception e)
{
throw new ArgumentException($"获取MCS物料信息异常:{e.Message}");
}
}
}
}

@ -1,90 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
namespace SlnMesnac.Controllers
{
/// <summary>
/// 物料信息
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BaseMaterialInfoController
{
private ILogger<BaseMaterialInfoController> _logger;
private IBaseMaterialService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
public BaseMaterialInfoController(ILogger<BaseMaterialInfoController> logger, IBaseMaterialService service)
{
_logger = logger;
_service = service;
}
/// <summary>
/// 获取物料信息
/// </summary>
/// <returns></returns>
[HttpGet]
public IEnumerable<BaseMaterialInfo> Get()
{
IEnumerable<BaseMaterialInfo> materialInfos = null;
try
{
materialInfos = _service.GetMaterialInfos();
}
catch (Exception ex)
{
_logger.LogError($"获取物料信息接口调用异常:{ex.Message}");
}
return materialInfos;
}
/// <summary>
/// 根据物料编号获取物料信息
/// </summary>
/// <param name="materialCode">物料编号</param>
/// <returns></returns>
[HttpGet("Get/{materialCode}")]
public BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode)
{
BaseMaterialInfo materialInfo = null;
try
{
materialInfo = _service.GetMaterialInfoByMaterialCode(materialCode);
}
catch (Exception ex)
{
_logger.LogError($"根据物料编号获取物料信息接口调用异常:{ex.Message}");
}
return materialInfo;
}
/// <summary>
/// 通过物料类别获取物料信息
/// </summary>
/// <param name="majorTypeId">物料大类</param>
/// <param name="minorTypeId">物料细类</param>
/// <returns></returns>
[HttpGet("Get/{majorTypeId}/{minorTypeId}")]
public IEnumerable<BaseMaterialInfo> GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId)
{
IEnumerable<BaseMaterialInfo> materialInfos = null;
try
{
materialInfos = _service.GetMaterialInfosByMaterialType(majorTypeId, minorTypeId);
}
catch (Exception ex)
{
_logger.LogError($"通过物料类别获取物料信息接口调用异常:{ex.Message}");
}
return materialInfos;
}
}
}

@ -1,81 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.domain;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
namespace SlnMesnac.Controllers
{
/// <summary>
/// 人员基础信息
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BaseUserController : ControllerBase
{
private readonly ILogger<BaseUserController> _logger;
private readonly IBaseUserService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
public BaseUserController(ILogger<BaseUserController> logger, IBaseUserService service)
{
_logger = logger;
_service = service;
}
/// <summary>
/// 获取人员基础信息
/// </summary>
/// <returns></returns>
[HttpGet]
public IEnumerable<BaseUser> Get()
{
IEnumerable<BaseUser> users = null;
try
{
users = _service.GetUsers();
}
catch (Exception ex)
{
_logger.LogError($"获取用户信息接口调用异常:{ex.Message}");
}
return users;
}
/// <summary>
/// 通过用户名称获取指定用户信息
/// </summary>
/// <param name="userName">用户名称</param>
/// <returns></returns>
[HttpGet("Gets/{userName}")]
public IEnumerable<BaseUser> GetUserByUserName(string userName)
{
IEnumerable<BaseUser> users = null;
try
{
users = _service.GetUsers();
}
catch (Exception ex)
{
_logger.LogError($"获取用户信息接口调用异常:{ex.Message}");
}
return users;
}
/// <summary>
/// 添加用户信息
/// </summary>
/// <param name="users">用户列表</param>
/// <returns></returns>
[HttpPut]
public bool InsertUserInfo(List<BaseUser> users)
{
return _service.InsertUsers(users);
}
}
}

@ -5,6 +5,7 @@ using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using TouchSocket.Core;
namespace SlnMesnac.Controllers;
@ -17,26 +18,72 @@ public class IngCheckController
{
private ILogger<IngCheckController> _logger;
private AppConfig _appConfig;
private PlcPool _plcPool;
private IMcsBinToMaterService _mcsBinToMaterService;
private IWmsTaskOutService _wmsTaskOutService;
private PlcPool _plcPool;
private IMcsMaterialInfoService _mcsMaterialInfoService;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="mcsBinToMaterService"></param>
/// <param name="appConfig"></param>
/// <param name="wmsTaskOutService"></param>
/// <param name="plcPool"></param>
/// <param name="mcsMaterialInfoService"></param>
public IngCheckController(ILogger<IngCheckController> logger,
IMcsBinToMaterService mcsBinToMaterService,
AppConfig appConfig,
IWmsTaskOutService wmsTaskOutService,
PlcPool plcPool)
PlcPool plcPool,
IMcsMaterialInfoService mcsMaterialInfoService)
{
_logger = logger;
_mcsBinToMaterService = mcsBinToMaterService;
_appConfig = appConfig;
_wmsTaskOutService = wmsTaskOutService;
_plcPool = plcPool;
_mcsMaterialInfoService = mcsMaterialInfoService;
}
/// <summary>
/// 根据物料条码获取MCS物料信息
/// </summary>
/// <param name="MaterialBarcode"></param>
/// <returns></returns>
[HttpGet("GetMcsMaterialInfo/{MaterialBarcode}")]
public ApiResponse GetMcsMaterialInfo(string MaterialBarcode)
{
var result = new ApiResponse();
try
{
do
{
WmsTaskOut wmsInfo = this.GetWmsTaskOutBySerialNum(MaterialBarcode);
if (wmsInfo == null)
{
result.SetFailure($"物料信息获取失败,根据物料条码获取物料编号为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
break;
}
var info = _mcsMaterialInfoService.GetMcsMaterialInfoByMatCode(wmsInfo.MaterNo);
if(info == null)
{
result.SetFailure($"物料信息获取失败根据物料编号获取MCS物料信息为空时间{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
else
{
result.SetSuccess(JsonSerializer.Serialize(info));
}
} while (false);
}
catch(Exception e)
{
result.SetException(e, "物料信息获取异常");
_logger.LogError($"物料信息获取异常:{e.Message}");
}
return result;
}
/// <summary>
@ -60,14 +107,14 @@ public class IngCheckController
_logger.LogInformation($"上辅机验证参数:{JsonSerializer.Serialize(ingredientInfo)}");
McsBinToMater mcsInfo = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(1, ingredientInfo.CanNumber);
McsBinToMater mcsInfo = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(ingredientInfo.EquipId, ingredientInfo.CanNumber);
if (mcsInfo == null)
{
result.SetFailure($"上辅机校验失败,根据料罐获取对应信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
break;
}
WmsTaskOut wmsInfo = _wmsTaskOutService.GetWmsTaskOutBySerialNum(ingredientInfo.MaterialBarcode);
WmsTaskOut wmsInfo = this.GetWmsTaskOutBySerialNum(ingredientInfo.MaterialBarcode);
if (wmsInfo == null)
{
result.SetFailure($"上辅机校验失败,根据物料条码获取物料信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
@ -86,15 +133,15 @@ public class IngCheckController
if (ingredientInfo.IsOpen == 1)
{
var openFlag = _plcPool.GetPlcByKey("mcs").writeInt32ByAddress(_appConfig.mcsOpenAddr,ingredientInfo.CanNumber);
var openFlag = _plcPool.GetPlcByKey("mcs").writeValueByAddress(mcsInfo.BinNo,_appConfig.mcsOpenAddr);
if (openFlag)
{
_logger.LogInformation($"上辅机开仓指令下发成功");
_logger.LogInformation($"上辅机开仓指令下发成功");
result.SetSuccess($"上辅机校验成功,开仓指令下发成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
else
{
_logger.LogError("上辅机开仓指令下发失败");
_logger.LogInformation("上辅机开仓指令下发失败");
result.SetSuccess($"上辅机校验成功,开仓指令下发失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
break;
}
@ -147,24 +194,22 @@ public class IngCheckController
}
/// <summary>
/// 下发开仓指令
/// 根据物料条码获取WMS出库记录反馈信息
/// </summary>
/// <param name="address"></param>
/// <param name="canNumber"></param>
/// <param name="MaterialBarcode"></param>
/// <returns></returns>
private bool SendOpenInstructions(string plcType, string address, int canNumber)
private WmsTaskOut GetWmsTaskOutBySerialNum(string MaterialBarcode)
{
bool result = false;
WmsTaskOut? result = null;
try
{
result = _plcPool.GetPlcByKey(plcType).writeInt32ByAddress(address,canNumber);
{
result = _wmsTaskOutService.GetWmsTaskOutBySerialNum(MaterialBarcode);
_logger.LogInformation($"根据物料条码:{MaterialBarcode};获取WMS出库记录{JsonSerializer.Serialize(result)},时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
catch (Exception e)
catch (Exception ex)
{
_logger.LogError($"开仓指令下发异常:{e.Message}");
_logger.LogError($"根据物料条码:{MaterialBarcode};获取WMS出库记录异常{ex.Message}");
}
return result;
}
}

@ -8,13 +8,14 @@
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsOpenAddr": "D75367",
//"logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"logPath": "E:/桌面/杜肯密炼MES项目/程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsOpenAddr": "D100",
"cwssOpenAddr": "DB122",
"SqlConfig": [
{
"configId": "mcs",
"dbType": 1, //MySql-0;SqlServer-1;Sqlite-2;Oracle-3
"dbType": 1, //MySql-0;SqlServer-1;Sqlite-2;Oracle-3
"connStr": "server=58.63.214.27,23313;uid=dkmes;pwd=Duken123;database=mesnac_MCS_ShareDB"
},
{
@ -28,19 +29,19 @@
"connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
}
],
"PlcConfig":[
"PlcConfig": [
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1", //192.168.1.71
"plcPort": 102,
"plcPort": 6000,
"plcKey": "mcs"
},
{
"configId": 2,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 102,
"plcPort": 6000,
"plcKey": "cwss"
}
]

Loading…
Cancel
Save