修改钣金功能

dev
liulb@mesnac.com 1 year ago
parent bff3520110
commit ea831bbed6

@ -2356,6 +2356,16 @@
产品简码
</summary>
</member>
<member name="P:Admin.Core.Model.ModeStatusView.XValue">
<summary>
夹具型号
</summary>
</member>
<member name="P:Admin.Core.Model.ModeStatusView.YValue">
<summary>
y
</summary>
</member>
<member name="T:Admin.Core.Model.OffLineInfo">
<summary>
条码下线信息记录

@ -1,3 +1,3 @@
is_global = true
build_property.RootNamespace = Admin.Core.FrameWork
build_property.ProjectDir = E:\桌面\AUCMA_SCADA\Admin.Core.FrameWork\
build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.FrameWork\

@ -40,5 +40,14 @@ namespace Admin.Core.IRepository
/// <param name="productLineCode"></param>
/// <returns></returns>
Task<List<SheetMetaHourDataView>> GetSheetMetaHourData(string productLineCode);
/// <summary>
/// 当前订单执行第一次数据采集时候更新SAP计划
/// </summary>
int UpdateSapPlan(string sapCode);
/// <summary>
/// 获取夹具状态
/// </summary>
/// <returns></returns>
Task<List<ModeStatusView>> StatisticalModelStatus();
}
}

@ -1,5 +1,6 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using System;
using System.Collections.Generic;
@ -50,5 +51,16 @@ namespace Admin.Core.IService
/// <returns></returns>
Task<List<SheetMetaHourDataView>> GetSheetMetaHourData(string productLineCode);
/// <summary>
/// 钣金第一次执行更新日历表
/// </summary>
/// <param name="sapCode"></param>
/// <returns></returns>
int UpdateSapPlan(string sapCode);
/// <summary>
/// 夹具状态
/// </summary>
/// <returns></returns>
Task<List<ModeStatusView>> StatisticalModelStatus();
}
}

@ -0,0 +1,23 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model
{
public class ModeStatusView
{
/// <summary>
/// 夹具型号
/// </summary>
[SugarColumn(ColumnName = "X_VALUE")]
public string XValue { get; set; }
/// <summary>
/// y
/// </summary>
[SugarColumn(ColumnName = "Y_VALUE")]
public string YValue { get; set; }
}
}

@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.RealTimeService
build_property.ProjectDir = E:\桌面\AUCMA_SCADA\Admin.Core.RealTimeService\
build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.RealTimeService\

@ -89,37 +89,35 @@ namespace Admin.Core.Repository
/// <returns></returns>
public List<SheetMetaPlanInfoView> QuerySheetMetalPlanData(string stationCode)
{
string sql = $@"SELECT
P.OBJ_ID,
P.PLAN_CODE,
P.ORDER_CODE,
o.MATERIAL_CODE,
o.MATERIAL_NAME,
m.MATERIAL_SPECIFICATIONS,
P.PRODUCTLINE_CODE,
P.PLAN_AMOUNT,
P.COMPLETE_AMOUNT,
P.BEGIN_TIME,
P.END_TIME
FROM C##AUCMA_MES.PRODUCT_PLANINFO p INNER JOIN
C##AUCMA_MES.BASE_ORDERINFO o ON o.ORDER_CODE = p.ORDER_CODE
INNER JOIN C##AUCMA_MES.BASE_MATERIALINFO m ON o.MATERIAL_CODE = m.MATERIAL_CODE
WHERE
p.ORDER_CODE IN ( SELECT ORDER_CODE FROM C##AUCMA_MES.PRODUCT_PLANINFO p WHERE p.PRODUCTLINE_CODE = '{stationCode}' )
group by P.OBJ_ID,
P.PLAN_CODE,
P.ORDER_CODE,
o.MATERIAL_CODE,
o.MATERIAL_NAME,
m.MATERIAL_SPECIFICATIONS,
P.PRODUCTLINE_CODE,
P.PLAN_AMOUNT,
P.COMPLETE_AMOUNT,
P.BEGIN_TIME,
P.END_TIME
order by OBJ_ID";
string sql = $@"select o.OBJ_ID,
P.PLAN_CODE,
P.ORDER_CODE,
o.MATERIAL_CODE,
o.MATERIAL_NAME,
m.MATERIAL_SPECIFICATIONS,
P.PRODUCTLINE_CODE,
P.PLAN_AMOUNT,
P.COMPLETE_AMOUNT,
P.BEGIN_TIME,
P.END_TIME
FROM C##AUCMA_MES.PRODUCT_PLANINFO p INNER JOIN
C##AUCMA_MES.BASE_ORDERINFO o ON o.ORDER_CODE = p.ORDER_CODE
INNER JOIN C##AUCMA_MES.BASE_MATERIALINFO m ON o.MATERIAL_CODE = m.MATERIAL_CODE
INNER JOIN C##AUCMA_MES.BASE_MATERIALINFO m ON o.MATERIAL_CODE = m.MATERIAL_CODE where p.PRODUCTLINE_CODE='{stationCode}'
group by o.OBJ_ID,
P.PLAN_CODE,
P.ORDER_CODE,
o.MATERIAL_CODE,
o.MATERIAL_NAME,
m.MATERIAL_SPECIFICATIONS,
P.PRODUCTLINE_CODE,
P.PLAN_AMOUNT,
P.COMPLETE_AMOUNT,
P.BEGIN_TIME,
P.END_TIME
order by o.OBJ_ID";
return Db.CopyNew().SqlQueryable<SheetMetaPlanInfoView>(sql).Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
return Db.CopyNew().SqlQueryable<SheetMetaPlanInfoView>(sql).ToList();
}
/// <summary>
/// 获取钣金下发的计划

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System;
using Microsoft.IdentityModel.Logging;
using System.Linq;
using SqlSugar;
namespace Admin.Core.Repository
{
@ -104,13 +105,33 @@ namespace Admin.Core.Repository
#endregion
#region 当前订单执行第一次数据采集时候更新SAP计划
/// <summary>
/// /更新计划表数据
/// 当前订单执行第一次数据采集时候更新SAP计划
/// </summary>
//public void UpdateSAPPlan(string PlanCode)
//{
// string sql = "UPDATE PRODUCT_CALENDAR_INFO SET IS_SCHEDULING = 0 WHERE SAP_PLAN_CODE = '11227552'";
// return await Db.CopyNew().Ado.ExecuteCommandAsync(sql);
//}
public int UpdateSapPlan(string sapCode)
{
var parameters = new SugarParameter[]
{
new SugarParameter("@SAP_PLAN_CODE", sapCode)
};
string sql = "UPDATE PRODUCT_CALENDAR_INFO SET IS_SCHEDULING = 0 WHERE SAP_PLAN_CODE = @SAP_PLAN_CODE";
int affectedRows = Db.CopyNew().Ado.ExecuteCommand(sql, parameters);
return affectedRows;
}
#endregion
#region 统计夹具型号状态
/// <summary>
/// 统计夹具型号状态
/// </summary>
public async Task<List<ModeStatusView>> StatisticalModelStatus()
{
string sql = "select * from table (scada_xk_fp_01('') )";
return await Db.CopyNew().Ado.SqlQueryAsync<ModeStatusView>(sql);
}
#endregion
}
}

