添加泡前库入库逻辑

dev
liulb@mesnac.com 10 months ago
parent 1f1769a34b
commit bf1b9ff1c1

@ -0,0 +1,4 @@
[*.cs]
# IDE0055: 修正格式
dotnet_diagnostic.IDE0055.severity = silent

@ -15,7 +15,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
bc08828a5b48f624dd6d5abe3bdff5fd403be6ac84077e857acb5bb807813719
74179ae8157f7852c9431e0f012388d24731455a211a8eff479efc28af69b31d

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
2bd9626a40ad39436bf5e1b84fa9f38d49d2e4a3f6ef51f237c8d39877a0ba3e
9eb9c3343bb1a3a8e3426fc92f4e398af1f4cb1ade520efc3416cbca1a18e1cd

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
495590e33b83e22caa118223c3004f944888925725f8803a7ba8c96f04105aca
a165af674a441087eb22ae19c77f979a6da84cbec6e5cbc681f8782efbaf2a96

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
86a8d3f4886cdec96603268afa7f52fbf2efcc1bdeea396c58803f4916223197
50db5bdaed5a2e50771f8e9b59e9015f322c4f69836771d4f10280033baddf0f

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
44da4beeb5eacddcea2afa79795837b0d17de69fd701240a7d63befcb1ac1a30
e4ff5feba5f86593977c536e74c908c2b5f430e00657cc6a35b4093b4fba7066

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
79efd6043fad8be9581f5a90809edb04d2d84e6d25c463a66c1656e4c27ff82d
340b53e9f3980b2f035b259b8c24855db503861dc7ce044dd8125b484ea52e3e

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
4cd70a2fc9671c416cc84abcbf1a567abaca33435a5f99689731fa69744a2c65
1771f1e0c2289705e94aa4abfed5bb91ff856e44a3ad0211a3208ce94b3dc6ec

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
690cfa7b500416435057215bd4859366152188330efd80fdfbf19d4026d56ef6
9068062e57a5b81a7148289fc74572e59369ccf4ef2cbf765ccb11dfb12a171b

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
e55d1a640be76ced9a41bd7bbaa7d82a0cb6dad20ec943f7d56f31741ab36883
c2fbac0fe4030a2a6945b05a3ea3e3d88f5f76084e501a716f7f8a0042118937

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
9af1783e4ebfb11e27e3fd206f03503852e7ad2c68ac68878cd1f83ed3ac1e4e
093f57870764331d57de6cafb70e8f3a16edeae5233ad8a1eddbd307df44fba2

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
ce4adcd562b351893be69d7fdff44e39709f3d6cd7656d249760eb404525ae0d
ec73500b8c3ed36309792e9a99c4baf2dda48b653bd87333e427a308f0235421

@ -14,6 +14,10 @@
<None Remove="Service_New\SysUserService.cs~RF1d4a1e01.TMP" />
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.Core.IRepository\Admin.Core.IRepository.csproj" />
<ProjectReference Include="..\Admin.Core.IService\Admin.Core.IService.csproj" />

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
87e8a3f968aecefec0debd41eb65bafbe7c9cb35b730ee6addad1ea897e6020f
684ec858c0135ef17a23f6f4ba9440db1d8c00ab0db171f9b67e882bc38e153d

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
d34fb7aa196c3355db386bcbef481b7adeacfd1f72012a4689388113675c0af5
bc3b83989d0a9bbe7fbe3b0dd43a98d703c9202d722100e83165ea0560759ef7

@ -93,6 +93,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.TemperatureTask"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.PerfusionTask", "Aucma.Core.PerfusionTask\Aucma.Core.PerfusionTask.csproj", "{9762EE52-F073-4CF6-AAAE-7FCDC894C967}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84DFF535-D535-4AB1-A9DA-3749665EB639}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

