change - 通过PLC获取货道信息

foamRearStore
wenjy 1 year ago
parent f77625e643
commit 6d798da20e

Binary file not shown.

@ -121,7 +121,10 @@ namespace Aucma.Scada.Business
{ {
PrintLogInfoMessage($"扫码成功,物料码:{materialCode}"); PrintLogInfoMessage($"扫码成功,物料码:{materialCode}");
string materialType = SubStringMaterialCode(materialCode); string materialType = SubStringMaterialCode(materialCode);
var spaceInfo = _spaceInfoService.InStoreGetSpaceInfoByMaterialType(appConfig.foamStoreCode, materialType); #region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量改为通过PLC获取货道信息
//var spaceInfo = _spaceInfoService.InStoreGetSpaceInfoByMaterialType(appConfig.foamStoreCode, materialType);
#endregion
var spaceInfo = GetSpaceInfoByMaterialType(appConfig.foamStoreCode, materialType);
if (spaceInfo != null) if (spaceInfo != null)
{ {
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
@ -129,7 +132,8 @@ namespace Aucma.Scada.Business
var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务 var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务
if (result) if (result)
{ {
spaceInfo.onRouteAmount += 1; //spaceInfo.onRouteAmount += 1; //通过PLC获取货道信息在库、在途数量时不需要修改在途数量
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
} }
} }
@ -308,11 +312,18 @@ namespace Aucma.Scada.Business
if (spaceInfo != null) if (spaceInfo != null)
{ {
//读取PLC获取货道信息存放数量、在途数量
//实际应用改为读取PLC库存信息
spaceInfo.materialType = taskInfo.materialType; spaceInfo.materialType = taskInfo.materialType;
spaceInfo.spaceStock = spaceInfo.spaceStock + 1; spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
spaceInfo.onRouteAmount -= 1; spaceInfo.onRouteAmount -= 1;
//读取PLC获取货道信息存放数量、在途数量,
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = taskHandle.ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.spaceStock = item.spaceStock;
spaceInfo.onRouteAmount = item.onRouteAmount;
spaceInfo.spaceStatus = item.spaceStatus;
#endregion
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
#region 添加货道明细 #region 添加货道明细
BaseSpaceDetail spaceDetail = new BaseSpaceDetail(); BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
@ -431,5 +442,43 @@ namespace Aucma.Scada.Business
return groups; return groups;
} }
/// 通过PLC读取货道信息在途数量、在库数量、货道状态)
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
{
BaseSpaceInfo result = null;
try
{
List<BaseSpaceInfo> info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType);
if (info != null)
{
if (info.Count > 0)
{
foreach (BaseSpaceInfo item in info)
{
var spaceInfo = taskHandle.ReadSpaceInfoByPlc(item);
item.spaceStock = spaceInfo.spaceStock;
item.onRouteAmount = spaceInfo.onRouteAmount;
item.spaceStatus = spaceInfo.spaceStatus;
}
result = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).OrderByDescending(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
}
}
}
catch (Exception ex)
{
PrintLogErrorMessage("货道信息读取异常", ex);
}
return result;
}
} }
} }

@ -33,6 +33,8 @@ namespace Aucma.Scada.Business
private PlcConfig plcConfig = PlcConfig.Instance; private PlcConfig plcConfig = PlcConfig.Instance;
private PlcPool _pool = PlcPool.Instance; private PlcPool _pool = PlcPool.Instance;
private PlcSpaceConfig spaceConfig = PlcSpaceConfig.Instance;
#endregion #endregion
#region 私有变量 #region 私有变量
@ -208,5 +210,28 @@ namespace Aucma.Scada.Business
} }
} }
#endregion #endregion
/// <summary>
/// 通过PLC获取货道信息
/// </summary>
/// <param name="spaceInfo"></param>
/// <returns></returns>
public BaseSpaceInfo ReadSpaceInfoByPlc(BaseSpaceInfo spaceInfo)
{
var spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.storeCode, spaceInfo.spaceCode);
IPlc _plc = _plcDictionary[spaceInfo.storeCode];
if (_plc != null)
{
if (_plc.IsConnected)
{
spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
}
}
return spaceInfo;
}
} }
} }

