Init - 初始化仓库

master
wenjy 8 months ago
parent fe2b7bc742
commit 34c7b76aaf

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/.idea.SlnMesnac.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business.business;
using SlnMesnac.Config;
using SlnMesnac.TouchSocket;
namespace SlnMesnac.Business
{
public static class BusinessSetup
{
public static void AddBusinessSetup(this IServiceCollection services)
{
services.AddSingleton<InStoreBusiness>();
}
public static IApplicationBuilder UseBusinessExtensions(this IApplicationBuilder app)
{
var _inStore = app.ApplicationServices.GetService<InStoreBusiness>();
_inStore.Init();
return app;
}
}
}

@ -1,9 +0,0 @@
using System;
namespace SlnMesnac.Business
{
public class Class1
{
//业务逻辑类
}
}

@ -5,4 +5,22 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="MvCodeReaderSDK.Net">
<HintPath>..\..\..\Aucma.Scada\HighWayIot.Library\MvCodeReaderSDK.Net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" />
<ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" />
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.TouchSocket\SlnMesnac.TouchSocket.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,332 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Config;
using SlnMesnac.Model.domain;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using SlnMesnac.TouchSocket;
using TouchSocket.Sockets;
namespace SlnMesnac.Business.business
{
/// <summary>
/// 分垛库入库逻辑
/// </summary>
public class InStoreBusiness
{
private readonly ILogger<InStoreBusiness> _logger;
private readonly TcpServer _tcpServer;
private readonly AppConfig _appConfig;
private readonly StringChange _stringChange;
private readonly IProductOfflineService _offlineService;
private readonly IBaseSpaceinfoService _spaceinfoService;
private readonly PlcPool _plcPool;
private const string BarcodeRef = "6933973114570;1621240AP0098E3D3497";
public InStoreBusiness(TcpServer tcpServer, ILogger<InStoreBusiness> logger, IProductOfflineService offlineService, IBaseSpaceinfoService spaceinfoService, AppConfig appConfig, PlcPool plcPool, StringChange stringChange)
{
_tcpServer = tcpServer;
_logger = logger;
_offlineService = offlineService;
_spaceinfoService = spaceinfoService;
_appConfig = appConfig;
_plcPool = plcPool;
_stringChange = stringChange;
}
public void Init()
{
_tcpServer.ReceivedClientBufferEvent += ReceivedBuffer;
}
/// <summary>
/// Buffer缓冲
/// </summary>
/// <param name="buffer"></param>
private void ReceivedBuffer(SocketClient client,byte[] buffer)
{
try
{
//_logger.LogInformation($"接收客户端:{client.Id};原始报文:{_stringChange.bytesToHexStr(buffer, buffer.Length)}");
do
{
string asciiStr = Encoding.ASCII.GetString(buffer);
if (asciiStr.Contains("heartbeat"))
{
_logger.LogInformation($"收到客户端:{client.Id};心跳指令:{asciiStr}");
continue;
}
if (asciiStr.Contains("NoRead"))
{
NoReadHandle(client.Id);
continue;
}
_logger.LogInformation($"收到客户端:{client.Id}条码信息:{asciiStr}");
InStore(client.Id, asciiStr);
} while (false);
}
catch (Exception e)
{
_logger.LogError($"Buffer缓冲异常:{e.Message}");
}
}
/// <summary>
/// 入库申请
/// </summary>
/// <param name="spaceArea">货道区域</param>
/// <param name="asciiStr"></param>
private void InStore(string spaceArea, string asciiStr)
{
try
{
if (string.IsNullOrEmpty(asciiStr))
{
throw new ArgumentException($"入库申请处理异常:条码信息为空");
}
if (string.IsNullOrEmpty(spaceArea))
{
throw new ArgumentException($"入库申请处理异常:货道区域为空");
}
if (asciiStr.Contains(";") && asciiStr.Length == BarcodeRef.Length)
{
string[] splitStr = asciiStr.Split(";");
if (splitStr.Length > 1)
{
asciiStr = splitStr[1];
}
}
_offlineService.GetProductInfosBySnCode(asciiStr,out ProductOffline prodInfo);
if (prodInfo == null)
{
throw new ArgumentException($"入库申请处理异常:根据成品码获取成品信息为空");
}
GetSpaceInfoByMaterialType(spaceArea, prodInfo, out BaseSpaceinfo laseSpaceinfo,
out BaseSpaceinfo spaceinfo);
bool result = false;
SendInStoreTask(spaceinfo, ref result);
if (!result)
{
throw new ArgumentException($"入库申请处理异常:入库任务下发至PLC失败");
}
else
{
List<BaseSpaceinfo> spaceinfos = new List<BaseSpaceinfo>();
if (laseSpaceinfo != null)
{
laseSpaceinfo.InstoreFlag = 1;
spaceinfos.Add(laseSpaceinfo);
}
spaceinfo.InstoreFlag = 3;
spaceinfos.Add(spaceinfo);
_spaceinfoService.UpdateSpaceInfo(spaceinfos);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
//异常处理,手动入库
}
}
/// <summary>
/// 通过物料型号获取货道信息
/// </summary>
/// <param name="spaceArea"></param>
/// <param name="prodInfo"></param>
/// <param name="laseSpaceinfo"></param>
/// <param name="spaceinfo"></param>
/// <param name="isBig"></param>
/// <exception cref="ArgumentException"></exception>
private void GetSpaceInfoByMaterialType(string spaceArea,ProductOffline prodInfo,out BaseSpaceinfo laseSpaceinfo,out BaseSpaceinfo spaceinfo,bool isBig = false)
{
List<BaseSpaceinfo> spaceinfos = null;
if (isBig)
{
_spaceinfoService.GetSpaceInfosByExpression(out spaceinfos,x=>x.StoreCode == _appConfig.storeCode && x.SpaceArea == spaceArea && x.MaterialType == prodInfo.ProductCode && x.SpaceType == 1);
}
else
{
_spaceinfoService.GetSpaceInfosByExpression(out spaceinfos,x=>x.StoreCode == _appConfig.storeCode && x.SpaceArea == spaceArea && x.MaterialType == prodInfo.ProductCode);
}
if (spaceinfos == null)
{
throw new ArgumentException($"通过物料型号获取货道信息异常:根据成品信息获取货道信息为空");
}
spaceinfos = spaceinfos.OrderBy(x => x.ObjId).ToList();
MatchSpaceInfoByPlc(ref spaceinfos);
if (spaceinfos == null)
{
throw new ArgumentException($"通过物料型号获取货道信息异常:通过PLC匹配可用货道信息为空");
}
FiltrateSpaceInfo(spaceinfos, out laseSpaceinfo, out spaceinfo);
if (spaceinfo == null)
{
throw new ArgumentException($"通过物料型号获取货道信息异常:未获取到匹配的货道信息");
}
}
/// <summary>
/// 通过PLC匹配获取去除已满的货道
/// </summary>
/// <param name="spaceinfos"></param>
private void MatchSpaceInfoByPlc(ref List<BaseSpaceinfo> spaceinfos)
{
var _plc = _plcPool.GetPlcByKey("cpk");
foreach (var item in spaceinfos)
{
item.SpaceCode = ExtractNumber(item.SpaceName);
var plcAddress = _appConfig.plcConfig.First().plcAddr.Where(x => x.spaceCode.ToString() == item.SpaceCode && x.spaceArea == item.SpaceArea).First();
int isFlag = _plc.readInt16ByAddress(plcAddress.address);
if (isFlag == 1)
{
item.SpaceStatus = 3;
}
}
spaceinfos = spaceinfos.Where(x => x.SpaceStatus != 3).ToList();
}
/// <summary>
/// 筛选货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <param name="spaceinfo"></param>
/// <exception cref="ArgumentException"></exception>
private void FiltrateSpaceInfo(List<BaseSpaceinfo> spaceinfos, out BaseSpaceinfo laseSpaceinfo,out BaseSpaceinfo spaceinfo)
{
if (spaceinfos == null)
{
throw new ArgumentException($"筛选货道信息异常:传入货道信息参数为空");
}
int count = spaceinfos.Where(x => x.InstoreFlag == 3).ToList().Count;
if ( count > 0)
{
int index = spaceinfos.FindIndex(entity => entity.InstoreFlag == 3);
laseSpaceinfo = spaceinfos[index];
int nextIndex = (index + 1) % spaceinfos.Count;
spaceinfo = spaceinfos[nextIndex];
}
else
{
laseSpaceinfo = null;
spaceinfo = spaceinfos.First();
}
}
/// <summary>
/// 下发入库任务至PLC
/// </summary>
/// <param name="spaceinfo"></param>
/// <param name="result"></param>
/// <exception cref="ArgumentException"></exception>
private void SendInStoreTask(BaseSpaceinfo spaceinfo,ref bool result)
{
var _plc = _plcPool.GetPlcByKey("cpk");
bool isFlag = true;
while (isFlag)
{
bool answerFlag = _plc.readBoolByAddress("X1000");
if (answerFlag)
{
isFlag = false;
}
Task.Delay(1000*2).Wait();
}
int spaceCode = _stringChange.ParseToInt(spaceinfo.SpaceCode);
int spinFlag = 0;
if (spaceCode % 2 == 0) //偶数 转180°
{
spinFlag = 4;
}
if (spaceinfo.SpaceArea == "A")
{
if (!_plc.writeInt16ByAddress("D2", spinFlag))
{
throw new ArgumentException($"旋转角度下发至PLC失败");
}
if (!_plc.writeInt16ByAddress("D29", spaceCode))
{
throw new ArgumentException($"货道号下发至PLC失败");
}
result = true;
}else if (spaceinfo.SpaceArea == "B")
{
result = false;
}
}
/// <summary>
/// 提取货道号
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static string ExtractNumber(string input)
{
string pattern = @"\d+";
Match match = Regex.Match(input, pattern);
if (match.Success)
{
return match.Value.TrimStart('0');
}
else
{
return null; // 或者返回默认值,如"0"
}
}
/// <summary>
/// 读取失败处理
/// </summary>
/// <param name="client"></param>
private void NoReadHandle(string client)
{
_logger.LogError($"客户端:{client};读取失败!!!!!!");
}
}
}

@ -14,6 +14,16 @@ namespace SlnMesnac.Config
/// </summary>
public string logPath { get; set; }
/// <summary>
/// TcpServer监听端口
/// </summary>
public int listernPort { get; set; }
/// <summary>
/// 仓库编号
/// </summary>
public string storeCode { get; set; }
/// <summary>
/// Sql连接配置
/// </summary>

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace SlnMesnac.Config
{
/// <summary>
@ -9,30 +11,57 @@ namespace SlnMesnac.Config
/// 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; }
/// <summary>
/// 是否启用
/// </summary>
public bool isFlage { get; set; }
public List<PlcAddress> plcAddr = new List<PlcAddress>()
{
new PlcAddress(){spaceCode = 1,spaceArea = "A",address = "X10D3"},
new PlcAddress(){spaceCode = 2,spaceArea = "A",address = "X10D9"},
new PlcAddress(){spaceCode = 3,spaceArea = "A",address = "X10E3"},
new PlcAddress(){spaceCode = 4,spaceArea = "A",address = "X10E9"},
new PlcAddress(){spaceCode = 5,spaceArea = "A",address = "X10F3"},
new PlcAddress(){spaceCode = 6,spaceArea = "A",address = "X10F9"},
new PlcAddress(){spaceCode = 7,spaceArea = "A",address = "X1103"},
new PlcAddress(){spaceCode = 8,spaceArea = "A",address = "X1109"},
new PlcAddress(){spaceCode = 9,spaceArea = "A",address = "X1113"},
new PlcAddress(){spaceCode = 10,spaceArea = "A",address = "X1119"},
new PlcAddress(){spaceCode = 11,spaceArea = "A",address = "X1123"},
new PlcAddress(){spaceCode = 12,spaceArea = "A",address = "X1129"},
new PlcAddress(){spaceCode = 13,spaceArea = "A",address = "X1133"},
new PlcAddress(){spaceCode = 14,spaceArea = "A",address = "X1139"}
};
}
}
public class PlcAddress
{
public int spaceCode { get; set; }
public string spaceArea { get; set; }
public string address { get; set; }
}