@ -2,6 +2,7 @@
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using log4net;
@ -9,6 +10,7 @@ using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Threading.Tasks;
namespace Admin.Core.IService
@ -83,5 +85,19 @@ namespace Admin.Core.IService
{
return await _sysUserInfoRepository.GetSheetMetaHourData(productLineCode);
}
public int UpdateSapPlan(string sapCode)
{
return _sysUserInfoRepository.UpdateSapPlan(sapCode);
}
/// <summary>
/// 获取夹具状态
/// </summary>
/// <returns></returns>
public Task<List<ModeStatusView>> StatisticalModelStatus()
{
return _sysUserInfoRepository.StatisticalModelStatus();
}
}
}

@ -76,7 +76,7 @@ namespace Aucma.Core.HwPLc
/// <returns></returns>
public bool Connect(string iP, int port)
{
melsecMcNet.IpAddress = iP;//正式环境开启
//melsecMcNet.IpAddress = iP;//正式环境开启
melsecMcNet.Port = port;
// 如果网络不太理想,配置了两个端口,一个有问题,立即切换另一个的话,可以配置如下的代码

@ -10,10 +10,13 @@ using System.Windows.Documents;
using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Aucma.Core.HwPLc;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using NPOI.SS.Formula.Functions;
using SqlSugar;
namespace Aucma.Core.SheetMetal.Business;
@ -61,7 +64,7 @@ public class SheetMetalPlanTaskHandle
/// <summary>
/// 刷新当前正在执行的计划
/// </summary>
public delegate void RefreshExecInfo(string message);
public delegate void RefreshExecInfo(string message,string color);
public static event RefreshExecInfo RefreshExecInfoEvent;
#endregion
@ -70,15 +73,19 @@ public class SheetMetalPlanTaskHandle
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
protected readonly ISysUserInfoServices? _sysUserInfoServices;
protected readonly IMaterialCompletionServices? _materialCompletionServices;
public HwPLc.PlcModel plc1 = null;
public SheetMetalPlanTaskHandle()
{
_executePlanInfoServices =
App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_executePlanInfoServices =App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_sidePanelComplateServices = App.ServiceProvider.GetService<IRecordSidePanelComplateServices>();
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
_materialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
}
@ -109,6 +116,8 @@ public class SheetMetalPlanTaskHandle
if (planInfo == null) continue;
if (planInfo.PlanType == 3 || planInfo.PlanType == 1)//如果为3或者为1 后板计划单独下发 以前板完成为主
{
//获取设置的型号查询对应的型号,下发计划
SendPlanTaskToBackPanel(planInfo, obj_backPanel);
UpdateBackPanelPlanTaskByComplate(planInfo);
@ -183,7 +192,7 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。","White");
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
@ -195,7 +204,7 @@ public class SheetMetalPlanTaskHandle
{
obj_sidePanel.plc.WriteInt32("D6021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】,收到前板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址", "White");
startTime=DateTime.Now;
isFlag = false;
}
@ -255,7 +264,7 @@ public class SheetMetalPlanTaskHandle
obj_backPanel.plc.WriteInt32("D4021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】已下发,等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】下发,等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】下发,等待背板设备应答。。。。。。", "White");
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
@ -267,7 +276,7 @@ public class SheetMetalPlanTaskHandle
{
obj_backPanel.plc.WriteInt32("D4021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
startTime = DateTime.Now;
isFlag = false;
}
@ -328,7 +337,7 @@ public class SheetMetalPlanTaskHandle
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
int sumAmount = 0;
if (planInfo.PlanType == 1)
@ -339,7 +348,6 @@ public class SheetMetalPlanTaskHandle
{
sumAmount = sumSidePanelAmount;
planInfo.ExecuteStatus = 3;
}
if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
{
@ -420,7 +428,7 @@ public class SheetMetalPlanTaskHandle
catch (Exception ex)
{
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
}
}
/// <summary>
@ -446,7 +454,7 @@ public class SheetMetalPlanTaskHandle
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
int sumAmount = 0;
@ -516,7 +524,7 @@ public class SheetMetalPlanTaskHandle
catch (Exception ex)
{
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
}
} while (isComplate);
@ -534,74 +542,6 @@ public class SheetMetalPlanTaskHandle
#endregion
#region 更新计划列表数量
/// <summary>
/// 更新计划列表数量
/// </summary>
public void UpdateComplatePlan()
{
string stationCode = Appsettings.app("StationInfo", "StationCode");
while (true)
{
var planInfoList = _executePlanInfoServices.QueryAsync(d=>d.ProductLineCode.Contains(stationCode)).Result;
if (planInfoList == null || planInfoList.Count == 0) continue;
var list = from d in planInfoList
select new
{
d.OrderCode,
d.CompleteAmount
};
var grouplist =( from d in list
group d by d.OrderCode into g
select new
{
OrderCode = g.Key,
CompleteAmount = g.Sum(d=>d.CompleteAmount)
}).OrderBy(t => t.OrderCode).ToList();
var productPlanInfoList= _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode)&& d.CompleteAmount!=d.PlanAmount).Result;
productPlanInfoList.ForEach(t =>
{
var obj= grouplist.SingleOrDefault(d=>d.OrderCode.Equals(t.OrderCode));
if (obj != null)
{
if (t.PlanAmount == obj.CompleteAmount)
{
t.CompleteAmount = obj.CompleteAmount;
t.EndTime = DateTime.Now;
}
if (t.PlanAmount > obj.CompleteAmount)
{
t.CompleteAmount = obj.CompleteAmount;
}
else
{
t.CompleteAmount = t.PlanAmount;
}
if (obj.CompleteAmount!=0)
{
_productPlanInfoServices.UpdateAsync(t);
}
}
});
Thread.Sleep(5000);
}
}
#endregion
#region 下发单个计划逻辑
@ -678,7 +618,7 @@ public class SheetMetalPlanTaskHandle
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
int sumAmount = 0;
if (planInfo.PlanType == 1)
@ -724,7 +664,7 @@ public class SheetMetalPlanTaskHandle
catch (Exception ex)
{
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
}
}
@ -751,7 +691,7 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke("等待前板设备应答......");
RefreshExecInfoEvent?.Invoke("等待前板设备应答......","Red");
//下发完成后读取PLC应答应答后复位应答信号
#region PLC反馈信号逻辑处理
@ -764,7 +704,7 @@ public class SheetMetalPlanTaskHandle
{
obj_sidePanel.plc.WriteInt32("D6021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号,复位应答地址","White");
isFlag = false;
}
Thread.Sleep(2000);
@ -803,7 +743,7 @@ public class SheetMetalPlanTaskHandle
obj_backPanel.plc.WriteInt32("D4021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
@ -813,7 +753,7 @@ public class SheetMetalPlanTaskHandle
{
obj_backPanel.plc.WriteInt32("D4021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址", "White");
isFlag = false;
}
Thread.Sleep(2000);
@ -870,7 +810,7 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke("等待前板设备应答......");
RefreshExecInfoEvent?.Invoke("等待前板设备应答......", "White");
//下发完成后读取PLC应答应答后复位应答信号
#region PLC反馈信号逻辑处理
@ -882,7 +822,7 @@ public class SheetMetalPlanTaskHandle
{
obj_sidePanel.plc.WriteInt32("D6021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号......");
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号......", "White");
isFlag = false;
}
Thread.Sleep(2000);
@ -955,7 +895,7 @@ public class SheetMetalPlanTaskHandle
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
Console.WriteLine($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
RefreshExecInfoEvent?.Invoke($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
RefreshExecInfoEvent?.Invoke($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
//添加完工记录
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
@ -1011,7 +951,7 @@ public class SheetMetalPlanTaskHandle
{
isFlag = false;
Console.WriteLine($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
RefreshExecInfoEvent?.Invoke($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
RefreshExecInfoEvent?.Invoke($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
}
}
}
@ -1041,7 +981,7 @@ public class SheetMetalPlanTaskHandle
catch (Exception e)
{
Console.WriteLine($"读取前板设备完成数据异常:{e.Message}");
RefreshExecInfoEvent?.Invoke($"读取前板设备完成数据异常:{e.Message}");
RefreshExecInfoEvent?.Invoke($"读取前板设备完成数据异常:{e.Message}", "Red");
}
} while (isFlag);
@ -1078,7 +1018,7 @@ public class SheetMetalPlanTaskHandle
obj_backPanel.plc.WriteInt32("D4021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
@ -1089,7 +1029,7 @@ public class SheetMetalPlanTaskHandle
{
obj_backPanel.plc.WriteInt32("D4021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
isFlag = false;
}
Thread.Sleep(2000);
@ -1161,7 +1101,7 @@ public class SheetMetalPlanTaskHandle
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
Console.WriteLine($"背板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
RefreshExecInfoEvent?.Invoke($"当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
//添加完工记录
RecordBackPanelComplate backPanelComplate = new RecordBackPanelComplate()
{
@ -1215,7 +1155,7 @@ public class SheetMetalPlanTaskHandle
{
isFlag = false;
Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
}
}
}
@ -1244,7 +1184,7 @@ public class SheetMetalPlanTaskHandle
catch (Exception e)
{
Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}");
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}", "Red");
}
}
@ -1271,9 +1211,92 @@ public class SheetMetalPlanTaskHandle
}
}
return returnStr;
}
}
#endregion
#region 更新计划列表数量
/// <summary>
/// 更新计划列表数量
/// </summary>
public void UpdateComplatePlan()
{
string stationCode = Appsettings.app("StationInfo", "StationCode");
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
List<ProductPlanInfo> pPlanInfoList = new List<ProductPlanInfo>();
while (true)
{
var planInfoList = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode)).Result;
if (planInfoList == null || planInfoList.Count == 0) continue;
var list = from d in planInfoList
select new
{
d.OrderCode,
d.CompleteAmount
};
var grouplist = (from d in list
group d by d.OrderCode into g
select new
{
OrderCode = g.Key,
CompleteAmount = g.Sum(d => d.CompleteAmount)
}).OrderBy(t => t.OrderCode).ToList();
var productPlanInfoList = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.CompleteAmount != d.PlanAmount).Result;
productPlanInfoList.ForEach(async t =>
{
var materialCompletionList = _materialCompletionServices.QueryAsync(d => d.ProductLineCode.Contains(productLineCode) && d.StationName.Equals(stationCode)).Result;
var obj = grouplist.FirstOrDefault(d => d.OrderCode.Equals(t.OrderCode));
if (obj != null)
{
ProductPlanInfo productPlanInfo = new ProductPlanInfo();
if (obj.CompleteAmount == 1 && t.CompleteAmount == 0)
{
productPlanInfo.EndTime = DateTime.Now;
_sysUserInfoServices.UpdateSapPlan(obj.OrderCode);//第一次执行更新日历表
}
if (t.PlanAmount == obj.CompleteAmount)
{
productPlanInfo.CompleteAmount = obj.CompleteAmount;
productPlanInfo.EndTime = DateTime.Now;
}
if (t.PlanAmount > obj.CompleteAmount)
{
productPlanInfo.CompleteAmount = obj.CompleteAmount;
}
else
{
productPlanInfo.CompleteAmount = t.PlanAmount;
}
int completeNum = materialCompletionList.Count();//过点完成数量
if ((obj.CompleteAmount - completeNum) > 0)
{
MaterialCompletion materialCompletion = new MaterialCompletion();
materialCompletion.OrderCode = t.OrderCode;
materialCompletion.ProductLineCode = productLineCode;
materialCompletion.MaterialCode = t.MaterialCode;
materialCompletion.MaterialName = t.MaterialName;
materialCompletion.StationName = stationCode;
materialCompletion.CompleteDate = DateTime.Now;
materialCompletion.planCode = t.PlanCode;
await _materialCompletionServices.AddAsync(materialCompletion);
}
}
});
if (pPlanInfoList.Count != 0 && pPlanInfoList != null)
{
_productPlanInfoServices.UpdateAsync(pPlanInfoList);
}
Thread.Sleep(3000);
}
}
#endregion
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.SheetMetal.Models
{
public class ListBoxDataView
{
/// <summary>
/// 颜色
/// </summary>
public string Color { get; set; }
/// <summary>
/// 内容
/// </summary>
public string Content { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.SheetMetal.Models
{
public enum SelectColorView
{
Red,
White
}
}

@ -19,13 +19,11 @@ using Admin.Core.Common;
using LiveCharts.Defaults;
using Aucma.Core.SheetMetal.Business;
using Admin.Core.Model.ViewModels;
using NPOI.SS.Formula.Functions;
using log4net;
using Aucma.Core.HwPLc;
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
using System.Text;
using System.Threading;
using Admin.Core.Service;
using Admin.Core.Model.Model_New;
/*
*
*/
@ -33,7 +31,10 @@ namespace Aucma.Core.SheetMetal.ViewModels
{
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(LogPageViewModel));
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
#region 初始化接口
protected readonly IExecutePlanInfoServices? _taskExecutionPlanInfoServices;
protected readonly IRecordBackPanelComplateServices _recordBackPanelComplateServices;
protected readonly IRecordSidePanelComplateServices _recordSidePanelComplateServices;
@ -41,8 +42,12 @@ namespace Aucma.Core.SheetMetal.ViewModels
protected readonly IBaseBomInfoServices _baseBomInfoServices;
private readonly ISysUserInfoServices _sysUserInfoServices;
private readonly IRecordInStoreServices _recordInstoreServices;
private AppConfigHelper appConfig = new AppConfigHelper();
List<SelectModel> list = new List<SelectModel>() { new SelectModel()
private readonly IBaseOrderInfoServices _baseOrderInfoServices;
#endregion
#region 初始化下拉数据
private AppConfigHelper appConfig = new AppConfigHelper();//读取保存的文本数据
List<SelectModel> selectList = new List<SelectModel>() { new SelectModel()
{
ID=1,
TypeName="手动"
@ -52,13 +57,18 @@ namespace Aucma.Core.SheetMetal.ViewModels
ID=2,
TypeName="自动"
}};
#endregion
#region 定义对象和定义字段
public Func<double, string> Formatter { get; set; }
public HwPLc.PlcModel obj = null;
public HwPLc.PlcModel obj = null;
#endregion
#region 构造函数
public IndexPageViewModel()
{
_stationName = Appsettings.app("StationInfo", "StationName");//工位名称
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
_executePlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_taskExecutionPlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_recordBackPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
@ -78,17 +88,19 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
#endregion
#region 更新前端数据
public Task RefreshChat()
{
RefreshHourAmountChart();//小时产量
RefreshMaterialChart();//型号产量
return Task.CompletedTask;
}
}
#endregion
#region 下拉
public void AddSelectData()
{
foreach (var item in list)
foreach (var item in selectList)
{
LocationSource.Add(item);
}
@ -268,22 +280,22 @@ namespace Aucma.Core.SheetMetal.ViewModels
#endregion
#region 刷新计划执行
public void RefreshPlanShow(SheetMetaSendPlanInfoView execPlan)
public async void RefreshPlanShow(SheetMetaSendPlanInfoView execPlan)
{
//更新首页显示信息
//ExecutePlanInfo execPlan = execList.SingleOrDefault(d => d.ExecuteStatus == 2);
if (execPlan != null)
BaseOrderInfo orderPlan =await _baseOrderInfoServices.FirstAsync(d => d.OrderCode == execPlan.OrderCode);
if (orderPlan != null)
{
OrderCode = execPlan.OrderCode;
MesMOrderCode = execPlan.ProductPlanCode;
ProductModel = execPlan.MaterialName;
BeginTime = string.IsNullOrEmpty(execPlan.BeginTime)?"": execPlan.BeginTime.ToString();
PlanMaxNum = PlanNum = execPlan.PlanAmount;//显示SAP订单数而不是拆分订单计划数
RealQuantity = execPlan.CompleteAmount;
double diff = _planMaxNum - _realQuantity;
PlanMaxNum = orderPlan.OrderAmount;//显示SAP订单数而不是拆分订单计划数
RealQuantity = orderPlan.CompleteAmount;
double diff = orderPlan.OrderAmount - RealQuantity;
DiffQuantity = int.Parse(diff.ToString());
//CompletionRate = (_realQuantity/_planMaxNum).ToString("0%");
CompletionRate = (_realQuantity / _planMaxNum);
CompletionRate = double.Parse((RealQuantity / orderPlan.OrderAmount).ToString());
}
else
{
@ -778,7 +790,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
{
//读取入到配置文件中
var queryExec = appConfig.queryExec;
var model = list.FirstOrDefault(d => d.ID == int.Parse(queryExec));
var model = selectList.FirstOrDefault(d => d.ID == int.Parse(queryExec));
return model;
}
#endregion
@ -830,6 +842,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "前板";
column.ScalesYAt = 0;
column.Values = hourAchievement1;
column.Foreground = Brushes.White;
column.FontSize = 18;
@ -840,7 +853,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
{
DataLabels = true,
Title = "后板",
Values = hourAchievement2,
ScalesYAt = 0,
Values = hourAchievement2,
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
Foreground = Brushes.CadetBlue,
FontSize = 18
@ -852,7 +866,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
#endregion
#region 更新小时产量统计
/// <summary>
/// 更新小时产量统计
@ -882,7 +895,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
#endregion
#region 刷新物料型号统计
/// <summary>
/// 刷新物料型号统计
@ -914,6 +926,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
var column2 = new ColumnSeries();
column2.DataLabels = true;
column2.Title = "前板";
column2.ScalesYAt = 0;
column2.Values = achievement1;
column2.Foreground = Brushes.White;
column2.FontSize = 18;
@ -924,7 +937,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
DataLabels = true,
Title = "后板",
Values = achievement2,
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
ScalesYAt = 0,
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
Foreground = Brushes.White,
FontSize = 18
});
@ -935,7 +949,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
#endregion
#region 刷新物料型号统计
/// <summary>
/// 刷新物料型号统计
@ -993,63 +1006,86 @@ namespace Aucma.Core.SheetMetal.ViewModels
public CurrentTeamTimeView GetTeamHour()
{
List<CurrentTeamTimeView> obj = _sysUserInfoServices.GetTeamData().Result;
if (obj != null)
try
{
List<CurrentTeamTimeView> obj = _sysUserInfoServices.GetTeamData().Result;
if (obj != null)
{
CurrentTeamTimeView view = new CurrentTeamTimeView();
view.TeamName = obj.FirstOrDefault(d => d.Seq == 1).TeamName;
view.StartTime = obj.Min(d => d.StartTime);
view.EndTime = obj.Max(d => d.EndTime);
return view;
}
}
catch (Exception ex)
{
CurrentTeamTimeView view = new CurrentTeamTimeView();
view.TeamName = obj.FirstOrDefault(d => d.Seq == 1).TeamName;
view.StartTime = obj.Min(d => d.StartTime);
view.EndTime = obj.Max(d => d.EndTime);
return view;
log.Error($"获取当前班组时间异常:{ex.Message}");
}
return null;
}
#endregion
#region PLC存储的当前正在执行的前后板计划编号
public string GetSidePlanCode(PlcModel obj)
{
bool flag = true;
string planCode = string.Empty;
do
try
{
byte[] info = obj.plc.Read("D6030", 59);
if (info == null)
do
{
Thread.Sleep(1000);
continue;
}
//计划编号
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
if (!string.IsNullOrEmpty(planCode)) flag = false;
} while (flag);
byte[] info = obj.plc.Read("D6030", 59);
if (info == null)
{
Thread.Sleep(1000);
continue;
}
//计划编号
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
if (!string.IsNullOrEmpty(planCode)) flag = false;
} while (flag);
}
catch (Exception ex)
{
log.Error($"获取前板传入的计划编号:{ex.Message}");
}
return planCode;
}
public string GetBackPlanCode(PlcModel obj)
{
bool flag = true;
string planCode = string.Empty;
do
try
{
byte[] info = obj.plc.Read("D4030", 59);
if (info == null)
bool flag = true;
do
{
Thread.Sleep(1000);
continue;
}
byte[] info = obj.plc.Read("D4030", 59);
if (info == null)
{
Thread.Sleep(1000);
continue;
}
//计划编号
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
if (!string.IsNullOrEmpty(planCode)) flag = false;
} while (flag);
//计划编号
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
if (!string.IsNullOrEmpty(planCode)) flag = false;
} while (flag);
}
catch (Exception ex)
{
log.Error($"获取后板传入的计划编号:{ex.Message}");
}
return planCode;
}
}
#endregion
}
}