@ -11,6 +11,11 @@ using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Profiling.Internal;
using Aucma.Core.HwPLc;
using Org.BouncyCastle.Asn1.Tsp;
using NetTaste;
using System.Windows.Media.Media3D;
using System.Windows.Forms;
using Admin.Core.Model.Model_New;
namespace Aucma.Core.BoxFoam.Business
{
@ -104,13 +109,293 @@ namespace Aucma.Core.BoxFoam.Business
public InStoreBusiness()
{
MvCodeHelper.PQKReceiveCodeEvent += InStore;
MvCodeHelper.PQKReceiveCodeEvent += NewTask;
storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
init();
#region 入库任务
Task.Run(async () =>
{
await InitEnterStore();
});
#endregion
}
#endregion
#region 根据条码入库
/// <summary>
/// 根据条码入库——泡前库始终只有一条任务在
/// </summary>
/// <param name="materialBarCode"></param>
/// <returns></returns>
public async Task NewTask(string materialBarCode)
{
if (string.IsNullOrEmpty(materialBarCode))
{
LogDelegateEvent?.Invoke("未扫到二维码信息!");
Console.WriteLine($"【{DateTime.Now}】未扫到二维码信息,请重新扫码!");
return;
}
string materialCode = SubString(materialBarCode);
//创建入库任务
Console.WriteLine($"【{DateTime.Now}】扫码成功,物料条码:{materialBarCode}");
logHelper.Info($"扫码成功,物料条码:{materialBarCode}");
LogDelegateEvent?.Invoke($"扫码成功,物料条码:{materialBarCode}");
var taskList = await _realTaskInfoService.QueryAsync(d=>d.StoreCode== storeCode);
if (taskList.Count() > 0)
{
//如果存在多条物料任务删除重新创建
taskList.ForEach(d=>d.TaskStatus= 3);
_ = _realTaskInfoService.UpdateAsync(taskList).Result;
}
var result = await CreateRecordTask(materialBarCode); //创建入库任务
if (result)
{
Console.WriteLine($"【{DateTime.Now}】物料条码:{materialBarCode},创建任务成功!");
}
await Task.CompletedTask;
}
#region 创建入库任务
/// <summary>
/// 创建入库任务
/// </summary>
/// <param name="materialBarCode">物料条码</param>
private async Task<bool> CreateRecordTask(string materialBarCode)
{
bool result = false;
try
{
//生成入库任务
RealTaskInfo realTaskInfo = new RealTaskInfo();
realTaskInfo.TaskType = 1;
realTaskInfo.TaskCode = System.Guid.NewGuid().ToString("N").Substring(0, 6);
realTaskInfo.MaterialCode = materialBarCode;//存储物料条码
realTaskInfo.PlanAmount = 1;
realTaskInfo.TaskStatus = 1; //任务状态1 - 待执行2 - 执行中3 - 完成
realTaskInfo.CreateTime = DateTime.Now;
realTaskInfo.StoreCode = storeCode;
int flag = await _realTaskInfoService.AddAsync(realTaskInfo);
if (flag > 0)
{
logHelper.Info("入库任务创建成功");
LogDelegateEvent?.Invoke($"[{materialBarCode}]入库任务创建成功");
RefreshInStoreTaskEvent?.Invoke(realTaskInfo);//刷新datagrid 列表
result = true;
}
else
{
logHelper.Info("入库任务创建失败");
LogDelegateEvent?.Invoke($"[{materialBarCode}]入库任务创建失败");
result = false;
}
}
catch (Exception ex)
{
logHelper.Info($"入库任务创建异常:{ex.Message}");
result = false;
}
return result;
}
#endregion
#endregion
#region 任务执行入库
public async Task EnterStore(string barCode, int store)
{
//获取货道详情
string spaceCode = string.Empty;
switch (store)
{
case 1:
spaceCode = "PB01_001";
break;
case 2:
spaceCode = "PB01_002";
break;
case 3:
spaceCode = "PB01_003";
break;
case 4:
spaceCode = "PB01_004";
break;
case 5:
spaceCode = "PB01_005";
break;
case 6:
spaceCode = "PB01_006";
break;
default:
break;
}
if (string.IsNullOrEmpty(spaceCode)) return;
var baseStoreInfo = await _baseStoreInfoServices.FirstAsync(d => d.StoreCode.Equals(storeCode));//仓库
var baseSpace = await _baseSpaceInfoServices.FirstAsync(d => d.SpaceCode.Equals(spaceCode));
//入库记录表
//根据条码获取物料详情
var material = _printBarCodeServices.FirstAsync(d => d.MaterialBarcode == barCode).Result;
RecordInStore recordInstore = new RecordInStore();
recordInstore.StoreCode = storeCode;
recordInstore.StoreArea = baseStoreInfo.StoreArea;
recordInstore.SpaceCode = baseSpace.SpaceCode;
string materialType = SubString(barCode);//截取中间物料条码
recordInstore.MaterialType = materialType;
recordInstore.MaterialCode = material.MaterialCode;
recordInstore.InStoreTime = DateTime.Now;
recordInstore.BarCodeCode = barCode;
recordInstore.MaterialName = material.MaterialName;
recordInstore.EntryPattern = 0;
recordInstore.IsFlag = 0;
recordInstore.CreatedTime = DateTime.Now;
//入库详情表
BaseSpaceDetail baseDetail = new BaseSpaceDetail();
baseDetail.StoreCode = storeCode;
baseDetail.SpaceCode = baseSpace.SpaceCode;
baseDetail.MaterialCode = material.MaterialCode;
baseDetail.MaterialName = material.MaterialName;
baseDetail.MaterialAmount = 1;
baseDetail.CreatedTime = DateTime.Now;
bool result = _recordInstoreServices.SaveRecordToDb(recordInstore, null, baseSpace, baseDetail).Result;
if (result)
{
string message = $"物料[{material.MaterialName}], 入{baseSpace.SpaceName},入库成功!";
RefreshScanMateriaCodeEvent?.Invoke(material.MaterialCode, barCode, material.MaterialName, baseSpace.SpaceName, message); //刷新界面扫码信息
LogDelegateEvent?.Invoke($"物料[{material.MaterialName}], 入库[{baseSpace.SpaceName}]成功!");
RefreshDataGridDelegateEvent?.Invoke();
}
else
{
LogDelegateEvent?.Invoke($"物料[{material.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!");
logHelper.Error($"物料[{material.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!");
}
}
#endregion
#region 执行入库任务
public async Task InitEnterStore()
{
RealTaskInfo realTaskInfo = null;
Thread.Sleep(3000);
bool flag = true;
do
{
var taskList = await _realTaskInfoService.QueryAsync(d=>d.StoreCode== storeCode&&d.TaskStatus==1);
if (taskList == null || taskList.Count() == 0) continue;
var taskTime = taskList.Max(d => d.CreateTime);
realTaskInfo = taskList.First(d => d.CreateTime == taskTime);
if (realTaskInfo==null) continue;
#region 执行任务
string materialCode = SubString(realTaskInfo.MaterialCode);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("PqPlc"));
if (obj != null)
{
if (obj.plc.IsConnected)
{
if (flag)
{
try
{
Thread.Sleep(1000);
flag = false;
LogDelegateEvent?.Invoke($"获取物料编码:{materialCode}");
Console.WriteLine($"获取物料编码:{materialCode}");
obj.plc.WriteString("DB200.132", materialCode);
int store = obj.plc.ReadInt16("DB200.438");//读取货道
Console.WriteLine($"进入货道:{store}");
if (store == 0) continue;
{
LogDelegateEvent?.Invoke($"物料编码:{materialCode},进入货道:{store}货道");
bool r = obj.plc.WriteInt16("DB200.2", "1");
Console.WriteLine($"写入应答字为1写入结果为{r}");
LogDelegateEvent?.Invoke($"写入应答字为1写入结果为{r}");
}
{
LogDelegateEvent?.Invoke($"等待PLC入库完成信号....");
int an = obj.plc.ReadInt16("DB200.86");
if (an == 2)
{
LogDelegateEvent?.Invoke($"物料入库完成,清空物料信息。");
obj.plc.WriteString("DB200.132", "");
obj.plc.WriteInt16("DB200.86", "0");
//任务完成更新任务状态
realTaskInfo.TaskStatus = 3;
_ = _realTaskInfoService.UpdateAsync(realTaskInfo).Result;
//更新货道入库
await EnterStore(realTaskInfo.MaterialCode, store);
//更新过点数
await UpdateComplete(realTaskInfo.MaterialCode);
Console.WriteLine($"箱体入库成功!入库货道为:{store}货道");
LogDelegateEvent?.Invoke($"箱体入库成功!入库货道为:{store}货道");
RefreshInStoreTaskEvent?.Invoke(realTaskInfo);//刷新datagrid 列表
}
}
}
catch (Exception ex)
{
logHelper.Error($"入库业务异常:{ex}");
LogDelegateEvent?.Invoke($"入库业务异常:{ex}");
Console.WriteLine($"入库业务异常:{ex.Message}");
}
finally
{
flag = true;
}
}
}
}
else
{
Console.WriteLine("PLC连接中...");
Thread.Sleep(3000);
continue;
}
#endregion
Thread.Sleep(1000);
} while (true);
}
#endregion
#region 更新过点数
/// <summary>
/// 更新过点数
/// </summary>
/// <param name="materialBarCode"></param>
/// <returns></returns>
public async Task UpdateComplete(string materialBarCode)
{
#region 更新过点数据
PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == materialBarCode);
MaterialCompletion completion = new MaterialCompletion();
completion.OrderCode = print.OrderCode;
completion.MaterialBarcode = materialBarCode;
completion.MaterialCode = print.MaterialCode;
completion.MaterialName = print.MaterialName;
completion.StationName = "1004";
completion.ProductLineCode = "CX_02";
completion.isDownLine = 0;
completion.CompleteDate = DateTime.Now;
int i = await _iMaterialCompletionServices.AddAsync(completion);
Console.WriteLine($"过点数更新结果为{i > 0}");
#endregion
}
#endregion
#region 20240315之前
#region 初始化入库任务---模拟测试启用
/// <summary>
/// 初始化入库任务
@ -138,7 +423,7 @@ namespace Aucma.Core.BoxFoam.Business
logHelper.Info(ex.Message.ToString());
Console.WriteLine($"初始化异常:{ex.Message}");
}
}
}
#endregion
#region 定时器实时监测入库出库完成信号
@ -194,7 +479,7 @@ namespace Aucma.Core.BoxFoam.Business
Thread.Sleep(1000);
}
});
}
}
#endregion
#region 获取入库任务下发plc
@ -274,7 +559,7 @@ namespace Aucma.Core.BoxFoam.Business
logHelper.Info("获取待执行的入库任务异常", ex);
}
return taskInfo;
}
}
#endregion
#region 入库
@ -446,7 +731,7 @@ namespace Aucma.Core.BoxFoam.Business
info = info.Where(x => x.SpaceStatus == 1 && x.SpaceCapacity > (x.SpaceStock + x.OnRouteAmount)).ToList();
if (info == null || info.Count == 0) return result;
result = info.OrderByDescending(x => x.SpaceStock).First();
return result;
}
@ -476,7 +761,7 @@ namespace Aucma.Core.BoxFoam.Business
spaceInfo.SpaceStock = obj.plc.ReadInt16(spaceAddress.onStore);//获取
}
return spaceInfo;
}
}
#endregion
#endregion
@ -512,7 +797,7 @@ namespace Aucma.Core.BoxFoam.Business
//写入货道物料类型
obj.plc.WriteString(spaceAddress.materialType, taskInfo.BoxType);
//写入货道号plc收到货道号开始入库并非应答字所以货道号最后下发
obj.plc.WriteInt16("DB200.0", taskInfo.SpaceCode.Substring(7,1));
obj.plc.WriteInt16("DB200.0", taskInfo.SpaceCode.Substring(7, 1));
//写入完成后读取反馈号进行复位
ReadShellAnswer_InStore(taskInfo);
result = true;
@ -540,37 +825,37 @@ namespace Aucma.Core.BoxFoam.Business
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc"));
try
{
if (obj != null && obj.plc.IsConnected)
if (obj != null && obj.plc.IsConnected)
{
do
{
do
//读取PLC反馈号上位机清空写入的入库内容
if (obj.plc.ReadInt16("DB200.86") == 2)
{
//读取PLC反馈号上位机清空写入的入库内容
if (obj.plc.ReadInt16("DB200.86") == 2)
{
obj.plc.WriteInt16("DB200.86", "0");
//-------------plc清
//写入货道号
obj.plc.WriteInt16("DB200.0", "0");
// 写入应答字
obj.plc.WriteInt16("DB200.2", "0");
//写入货道物料类型
// obj.plc.WriteInt16(spaceAddress.materialType, taskInfo.MaterialType);
//----------------------
isFlag = false;
InStoreAnswer(taskInfo.TaskCode);
// TaskInfos.Add(taskInfo);
// ReadShellFinish_InStore(taskCode);
}
Thread.Sleep(500);
} while (isFlag);
}
else
{
logHelper.Info("PLC未连接");
}
obj.plc.WriteInt16("DB200.86", "0");
//-------------plc清
//写入货道号
obj.plc.WriteInt16("DB200.0", "0");
// 写入应答字
obj.plc.WriteInt16("DB200.2", "0");
//写入货道物料类型
// obj.plc.WriteInt16(spaceAddress.materialType, taskInfo.MaterialType);
//----------------------
isFlag = false;
InStoreAnswer(taskInfo.TaskCode);
// TaskInfos.Add(taskInfo);
// ReadShellFinish_InStore(taskCode);
}
Thread.Sleep(500);
} while (isFlag);
}
else
{
logHelper.Info("PLC未连接");
}
}
catch (Exception ex)
{
@ -579,7 +864,7 @@ namespace Aucma.Core.BoxFoam.Business
}
}
/// <summary>
/// 泡前库执行反馈
/// </summary>
@ -785,7 +1070,8 @@ namespace Aucma.Core.BoxFoam.Business
}
}
#endregion
#endregion
}
}
}