@ -0,0 +1,7 @@
namespace SlnMesnac.HkRobot
{
public class RobotAbsractFactory
{
}
}

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -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; }
}
}

@ -0,0 +1,109 @@
using System;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// 货道信息
///</summary>
[SugarTable("BASE_SPACEINFO"), TenantAttribute("mes")]
public class BaseSpaceinfo
{
/// <summary>
/// 主键标识
///</summary>
[SugarColumn(ColumnName="OBJ_ID" ,IsPrimaryKey = true )]
public decimal ObjId { get; set; }
/// <summary>
/// 货道编号
///</summary>
[SugarColumn(ColumnName="SPACE_CODE" )]
public string SpaceCode { get; set; }
/// <summary>
/// 货道名称
///</summary>
[SugarColumn(ColumnName="SPACE_NAME" )]
public string SpaceName { get; set; }
/// <summary>
/// 货道容量
///</summary>
[SugarColumn(ColumnName="SPACE_CAPACITY" )]
public decimal? SpaceCapacity { get; set; }
/// <summary>
/// 货道库存
///</summary>
[SugarColumn(ColumnName="SPACE_STOCK" )]
public decimal? SpaceStock { get; set; }
/// <summary>
/// 货道状态1-允许入库2-允许出库3-禁用货道4-异常货道)
///</summary>
[SugarColumn(ColumnName="SPACE_STATUS" )]
public short? SpaceStatus { get; set; }
/// <summary>
/// 货道类型1-单货道2-双货道)
///</summary>
[SugarColumn(ColumnName="SPACE_TYPE" )]
public short? SpaceType { get; set; }
/// <summary>
/// 所属仓库
///</summary>
[SugarColumn(ColumnName="STORE_CODE" )]
public string StoreCode { get; set; }
/// <summary>
/// 是否标识
///</summary>
[SugarColumn(ColumnName="IS_FLAG" )]
public short? IsFlag { get; set; }
/// <summary>
/// 创建人
///</summary>
[SugarColumn(ColumnName="CREATED_BY" )]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName="CREATED_TIME" )]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 更新人
///</summary>
[SugarColumn(ColumnName="UPDATED_BY" )]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
///</summary>
[SugarColumn(ColumnName="UPDATED_TIME" )]
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// 物料类型
///</summary>
[SugarColumn(ColumnName="MATERIAL_TYPE" )]
public string MaterialType { get; set; }
/// <summary>
/// 在途数量
///</summary>
[SugarColumn(ColumnName="ONROUTE_AMOUNT" )]
public long? OnrouteAmount { get; set; }
/// <summary>
/// 入库标识1-允许入库2-禁止入库
///</summary>
[SugarColumn(ColumnName="INSTORE_FLAG" )]
public decimal? InstoreFlag { get; set; }
/// <summary>
/// 出库状态1-允许出库2-禁止出库
///</summary>
[SugarColumn(ColumnName="OUTSTORE_FLAG" )]
public decimal? OutstoreFlag { get; set; }
/// <summary>
/// 异常标识1-正常货道2-异常货道,未使用
///</summary>
[SugarColumn(ColumnName="UNUSUAL_FLAG" )]
public decimal? UnusualFlag { get; set; }
/// <summary>
/// 货道区域:A\B
/// </summary>
[SugarColumn(ColumnName = "SPACE_AREA")]
public string SpaceArea { get; set; }
}
}