@ -12,14 +12,14 @@ using System.Threading.Tasks;
using System.Windows.Documents;
using Admin.Core.Tasks;
using Aucma.Core.SheetMetal.Business;
using Aucma.Core.SheetMetal.Models;
namespace Aucma.Core.SheetMetal.ViewModels
{
public class LogPageViewModel : ObservableObject
{
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(LogPageViewModel));
private ObservableCollection<ListBoxDataView> listItems = new ObservableCollection<ListBoxDataView>();
public LogPageViewModel()
{
SheetMetalPlanTaskHandle.RefreshExecInfoEvent += PrintMessageToListBox;
@ -28,8 +28,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
/// <summary>
/// LisBox数据模板
/// </summary>
private IEnumerable logInfoListBox;
public IEnumerable LogInfoListBox
private IEnumerable<ListBoxDataView> logInfoListBox;
public IEnumerable<ListBoxDataView> LogInfoListBox
{
get => logInfoListBox;
set => SetProperty(ref logInfoListBox, value);
@ -39,14 +39,19 @@ namespace Aucma.Core.SheetMetal.ViewModels
/// listBox绑定日志
/// </summary>
/// <param name="message"></param>
private void PrintMessageToListBox(string message)
/// <param name="color">Red or White</param>
private void PrintMessageToListBox(string message, string color)
{
try
{
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
LogInfoListBox = listItems.OrderByDescending(x => x);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
string content = $"{DateTime.Now.ToString("HH:mm:ss")}==>{message}";
ListBoxDataView view = new ListBoxDataView { Content = content, Color = color };
//listItems.Add(view);
listItems.Insert(0, view);
LogInfoListBox = listItems;
}));
}
catch (Exception ex)
{
@ -54,5 +59,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
}
public ObservableCollection<ListBoxDataView> Items { get; set; }
}
}