@ -66,7 +66,7 @@ namespace Aucma.Core.BoxFoam
services.AddScannerSetup();
//任务调度
services.AddJobSetup();
// services.AddJobSetup();
//PLC
services.AddPlcSetup();
@ -90,8 +90,7 @@ namespace Aucma.Core.BoxFoam
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService,
ISchedulerCenter schedulerCenter, IRunPlcService runPlcService,IScannerService scannerService)//
public void Configure(IApplicationBuilder app, IRunPlcService runPlcService)
{
// 使用静态文件
app.UseStaticFiles();
@ -99,11 +98,11 @@ namespace Aucma.Core.BoxFoam
//app.UseAuthorization();
// 开启QuartzNetJob调度服务
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
//app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
//PLC
app.UsePlcMildd(runPlcService);
//开启扫码服务
app.UseScannerMildd(scannerService);
//app.UseScannerMildd(scannerService);
}

@ -21,8 +21,8 @@ namespace Aucma.Core.BoxFoam.ViewModels
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
private IndexPageView firstPage = new IndexPageView();//首页
CollectionFoamLine line = new CollectionFoamLine();
CollectionFoamMachine machine = new CollectionFoamMachine();
//CollectionFoamLine line = new CollectionFoamLine();
//CollectionFoamMachine machine = new CollectionFoamMachine();
RealTimeInventoryPageView realTimeInventoryPage = new RealTimeInventoryPageView();
EnterWarehouseStatisticsPageView enterWarehouseStatisticsPage = new EnterWarehouseStatisticsPageView();
FoamPlanPageView foamPlanPageView = new FoamPlanPageView();