@ -0,0 +1,135 @@
using System;
using System.Runtime.Serialization;
using SqlSugar;
namespace SlnMesnac.Model.domain
{
/// <summary>
/// 成品下线表
///</summary>
[SugarTable("PRODUCT_OFFLINE"), TenantAttribute("scada")]
[DataContract(Name = "ProductOffline 扫描下线成品信息")]
public class ProductOffline
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="OBJ_ID" ,IsPrimaryKey = true )]
public decimal ObjId { get; set; }
/// <summary>
/// 计划工厂
///</summary>
[SugarColumn(ColumnName="PRODUCT_FACTORY_CODE" )]
public string ProductFactoryCode { get; set; }
/// <summary>
/// 公司条码
///</summary>
[SugarColumn(ColumnName="PRODUCT_SNCODE" )]
public string ProductSncode { get; set; }
/// <summary>
/// 工单号
///</summary>
[SugarColumn(ColumnName="PRODUCT_ORDER_NO" )]
public string ProductOrderNo { get; set; }
/// <summary>
/// 销售订单号
///</summary>
[SugarColumn(ColumnName="PRODUCT_SALE_NO" )]
public string ProductSaleNo { get; set; }
/// <summary>
/// 销售行号
///</summary>
[SugarColumn(ColumnName="PRODUCT_SALE_LINE_NO" )]
public string ProductSaleLineNo { get; set; }
/// <summary>
/// 物料编码
///</summary>
[SugarColumn(ColumnName="PRODUCT_CODE" )]
public string ProductCode { get; set; }
/// <summary>
/// 产品型号
///</summary>
[SugarColumn(ColumnName="PRODUCT_MODEL" )]
public string ProductModel { get; set; }
/// <summary>
/// 物料描述
///</summary>
[SugarColumn(ColumnName="PRODUCT_NAME" )]
public string ProductName { get; set; }
/// <summary>
/// 产品类型
///</summary>
[SugarColumn(ColumnName="PRODUCT_TYPE" )]
public string ProductType { get; set; }
/// <summary>
/// 验证组合
///</summary>
[SugarColumn(ColumnName="PRODUCT_CHECK_INFO" )]
public string ProductCheckInfo { get; set; }
/// <summary>
/// 标签特征
///</summary>
[SugarColumn(ColumnName="PRODUCT_REMARK" )]
public string ProductRemark { get; set; }
/// <summary>
/// 产品条码编码
///</summary>
[SugarColumn(ColumnName="PRODUCT_BAR_NO" )]
public string ProductBarNo { get; set; }
/// <summary>
/// 主型号
///</summary>
[SugarColumn(ColumnName="PRODUCT_MASTER_MODEL" )]
public string ProductMasterModel { get; set; }
/// <summary>
/// 版本号
///</summary>
[SugarColumn(ColumnName="PRODUCT_VERSION" )]
public string ProductVersion { get; set; }
/// <summary>
/// 用途位
///</summary>
[SugarColumn(ColumnName="PRODUCT_USERINFO" )]
public string ProductUserinfo { get; set; }
/// <summary>
/// 流通特性
///</summary>
[SugarColumn(ColumnName="PRODUCT_CIRCULATE" )]
public string ProductCirculate { get; set; }
/// <summary>
/// 生成日期
///</summary>
[SugarColumn(ColumnName="PRODUCT_CREATEDATE" )]
public string ProductCreatedate { get; set; }
/// <summary>
/// 扫描时间
///</summary>
[SugarColumn(ColumnName="PRODUCT_SCANTIME" )]
public DateTime? ProductScantime { get; set; }
/// <summary>
/// 箱体码
///</summary>
[SugarColumn(ColumnName="BOX_CODE" )]
public string BoxCode { get; set; }
/// <summary>
/// 产线编号
///</summary>
[SugarColumn(ColumnName="PRODUCT_LINE_CODE" )]
public string ProductLineCode { get; set; }
/// <summary>
/// 上传条码系统保存接口返回信息
///</summary>
[SugarColumn(ColumnName="SAVE_RETURN_INFO" )]
public string SaveReturnInfo { get; set; }
/// <summary>
/// 当前登录班组(一线白班,一线夜班,二线白班,二线夜班)
///</summary>
[SugarColumn(ColumnName="LOGIN_TEAM" )]
public string LoginTeam { get; set; }
/// <summary>
/// 下传plc放行结果下传为1plc应答为2
///</summary>
[SugarColumn(ColumnName="PLC_RESULT" )]
public string PlcResult { get; set; }
}
}