@ -4,22 +4,31 @@ using Admin.Core.Model;
using Admin.Core.Service;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
using Microsoft.Extensions.DependencyInjection;
using Pipelines.Sockets.Unofficial;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Media;
namespace Aucma.Core.SheetMetal.ViewModels
{
public partial class MaterialStatisticsViewModel : ObservableObject
{
private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
private readonly ISysUserInfoServices _sysUserInfoServices;
public MaterialStatisticsViewModel()
{
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
Refresh();
}
#region 刷新
@ -79,6 +88,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
if (string.IsNullOrEmpty(item.MaterialType)) continue;
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = item.MaterialType, SpaceStock = item.SpaceStock });
}
//夹具状态
RefreshModeStatus();
}
#endregion
@ -133,5 +144,77 @@ namespace Aucma.Core.SheetMetal.ViewModels
set => SetProperty(ref foamBeforeMaterialStockDataGrid, value);
}
#endregion
#region 刷新夹具统计
/// <summary>
/// 刷新夹具统计
/// </summary>
private void RefreshModeStatus()
{
App.Current.Dispatcher.Invoke((Action)(async () =>
{
var modeStatus = await _sysUserInfoServices.StatisticalModelStatus();
if (modeStatus != null)
{
if (Achievement.Count != 0) Achievement.Clear();
ModeTypeList = new List<string>();
ChartValues<double> achievement = new ChartValues<double>();
int hour = 0;
foreach (var item in modeStatus)
{
achievement.Add(Convert.ToInt32(item.YValue));
ModeTypeList.Add(item.XValue);
hour++;
}
#region 按夹具状态统计
Achievement.Add(new ColumnSeries
{
DataLabels = true,
Title = "夹具状态",
ScalesYAt = 0,
Values = achievement,
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
Foreground = Brushes.CadetBlue,
FontSize = 18
});
#endregion
}
}));
}
#endregion
#region 夹具状态统计
#region 夹具状态统计
/// <summary>
/// 夹具状态统计
/// </summary>
private List<string> modeTypeList;
public List<string> ModeTypeList
{
get { return modeTypeList; }
set { modeTypeList = value; }
}
#endregion
/// <summary>
/// 夹具状态统计
/// </summary>
private SeriesCollection achievement = new SeriesCollection();
public SeriesCollection Achievement
{
get { return achievement; }
set { achievement = value; }
}
#endregion
}
}

