diff --git a/.idea/.idea.SlnMesnac/.idea/.gitignore b/.idea/.idea.SlnMesnac/.idea/.gitignore
new file mode 100644
index 0000000..3016951
--- /dev/null
+++ b/.idea/.idea.SlnMesnac/.idea/.gitignore
@@ -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
diff --git a/.idea/.idea.SlnMesnac/.idea/encodings.xml b/.idea/.idea.SlnMesnac/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.SlnMesnac/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.SlnMesnac/.idea/indexLayout.xml b/.idea/.idea.SlnMesnac/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.SlnMesnac/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.SlnMesnac/.idea/vcs.xml b/.idea/.idea.SlnMesnac/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/.idea.SlnMesnac/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SlnMesnac.Business/BusinessSetup.cs b/SlnMesnac.Business/BusinessSetup.cs
new file mode 100644
index 0000000..a4bcc7b
--- /dev/null
+++ b/SlnMesnac.Business/BusinessSetup.cs
@@ -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();
+ }
+
+ public static IApplicationBuilder UseBusinessExtensions(this IApplicationBuilder app)
+ {
+ var _inStore = app.ApplicationServices.GetService();
+ _inStore.Init();
+ return app;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Business/Class1.cs b/SlnMesnac.Business/Class1.cs
deleted file mode 100644
index 8124245..0000000
--- a/SlnMesnac.Business/Class1.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace SlnMesnac.Business
-{
- public class Class1
- {
- //业务逻辑类
- }
-}
diff --git a/SlnMesnac.Business/SlnMesnac.Business.csproj b/SlnMesnac.Business/SlnMesnac.Business.csproj
index 8ef8970..4073d96 100644
--- a/SlnMesnac.Business/SlnMesnac.Business.csproj
+++ b/SlnMesnac.Business/SlnMesnac.Business.csproj
@@ -5,4 +5,22 @@
enable
+
+
+ ..\..\..\Aucma.Scada\HighWayIot.Library\MvCodeReaderSDK.Net.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.Business/business/InStoreBusiness.cs b/SlnMesnac.Business/business/InStoreBusiness.cs
new file mode 100644
index 0000000..fd3e643
--- /dev/null
+++ b/SlnMesnac.Business/business/InStoreBusiness.cs
@@ -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
+{
+ ///
+ /// 分垛库入库逻辑
+ ///
+ public class InStoreBusiness
+ {
+ private readonly ILogger _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 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;
+ }
+
+ ///
+ /// Buffer缓冲
+ ///
+ ///
+ 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}");
+ }
+ }
+
+ ///
+ /// 入库申请
+ ///
+ /// 货道区域
+ ///
+ 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 spaceinfos = new List();
+ 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);
+ //异常处理,手动入库
+ }
+ }
+
+ ///
+ /// 通过物料型号获取货道信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void GetSpaceInfoByMaterialType(string spaceArea,ProductOffline prodInfo,out BaseSpaceinfo laseSpaceinfo,out BaseSpaceinfo spaceinfo,bool isBig = false)
+ {
+ List 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($"通过物料型号获取货道信息异常:未获取到匹配的货道信息");
+ }
+
+ }
+
+ ///
+ /// 通过PLC匹配获取,去除已满的货道
+ ///
+ ///
+ private void MatchSpaceInfoByPlc(ref List 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();
+ }
+
+ ///
+ /// 筛选货道信息
+ ///
+ ///
+ ///
+ ///
+ private void FiltrateSpaceInfo(List 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();
+ }
+ }
+
+ ///
+ /// 下发入库任务至PLC
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ }
+
+ ///
+ /// 提取货道号
+ ///
+ ///
+ ///
+ 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"
+ }
+ }
+
+
+ ///
+ /// 读取失败处理
+ ///
+ ///
+ private void NoReadHandle(string client)
+ {
+ _logger.LogError($"客户端:{client};读取失败!!!!!!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs
index fac4e8b..a80a16d 100644
--- a/SlnMesnac.Config/AppConfig.cs
+++ b/SlnMesnac.Config/AppConfig.cs
@@ -14,6 +14,16 @@ namespace SlnMesnac.Config
///
public string logPath { get; set; }
+ ///
+ /// TcpServer监听端口
+ ///
+ public int listernPort { get; set; }
+
+ ///
+ /// 仓库编号
+ ///
+ public string storeCode { get; set; }
+
///
/// Sql连接配置
///
diff --git a/SlnMesnac.Config/PlcConfig.cs b/SlnMesnac.Config/PlcConfig.cs
index c061dd4..d2c24ac 100644
--- a/SlnMesnac.Config/PlcConfig.cs
+++ b/SlnMesnac.Config/PlcConfig.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
namespace SlnMesnac.Config
{
///
@@ -9,30 +11,57 @@ namespace SlnMesnac.Config
/// PLC配置ID
///
public int configId { get; set; }
-
+
///
/// PIC类型
///
public string plcType { get; set; }
-
+
///
/// PLC IP
///
public string plcIp { get; set; }
-
+
///
/// PLC Port
///
public int plcPort { get; set; }
-
+
///
/// PLC Key
///
public string plcKey { get; set; }
-
+
///
/// 是否启用
///
public bool isFlage { get; set; }
+
+ public List plcAddr = new List()
+ {
+ 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; }
}
\ No newline at end of file
diff --git a/SlnMesnac.HkRobot/RobotAbsractFactory.cs b/SlnMesnac.HkRobot/RobotAbsractFactory.cs
new file mode 100644
index 0000000..4db0b13
--- /dev/null
+++ b/SlnMesnac.HkRobot/RobotAbsractFactory.cs
@@ -0,0 +1,7 @@
+namespace SlnMesnac.HkRobot
+{
+ public class RobotAbsractFactory
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.HkRobot/SlnMesnac.HkRobot.csproj b/SlnMesnac.HkRobot/SlnMesnac.HkRobot.csproj
new file mode 100644
index 0000000..8fb8d5e
--- /dev/null
+++ b/SlnMesnac.HkRobot/SlnMesnac.HkRobot.csproj
@@ -0,0 +1,8 @@
+
+
+
+ netstandard2.1
+ enable
+
+
+
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/BaseSpaceinfo.cs b/SlnMesnac.Model/domain/BaseSpaceinfo.cs
new file mode 100644
index 0000000..5631990
--- /dev/null
+++ b/SlnMesnac.Model/domain/BaseSpaceinfo.cs
@@ -0,0 +1,109 @@
+using System;
+using SqlSugar;
+
+namespace SlnMesnac.Model.domain
+{
+ ///
+ /// 货道信息
+ ///
+ [SugarTable("BASE_SPACEINFO"), TenantAttribute("mes")]
+ public class BaseSpaceinfo
+ {
+ ///
+ /// 主键标识
+ ///
+ [SugarColumn(ColumnName="OBJ_ID" ,IsPrimaryKey = true )]
+ public decimal ObjId { get; set; }
+ ///
+ /// 货道编号
+ ///
+ [SugarColumn(ColumnName="SPACE_CODE" )]
+ public string SpaceCode { get; set; }
+ ///
+ /// 货道名称
+ ///
+ [SugarColumn(ColumnName="SPACE_NAME" )]
+ public string SpaceName { get; set; }
+ ///
+ /// 货道容量
+ ///
+ [SugarColumn(ColumnName="SPACE_CAPACITY" )]
+ public decimal? SpaceCapacity { get; set; }
+ ///
+ /// 货道库存
+ ///
+ [SugarColumn(ColumnName="SPACE_STOCK" )]
+ public decimal? SpaceStock { get; set; }
+ ///
+ /// 货道状态(1-允许入库;2-允许出库;3-禁用货道;4-异常货道)
+ ///
+ [SugarColumn(ColumnName="SPACE_STATUS" )]
+ public short? SpaceStatus { get; set; }
+ ///
+ /// 货道类型(1-单货道,2-双货道)
+ ///
+ [SugarColumn(ColumnName="SPACE_TYPE" )]
+ public short? SpaceType { get; set; }
+ ///
+ /// 所属仓库
+ ///
+ [SugarColumn(ColumnName="STORE_CODE" )]
+ public string StoreCode { get; set; }
+ ///
+ /// 是否标识
+ ///
+ [SugarColumn(ColumnName="IS_FLAG" )]
+ public short? IsFlag { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(ColumnName="CREATED_BY" )]
+ public string CreatedBy { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(ColumnName="CREATED_TIME" )]
+ public DateTime? CreatedTime { get; set; }
+ ///
+ /// 更新人
+ ///
+ [SugarColumn(ColumnName="UPDATED_BY" )]
+ public string UpdatedBy { get; set; }
+ ///
+ /// 更新时间
+ ///
+ [SugarColumn(ColumnName="UPDATED_TIME" )]
+ public DateTime? UpdatedTime { get; set; }
+ ///
+ /// 物料类型
+ ///
+ [SugarColumn(ColumnName="MATERIAL_TYPE" )]
+ public string MaterialType { get; set; }
+ ///
+ /// 在途数量
+ ///
+ [SugarColumn(ColumnName="ONROUTE_AMOUNT" )]
+ public long? OnrouteAmount { get; set; }
+ ///
+ /// 入库标识;1-允许入库;2-禁止入库
+ ///
+ [SugarColumn(ColumnName="INSTORE_FLAG" )]
+ public decimal? InstoreFlag { get; set; }
+ ///
+ /// 出库状态:1-允许出库;2-禁止出库
+ ///
+ [SugarColumn(ColumnName="OUTSTORE_FLAG" )]
+ public decimal? OutstoreFlag { get; set; }
+ ///
+ /// 异常标识:1-正常货道;2-异常货道,未使用
+ ///
+ [SugarColumn(ColumnName="UNUSUAL_FLAG" )]
+ public decimal? UnusualFlag { get; set; }
+
+ ///
+ /// 货道区域:A\B
+ ///
+ [SugarColumn(ColumnName = "SPACE_AREA")]
+ public string SpaceArea { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Model/domain/ProductOffline.cs b/SlnMesnac.Model/domain/ProductOffline.cs
new file mode 100644
index 0000000..1ebf65f
--- /dev/null
+++ b/SlnMesnac.Model/domain/ProductOffline.cs
@@ -0,0 +1,135 @@
+using System;
+using System.Runtime.Serialization;
+using SqlSugar;
+
+namespace SlnMesnac.Model.domain
+{
+ ///
+ /// 成品下线表
+ ///
+ [SugarTable("PRODUCT_OFFLINE"), TenantAttribute("scada")]
+ [DataContract(Name = "ProductOffline 扫描下线成品信息")]
+ public class ProductOffline
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName="OBJ_ID" ,IsPrimaryKey = true )]
+ public decimal ObjId { get; set; }
+ ///
+ /// 计划工厂
+ ///
+ [SugarColumn(ColumnName="PRODUCT_FACTORY_CODE" )]
+ public string ProductFactoryCode { get; set; }
+ ///
+ /// 公司条码
+ ///
+ [SugarColumn(ColumnName="PRODUCT_SNCODE" )]
+ public string ProductSncode { get; set; }
+ ///
+ /// 工单号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_ORDER_NO" )]
+ public string ProductOrderNo { get; set; }
+ ///
+ /// 销售订单号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_SALE_NO" )]
+ public string ProductSaleNo { get; set; }
+ ///
+ /// 销售行号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_SALE_LINE_NO" )]
+ public string ProductSaleLineNo { get; set; }
+ ///
+ /// 物料编码
+ ///
+ [SugarColumn(ColumnName="PRODUCT_CODE" )]
+ public string ProductCode { get; set; }
+ ///
+ /// 产品型号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_MODEL" )]
+ public string ProductModel { get; set; }
+ ///
+ /// 物料描述
+ ///
+ [SugarColumn(ColumnName="PRODUCT_NAME" )]
+ public string ProductName { get; set; }
+ ///
+ /// 产品类型
+ ///
+ [SugarColumn(ColumnName="PRODUCT_TYPE" )]
+ public string ProductType { get; set; }
+ ///
+ /// 验证组合
+ ///
+ [SugarColumn(ColumnName="PRODUCT_CHECK_INFO" )]
+ public string ProductCheckInfo { get; set; }
+ ///
+ /// 标签特征
+ ///
+ [SugarColumn(ColumnName="PRODUCT_REMARK" )]
+ public string ProductRemark { get; set; }
+ ///
+ /// 产品条码编码
+ ///
+ [SugarColumn(ColumnName="PRODUCT_BAR_NO" )]
+ public string ProductBarNo { get; set; }
+ ///
+ /// 主型号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_MASTER_MODEL" )]
+ public string ProductMasterModel { get; set; }
+ ///
+ /// 版本号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_VERSION" )]
+ public string ProductVersion { get; set; }
+ ///
+ /// 用途位
+ ///
+ [SugarColumn(ColumnName="PRODUCT_USERINFO" )]
+ public string ProductUserinfo { get; set; }
+ ///
+ /// 流通特性
+ ///
+ [SugarColumn(ColumnName="PRODUCT_CIRCULATE" )]
+ public string ProductCirculate { get; set; }
+ ///
+ /// 生成日期
+ ///
+ [SugarColumn(ColumnName="PRODUCT_CREATEDATE" )]
+ public string ProductCreatedate { get; set; }
+ ///
+ /// 扫描时间
+ ///
+ [SugarColumn(ColumnName="PRODUCT_SCANTIME" )]
+ public DateTime? ProductScantime { get; set; }
+ ///
+ /// 箱体码
+ ///
+ [SugarColumn(ColumnName="BOX_CODE" )]
+ public string BoxCode { get; set; }
+ ///
+ /// 产线编号
+ ///
+ [SugarColumn(ColumnName="PRODUCT_LINE_CODE" )]
+ public string ProductLineCode { get; set; }
+ ///
+ /// 上传条码系统保存接口返回信息
+ ///
+ [SugarColumn(ColumnName="SAVE_RETURN_INFO" )]
+ public string SaveReturnInfo { get; set; }
+ ///
+ /// 当前登录班组(一线白班,一线夜班,二线白班,二线夜班)
+ ///
+ [SugarColumn(ColumnName="LOGIN_TEAM" )]
+ public string LoginTeam { get; set; }
+ ///
+ /// 下传plc放行结果,下传为1,plc应答为2
+ ///
+ [SugarColumn(ColumnName="PLC_RESULT" )]
+ public string PlcResult { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/SqlsugarSetup.cs b/SlnMesnac.Repository/SqlsugarSetup.cs
index 90a808e..cda0bbf 100644
--- a/SlnMesnac.Repository/SqlsugarSetup.cs
+++ b/SlnMesnac.Repository/SqlsugarSetup.cs
@@ -55,7 +55,8 @@ namespace SlnMesnac.Repository
//services.AddSingleton>();
services.AddSingleton(typeof(Repository<>));
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/IBaseSpaceinfoService.cs b/SlnMesnac.Repository/service/IBaseSpaceinfoService.cs
new file mode 100644
index 0000000..61de6cb
--- /dev/null
+++ b/SlnMesnac.Repository/service/IBaseSpaceinfoService.cs
@@ -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
+ {
+ ///
+ /// 获取指定的货道信息
+ ///
+ ///
+ ///
+ void GetSpaceInfosByExpression(out List spaceinfos,Expression> whereExpression = null);
+
+ ///
+ /// 根据物料类型获取指定仓库的货道信息
+ ///
+ ///
+ ///
+ ///
+ void GetSpaceInfoByMaterialType(out List spaceinfos, string storeCode, string materialType);
+
+ ///
+ /// 更新货道信息
+ ///
+ ///
+ ///
+ bool UpdateSpaceInfo(List spaceinfos);
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/IProductOfflineService.cs b/SlnMesnac.Repository/service/IProductOfflineService.cs
new file mode 100644
index 0000000..b245d7c
--- /dev/null
+++ b/SlnMesnac.Repository/service/IProductOfflineService.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using SlnMesnac.Model.domain;
+
+namespace SlnMesnac.Repository.service
+{
+ ///
+ /// 成品下线接口
+ ///
+ public interface IProductOfflineService
+ {
+ ///
+ /// 获取所有已下线成品信息
+ ///
+ ///
+ ///
+ void GetProductInfos(out List productOfflines,Expression> whereExpressio = null);
+
+ ///
+ /// 根据SN条码获取已下线成品信息
+ ///
+ ///
+ ///
+ void GetProductInfosBySnCode(string snCode,out ProductOffline productOffline);
+
+ ///
+ /// 修改下线记录
+ ///
+ ///
+ ///
+ bool UpdateProductInfo(ProductOffline productOffline);
+ }
+}
\ No newline at end of file
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/BaseSpaceinfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/BaseSpaceinfoServiceImpl.cs
new file mode 100644
index 0000000..817fb5b
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/BaseSpaceinfoServiceImpl.cs
@@ -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 _logger;
+
+ private readonly Repository _rep;
+
+ public BaseSpaceinfoServiceImpl(ILogger logger, Repository rep)
+ {
+ _logger = logger;
+ _rep = rep;
+ }
+
+ ///
+ /// 获取指定的货道信息
+ ///
+ ///
+ ///
+ ///
+ public void GetSpaceInfosByExpression(out List spaceinfos, Expression> whereExpression = null)
+ {
+ try
+ {
+ var exp = whereExpression != null ? whereExpression : x=>1==1;
+ spaceinfos = _rep.GetList(exp);
+ }
+ catch (Exception e)
+ {
+ throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}");
+ }
+ }
+
+ ///
+ /// 根据物料类型获取指定仓库的货道信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void GetSpaceInfoByMaterialType(out List 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}");
+ }
+ }
+
+ ///
+ /// 更新货道信息
+ ///
+ ///
+ ///
+ ///
+ public bool UpdateSpaceInfo(List spaceinfos)
+ {
+ bool result = false;
+ try
+ {
+ result = _rep.UpdateRange(spaceinfos);
+ }
+ catch (Exception e)
+ {
+ throw new InvalidOperationException($"更新货道信息异常:{e.Message}");
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/Impl/ProductOfflineServiceImpl.cs b/SlnMesnac.Repository/service/Impl/ProductOfflineServiceImpl.cs
new file mode 100644
index 0000000..ea635cd
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/ProductOfflineServiceImpl.cs
@@ -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
+{
+ ///
+ /// 成品下线
+ ///
+ public class ProductOfflineServiceImpl:IProductOfflineService
+ {
+
+ private readonly ILogger _logger;
+
+ private readonly Repository _rep;
+
+ public ProductOfflineServiceImpl(ILogger logger, Repository rep)
+ {
+ _logger = logger;
+ _rep = rep;
+ }
+
+ ///
+ /// 获取所有已下线成品信息
+ ///
+ ///
+ ///
+ ///
+ public void GetProductInfos(out List productOfflines,Expression> whereExpression = null)
+ {
+ try
+ {
+ var exp = whereExpression != null ? whereExpression : x=>1==1;
+ productOfflines = _rep.GetList(exp);
+ }
+ catch (Exception e)
+ {
+ throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}");
+ }
+
+ }
+
+ ///
+ /// 根据SN条码获取已下线成品信息
+ ///
+ ///
+ ///
+ ///
+ 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}");
+ }
+ }
+
+ ///
+ /// 修改下线记录
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.TouchSocket/TcpServer.cs b/SlnMesnac.TouchSocket/TcpServer.cs
index fc3ecb7..b734ced 100644
--- a/SlnMesnac.TouchSocket/TcpServer.cs
+++ b/SlnMesnac.TouchSocket/TcpServer.cs
@@ -14,7 +14,7 @@ namespace SlnMesnac.TouchSocket
///
/// 接收客户端指令委托
///
- 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}");
}
diff --git a/SlnMesnac.TouchSocket/TouchSocketSetup.cs b/SlnMesnac.TouchSocket/TouchSocketSetup.cs
index b300018..9291294 100644
--- a/SlnMesnac.TouchSocket/TouchSocketSetup.cs
+++ b/SlnMesnac.TouchSocket/TouchSocketSetup.cs
@@ -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();
var _server = app.ApplicationServices.GetService();
- _server.Init(20108);
+ _server.Init(appConfig.listernPort);
return app;
}
}
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index 38a951d..c9a9913 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -19,6 +19,7 @@
+
diff --git a/SlnMesnac.WPF/Startup.cs b/SlnMesnac.WPF/Startup.cs
index 29c207e..d60b895 100644
--- a/SlnMesnac.WPF/Startup.cs
+++ b/SlnMesnac.WPF/Startup.cs
@@ -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();
}
///
@@ -84,9 +82,13 @@ namespace SlnMesnac.WPF
//初始化PLC中间件
app.UsePlcExtensions();
+
+ app.UseTouchSocketExtensions();
+
+ app.UseBusinessExtensions();
//初始化RFID中间件
- app.UseRfidExtensions();
+ //app.UseRfidExtensions();
app.UseRouting();
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index a1f2ad9..ebd8ff9 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -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
}
]
}
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/ProductOfflineController.cs b/SlnMesnac/Controllers/ProductOfflineController.cs
new file mode 100644
index 0000000..a313d98
--- /dev/null
+++ b/SlnMesnac/Controllers/ProductOfflineController.cs
@@ -0,0 +1,48 @@
+using Microsoft.AspNetCore.Mvc;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service;
+
+namespace SlnMesnac.Controllers;
+
+///
+/// 扫描下线成品记录
+///
+[Route("api/[controller]")]
+[ApiController]
+public class ProductOfflineController:ControllerBase
+{
+ private readonly IProductOfflineService _service;
+
+ ///
+ ///
+ ///
+ ///
+ public ProductOfflineController(IProductOfflineService service)
+ {
+ _service = service;
+ }
+
+ ///
+ /// 获取成品下线扫描记录
+ ///
+ ///
+ [HttpGet]
+ public IEnumerable Get()
+ {
+ _service.GetProductInfos(out var info);
+
+ return info;
+ }
+
+ ///
+ /// 根据SN条码获取已下线成品信息
+ ///
+ ///
+ ///
+ [HttpGet("Gets/{snCode}")]
+ public IEnumerable GetProdInfoBySnCode(string snCode)
+ {
+ _service.GetProductInfosBySnCode(snCode,out var info);
+ return new ProductOffline[] { info };
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac/Startup.cs b/SlnMesnac/Startup.cs
index 7dccfe0..7ff3ac5 100644
--- a/SlnMesnac/Startup.cs
+++ b/SlnMesnac/Startup.cs
@@ -82,7 +82,7 @@ namespace SlnMesnac
services.AddServices();
//注册任务调度
- services.AddQuartzSetUp();
+ //services.AddQuartzSetUp();
//注册PLC
services.AddPlcSetup();
diff --git a/SlnMesnac/appsettings.Development.json b/SlnMesnac/appsettings.Development.json
index 0c208ae..40e1dcb 100644
--- a/SlnMesnac/appsettings.Development.json
+++ b/SlnMesnac/appsettings.Development.json
@@ -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
+ }
+ ]
}
}