@ -202,7 +202,7 @@
"PLCServer": [
{
"Id": 1,
"EquipName": "泡前库Plc",
"EquipName": "PqPlc",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.41",

@ -183,11 +183,11 @@ namespace Aucma.Core.PrintTo.ViewModels
MessageBox.Show("请输入打印数量!", "系统提醒");
return;
}
if (SelectedCells.PlanAmount < PrintAmount)
{
MessageBox.Show("打印数量不能高于计划数量!", "系统提醒");
return;
}
//if (SelectedCells.PlanAmount > PrintAmount)
//{
// MessageBox.Show("打印数量不能高于计划数量!", "系统提醒");
// return;
//}
if (printType==0)
{
MessageBox.Show("请选择打印类型!", "系统提醒");
@ -220,16 +220,16 @@ namespace Aucma.Core.PrintTo.ViewModels
{
int num= list.Count;//已经打印数量
int residue= SelectedCells.PlanAmount - num;//剩余打印数量
if (residue == standard_amount)
{
MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
return;
}
if ((residue- standard_amount)< 1)
{
MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
return;
}
//if (residue > standard_amount)
//{
// MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
// return;
//}
//if ((residue- standard_amount)< 1)
//{
// MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
// return;
//}
}
//更新打印名称

@ -389,6 +389,7 @@ namespace Aucma.Core.PrintTo.ViewModels
log.Error($"打印出错:{ex.Message}\n{printBarCode.ToJson()}");
ErrorNum++;
}
Thread.Sleep(500);
Progress = i;
i++;
}