@ -16,99 +16,105 @@ using Castle.Core.Internal;
using CommunityToolkit.Mvvm.Messaging;
using Aucma.Core.SheetMetal.Views;
using Aucma.Core.SheetMetal.Common;
using System.Windows.Input;
using Admin.Core.Common;
using System.Drawing.Drawing2D;
using Aucma.Core.SheetMetal.Business;
using Aucma.Core.HwPLc;
using Admin.Core.Service;
namespace Aucma.Core.SheetMetal.ViewModels
{
public partial class SplitPlanViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SplitPlanViewModel));
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
private AppConfigHelper appConfig = new AppConfigHelper();
private AppConfigHelper appConfig = new AppConfigHelper();//读取配置文件保存的查询内容
#region 构造函数
public SplitPlanViewModel()
{
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
_executePlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
Task.WaitAll(LoadData());
//加载快捷方式
SaveSearchCriteria();
SaveSearchCriteria();
WeakReferenceMessenger.Default.Register<string>(this, SaveSearchCriteria);
_radioButtonStatus = 1;
}
}
#endregion
#region 加载DataGrid数据
private async Task LoadData()
{
MaterialDataGrid.Clear();
int i = 1;
string station = Appsettings.app("StationInfo", "StationCode");
var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station);
if (execList == null) return;
foreach (var item in execList)
try
{
int residue = 0;
if (execList == null) residue = 0;
else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount);
MaterialDataGrid.Add(new ProductPlanInfoModel()
MaterialDataGrid.Clear();
int i = 1;
string station = Appsettings.app("StationInfo", "StationCode");
var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station);
if (execList == null) return;
foreach (var item in execList)
{
No = i,
PlanCode = item.PlanCode,
MaterialCode = item.MaterialCode,
MaterialName = item.MaterialName,
OrderCode = item.OrderCode,
PlanAmount = item.PlanAmount,
ResidueAmount = item.PlanAmount - item.CompleteAmount,
SpliteResidueAmount = item.PlanAmount - residue,
MaterialSpecificatons = item.MaterialSpecificatons,
StartDate = item.BeginTime
});
i++;
}
int residue = 0;
if (execList == null) residue = 0;
else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount);
MaterialDataGrid.Add(new ProductPlanInfoModel()
{
No = i,
PlanCode = item.PlanCode,
OrderCode = item.OrderCode,
MaterialCode = item.MaterialCode,
MaterialName = item.MaterialName,
PlanAmount = item.PlanAmount,
ResidueAmount = item.PlanAmount - item.CompleteAmount,
SpliteResidueAmount = item.PlanAmount - residue,
MaterialSpecificatons = item.MaterialSpecificatons,
CompleteAmount = item.CompleteAmount,
StartDate = item.BeginTime
});
i++;
}
await Task.CompletedTask;
}
catch (Exception ex)
{
log.Error($"初始化查询:{ex.Message}");
}
await Task.CompletedTask;
}
private async Task LoadData(string obj)
{
string station = Appsettings.app("StationInfo", "StationCode");
MaterialDataGrid.Clear();
int i = 1;
//var planlist = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result;
//if (planlist == null) return ;
//var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station));
//if (execList == null) return;
var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station);
if (execList == null) return;
execList=execList.Where(d => d.MaterialName.Contains(obj) || d.OrderCode.Contains(obj) || d.PlanCode.Contains(obj)).ToList();
foreach (var item in execList)
try
{
int residue = 0;
if (execList == null) residue = 0;
else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount);
MaterialDataGrid.Add(new ProductPlanInfoModel()
string station = Appsettings.app("StationInfo", "StationCode");
MaterialDataGrid.Clear();
int i = 1;
var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station);
if (execList == null) return;
execList = execList.Where(d => d.MaterialName.Contains(obj) || d.OrderCode.Contains(obj) || d.PlanCode.Contains(obj)).ToList();
foreach (var item in execList)
{
No = i,
PlanCode = item.PlanCode,
MaterialCode = item.MaterialCode,
MaterialName = item.MaterialName,
OrderCode = item.OrderCode,
PlanAmount = item.PlanAmount,
ResidueAmount = item.PlanAmount - item.CompleteAmount,
SpliteResidueAmount = item.PlanAmount - residue,
MaterialSpecificatons = item.MaterialSpecificatons,
StartDate = item.BeginTime
});
i++;
int residue = 0;
if (execList == null) residue = 0;
else residue = (execList.Where(d => d.MaterialCode.Equals(item.MaterialCode))).Sum(d => d.PlanAmount);
MaterialDataGrid.Add(new ProductPlanInfoModel()
{
No = i,
PlanCode = item.PlanCode,
MaterialCode = item.MaterialCode,
MaterialName = item.MaterialName,
OrderCode = item.OrderCode,
PlanAmount = item.PlanAmount,
ResidueAmount = item.PlanAmount - item.CompleteAmount,
SpliteResidueAmount = item.PlanAmount - residue,
MaterialSpecificatons = item.MaterialSpecificatons,
StartDate = item.BeginTime
});
i++;
}
}
catch (Exception ex)
{
log.Error($"根据搜索条件查询:{ex.Message}");
}
await Task.CompletedTask;
}