@ -55,7 +55,8 @@ namespace SlnMesnac.Repository
//services.AddSingleton<Repository<BaseUser>>();
services.AddSingleton(typeof(Repository<>));
services.AddSingleton<IBaseUserService, BaseUserServiceImpl>();
services.AddSingleton<IBaseMaterialService, BaseMaterialServiceImpl>();
services.AddSingleton<IProductOfflineService, ProductOfflineServiceImpl>();
services.AddSingleton<IBaseSpaceinfoService, BaseSpaceinfoServiceImpl>();
}
}
}

@ -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);
}
}

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service
{
public interface IBaseSpaceinfoService
{
/// <summary>
/// 获取指定的货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <param name="whereExpressio"></param>
void GetSpaceInfosByExpression(out List<BaseSpaceinfo> spaceinfos,Expression<Func<BaseSpaceinfo, bool>> whereExpression = null);
/// <summary>
/// 根据物料类型获取指定仓库的货道信息
/// </summary>
/// <param name="spaceinfo"></param>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
void GetSpaceInfoByMaterialType(out List<BaseSpaceinfo> spaceinfos, string storeCode, string materialType);
/// <summary>
/// 更新货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <returns></returns>
bool UpdateSpaceInfo(List<BaseSpaceinfo> spaceinfos);
}
}

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service
{
/// <summary>
/// 成品下线接口
/// </summary>
public interface IProductOfflineService
{
/// <summary>
/// 获取所有已下线成品信息
/// </summary>
/// <param name="productOfflines"></param>
/// <param name="whereExpressio"></param>
void GetProductInfos(out List<ProductOffline> productOfflines,Expression<Func<ProductOffline, bool>> whereExpressio = null);
/// <summary>
/// 根据SN条码获取已下线成品信息
/// </summary>
/// <param name="snCode"></param>
/// <returns></returns>
void GetProductInfosBySnCode(string snCode,out ProductOffline productOffline);
/// <summary>
/// 修改下线记录
/// </summary>
/// <param name="productOffline"></param>
/// <returns></returns>
bool UpdateProductInfo(ProductOffline productOffline);
}
}