@ -151,7 +151,10 @@ namespace Aucma.Scada.Business
try try
{ {
PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.materialCode}"); PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.materialCode}");
BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode); #region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量改为通过PLC获取货道信息
//BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode);
#endregion
BaseSpaceInfo spaceInfo = GetSpaceInfoByMaterialType(storeCode, bomInfo.materialCode);
if (spaceInfo != null) if (spaceInfo != null)
{ {
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
@ -446,9 +449,16 @@ namespace Aucma.Scada.Business
if (spaceInfo != null) if (spaceInfo != null)
{ {
//读取PLC获取货道信息存放数量、在途数量 //读取PLC获取货道信息存放数量、在途数量
//spaceInfo.materialType = taskInfo.materialType;
spaceInfo.spaceStock -= 1; spaceInfo.spaceStock -= 1;
spaceInfo.outRouteAmount -= 1; spaceInfo.outRouteAmount -= 1;
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = taskHandleBusiness.ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.spaceStock = item.spaceStock;
spaceInfo.onRouteAmount = item.onRouteAmount;
spaceInfo.spaceStatus = item.spaceStatus;
#endregion
if (spaceInfo.spaceStock == 0) if (spaceInfo.spaceStock == 0)
{ {
spaceInfo.materialType = string.Empty; spaceInfo.materialType = string.Empty;
@ -663,5 +673,43 @@ namespace Aucma.Scada.Business
return materialName; return materialName;
} }
/// 通过PLC读取货道信息在库数量、货道状态)
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
{
BaseSpaceInfo result = null;
try
{
List<BaseSpaceInfo> info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType);
if (info != null)
{
if (info.Count > 0)
{
foreach (BaseSpaceInfo item in info)
{
var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item);
item.spaceStock = spaceInfo.spaceStock;
item.onRouteAmount = spaceInfo.onRouteAmount;
item.spaceStatus = spaceInfo.spaceStatus;
}
result = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).OrderBy(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
}
}
}
catch (Exception ex)
{
PrintLogErrorMessage("货道信息读取异常", ex);
}
return result;
}
} }
} }

@ -34,6 +34,8 @@ namespace Aucma.Scada.Business
private PlcConfig plcConfig = PlcConfig.Instance; private PlcConfig plcConfig = PlcConfig.Instance;
private PlcPool _pool = PlcPool.Instance; private PlcPool _pool = PlcPool.Instance;
private PlcSpaceConfig spaceConfig = PlcSpaceConfig.Instance;
#endregion #endregion
#region 私有变量 #region 私有变量
@ -227,5 +229,27 @@ namespace Aucma.Scada.Business
} }
#endregion #endregion
/// <summary>
/// 通过PLC获取货道信息
/// </summary>
/// <param name="spaceInfo"></param>
/// <returns></returns>
public BaseSpaceInfo ReadSpaceInfoByPlc(BaseSpaceInfo spaceInfo)
{
var spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.storeCode, spaceInfo.spaceCode);
IPlc _plc = _plcDictionary[spaceInfo.storeCode];
if (_plc != null)
{
if (_plc.IsConnected)
{
spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
}
}
return spaceInfo;
}
} }
} }

@ -0,0 +1,43 @@
#泡后库货道信息
[FPJCK-001_PH_001]
在库数量=D7201
在途数量=D7211
是否已满=D7221
货道状态=D7231
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240
[FPJCK-001_PH_002]
在库数量=D7202
在途数量=D7212
是否已满=D7222
货道状态=D7232
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240
[FPJCK-001_PH_003]
在库数量=D7203
在途数量=D7213
是否已满=D7223
货道状态=D7233
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240
[FPJCK-001_PH_004]
在库数量=D7204
在途数量=D7214
是否已满=D7224
货道状态=D7234
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240
[FPJCK-001_PH_005]
在库数量=D7205
在途数量=D7215
是否已满=D7225
货道状态=D7235
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240
[FPJCK-001_PH_006]
在库数量=D7206
在途数量=D7216
是否已满=D7226
货道状态=D7236
仓库状态=D7300 #设备状态字,0未启动状态,1已自动运行,2维修调试状态,禁止启动
出库完成=D7240

@ -1,4 +1,4 @@
 E:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\obj\Debug\GeneratedInternalTypeHelper.g.cs
FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\App.xaml;; FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\App.xaml;;
FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\Page\AssemblyPlan\AssemblyPlanControl.xaml;; FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\Page\AssemblyPlan\AssemblyPlanControl.xaml;;
FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\Page\AssemblyPlan\PlanInfoEditWindow.xaml;; FE:\桌面\澳柯玛MES项目\程序设计\Aucma.Scada\Aucma.Scada.UI\Page\AssemblyPlan\PlanInfoEditWindow.xaml;;