@ -254,7 +254,7 @@
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid Margin="10,10">
<lvc:CartesianChart Series="{Binding Achievement, UpdateSourceTrigger=PropertyChanged}" DisableAnimations="True" LegendLocation="Top" Foreground="White">
<lvc:CartesianChart Series="{Binding Achievement, UpdateSourceTrigger=PropertyChanged}" DisableAnimations="True" LegendLocation="Top" Foreground="White">
<lvc:CartesianChart.DataTooltip >
<lvc:DefaultTooltip SelectionMode="OnlySender" BulletSize="10" Foreground="Black"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>
@ -269,7 +269,7 @@
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="18" Foreground="White">
<lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Step="1 " Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
@ -312,7 +312,7 @@
<DataGridTextColumn Binding="{Binding SidePanelAmount}" Header="前板" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding BackPanelAmount}" Header="后板" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanType}" Header="计划类型" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanType}" Header="配方" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Visibility="Collapsed"/>
<DataGridTextColumn Binding="{Binding PlanType}" Header="配方" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding BeginTime ,StringFormat=\{0:MM-dd HH:mm\}}" Header="开始时间" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ExecuteStatus}" Header="执行状态" Visibility="Collapsed"/>
@ -385,7 +385,7 @@
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="18" Foreground="White">
<lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Step="1 " Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>