@ -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;
}
}
}

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service.Impl
{
public class BaseSpaceinfoServiceImpl:IBaseSpaceinfoService
{
private readonly ILogger<BaseSpaceinfo> _logger;
private readonly Repository<BaseSpaceinfo> _rep;
public BaseSpaceinfoServiceImpl(ILogger<BaseSpaceinfo> logger, Repository<BaseSpaceinfo> rep)
{
_logger = logger;
_rep = rep;
}
/// <summary>
/// 获取指定的货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <param name="whereExpression"></param>
/// <exception cref="InvalidOperationException"></exception>
public void GetSpaceInfosByExpression(out List<BaseSpaceinfo> spaceinfos, Expression<Func<BaseSpaceinfo, bool>> whereExpression = null)
{
try
{
var exp = whereExpression != null ? whereExpression : x=>1==1;
spaceinfos = _rep.GetList(exp);
}
catch (Exception e)
{
throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}");
}
}
/// <summary>
/// 根据物料类型获取指定仓库的货道信息
/// </summary>
/// <param name="spaceinfo"></param>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <exception cref="ArgumentException"></exception>
public void GetSpaceInfoByMaterialType(out List<BaseSpaceinfo> spaceinfos, string storeCode, string materialType)
{
if (string.IsNullOrEmpty(storeCode))
{
throw new ArgumentException($"根据物料类型获取指定仓库的货道信息异常:仓库编号为空");
}
if (string.IsNullOrEmpty(materialType))
{
throw new ArgumentException($"根据物料类型获取指定仓库的货道信息异常:物料类型为空");
}
try
{
spaceinfos = _rep.GetList(x => x.StoreCode == storeCode && x.MaterialType == materialType);
}
catch (Exception e)
{
throw new InvalidOperationException($"根据物料类型获取指定仓库的货道信息异常:{e.Message}");
}
}
/// <summary>
/// 更新货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public bool UpdateSpaceInfo(List<BaseSpaceinfo> spaceinfos)
{
bool result = false;
try
{
result = _rep.UpdateRange(spaceinfos);
}
catch (Exception e)
{
throw new InvalidOperationException($"更新货道信息异常:{e.Message}");
}
return result;
}
}
}

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service.Impl
{
/// <summary>
/// 成品下线
/// </summary>
public class ProductOfflineServiceImpl:IProductOfflineService
{
private readonly ILogger<ProductOffline> _logger;
private readonly Repository<ProductOffline> _rep;
public ProductOfflineServiceImpl(ILogger<ProductOffline> logger, Repository<ProductOffline> rep)
{
_logger = logger;
_rep = rep;
}
/// <summary>
/// 获取所有已下线成品信息
/// </summary>
/// <param name="productOfflines"></param>
/// <param name="whereExpression"></param>
/// <exception cref="InvalidOperationException"></exception>
public void GetProductInfos(out List<ProductOffline> productOfflines,Expression<Func<ProductOffline, bool>> whereExpression = null)
{
try
{
var exp = whereExpression != null ? whereExpression : x=>1==1;
productOfflines = _rep.GetList(exp);
}
catch (Exception e)
{
throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}");
}
}
/// <summary>
/// 根据SN条码获取已下线成品信息
/// </summary>
/// <param name="snCode"></param>
/// <param name="productOffline"></param>
/// <exception cref="ArgumentException"></exception>
public void GetProductInfosBySnCode(string snCode,out ProductOffline productOffline)
{
if (string.IsNullOrEmpty(snCode))
{
throw new ArgumentException($"根据SN条码获取已下线成品信息异常:SN码为空");
}
try
{
productOffline = _rep.GetFirst(x => x.ProductSncode == snCode);
}
catch (Exception e)
{
throw new InvalidOperationException($"根据SN条码获取已下线成品信息异常:{e.Message}");
}
}
/// <summary>
/// 修改下线记录
/// </summary>
/// <param name="productOffline"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
public bool UpdateProductInfo(ProductOffline productOffline)
{
bool result = false;
if (productOffline == null)
{
throw new ArgumentException($"修改下线记录异常:成品信息参数为空");
}
try
{
result = _rep.Update(productOffline);
}
catch (Exception e)
{
throw new InvalidOperationException($"修改下线记录异常:{e.Message}");
}
return result;
}
}
}