@ -1,62 +1,2 @@
//------------------------------------------------------------------------------ 
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace XamlGeneratedNamespace {
/// <summary>
/// GeneratedInternalTypeHelper
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper {
/// <summary>
/// CreateInstance
/// </summary>
protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) {
return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)
| (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture);
}
/// <summary>
/// GetPropertyValue
/// </summary>
protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) {
return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture);
}
/// <summary>
/// SetPropertyValue
/// </summary>
protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) {
propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture);
}
/// <summary>
/// CreateDelegate
/// </summary>
protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) {
return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod
| (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] {
delegateType,
handler}, null)));
}
/// <summary>
/// AddEventHandler
/// </summary>
protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) {
eventInfo.AddEventHandler(target, handler);
}
}
}

@ -43,6 +43,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="PlcConfig.cs" /> <Compile Include="PlcConfig.cs" />
<Compile Include="AppConfig.cs" /> <Compile Include="AppConfig.cs" />
<Compile Include="PlcSpaceConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,61 @@
using HighWayIot.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Config
{
public sealed class PlcSpaceConfig
{
private static IniHelper iniHelper = new IniHelper(System.Environment.CurrentDirectory + "/config/PlcSpace.Ini");
private static readonly Lazy<PlcSpaceConfig> lazy = new Lazy<PlcSpaceConfig>(() => new PlcSpaceConfig());
public static PlcSpaceConfig Instance
{
get
{
return lazy.Value;
}
}
private PlcSpaceConfig()
{
}
public SpaceAddress GetSpaceAddress(string storeCode,string spaceCode)
{
SpaceAddress spaceAddress = new SpaceAddress();
spaceAddress.onStore = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "在库数量");
spaceAddress.onRoute = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "在途数量");
spaceAddress.isFull = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "是否已满");
spaceAddress.spaceStatus = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "货道状态");
spaceAddress.storeStatus = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "仓库状态");
spaceAddress.alarmInfo = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "报警信息");
spaceAddress.outStoreFinish = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "出库完成");
return spaceAddress;
}
}
public class SpaceAddress
{
public string onStore { get; set; }
public string onRoute { get; set; }
public string isFull { get; set; }
public string spaceStatus { get; set; }
public string storeStatus { get; set; }
public string alarmInfo { get; set; }
public string outStoreFinish { get; set; }
}
}

@ -1 +1 @@
498314701cc69a2bb9a908cd676c2b8fb46f08d1 2e5578ef355ebd86a51e35872287d736e1b032e2

@ -39,6 +39,14 @@ namespace HighWayIot.Repository.service
/// <returns></returns> /// <returns></returns>
List<BaseSpaceInfo> GetSpaceInfosByStoreCode(string storeCode); List<BaseSpaceInfo> GetSpaceInfosByStoreCode(string storeCode);
/// <summary>
/// 通过物料类型获取货道信息,如果没有返回空白货道
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
List<BaseSpaceInfo> GetBaseSpaceInfosByMaterialType(string storeCode, string materialType);
/// <summary> /// <summary>
/// 更新货道信息 /// 更新货道信息
/// </summary> /// </summary>

@ -202,5 +202,28 @@ namespace HighWayIot.Repository.service.Impl
} }
return result; return result;
} }
public List<BaseSpaceInfo> GetBaseSpaceInfosByMaterialType(string storeCode, string materialType)
{
List<BaseSpaceInfo> spaceInfos = null;
try
{
Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.spaceStatus == 1); //相同型号、启用状态的货道信息
spaceInfos = _mesRepository.GetList(exp);
if (spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配
{
spaceInfos = GetEmptySpaceInfo(storeCode);
}
logHelper.Info($"根据仓库{storeCode};物料:{materialType};获取到的货道信息:{jsonChange.ModeToJson(spaceInfos)}");
}
catch (Exception ex)
{
logHelper.Error("获取货道信息异常", ex);
}
return spaceInfos;
}
} }
} }

@ -0,0 +1,31 @@
[plcSystem]
箱壳PLCIP=127.0.0.1
箱壳PLC端口=6000
内胆PLCIP=127.0.0.1
内胆PLC端口=6000
#箱壳入库地址
[shell_inStore_address]
入库货道号=D101
入库应答字=D103
入库任务号=D104
入库完成=D105
#内胆入库地址
[liner_inStore_address]
入库货道号=D201
入库应答字=D203
入库任务号=D204
入库完成=D205
#箱壳出库地址
[shell_outStore_address]
出库货道号=M101
出库数量=M102
出库应答字=M103
出库任务号=M104
出库完成=M105
#内胆出库地址
[liner_outStore_address]
出库货道号=M201
出库数量=M202
出库应答字=M203
出库任务号=M204
出库完成=M205
Loading…
Cancel
Save