@ -17,49 +17,42 @@ namespace Aucma.Core.RunPlc
}
#endregion
public async Task StartMelsecMcSeverAsync()
{
await Task.Run(async () =>
{
await StartMelsecMcPlcServer();
});
}
public async Task StartSiemensSever()
{
await Task.Run(async () =>
{
await StartSiemensPlcServer();
});
//await Task.Run(async () =>
//{
// await StartSiemensPlcServer();
//});
Task.WaitAny(StartSiemensPlcServer());
}
#region 心跳
public async Task StartMelsecPlcAsync()
{
await Task.Run(async () =>
{
System.Timers.Timer timer = new System.Timers.Timer(3000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(ExecMelsecMcHeartTask); //到达时间的时候执行事件;
timer.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
await Task.CompletedTask;
});
}
public async Task StartSiemensPlcAsync()
{
await Task.Run(async () =>
{
System.Timers.Timer timer = new System.Timers.Timer(3000);//创建定时器设置间隔时间为1000毫秒
timer.Elapsed += new System.Timers.ElapsedEventHandler(ExecSiemensHeartTask);
timer.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
await Task.CompletedTask;
});
}
private static async Task StartMelsecMcPlcServer()
{

@ -75,7 +75,7 @@ namespace Aucma.Core.Tasks
try
{
int signal = obj.plc.ReadInt16("DB55.84.0");
Console.WriteLine($"【{DateTime.Now}】》当前灌注采集信号:{signal}");
if (signal == 0)
{
Thread.Sleep(1000);
@ -92,58 +92,58 @@ namespace Aucma.Core.Tasks
continue;
}
Console.WriteLine($"【{DateTime.Now}】》灌注数据条码:{record.PerfusionBoxCode}》灌注结果:{record.PerfusionResult}》设定灌注量:{record.PerfusionSetVolume}》灌注量:{record.PerfusionActualVolume}");
var tempRecord = _perfusionRecordServices.FirstAsync(d => d.PerfusionBoxCode.Equals(record.PerfusionBoxCode) && d.PerfusionResult == record.PerfusionResult).Result;
if (tempRecord != null)
{
Console.WriteLine($"【{DateTime.Now}】》灌注数据条码:[{record.PerfusionBoxCode}],灌注结果:[{record.PerfusionResult}],已存在系统中");
bool fw=obj.plc.WriteInt16("DB55.84.0", "0");//存盘成功写入bool
Console.WriteLine($"【{DateTime.Now}】》写入复位信号{fw}");
Thread.Sleep(1000);
continue;
}
#region 更新设备状态
Perfusion_DeviceStatus device = _perfusionDeviceStatusServices.FirstAsync().Result;
if (device == null)
{
_ = _perfusionDeviceStatusServices.AddAsync(perfusion_DeviceStatus).Result;
}
else
{
device.PerfusionStatus = perfusion_DeviceStatus.PerfusionStatus;
var rsult = _perfusionDeviceStatusServices.UpdateAsync(device).Result;
}
#endregion
#region 更新报警信息
if (perfusion_Alarm.PerfusionStatus > 0)
{
int a = _perfusionAlarmServices.AddAsync(perfusion_Alarm).Result;
}
#endregion
record.IsFlag = 0;
//充注结束
int result = _perfusionRecordServices.AddAsync(record).Result;
if (result == 0)
{
//添加过点数
Console.WriteLine($"【{DateTime.Now}】》灌注结果:{record.PerfusionResult}");
if (record.PerfusionResult == 8)
{
var insert= InsertToCompleteAndCheck(record);
if (insert)
{
Console.WriteLine($"【{DateTime.Now}】》保存过点数成功!");
}
}
ToMes();//灌注
Console.WriteLine(record.ToJson());
}
bool r = obj.plc.WriteInt16("DB55.84.0", "0");//存盘成功写入bool
Console.WriteLine($"【{DateTime.Now}】》写入复位信号{r}");
Console.WriteLine($"【{DateTime.Now}】》灌注数据采集结束");
//var tempRecord = _perfusionRecordServices.FirstAsync(d => d.PerfusionBoxCode.Equals(record.PerfusionBoxCode) && d.PerfusionResult == record.PerfusionResult).Result;
continue;
//if (tempRecord != null)
//{
// Console.WriteLine($"【{DateTime.Now}】》灌注数据条码:[{record.PerfusionBoxCode}],灌注结果:[{record.PerfusionResult}],已存在系统中");
// bool fw=obj.plc.WriteInt16("DB55.84.0", "0");//存盘成功写入bool
// Console.WriteLine($"【{DateTime.Now}】》写入复位信号{fw}");
// Thread.Sleep(1000);
// continue;
//}
//#region 更新设备状态
//Perfusion_DeviceStatus device = _perfusionDeviceStatusServices.FirstAsync().Result;
//if (device == null)
//{
// _ = _perfusionDeviceStatusServices.AddAsync(perfusion_DeviceStatus).Result;
//}
//else
//{
// device.PerfusionStatus = perfusion_DeviceStatus.PerfusionStatus;
// var rsult = _perfusionDeviceStatusServices.UpdateAsync(device).Result;
//}
//#endregion
//#region 更新报警信息
//if (perfusion_Alarm.PerfusionStatus > 0)
//{
// int a = _perfusionAlarmServices.AddAsync(perfusion_Alarm).Result;
//}
//#endregion
//record.IsFlag = 0;
////充注结束
//int result = _perfusionRecordServices.AddAsync(record).Result;
//if (result == 0)
//{
// //添加过点数
// Console.WriteLine($"【{DateTime.Now}】》灌注结果:{record.PerfusionResult}");
// if (record.PerfusionResult == 8)
// {
// var insert= InsertToCompleteAndCheck(record);
// if (insert)
// {
// Console.WriteLine($"【{DateTime.Now}】》保存过点数成功!");
// }
// }
// ToMes();//灌注
// Console.WriteLine(record.ToJson());
//}
//bool r = obj.plc.WriteInt16("DB55.84.0", "0");//存盘成功写入bool
//Console.WriteLine($"【{DateTime.Now}】》写入复位信号{r}");
//Console.WriteLine($"【{DateTime.Now}】》灌注数据采集结束");
}
catch (Exception ex)
{

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a7d260f43ac717e64a38d883b80b6b7647a514b3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f1769a34b701f2b8f03838d72e1f49991068d57")]
[assembly: System.Reflection.AssemblyProductAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyTitleAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
169f6aa55d6b86ad22c8ea29d0efd895b08fd3c55ed8246c67d6b12dca4b6058
cbeff29e757208ba6b6519cfe0f0f0a4c3216a27c70a7e6ba8b9780a6ce4b085

Loading…
Cancel
Save