@ -14,7 +14,7 @@ namespace SlnMesnac.TouchSocket
/// <summary>
/// 接收客户端指令委托
/// </summary>
public delegate void ReceivedClientBuffer(byte[] buffer);
public delegate void ReceivedClientBuffer(SocketClient client,byte[] buffer);
public event ReceivedClientBuffer? ReceivedClientBufferEvent;
public delegate void RefreshClientInfo(TcpService tcpService);
@ -36,12 +36,24 @@ namespace SlnMesnac.TouchSocket
};
_service.Connected = (client, e) => {
_logger.LogInformation($"客户端{client.IP}接入服务成功");
if (client.IP == "192.168.106.102")
{
client.ResetId("A");
}else if (client.IP == "10.10.92.137")
{
client.ResetId("B");
}
RefreshClientInfoEvent?.Invoke(_service);
return EasyTask.CompletedTask;
};
_service.Disconnecting= (client, e) => {
_logger.LogInformation($"客户端{client.Id}正在断开连接");
//RefreshClientInfoEvent?.Invoke(_service);
return EasyTask.CompletedTask;
};
_service.Disconnected = (client, e) => {
_logger.LogInformation($"客户端{client.IP}断开连接");
RefreshClientInfoEvent?.Invoke(_service);
_logger.LogInformation($"客户端{client.Id}断开连接");
//RefreshClientInfoEvent?.Invoke(_service);
return EasyTask.CompletedTask;
};
_service.Received = (client, e) =>
@ -51,7 +63,7 @@ namespace SlnMesnac.TouchSocket
byte[] receivedBuffer = new byte[e.ByteBlock.Len];
Array.Copy(e.ByteBlock.Buffer, 0, receivedBuffer, 0, e.ByteBlock.Len);
ReceivedClientBufferEvent?.Invoke(receivedBuffer);
ReceivedClientBufferEvent?.Invoke(client,receivedBuffer);
return EasyTask.CompletedTask;
};
@ -71,7 +83,6 @@ namespace SlnMesnac.TouchSocket
}
catch (Exception ex)
{
//throw new InvalidOperationException($"TcpServer启动异常{ex.Message}");
_logger.LogError($"TcpServer启动异常{ex.Message}");
}

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Builder;
using SlnMesnac.Config;
using TouchSocket.Sockets;
namespace SlnMesnac.TouchSocket
@ -20,8 +21,9 @@ namespace SlnMesnac.TouchSocket
public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app)
{
var appConfig = app.ApplicationServices.GetService<AppConfig>();
var _server = app.ApplicationServices.GetService<TcpServer>();
_server.Init(20108);
_server.Init(appConfig.listernPort);
return app;
}
}