@ -7,6 +7,7 @@
mc:Ignorable="d" Background="#1152AC" FontFamily="Microsoft YaHei"
d:DesignHeight="450" d:DesignWidth="800"
>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="5 15 5 5">
<Grid>
<Grid.RowDefinitions>
@ -18,7 +19,24 @@
</Border>
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid Margin="10,10">
<ListBox Grid.Row="1" x:Name="listBox" FontSize="18" ItemsSource="{Binding LogInfoListBox}" Foreground="White" Background="Transparent" BorderBrush="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"/>
<!--<ListBox Grid.Row="1" x:Name="listBox" FontSize="18" ItemsSource="{Binding LogInfoListBox}" Foreground="White" Background="Transparent" BorderBrush="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"/>-->
<ListBox ItemsSource="{Binding LogInfoListBox}" >
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtName" Text="{Binding Content}" FontSize="18" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Color}" Value="Red">
<Setter TargetName="txtName" Property="Foreground" Value="{Binding Color}" />
</DataTrigger>
<DataTrigger Binding="{Binding Color}" Value="White">
<Setter TargetName="txtName" Property="Foreground" Value="{Binding Color}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</Grid>

@ -26,5 +26,7 @@ namespace Aucma.Core.SheetMetal.Views
InitializeComponent();
this.DataContext = new LogPageViewModel();
}
}
}

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:local="clr-namespace:Aucma.Core.SheetMetal.Views"
mc:Ignorable="d" Background="#1152AC" FontFamily="Microsoft YaHei"
Title="物料库存统计" Height="650" Width="1000" Name="window" WindowStartupLocation="CenterScreen"
@ -185,13 +186,35 @@
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="发 泡 夹 具 状 态" Foreground="#FFFFFF" FontSize="18"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="mode">
<Grid>
<lvc:CartesianChart LegendLocation="Top" Series="{Binding Achievement, UpdateSourceTrigger=PropertyChanged}" DisableAnimations="True" Foreground="White" Margin="-229,-110,-228,-102">
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip BulletSize="10" Foreground="Black"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding ModeTypeList}" FontSize="18" Foreground="White">
<lvc:Axis.Separator>
<lvc:Separator Step="1" Visibility="Hidden" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="18" Foreground="White">
<lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Step="1 " Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="2" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2">
<Border Grid.Row="2" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="0">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,20,0">
<Button Content="刷 新" Command="{Binding RefreshCommand}" Background="#007DFA" BorderBrush="#007DFA" Width="100" Height="30" Margin="20,0,0,0"/>
<Button Content="取 消" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=window}" Background="#FF9900" Foreground="white" Margin="20,0,50,0" Height="30" BorderBrush="#FF9900" Width="100" />

