diff --git a/SlnMesnac.Model/domain/BaseMaterialInfo.cs b/SlnMesnac.Model/domain/BaseMaterialInfo.cs deleted file mode 100644 index 333aa8c..0000000 --- a/SlnMesnac.Model/domain/BaseMaterialInfo.cs +++ /dev/null @@ -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 - { - /// - /// - /// - [SugarColumn(ColumnName = "ObjID", IsPrimaryKey = true)] - public int ObjID { get; set; } - /// - /// 大类+小类+规格+胶代码或最后4顺序号 - /// - [SugarColumn(ColumnName = "MaterialCode")] - public string MaterialCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MajorTypeID")] - public int? MajorTypeID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MinorTypeID")] - public string MinorTypeID { get; set; } - /// - /// - /// 默认值: ('') - /// - [SugarColumn(ColumnName = "RubCode")] - public string RubCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaterialName")] - public string MaterialName { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaterialOtherName")] - public string MaterialOtherName { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaterialSimpleName")] - public string MaterialSimpleName { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ProductMaterialCode")] - public string ProductMaterialCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaterialLevel")] - public string MaterialLevel { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaterialGroup")] - public string MaterialGroup { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UserCode")] - public string UserCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "PlanPrice")] - public decimal? PlanPrice { get; set; } - /// - /// 具体到县级市,长度为6,国外的只具体国家 - /// - [SugarColumn(ColumnName = "ProductArea")] - public string ProductArea { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MinStock")] - public decimal? MinStock { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "MaxStock")] - public decimal? MaxStock { get; set; } - /// - /// 千克,克,块,桶,升 - /// - [SugarColumn(ColumnName = "UnitID")] - public int? UnitID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "StaticUnitID")] - public int? StaticUnitID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "StaticUnitCoefficient")] - public decimal? StaticUnitCoefficient { get; set; } - /// - /// 显为百分比 - /// - [SugarColumn(ColumnName = "CheckPermitError")] - public decimal? CheckPermitError { get; set; } - /// - /// 按小时计算 - /// - [SugarColumn(ColumnName = "MaxParkTime")] - public decimal? MaxParkTime { get; set; } - /// - /// 小时计算 - /// - [SugarColumn(ColumnName = "MinParkTime")] - public decimal? MinParkTime { get; set; } - /// - /// - /// 默认值: (getdate()) - /// - [SugarColumn(ColumnName = "DefineDate")] - public DateTime? DefineDate { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "StandardCode")] - public string StandardCode { get; set; } - /// - /// - /// 默认值: ((1)) - /// - [SugarColumn(ColumnName = "StaticClass")] - public int? StaticClass { get; set; } - /// - /// - /// 默认值: ((0)) - /// - [SugarColumn(ColumnName = "IsEqualMaterial")] - public string IsEqualMaterial { get; set; } - /// - /// - /// 默认值: ((0)) - /// - [SugarColumn(ColumnName = "IsPutJar")] - public string IsPutJar { get; set; } - /// - /// - /// 默认值: ((1)) - /// - [SugarColumn(ColumnName = "IsQualityRateCount")] - public string IsQualityRateCount { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ERPCode")] - public string ERPCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "Remark")] - public string Remark { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "DeleteFlag")] - public string DeleteFlag { get; set; } - /// - /// - /// 默认值: ((0)) - /// - [SugarColumn(ColumnName = "ValidDate")] - public decimal ValidDate { get; set; } - /// - /// - /// 默认值: ((0)) - /// - [SugarColumn(ColumnName = "ValidDateB")] - public decimal ValidDateB { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "SAPMaterialCode")] - public string SAPMaterialCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "SAPMaterialShortCode")] - public string SAPMaterialShortCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ERPCode_Bak")] - public string ErpcodeBak { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "OperSourceTemp")] - public string OperSourceTemp { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "IsQualityrateCountBak")] - public int? IsQualityrateCountBak { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "CMaterialLevel")] - public string CMaterialLevel { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "CMaterialGroup")] - public string CMaterialGroup { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "XBStock")] - public decimal? XBStock { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "HFCode")] - public string HFCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "HFCode2")] - public string HFCode2 { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UNITName")] - public string UNITName { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "KFACSTATUS")] - public string Kfacstatus { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "Ordertype")] - public string Ordertype { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "CreateDate")] - public string CreateDate { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UpdateDate")] - public string UpdateDate { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UnAudit")] - public string UnAudit { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ChkStand")] - public string ChkStand { get; set; } - /// - /// 1 KG 2 PC 3 标准KG - /// 默认值: ((1)) - /// - [SugarColumn(ColumnName = "SapUpUnit")] - public int? SapUpUnit { get; set; } - /// - /// 是否为轨道事业部物料:0:不是,1:是 - /// - [SugarColumn(ColumnName = "IsGDMaterial")] - public int? IsGDMaterial { get; set; } - } -} diff --git a/SlnMesnac.Model/domain/BaseUser.cs b/SlnMesnac.Model/domain/BaseUser.cs deleted file mode 100644 index c6f3e28..0000000 --- a/SlnMesnac.Model/domain/BaseUser.cs +++ /dev/null @@ -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 -{ - /// - /// 系统基础资料-人员基础资料 yuany - /// - [SugarTable("BasUser"), TenantAttribute("mes")] - [DataContract(Name = "BaseUser 人员基础资料")] - public class BaseUser - { - /// - /// - /// - [SugarColumn(ColumnName = "ObjID", IsPrimaryKey = true, IsIdentity = true)] - public int ObjID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UserName")] - public string UserName { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "UserPWD")] - public string UserPWD { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "RealName")] - public string RealName { get; set; } - /// - /// - /// 默认值: ((1)) - /// - [SugarColumn(ColumnName = "Sex")] - public int? Sex { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "Telephone")] - public string Telephone { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "WorkBarcode")] - public string WorkBarcode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "DeptCode")] - public string DeptCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "WorkID")] - public int? WorkID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ShiftID")] - public int? ShiftID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "WorkShopID")] - public int? WorkShopID { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "HRCode")] - public string HRCode { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "ERPCode")] - public string ERPCode { get; set; } - /// - /// - /// 默认值: ((0)) - /// - [SugarColumn(ColumnName = "DeleteFlag")] - public string DeleteFlag { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "Remark")] - public string Remark { get; set; } - /// - /// - /// 默认值: ((1)) - /// - [SugarColumn(ColumnName = "IsEmployee")] - public string IsEmployee { get; set; } - /// - /// - /// - [SugarColumn(ColumnName = "RecordTime")] - public DateTime? RecordTime { get; set; } - } -} - diff --git a/SlnMesnac.Model/domain/McsMaterialInfo.cs b/SlnMesnac.Model/domain/McsMaterialInfo.cs new file mode 100644 index 0000000..f37b223 --- /dev/null +++ b/SlnMesnac.Model/domain/McsMaterialInfo.cs @@ -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 + { + /// + /// + /// + [SugarColumn(ColumnName = "GUID", IsPrimaryKey = true)] + public string Guid { get; set; } + + /// + /// 机台编号 + /// + [SugarColumn(ColumnName = "EquipID")] + public int EquipId { get; set; } + + /// + /// 机台类型:CWS-小料;MCS-上辅机 + /// + [SugarColumn(ColumnName = "EquipType")] + public string EquipType { get; set; } + + + /// + /// 物料代码 + /// + [SugarColumn(ColumnName = "MatCode")] + public string MatCode { get; set; } + + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MatName")] + public string MatName { get; set; } + + /// + /// 物料条码 + /// + [SugarColumn(ColumnName = "MatBarcode")] + public string MatBarcode { get; set; } + + /// + /// 物料类型编号 + /// + [SugarColumn(ColumnName = "MatTypeID")] + public string MatTypeId { get; set; } + + /// + /// 物料类型 + /// + [SugarColumn(ColumnName = "MatType")] + public string MatType { get; set; } + + /// + /// 物料秤类别 + /// + [SugarColumn(ColumnName = "ScaleID")] + public string ScaleId { get; set; } + + /// + /// 秤名称 + /// + [SugarColumn(ColumnName = "ScaleName")] + public string ScaleName { get; set; } + + /// + /// 胶料类别 + /// + [SugarColumn(ColumnName = "MatRubType")] + public string MatRubType { get; set; } + + /// + /// 小料设备号 + /// + [SugarColumn(ColumnName = "CWSID")] + public string CWSID { get; set; } + + /// + /// 写入时间 + /// + [SugarColumn(ColumnName = "WriteTime")] + public DateTime WriteTime { get; set; } + } +} diff --git a/SlnMesnac.Model/dto/ApiResponse.cs b/SlnMesnac.Model/dto/ApiResponse.cs index b7e99ab..3fbb9a9 100644 --- a/SlnMesnac.Model/dto/ApiResponse.cs +++ b/SlnMesnac.Model/dto/ApiResponse.cs @@ -19,7 +19,7 @@ namespace SlnMesnac.Model.dto /// 是否成功 /// public bool IsSuccess { get; set; } - + /// /// 信息 /// diff --git a/SlnMesnac.Model/dto/IngredientInfoDto.cs b/SlnMesnac.Model/dto/IngredientInfoDto.cs index ec79861..b7b897b 100644 --- a/SlnMesnac.Model/dto/IngredientInfoDto.cs +++ b/SlnMesnac.Model/dto/IngredientInfoDto.cs @@ -17,7 +17,7 @@ namespace SlnMesnac.Model.dto /// /// 料罐编号 /// - public int CanNumber { get; set; } + public string CanNumber { get; set; } /// /// 物料条码 diff --git a/SlnMesnac.Repository/SqlsugarSetup.cs b/SlnMesnac.Repository/SqlsugarSetup.cs index 21b148e..05525dd 100644 --- a/SlnMesnac.Repository/SqlsugarSetup.cs +++ b/SlnMesnac.Repository/SqlsugarSetup.cs @@ -55,10 +55,9 @@ namespace SlnMesnac.Repository { //services.AddSingleton>(); services.AddSingleton(typeof(Repository<>)); - services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); } } } diff --git a/SlnMesnac.Repository/service/IBaseMaterialService.cs b/SlnMesnac.Repository/service/IBaseMaterialService.cs deleted file mode 100644 index 638d67e..0000000 --- a/SlnMesnac.Repository/service/IBaseMaterialService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using SlnMesnac.Model.domain; -using System; -using System.Collections.Generic; -using System.Text; - -namespace SlnMesnac.Repository.service -{ - public interface IBaseMaterialService - { - - /// - /// 获取所有的物料信息 - /// - /// - List GetMaterialInfos(); - - /// - /// 通过物料编码获取物料信息 - /// - /// - /// - BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode); - - /// - /// 通过SAP物料编码获取物料信息 - /// - /// - /// - BaseMaterialInfo GetMaterialInfoBySapMaterialCode(string sapMaterialCode); - - /// - /// 通过物料类别获取物料信息 - /// - /// 物料大类 - /// 物料细类 - /// - List GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId); - } -} diff --git a/SlnMesnac.Repository/service/IMcsBinToMaterService.cs b/SlnMesnac.Repository/service/IMcsBinToMaterService.cs index 76d391d..16d044e 100644 --- a/SlnMesnac.Repository/service/IMcsBinToMaterService.cs +++ b/SlnMesnac.Repository/service/IMcsBinToMaterService.cs @@ -20,6 +20,6 @@ namespace SlnMesnac.Repository.service /// /// /// - McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,int BinNo); + McsBinToMater GetMcsBinToMaterByBinNo(int EquipId,string BinNo); } } \ No newline at end of file diff --git a/SlnMesnac.Repository/service/IBaseUserService.cs b/SlnMesnac.Repository/service/IMcsMaterialInfoService.cs similarity index 51% rename from SlnMesnac.Repository/service/IBaseUserService.cs rename to SlnMesnac.Repository/service/IMcsMaterialInfoService.cs index 35bbea0..f96efa0 100644 --- a/SlnMesnac.Repository/service/IBaseUserService.cs +++ b/SlnMesnac.Repository/service/IMcsMaterialInfoService.cs @@ -5,19 +5,19 @@ using System.Text; namespace SlnMesnac.Repository.service { - public interface IBaseUserService + public interface IMcsMaterialInfoService { /// - /// 获取用户信息 + /// 获取MCS物料信息 /// /// - List GetUsers(); + List GetMcsMaterialInfoList(); /// - /// 验证添加用户信息,有一个错误时进行回滚 + /// 根据物料代码获取物料信息 /// - /// + /// /// - bool InsertUsers(List users); + McsMaterialInfo GetMcsMaterialInfoByMatCode(string MatCode); } } diff --git a/SlnMesnac.Repository/service/Impl/BaseMaterialServiceImpl.cs b/SlnMesnac.Repository/service/Impl/BaseMaterialServiceImpl.cs deleted file mode 100644 index 8985d53..0000000 --- a/SlnMesnac.Repository/service/Impl/BaseMaterialServiceImpl.cs +++ /dev/null @@ -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 _repository; - - private ILogger _logger; - - public BaseMaterialServiceImpl(Repository repository, ILogger logger) - { - _repository = repository; - _logger = logger; - } - - /// - /// 通过物料编码获取物料信息 - /// - /// - /// - 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; - } - - /// - /// 通过SAP物料编码获取物料信息 - /// - /// - /// - 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; - } - - /// - /// 获取所有的物料信息 - /// - /// - public List GetMaterialInfos() - { - List materialInfos = null; - try - { - materialInfos = _repository.GetList(); - } - catch (Exception ex) - { - _logger.LogError($"获取物料信息异常:{ex.Message}"); - } - return materialInfos; - } - - /// - /// 通过物料类别获取物料信息 - /// - /// 物料大类 - /// 物料细类 - /// - public List GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId) - { - List materialInfos = null; - try - { - Expression> 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; - } - } -} - diff --git a/SlnMesnac.Repository/service/Impl/BaseUserServiceImpl.cs b/SlnMesnac.Repository/service/Impl/BaseUserServiceImpl.cs deleted file mode 100644 index 942774b..0000000 --- a/SlnMesnac.Repository/service/Impl/BaseUserServiceImpl.cs +++ /dev/null @@ -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 _logger; - - private readonly Repository _rep; - - public BaseUserServiceImpl(ILogger logger, Repository rep) - { - _logger = logger; - _rep = rep; - } - - - public List GetUsers() - { - List users = null; - try - { - users = _rep.GetList(); - } - catch (Exception ex) - { - _logger.LogError($"获取用户信息异常{ex.Message}"); - } - return users; - } - - public bool InsertUsers(List 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; - } - } -} diff --git a/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs b/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs index d317818..f6e683e 100644 --- a/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/McsBinToMaterServiceImpl.cs @@ -39,11 +39,12 @@ namespace SlnMesnac.Repository.service.Impl /// /// /// - 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) { diff --git a/SlnMesnac.Repository/service/Impl/McsMaterialInfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/McsMaterialInfoServiceImpl.cs new file mode 100644 index 0000000..455e53a --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/McsMaterialInfoServiceImpl.cs @@ -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 _rep; + + public McsMaterialInfoServiceImpl(Repository rep) + { + _rep = rep; + } + + /// + /// 根据物料代码获取物料信息 + /// + /// + /// + /// + + 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}"); + } + } + + /// + /// 获取MCS物料信息 + /// + /// + /// + public List GetMcsMaterialInfoList() + { + try + { + return _rep.GetList(); + } + catch (Exception e) + { + throw new ArgumentException($"获取MCS物料信息异常:{e.Message}"); + } + } + } +} diff --git a/SlnMesnac/Controllers/BaseMaterialInfoController.cs b/SlnMesnac/Controllers/BaseMaterialInfoController.cs deleted file mode 100644 index 57d541b..0000000 --- a/SlnMesnac/Controllers/BaseMaterialInfoController.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using SlnMesnac.Model.domain; -using SlnMesnac.Repository.service; - -namespace SlnMesnac.Controllers -{ - /// - /// 物料信息 - /// - [Route("api/[controller]")] - [ApiController] - public class BaseMaterialInfoController - { - private ILogger _logger; - - private IBaseMaterialService _service; - - /// - /// - /// - /// - /// - public BaseMaterialInfoController(ILogger logger, IBaseMaterialService service) - { - _logger = logger; - _service = service; - } - - /// - /// 获取物料信息 - /// - /// - [HttpGet] - public IEnumerable Get() - { - IEnumerable materialInfos = null; - try - { - materialInfos = _service.GetMaterialInfos(); - } - catch (Exception ex) - { - _logger.LogError($"获取物料信息接口调用异常:{ex.Message}"); - } - return materialInfos; - } - - /// - /// 根据物料编号获取物料信息 - /// - /// 物料编号 - /// - [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; - } - - /// - /// 通过物料类别获取物料信息 - /// - /// 物料大类 - /// 物料细类 - /// - [HttpGet("Get/{majorTypeId}/{minorTypeId}")] - public IEnumerable GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId) - { - IEnumerable materialInfos = null; - try - { - materialInfos = _service.GetMaterialInfosByMaterialType(majorTypeId, minorTypeId); - } - catch (Exception ex) - { - _logger.LogError($"通过物料类别获取物料信息接口调用异常:{ex.Message}"); - } - return materialInfos; - } - } -} diff --git a/SlnMesnac/Controllers/BaseUserController.cs b/SlnMesnac/Controllers/BaseUserController.cs deleted file mode 100644 index 3cdd7e0..0000000 --- a/SlnMesnac/Controllers/BaseUserController.cs +++ /dev/null @@ -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 -{ - /// - /// 人员基础信息 - /// - [Route("api/[controller]")] - [ApiController] - public class BaseUserController : ControllerBase - { - private readonly ILogger _logger; - - private readonly IBaseUserService _service; - - /// - /// - /// - /// - /// - public BaseUserController(ILogger logger, IBaseUserService service) - { - _logger = logger; - _service = service; - } - - /// - /// 获取人员基础信息 - /// - /// - [HttpGet] - public IEnumerable Get() - { - IEnumerable users = null; - try - { - users = _service.GetUsers(); - } - catch (Exception ex) - { - _logger.LogError($"获取用户信息接口调用异常:{ex.Message}"); - } - return users; - } - - /// - /// 通过用户名称获取指定用户信息 - /// - /// 用户名称 - /// - [HttpGet("Gets/{userName}")] - public IEnumerable GetUserByUserName(string userName) - { - IEnumerable users = null; - try - { - users = _service.GetUsers(); - } - catch (Exception ex) - { - _logger.LogError($"获取用户信息接口调用异常:{ex.Message}"); - } - return users; - } - - /// - /// 添加用户信息 - /// - /// 用户列表 - /// - [HttpPut] - public bool InsertUserInfo(List users) - { - return _service.InsertUsers(users); - } - } -} diff --git a/SlnMesnac/Controllers/IngCheckController.cs b/SlnMesnac/Controllers/IngCheckController.cs index 4505914..a39b662 100644 --- a/SlnMesnac/Controllers/IngCheckController.cs +++ b/SlnMesnac/Controllers/IngCheckController.cs @@ -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 _logger; private AppConfig _appConfig; + private PlcPool _plcPool; private IMcsBinToMaterService _mcsBinToMaterService; private IWmsTaskOutService _wmsTaskOutService; - - private PlcPool _plcPool; + private IMcsMaterialInfoService _mcsMaterialInfoService; /// /// /// /// + /// + /// + /// + /// + /// public IngCheckController(ILogger 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; + } + + + /// + /// 根据物料条码获取MCS物料信息 + /// + /// + /// + [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; } /// @@ -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 } /// - /// 下发开仓指令 + /// 根据物料条码获取WMS出库记录反馈信息 /// - /// - /// + /// /// - 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; } } \ No newline at end of file diff --git a/SlnMesnac/appsettings.json b/SlnMesnac/appsettings.json index 599b0e8..9dce048 100644 --- a/SlnMesnac/appsettings.json +++ b/SlnMesnac/appsettings.json @@ -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" } ]