@ -19,6 +19,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Business\SlnMesnac.Business.csproj" />
<ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" />
<ProjectReference Include="..\SlnMesnac.Config\SlnMesnac.Config.csproj" />
<ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" />

@ -4,16 +4,12 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Common;
using SlnMesnac.Quartz;
using SlnMesnac.Repository;
using SlnMesnac.Plc;
using SlnMesnac.Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using SlnMesnac.Business;
using SlnMesnac.Mqtt;
using SlnMesnac.Rfid;
using SlnMesnac.TouchSocket;
@ -58,13 +54,15 @@ namespace SlnMesnac.WPF
services.AddPlcSetup();
//注册MQTT
services.AddMqttSetup();
//services.AddMqttSetup();
//注册TouchSocket
services.AddTouchSocketSetup();
//注册RFID
services.AddRfidSetup();
//services.AddRfidSetup();
services.AddBusinessSetup();
}
/// <summary>
@ -84,9 +82,13 @@ namespace SlnMesnac.WPF
//初始化PLC中间件
app.UsePlcExtensions();
app.UseTouchSocketExtensions();
app.UseBusinessExtensions();
//初始化RFID中间件
app.UseRfidExtensions();
//app.UseRfidExtensions();
app.UseRouting();

@ -2,33 +2,34 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "E:\\桌面\\SlnMesnac\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows",
"listernPort":5000,
"storeCode":"FDK-001",
"SqlConfig": [
{
"configId": "mes",
"dbType": 1,
"connStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS"
"dbType": 3,
"connStr": "Data Source=10.100.72.20/ORCLCDB;User ID=c##aucma_mes;Password=aucma"
},
{
"configId": "mcs",
"configId": "scada",
"dbType": 3,
"connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
"connStr": "Data Source=10.100.72.20/ORCLCDB;User ID=c##aucma_scada;Password=aucma"
}
],
"PlcConfig": [
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "mcs",
"isFlage": false
"plcKey": "cpk",
"isFlage": true
},
{
"configId": 2,
@ -52,7 +53,7 @@
"equipIp": "127.0.0.1",
"equipPort": 6009,
"equipKey": "test2",
"isFlage": true
"isFlage": false
}
]
}