@ -10,6 +10,7 @@
Title="下达数量"
Height="500" Width="700" Name="window"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Topmost="False">
<Border Margin="5" BorderBrush="#0288d1" CornerRadius="10">
@ -97,7 +98,7 @@
<Button Grid.Row="2" Grid.Column="1" Content="8" FontSize="18" Margin="2,2" Command="{Binding KeypadButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Content}" Height="70" Width="100" />
<Button Grid.Row="2" Grid.Column="2" Content="9" FontSize="18" Margin="2,2" Command="{Binding KeypadButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Content}" Height="70" Width="100" />
<Button Grid.Row="3" Grid.Column="0" Content="0" FontSize="18" Margin="2,2" Command="{Binding KeypadButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Content}" Height="70" Width="100" />
<Button Grid.Row="3" Grid.Column="2" Content="清除" FontSize="15" Margin="2,2" Background="#FF9900" Foreground="white" BorderBrush="#FF9900" Command="{Binding ClearTransmitAmountCommand}" Height="70" Width="100" />
<Button Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Content="清除" FontSize="15" Margin="2,2" Background="#FF9900" Foreground="white" BorderBrush="#FF9900" Command="{Binding ClearTransmitAmountCommand}" Height="70" />
</Grid>
</Border>

@ -6,7 +6,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
Background="#1152AC"
Title="计划维护" FontFamily="Microsoft YaHei" Height="800" Width="1000"
Title="计划维护" FontFamily="Microsoft YaHei" Height="800" Width="1100"
d:DesignHeight="800" WindowStartupLocation="CenterScreen"
d:DesignWidth="1500" ResizeMode="NoResize" Topmost="False" >
@ -239,7 +239,7 @@
<DataGridTextColumn Binding="{Binding MaterialSpecificatons}" Header="产品型号" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Visibility="Collapsed"/>
<DataGridTextColumn Binding="{Binding PlanAmount}" Header="计划数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding BeginTime,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="开始时间" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding StartDate,StringFormat=\{0:MM-dd HH:mm\}}" Header="开始时间" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
</UniformGrid>

@ -136,7 +136,7 @@
"PlcType": "Melsec",
"Enabled": true,
"IP": "10.10.91.6",
"Port": 5553
"Port": 5552
}
]
}

Loading…
Cancel
Save