@ -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;
}
}
}

@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
namespace SlnMesnac.Controllers;
/// <summary>
/// 扫描下线成品记录
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class ProductOfflineController:ControllerBase
{
private readonly IProductOfflineService _service;
/// <summary>
///
/// </summary>
/// <param name="service"></param>
public ProductOfflineController(IProductOfflineService service)
{
_service = service;
}
/// <summary>
/// 获取成品下线扫描记录
/// </summary>
/// <returns></returns>
[HttpGet]
public IEnumerable<ProductOffline> Get()
{
_service.GetProductInfos(out var info);
return info;
}
/// <summary>
/// 根据SN条码获取已下线成品信息
/// </summary>
/// <param name="snCode"></param>
/// <returns></returns>
[HttpGet("Gets/{snCode}")]
public IEnumerable<ProductOffline> GetProdInfoBySnCode(string snCode)
{
_service.GetProductInfosBySnCode(snCode,out var info);
return new ProductOffline[] { info };
}
}

@ -82,7 +82,7 @@ namespace SlnMesnac
services.AddServices();
//注册任务调度
services.AddQuartzSetUp();
//services.AddQuartzSetUp();
//注册PLC
services.AddPlcSetup();

@ -4,5 +4,55 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "E:\\桌面\\SlnMesnac\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows",
"SqlConfig": [
{
"configId": "mes",
"dbType": 3,
"connStr": "Data Source=10.100.72.20/ORCLCDB;User ID=c##aucma_mes;Password=aucma"
},
{
"configId": "scada",
"dbType": 3,
"connStr": "Data Source=10.100.72.20/ORCLCDB;User ID=c##aucma_scada;Password=aucma"
}
],
"PlcConfig": [
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "mcs",
"isFlage": false
},
{
"configId": 2,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "cwss",
"isFlage": false
}
],
"RfidConfig": [
{
"configId": 1,
"equipIp": "127.0.0.1",
"equipPort": 6000,
"equipKey": "test1",
"isFlage": false
},
{
"configId": 2,
"equipIp": "127.0.0.1",
"equipPort": 6009,
"equipKey": "test2",
"isFlage": false
}
]
}
}

Loading…
Cancel
Save